#!/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
import ntuhgov.portal_selenium as portal


REGISTER_PATH = '/media/cifs/ST14/shares/Public/register3_result/'

def GetReg():
    for pat in os.listdir(REGISTER_PATH):
        for img in os.listdir(os.path.join(REGISTER_PATH, pat)):
            print (pat, img)
            exit()

def ExportEMR():

    patients = Patient.objects.all()
    for patient in patients:

        for e in patient.electronicmedicalreport_set.filter(report_code='XrayTextReport'):

            print(e)

            exit()



         
if __name__ == "__main__":
    GetReg()
    ExportEMR()
