def viewMembers(username): try: user_ = ConfigFileReader.find_by_username(username) if (user_ == False): return -1 else: if (user_.type == 'admin'): recs = DataFileReader.loadall( ['doctor', 'nurse', 'patient']) # print(recs) for k in recs: print("\n" + k + "\n") for ele in recs[k]: print("\n") print(ele.__str__()) return 1 elif (user_.type == 'doctor'): recs = DataFileReader.loadall(['nurse', 'patient']) for k in recs: print("\n" + k + "\n") for ele in recs[k]: print("\n") print(ele.__str__()) return 1 elif (user_.type == 'nurse'): recs = DataFileReader.loadall(['patient']) for k in recs: print("\n" + k + "\n") for ele in recs[k]: print("\n") print(ele.__str__()) return 1 else: print("you haven't priviledges") return -1 return 1 except Exception as e: print("No members to view") print(e) return -1
def find_own_records(username, type_): try: records = DataFileReader.find_by_username(username) l = [] d = [] s = [] for r in records: if (isinstance(r, LabTestPrescription)): l.append(r) elif (isinstance(r, SicknessDetails)): s.append(r) elif (isinstance(r, DrugPrescription)): d.append(r) if (type_ == "lab record"): if (len(l) != 0): print("\nLab Descriptions\n") for i in l: print("patient username: "******"Description: " + i.description) print("Result: " + i.result) print("Issued Date: " + i.date.__str__()) print("\n") elif (type_ == "sickness record"): if (len(s) != 0): print("\nSickness Descriptions\n") for i in s: print("patient username: "******"Description: " + i.description) print("sickness_name: " + i.sickness_name) print("Issued Date: " + i.date.__str__()) print("\n") elif (type_ == "drug record"): if (len(d) != 0): print("\nDrug Descriptions\n") for i in d: print("patient username: "******"Description: " + i.description) print("valid_period: " + i.valid_period) print("Issued Date: " + i.date.__str__()) print("\n") else: print("Wrong Type chosen\nTry again") return False except Exception as e: print("\nNo reocords for " + username + " .") print(e) print("\n") return False
def findowndetails(username): try: recs = DataFileReader.find_by_username(username) try: for i in recs: if (isinstance(i, PersonalData)): record = i break except Exception: record = recs print(record.__str__()) except Exception as e: print("\n") # print(e) print("\n")
def patientCreate(): print("enter details") while True: username = input("Enter_username:- ") if (ConfigFileReader.find_by_username(username) != False): print("username exist. Type a new one\n") continue else: break firstName = input("Enter_firstName:- ") lastName = input("Enter_lastName:- ") address = input("Enter_address:- ") while True: telephone = input("Enter_telephone:- +94") try: int(telephone) if (len(telephone) < 9): print("enter a valid telephone number") continue else: break except Exception: print("enter a valid telephone number") continue while True: age = input("Enter_age:- ") try: int(age) if (True): break except Exception: print("enter a valid age") continue special_notes = input("Enter_special_notes:- ") user_ = Patient( username, telephone ) #initial password was phone number. Patient has to change it immediatly data_ = PatientData(username, firstName, lastName, telephone, address, age, special_notes) val1 = ConfigFileReader.add(user_) val2 = DataFileReader.add(data_) if (val1 == False or val2 == False): return False return True
def viewRecords(username, type_=''): ''' Type can be either report type or all(given by '') ''' records = DataFileReader.Record_find_by_finder_username( username, type_) if (records == False): print("No records\n") return False else: l = [] d = [] s = [] for r in records: if (isinstance(r, LabTestPrescription)): l.append(r) elif (isinstance(r, SicknessDetails)): s.append(r) elif (isinstance(r, DrugPrescription)): d.append(r) if (len(l) != 0): print("\nLab Descriptions\n") for i in l: print("patient username: "******"Description: " + i.description) print("Result: " + i.result) print("Issued Date: " + i.date.__str__()) print("\n") if (len(d) != 0): print("\nDrug Descriptions\n") for i in d: print("patient username: "******"Description: " + i.description) print("valid_period: " + i.valid_period) print("Issued Date: " + i.date.__str__()) print("\n") if (len(s) != 0): print("\nSickness Descriptions\n") for i in s: print("patient username: "******"Description: " + i.description) print("sickness_name: " + i.sickness_name) print("Issued Date: " + i.date.__str__()) print("\n")
def doctorCreate(): print("enter details") while True: username = input("Enter_username:- ") if (ConfigFileReader.find_by_username(username) != False): print("username exist. Type a new one\n") continue else: break firstName = input("Enter_firstName:- ") lastName = input("Enter_lastName:- ") address = input("Enter_address:- ") while True: telephone = input("Enter_telephone:- +94") try: int(telephone) if (len(telephone) < 9): print("enter a valid telephone number") continue else: break except Exception: print("enter a valid telephone number") continue nic = input("Enter_NIC:- ") doc_id = input("Enter_SLRC ID:- ") user_ = Doctor( username, telephone ) #initial password was phone number. Patient has to change it immediatly data_ = DoctorData(username, firstName, lastName, telephone, address, doc_id, nic) val1 = ConfigFileReader.add(user_) val2 = DataFileReader.add(data_) if (val1 == False or val2 == False): return False return True
def find_user_records(username): ''' find all records for a specific user. find_user_records(seracher,owner) ''' try: while True: print("You have to type the report type and the userID") print( "Enter the type of your report ex:- lab record | sickness record | drug record\n Other inputs will discarded" ) print("Type 'exit' to exit.") type_ = input("Enter the type:- ").strip() if (type_ == 'exit'): return -1 if (type_ not in [ 'lab record', 'sickness record', 'drug record' ]): print("\nInvalid type . Type Again\n") continue else: break while True: patient = input("Enter the patient username:- ").strip() find = ConfigFileReader.find_by_username(patient) if (patient == 'exit'): return -1 if (find == False or find.type != 'patient'): print("\nUsername can't find . Type Again\n") continue else: break recs = DataFileReader.Record_find_by_finder_username( username, type_) records = [] for i in recs: if (i.username == patient): records.append(i) if (records == False): return False else: l = [] d = [] s = [] for r in records: if (isinstance(r, LabTestPrescription)): l.append(r) elif (isinstance(r, SicknessDetails)): s.append(r) elif (isinstance(r, DrugPrescription)): d.append(r) if (len(l) != 0): print("\nLab Descriptions\n") for i in l: print("patient username: "******"Description: " + i.description) print("Result: " + i.result) print("Issued Date: " + i.date.__str__()) print("\n") if (len(d) != 0): print("\nDrug Descriptions\n") for i in d: print("patient username: "******"Description: " + i.description) print("valid_period: " + i.valid_period) print("Issued Date: " + i.date.__str__()) print("\n") if (len(s) != 0): print("\nSickness Descriptions\n") for i in s: print("patient username: "******"Description: " + i.description) print("sickness_name: " + i.sickness_name) print("Issued Date: " + i.date.__str__()) print("\n") except Exception as e: print("No record\n") print(e) return False
def addRecords(username): user_ = ConfigFileReader.find_by_username(username) if (user_ == False or user_.type not in ['doctor', 'admin']): print("You haven't access to add records.\n") else: while True: print( "Enter the type of your report ex:- lab report | sickness report | drug report\n Other inputs will discarded" ) print("Type 'exit' to exit.") type_ = input("Enter the type:- ").strip() if (type_ == 'exit'): return -1 if (type_ not in [ 'lab report', 'sickness report', 'drug report' ]): print("\nInvalid type . Type Again\n") continue else: break while True: patient = input("Enter the patient username:- ").strip() find = ConfigFileReader.find_by_username(patient) if (patient == 'exit'): return -1 if (find == False or find.type != 'patient'): print("\nUsername can't find . Type Again\n") continue else: break while True: print( "\nType the sensivity. sensivity value should be one of below values" ) print("\t" + sensitive_level_1 + "," + sensitive_level_2 + "," + sensitive_level_3 + "," + sensitive_level_4) sen = input("Enter the sensivty of the record:- ") if (sen == 'exit'): return -1 if (sen not in [ sensitive_level_1, sensitive_level_2, sensitive_level_3, sensitive_level_4 ]): print("\nInvalid value. Try again\n") continue else: break description = input("Enter the description:- ").strip() if (description == 'exit'): return -1 date = datetime.date.today() if (type_ == 'lab report'): result = input( "Enter the result(If result not came yet press enter) :- ") if (result == 'exit'): return -1 if (result == ''): result = 'Pending' obj = LabTestPrescription(patient, result, sen, description, date) elif (type_ == 'sickness report'): name = input("Enter the sickness name :- ") if (name == 'exit'): return -1 obj = SicknessDetails(patient, name, sen, description, date) elif (type_ == 'drug report'): valid_period = input("Enter the valid period :- ") if (valid_period == 'exit'): return -1 obj = DrugPrescription(patient, valid_period, sen, description, date) else: print("\nwrong type. Try again\n") if (obj == None or obj == False): print("\nwrong type. Try again\n") return False else: result = DataFileReader.add(obj) if (result == False): return False else: print("Succefully added") return True