def test_closeChart(): nur = Nurse(db.getUser('Lq{3', 'Lq{345')) chart_id = db.createNewChartForPatient("15384") if db.isChartOpenForPatient("15384") != None: nur.closeChart(chart_id) assert db.isChartOpenForPatient("15384") == '10010'
def test_nurse_selectChart(): ''' nurse.selectChart(nur, patient): if nur.checkIfPatientHasOpenChart(patient["hcno"]) is not None: if raw_input("This patient already has an open chart (shown above), would you like to open it (y)? ") == "y": # return open chart return nur.checkIfPatientHasOpenChart(patient["hcno"]) while(True): chartId = raw_input("Which chart would you like to open? (type chart's id or 'new') ") if chartId == "new": # return new chart id return newChartFlow(nur, patient) else: # return chart id if not nur.printChartEntries(patient["hcno"], chartId): print("There was a problem, please type the chartid. ") else: return chartId ''' nur = Nurse(db.getUser('Lq{3', 'Lq{345')) # patient doesn't have open chart - opens old assert nurse_mod.selectChart(nur, nur.getPatient("15384"), True, '10001', True) == "10001" # patient has open chart chooses not to - opens old assert nurse_mod.selectChart(nur, nur.getPatient("20195"), False, '10009', True) == "10009" # patient has open chart chooses to open it assert nurse_mod.selectChart(nur, nur.getPatient("20195"), True, '10009', True) == "10009" # patient has open chart chooses not to - opens new assert nurse_mod.selectChart(nur, nur.getPatient("20195"), False, 'new', True) == 10010 # patient doesn't have open chart - opens old assert nurse_mod.selectChart(nur, nur.getPatient("15384"), True, '10001', True) == "10001" # patient has open chart chooses not to - opens new assert nurse_mod.selectChart(nur, nur.getPatient("20195"), False, 'new', True) == 10011
def test_listMedicationsForDiagnosis(): diagnosis = "Ebola" adm = AdminStaff(db.getUser('Lgtkejq', 'sygtv{')) assert adm.listMedicationsForDiagnosis(diagnosis) == True diagnosis = "DoesNotExist" assert adm.listMedicationsForDiagnosis(diagnosis) == False
def test_printChartEntries(capsys): doc = Doctor(db.getUser('RwiNqxg:', 'Vjgug"Pggf"Jcujkpi')) patient = doc.getPatient("15384") print (doc.printChartEntries(patient['hcno'], "10001")) out=capsys.readouterr() print (out) assert out[0] == 'Symptom 1:\n- chart_id: 10001\n- obs_date: 2015-01-08 18:22:55\n- staff_id: 37225\n- symptom: Nausea\n- hcno: 15384\nDiagnosis 1:\n- chart_id: 10001\n- diagnosis: Ebola\n- staff_id: 14334\n- ddate: 2015-01-11 14:06:01\n- hcno: 15384\nMedication 1:\n- staff_id: 14334\n- mdate: 2015-01-12 02:20:09\n- hcno: 15384\n- drug_name: ZMapp\n- amount: 8\n- start_med: 2015-01-12 19:50:32\n- end_med: 2015-02-21 02:51:33\n- chart_id: 10001\nTrue\n'
def test_getCharts(capsys): doc = Doctor(db.getUser('RwiNqxg:', 'Vjgug"Pggf"Jcujkpi')) patient = doc.getPatient("15384") doc.getCharts(patient['hcno']) out=capsys.readouterr() print(out) assert out[0] == 'Charts for patient with health care number 15384:\nChart 1:\n- adate: 2015-01-06 12:24:56\n- name: Angelina Jolie\n- edate: 2015-02-13 10:35:42\n- phone: 7801234567\n- hcno: 15384\n- address: 123-120 ST, Edmonton, Alberta\n- chart_id: 10001\n- emg_phone: 7801234567\n- age_group: 18-39\n'
def test_listDrugAmtForEachDoctor(capsys): start = "2015-01-11 19:50:32" end = "2015-01-13 19:50:32" adm = AdminStaff(db.getUser('Lgtkejq', 'sygtv{')) adm.listDrugAmtForEachDoctor(start, end) out=capsys.readouterr() print (out) assert out[0] == 'Report: Drug Amount Prescribed For Each Doctor Between 2015-01-11 19:50:32 and 2015-01-13 19:50:32:\n-----------------------\n- drug_name: Retrovir\n- DoctorName: Mehmet Oz\n- total_amount: 85\n-----------------------\n- drug_name: Viread\n- DoctorName: Phil McGraw\n- total_amount: 16\n'
def test_listDrugAmtForEachCategory(capsys): start = "2015-01-11 19:50:32" end = "2015-01-13 19:50:32" adm = AdminStaff(db.getUser('Lgtkejq', 'sygtv{')) adm.listDrugAmtForEachCategory(start, end) out=capsys.readouterr() print (out) assert out[0] == 'Report Part 1: Drug Amount Prescribed For Each Category Between 2015-01-11 19:50:32 and 2015-01-13 19:50:32\n-----------------------\n- category: anti-Ebola\n- drug_name: ZMapp\n- amount: 8\n-------------------------------------------------\nReport Part 2: Total Amount Prescribed For Each Category Between 2015-01-11 19:50:32 and 2015-01-13 19:50:32\n-----------------------\n- category: anti-Ebola\n- total: 8\n'
def test_addDiagnosis(): doc = Doctor(db.getUser('RwiNqxg:', 'Vjgug"Pggf"Jcujkpi')) doc.addDiagnosis("15384", '10001', '14334', 'Flu') entry = db.diagnosesForPatientAndChart("15384", "10001"); assert entry[0]['hcno'] == "15384" assert entry[0]['chart_id'] == "10001" assert entry[0]['diagnosis'] == "Ebola" assert entry[0]['staff_id'] == "14334"
def test_getPatient(): doc = Doctor(db.getUser('RwiNqxg:', 'Vjgug"Pggf"Jcujkpi')) patient = doc.getPatient("15384") assert patient['hcno'] == "15384" assert patient['name'] == "Angelina Jolie" assert patient['phone'] == "7801234567" assert patient['address'] == "123-120 ST, Edmonton, Alberta" assert patient['emg_phone'] == "7801234567" assert patient['age_group'] == "18-39"
def test_addSymptom(): # TODO doc = Doctor(db.getUser('RwiNqxg:', 'Vjgug"Pggf"Jcujkpi')) doc.addSymptom("15384","10001","00001","Flu") entry = db.symptomsForPatientAndChart("15384", "10001") assert entry[0]["hcno"] == "15384" assert entry[0]["chart_id"] == '10001' assert entry[0]["staff_id"] == '37225' assert entry[0]["obs_date"] == "2015-01-08 18:22:55" assert entry[0]["symptom"] == "Nausea"
def test_newPatient(): nur = Nurse(db.getUser('Lq{3', 'Lq{345')) newpatient = nur.newPatient("3", "Aaron", "18-39", "The zoo", "000000000", "000000") patient = db.getPatientWithHcno('3') assert patient["hcno"] == '3' assert patient["name"] == 'Aaron' assert patient["phone"] =='000000000' assert patient["address"] == "The zoo"
def test_addMedication(): doc = Doctor(db.getUser('RwiNqxg:', 'Vjgug"Pggf"Jcujkpi')) doc.addMedication("15384", '10001', '14334', "2015-01-22 19:50:32", "2015-02-22 02:51:33", "Viread", "8") entry = db.medicationsForPatientAndChart("15384", "10001") #assert entry['hcno'] == '15384' assert entry[0]['chart_id'] == '10001' assert entry[0]['staff_id'] == '14334' assert entry[0]['mdate'] == "2015-01-12 02:20:09" assert entry[0]['start_med'] == "2015-01-12 19:50:32" assert entry[0]['end_med'] == "2015-02-21 02:51:33" assert entry[0]['amount'] == 8 assert entry[0]['drug_name'] == "Viread"
def test_createUser(): #place in the database correctly createuser = db.createUser("D", "Calvin Ho", "Calvin", "CLHO") assert createuser['password'] == 'CLHO' assert createuser['role'] == 'D' assert createuser['login'] == 'Calvin' assert createuser['name'] == 'Calvin Ho' #make sure it's in the db user = db.getUser("Calvin", "CLHO") assert user['password'] == 'CLHO' assert user['role'] == 'D' assert user['login'] == 'Calvin' assert user['name'] == 'Calvin Ho'
def start(username, password, boolNewUser): user = getUser(encrypt(username), encrypt( password)) # return obj of user info, or None if can't be found if user is not None: return "Begin user flow" else: if boolNewUser: user = createUser(raw_input("Role (D, N or A) "), raw_input("Name "), encrypt(username), encrypt(password)) return "Create user flow" else: return "start()"
def test_classes_Admin_listDiagnosesMadeBeforePrescribingDrug(): ''' classes.Admin.listDiagnosesMadeBeforePrescribingDrug(self, drug_name): print 'Report: Diagnoses Made Before Prescribing ' + drug_name result = listDiagnosesMadeBeforePrescribingDrug(drug_name) for idx, row in enumerate(result): print '-----------------------' printRow(row) if result != None: return True else: return False ''' adm = AdminStaff(db.getUser('Lgtkejq', 'sygtv{')) # if there are diagnoses before drug assert adm.listDiagnosesMadeBeforePrescribingDrug("ZMapp") == True # if there are no diagnoses before drug assert adm.listDiagnosesMadeBeforePrescribingDrug("Heroin") == False
def test_admin_listMedicationsForDiagnosisFlow(capsys): ''' admin.listMedicationsForDiagnosisFlow(adm): diagnosis = raw_input("Which diagnosis would you like to search? ") if not adm.listMedicationsForDiagnosis(diagnosis): print("That diagnosis is not in the database") ''' adm = AdminStaff(db.getUser('Lgtkejq', 'sygtv{')) # if there are medications for diagnosis admfile.listMedicationsForDiagnosisFlow(adm) out=capsys.readouterr() assert out[0] == '' # if there are medications for diagnosis db_wipe() admfile.listMedicationsForDiagnosisFlow(adm) out=capsys.readouterr() assert out[0] == 'That diagnosis is not in the database'
def test_classes_Doctor_getCharts(): ''' classes.Doctor.getCharts(self, patient): print 'Charts for patient with health care number ' + patient + ':' charts = getChartsForPatient(patient) if len(charts) == 0: print 'No charts for patient ' + patient + '!' return "no_patient" for idx, row in enumerate(charts): print 'Chart ' + str(idx + 1) + ':' printRow(row) ''' doc = Doctor(db.getUser('RwiNqxg:', 'Vjgug"Pggf"Jcujkpi')) # if there are no charts for patient assert doc.getCharts('15385') == "no_patient" # if there are charts for patient assert doc.getCharts('15384') == None
def test_doctor_addMedicationFlow(): ''' doctor.addMedicationFlow(doc, patient, chart): drug = raw_input("Name the drug for the medication: ") amount = raw_input("How much would you like to prescribe? ") while not doc.checkMedicationAmountValid(drug, amount, patient["age_group"]): print("Warning, that is above the recommended amount.") rec = doc.getValidMedicationAmount(drug, patient["age_group"]) print "the suggested amount is " + str(rec["sug_amount"]) action = raw_input("\nWould you like to:\n \ (1) Confirm your prescription\n \ (2) Change your amount\n") if action == "2": amount = raw_input("How much would you like to prescribe? ") else: break if doc.checkPatientAllergicToDrug(patient["hcno"], drug): print("The patient is allergic to " + drug) if doc.checkInferredAllergyToDrug(patient["hcno"], drug) is not None: print("... and is also allergic to " + doc.checkInferredAllergyToDrug(patient["hcno"], drug)) start_med = raw_input("When would you like to start the medications? (YYYY-MM-DD HH:MM:SS) ") end_med = raw_input("When would you like to end the medications? (YYYY-MM-DD HH:MM:SS) ") doc.addMedication(patient["hcno"], chart, doc.id, start_med, end_med, drug, amount) print("Medication has been added to the database.") ''' doc = Doctor(db.getUser('RwiNqxg:', 'Vjgug"Pggf"Jcujkpi')) patient = db.getPatient('15384') charts = db.getChartsForPatient('15384') drug = "ZMapp" amount = "8" action = "2" start_med = "2015-01-12 19:50:32" end_med = "2015-02-21 02:51:33" assert doctor_mod.addMedicationFlow(doc, patient, chart, drug, amount, action, start_med, end_med) == '' assert doctor_mod.addMedicationFlow(doc, patient, chart, drug, "12", 1, start_med, end_med) == "Above recommended amount the suggested amount is 8" assert doctor_mod.addMedicationFlow(doc, patient, chart, "Tamiflu", amount, action, start_med, end_med) == "The patient is allergic to Tamiflu"
def test_classes_Admin_listMedicationsForDiagnosis(): ''' classes.Admin.listMedicationsForDiagnosis(self, diagnosis): print 'Report: Drugs Prescribed to Treat ' + diagnosis result = listMedicationsForDiagnosis(diagnosis) for idx, row in enumerate(result): print '-----------------------' printRow(row) if result != None: return True else: return False ''' adm = AdminStaff(db.getUser('Lgtkejq', 'sygtv{')) # if there are medications for diagnosis assert adm.listMedicationsForDiagnosis('Ebola') == True # if there are no medications for diagnosis assert adm.listMedicationsForDiagnosis('DoesNotExdgfsgdfsist') == False
def test_admin_listDiagnosisesForDrugFlow(capsys): ''' admin.listDiagnosisesForDrugFlow(adm): drug = raw_input("Which drug would you like to search? ") if not adm.listDiagnosesMadeBeforePrescribingDrug(drug): print("That drug is not in the database") ''' adm = AdminStaff(db.getUser('Lgtkejq', 'sygtv{')) # if there are diagnosis for drug admfile.listMedicationsForDiagnosisFlow(adm) out=capsys.readouterr() assert out[0] == '' # if there are no diagnosis for drug db_wipe() admfile.listMedicationsForDiagnosisFlow(adm) out=capsys.readouterr() assert out[0] == 'That drug is not in the database'
def test_nurse_getPatientFlow(capsys): ''' nurse.getPatientFlow(nur): patient_hcno = raw_input("What patient are you working with today? (hcno) ") if nur.getPatient(patient_hcno) is None: print "The patient with that hcno does not exist! Please create a new patient:" nur.newPatient(patient_hcno, raw_input("Patient name: "), raw_input("Patient age group: "), raw_input("Patient address: "), raw_input("Patient phone number: "), raw_input("Patient emergency number: ")) return patient_hcno ''' nur = Nurse(db.getUser('Lq{3', 'Lq{345')) # if user exists hcno = nurfile.getPatientFlow(nur) out = capsys.readouterr() assert out[0] == '' assert hcno == '15384' # if patient doesn't exist nurfile.getPatientFlow(nur) out = capsys.readouterr() assert out[0] == 'The patient with that hcno does not exist! Please create a new patient:'
def test_doctor_getChartsFlow(capsys): ''' doctor.getChartsFlow(doc): patient_hcno = raw_input("What patient are you working with today? (hcno) ") returnobj = doc.getCharts(patient_hcno) if returnobj == "no_patient": print("That is not a patient's hcno that we have registered. Please use hcno for the patient. ") patient_hcno = getChartsFlow(doc) return patient_hcno ''' doc = Doctor(db.getUser('RwiNqxg:', 'Vjgug"Pggf"Jcujkpi')) # if there is no patient with that hcno docfile.getChartsFlow(doc) out = capsys.readouterr() assert out[0] == '''That is not a patient's hcno that we have registered. Please use hcno for the patient. ''' # if patient with hcno exists hcno = docfile.getChartsFlow(doc) out = capsys.readouterr() assert out[0] == '' assert hcno == '15384'
def test_doctor_selectChart(capsys): ''' doctor.selectChart(doc, patient): chartId = raw_input("Which chart would you like to open? (select id) ") if not doc.printChartEntries(patient, chartId): print("There was a problem, please type the chartid. ") selectChart(doc, patient) return chartId ''' doc = Doctor(db.getUser('RwiNqxg:', 'Vjgug"Pggf"Jcujkpi')) # if there is no chart id # do not input 10001 docfile.selectChart(doc, "15384") out = capsys.readouterr() assert out[0] == 'There was a problem, please type the chartid. ' # if there is a chart id # input 10001 docfile.selectChart(doc, "15384") out = capsys.readouterr() assert out[0] == ''
def test_docIntroduce(): doc = Doctor(db.getUser('RwiNqxg:', 'Vjgug"Pggf"Jcujkpi')) assert doc.introduce() == "I'm a Doctor"
def test_newChart(): nur = Nurse(db.getUser('Lq{3', 'Lq{345')) newChart = nur.newChart("15384") print(newChart) assert newChart == 10010
def test_checkInferredAllergyToDrug(): doc = Doctor(db.getUser('RwiNqxg:', 'Vjgug"Pggf"Jcujkpi')) inferred = doc.checkInferredAllergyToDrug('15384', "ZMapp") assert inferred == None
def test_checkIfPatientHasOpenChart(): nur = Nurse(db.getUser('Lq{3', 'Lq{345')) assert nur.checkIfPatientHasOpenChart("20195") == "10009" assert nur.checkIfPatientHasOpenChart("15384") == None
def test_checkMedicationAmountValid(): doc = Doctor(db.getUser('RwiNqxg:', 'Vjgug"Pggf"Jcujkpi')) assert doc.checkMedicationAmountValid("ZMapp", "10", "18-39") == False assert doc.checkMedicationAmountValid("ZMapp", "5", "18-39") == True
def test_listDiagnosesMadeBeforePrescribingDrug(): drug_name = "ZMapp" adm = AdminStaff(db.getUser('Lgtkejq', 'sygtv{')) assert adm.listDiagnosesMadeBeforePrescribingDrug(drug_name) == True drug_name = "Heroin" assert adm.listDiagnosesMadeBeforePrescribingDrug(drug_name) == False
def test_nurIntroduce(): nur = Nurse(db.getUser('Lq{3', 'Lq{345')) assert nur.introduce() == "I'm a Nurse"