#!/usr/bin/python
# coding=utf-8

from __future__ import unicode_literals

import datetime
import os
import re

import django

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
# os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
django.setup()

# from mechanize import Browser
# br = Browser()
# br.set_handle_robots(False)

from ck.models import *
# from ntuhgov import intra
from ntuhgov.portal_selenium import *

def AI_CLINIC():
    # print(type(Patient))
    for mrn in OpenClinics('2019-3-22', '2', 10):
        try:
            p = Patient.objects.get(medical_records=mrn)
            print('%s %s' % (mrn, p.name))
        except:
            # print(mrn)
            continue
         
if __name__ == "__main__":
    AI_CLINIC()
#     PatientsRefresh()