def main(): # Set up command-line arguments. args = sys.argv arg1 = "" arg2 = "" db = DBAccess() fields = db.getDohmpiFieldNames() if (len(args) > 3): # too many arguments, pitch a fit. printsyntax(args) if (len(args) >= 2): arg1 = sys.argv[1] if (len(args) == 3): arg2 = sys.argv[2] # Run tasks based on format of arguments. if (len(args) == 1): # no arguments, process current date processDeathDate(fields,db.getCurrentDate()) elif (len(args) == 2): # one argument # check if date or name or id if (db.isdate(arg1)): # is it a date? arg1 = paddate(arg1) processDeathDate(fields,arg1) elif ("-" in arg1): # hyphen may mean provider license number index = arg1.index("-") if (arg1[0:index].isdigit() and arg1[index+1:].isdigit()): processDOHMPI(fields,arg1) else: # must be a hyphenated last name. processLastName(fields,arg1) else: # must be an unhyphenated last name. processLastName(fields,arg1) elif (len(args) == 3): # two arguments, date range or first and last name if (db.isdate(arg1) and db.isdate(arg2)): arg1 = paddate(arg1) arg2 = paddate(arg2) processRange(fields,arg1,arg2) # date range elif (not db.isdate(arg1) and not db.isdate(arg2)): processName(fields,arg1, arg2) # first and last name else: printsyntax(args) # no clue, remind user of command line options.
import createPatient as c from DBAccessor import DBAccess db = DBAccess() # get all deaths for the current date. #record = db.search('death',db.getCurrentDate(),'raw') record = db.search('all', 'raw') for i in range(len(record[1])): if i == 0: pass # this is the dohmpi field list, don't process it as a practitioner. elif len(record[1][i]) == 0: pass # the last tuple will be an empty list, don't process it. else: pat = c.createPatient(record[0], record[1][i]) # # Insert code here that adds a patient record to the # print("processed patient %d" % i) print pat.as_json() print("task completed")
from DBAccessor import DBAccess db = DBAccess() print db.getDohmpiFieldNames() print(db.search('all','line')) #print(db.search('birth','1/4/1949','array')) #print(db.search('death','6/7/2016','raw')) #print(db.search('range','10/14/2016','12/17/2016','line')) #print(db.search('mpi','201626406','array')) #print(db.search('name','TAWNLETHIA','WIMMER','line')) #print(db.search('lname','JONES','html')) #print(db.search('death',db.getCurrentDate(),'line')) #db.htmlWrite(db.search('range','1/1/2016','12/31/2016','html'),'FY2016.htm')
#print patient #patient.birthDate.isostring # '1963-06-12' #smart.human_name(patient.name[0]) #'Christy Ebert' #payload={ # 'grant_type': 'authorization_code', # 'client_id': nc.client_id, # 'client-secret' : nc.client_secret, # #}# from DBAccessor import DBAccess import createPatient as c db = DBAccess() record = db.search('death','3/29/2016','raw') print record payload = "" for i in range(len(record)): if i == 0: print ("A") pass # this is the dohmpi field list, don't process it as a practitioner. elif len(record[i]) == 0: print("B") pass # the last tuple will be an empty list, don't process it. else: pat = c.createPatient(record[0],record[i]) # # Insert code here that adds a patient record to the #
from fhirclient import client settings = { 'app_id': 'my_web_app', 'api_base': 'https://fhir-open-api-dstu2.smarthealthit.org' } smart = client.FHIRClient(settings=settings) from DBAccessor import DBAccess import createPatient as c import fhirclient.models.patient as p import json db = DBAccess() record = db.getRecordsByName('%', 'SMITH') field = db.getDohmpiFieldNames() pat = c.createPatient(field, record[0]) patient = client.create().resource(pat) print(patient.as_json())
def processRange(fields,start, end): # given two dates, process all dates between them. db = DBAccess() records = db.getRecordsByDeathRange(start,end) processRecords(fields,records)
def processName(fields,fname, lname): # given a first and last name, process people with that first name and last name db = DBAccess() records = db.getRecordsByName(fname.upper(),lname.upper()) processRecords(fields,records)
def processLastName(fields,lname): # given a last name, process all people with that last name. db = DBAccess() records = db.getRecordsByName("%",lname.upper()) processRecords(fields,records)
def processDOHMPI(fields,mpi): #given a dohmpi number, process that person. db = DBAccess() records = db.getRecordsByMPI(mpi) processRecords(fields,records)
def processDeathDate(fields,date): #given a date, process people who died on that date. db = DBAccess() records = db.getRecordsByDeathDate(date) processRecords(fields,records)