def createItems(): doc1 = doctor('1', 'Ольга', 'Яновская', 'Андреевна', 'Психолог', 'высшая категория') doc2 = doctor('2', 'Елена', 'Дорофеева', 'Борисовна', 'Психолог', '1 категория') h.appendDoctor(doc1) h.appendDoctor(doc2) r1 = procedure('1', 'тыкнуть носом', 50, doc1) r2 = procedure('2', 'консультация', 350, doc2) h.appendProcedure(r1) h.appendProcedure(r2) p1 = patient('1', 'Кирилл', 'Вторцев', 'Дмитриевич', '21.11.2001', 50) p2 = patient('2', 'Марк', 'Захаров', '', '08.05.2001', -90) h.appendPatient(p1) h.appendPatient(p2) d1 = deal('1', '02.11.2020', 'что-то там 1', p1, [r1]) d2 = deal('2', '03.11.2020', 'что-то там 2', p2, [r1, r2]) h.appendDeal(d1) d1.appendProcedure(r1) h.appendDeal(d2) d2.appendProcedure(r1) d2.appendProcedure(r2) h.save('res.json')
def patientData(patientlist, i, j): try: MasterAssemble = sio.loadmat('MasterAssemble.mat') data = MasterAssemble['MasterAssemble'] DataName = (data['playerName'][0][0][0]) DataX = (data['translationX'][0][:].tolist()) #[0][:][:][0][:]) DataY = (data['translationY'][0][:].tolist()) DataT = (data['translationTime'][0][:]) DataD = (data['translationDistance'][0][:]) DataEvents = (data['translationMessages'][0][:]) #segmentedRoute = segmenter(DataX, DataY, DataT, DataEvents) #DataX = segmentedRoute[0] #DataY = segmentedRoute[1] #print(segmentedRoute) #print(DataX) #(DataY) Patient = patient( DataName, DataX, DataY, DataT, DataD, DataEvents ) # def __init__(self, name, x, y, time, distance, events): return Patient except: return patient('none', 0, 0, 0, 0, [0]) print("Problem with reading MasterAssemble.mat" + patientlist[i] + str(j))
def patientData(patientlist, i, j): try: MasterAssemble = sio.loadmat('MasterAssemble.mat') data = MasterAssemble['MasterAssemble'] DataName = (data['playerName'][0][0][0]) DataX = (data['translationX'][0][:].tolist())#[0][:][:][0][:]) DataY = (data['translationY'][0][:].tolist()) DataT = (data['translationTime'][0][:]) DataD = (data['translationDistance'][0][:]) DataEvents = (data['translationMessages'][0][:]) #segmentedRoute = segmenter(DataX, DataY, DataT, DataEvents) #DataX = segmentedRoute[0] #DataY = segmentedRoute[1] #print(segmentedRoute) #print(DataX) #(DataY) Patient = patient(DataName, DataX, DataY, DataT, DataD, DataEvents) # def __init__(self, name, x, y, time, distance, events): return Patient except: return patient('none', 0, 0, 0, 0, [0]) print("Problem with reading MasterAssemble.mat" + patientlist[i] + str(j))
def scan_input(feed): # enrollment dictionary to store patient objects enrollment = dict() #### example full traversal filtrage with preconditions ####################### # we'll iterate through each procedure scheduled # english only, at least 2 days until procedure date, location one for every entry, etc # the patient class handles tour classification via procedures for row in feed: p = patient(dict(row)) # general enrollment for location 1 p.setLocation(1) # initial tour qualifications; english language & 2 day schedule buffer if (p.isLanguage('English') and p.isScheduled(2)): # add the patient to the enrollment list; else if they already exist, update their new procedure if (p.Patient not in enrollment): p.addProcedure(p.Date, p.Type) enrollment[p.Patient] = p else: enrollment[p.Patient].addProcedure(p.Date, p.Type) else: enrollment[p.Patient] = p enrollment[p.Patient].tour = -1 return enrollment
def add_patient(self): name = input("Paitent Name : ") phone = input("Paitent Phone Number : ") problem = input("Nature of Problem :") print("1.OPD 2.EMERGENCY ") choice = int(input("Enter 1 for OPD or 2 for EMERGENCY :")) if choice == 1: fee = 400 ward = 'OPD' else: fee = 1000 ward = 'EMERGENCY' self.show_doc() print("Please select Doctors from above table") docname = input("Doctor Name :") date = input("Enter Date of Admission (YYYY-MM-DD) :") print("Estimated fees is {} for doctor {} ".format(fee, docname)) payment = input("Payment Method (CASH/CARD) : ") Patient = patient(0, name, phone, payment, problem, ward, docname, date) print("Patient Data added sucessfully ") self.ps.add_patient(Patient) Patients = self.ps.search_number(phone) if Patients: PatientService.paint_data_list(Patients) else: print("No data found with Patient ID :{}".format(phone))
def addPatients(df): person = list() added_patient = list() patientList = {} patient_years = {} for index, row in df.iterrows(): sid = row.SUBJECT_ID admittime = date.parse_date(row.ADMITTIME) #Create patient if sid not in added_patient: dob = date.parse_date(row.DOB) if row.EXPIRE_FLAG == 1: dod = date.parse_date(row.DOD) else: dod = None pat = patient(sid, row.GENDER, dob, dod, row.EXPIRE_FLAG, admittime) patientList[sid] = pat added_patient.append(sid) else: patientList[sid].updateAdm(admittime) ########################################## for sid in patientList: maxdate = patientList[sid].getmaxadm() yeardif = date.generateYearDif(maxdate) patient_years[sid] = yeardif patientList[sid].changeDate(yeardif) val = (patientList[sid].getGender(), patientList[sid].getDoB(), patientList[sid].getFlag(), patientList[sid].getDoD(), 1, datetime.datetime.now()) person.append(val) returndata = [person, added_patient, patient_years] return returndata
def checkName(db, name): p = PatientMod.patient(db.getPatientDetails(patientsurname=name)) percentageChance = check(p) p.patientData[ 'percentage_chance'] = percentageChance #Add the new data to the patient record db.write(p) #Write the new record! #TODO We should probably write back to the DB here the chance that they got return percentageChance #get the id and check it.
def changeItems(): doc3 = doctor('3', 'Наталия', 'Чехонина', 'Павловна', 'стоматолог', '1 категория') h.appendDoctor(doc3) r3 = procedure('3', 'консультация', 500, doc3) h.appendProcedure(r3) p2 = patient('2', 'Марк', 'Захаров', '', '08.05.2001', -90) h.appendPatient(p2) d3 = deal('3', '13.12.2020', 'Зубной налет', p2, [r3]) h.appendDeal(d3)
def checkID(db, patientID): """ Checks if the patient has anthrax, sets that status in the DB, and returns true or false """ p = PatientMod.patient(db.getPatientDetails(patientid=patientID)) print(type(p.patientData)) percentageChance = check(p) # p.patientData['percentage_chance'] = percentageChance #Add the new data to the patient record # db.write(p) #Write the new record! #TODO We should probably write back to the DB here the chance that they got return percentageChance #get the id and check it.
def patient_details(): patient.patient()
# Creates a clinic, saves patient files and then retrieves all .pkl # files from a particular day. import file_manager import patient import datetime fm = file_manager.FileManager() fm.create_clinic_dir("my_clinic3", ".") p = patient.patient() p.date = datetime.datetime.now() p.family_name = "smith" p.id = "12345" p.given_name = "john" fm.save_patient_files(p, "tmp.img", "tmp.pkl") fm.save_patient_files(p, "tmp.img", "tmp.pkl") fm.save_patient_files(p, "tmp.img", "tmp.pkl") today = datetime.datetime.now().strftime("%d") files = fm.get_patient_files2(day=today, file_type=".pkl") print "files = ", " ".join(files)
import MySQLdb import patient import doctor from tabulate import tabulate while True: choice = input( "\n1.Register\n2.Display Records\n3.Update\n4.Delete\n5.Exit\n\n>>> ") if choice == 1: choice = input("\n1.Patient\n2. Doctor\n3.Exit\n\n>>> ") if choice == 1: while True: s = patient.patient() s.register() choice = raw_input("Add more? [Y/n] ") if choice.lower() == "y": pass elif choice.lower() == "n": break else: print "Please enter valid choice" elif choice == 2: while True: s = doctor.doctor() s.register() choice = raw_input("Add more? [Y/n] ") if choice.lower() == "y":
def analyzeID(db, Id): """Takes an ID, tracks the movement attached to it and finds other people that may have come in contact""" p = patient(db.getPatientDetails(patientid=Id)) ret = analyze(p) return json.dumps(ret, sort_keys=True)
def analyzeName(db, name): """ Takes an ID, tracks the movement attached to it and finds other people that may have come in contact""" p = patient(db.getPatientDetails(patientsurname=name)) return none
def build_patients(index=-1, freq_idx=0, if_weekly=0, if_2weekly=0, if_PSV=0, if_yrandom=0, if_sliding_window=0, sw_size=31, log=0, if_shuffle_label=0, reg=0): col_rs = hp.col_rs col_es = hp.col_es col_le = hp.col_le #build patient object p222_1 = patient('222_1', if_sliding_window=if_sliding_window, sw_size=sw_size, reg=reg) p222_2 = patient('222_2', if_sliding_window=if_sliding_window, sw_size=sw_size, reg=reg) p222_3 = patient('222_3', if_sliding_window=if_sliding_window, sw_size=sw_size, reg=reg) p222 = patient('222', if_sliding_window=if_sliding_window, sw_size=sw_size, reg=reg) p231 = patient('231', if_sliding_window=if_sliding_window, sw_size=sw_size, reg=reg) # local means whether to use local(weekly) median as threshold # p229 = patient('229', if_sliding_window = if_sliding_window, sw_size = sw_size, reg = reg) p241 = patient('241', if_sliding_window=if_sliding_window, sw_size=sw_size, reg=reg) # 06/2019 239,225,251,217,229 # p239_1 = patient('239_1', if_sliding_window = if_sliding_window, sw_size = sw_size, reg = reg) # p239_2 = patient('239_2', if_sliding_window = if_sliding_window, sw_size = sw_size, reg = reg) # p225_1 = patient('225_1', if_sliding_window = if_sliding_window, sw_size = sw_size, reg = reg) # p225_2 = patient('225_2', if_sliding_window = if_sliding_window, sw_size = sw_size, reg = reg) # p251 = patient('251', if_sliding_window = if_sliding_window, sw_size = sw_size, reg = reg) # p217 = patient('217', if_sliding_window = if_sliding_window, sw_size = sw_size, reg = reg) # p229 = patient('229', if_sliding_window = if_sliding_window, sw_size = sw_size, reg = reg) p239 = patient('239', if_sliding_window=if_sliding_window, sw_size=sw_size, reg=reg) p225 = patient('225', if_sliding_window=if_sliding_window, sw_size=sw_size, reg=reg) p201 = patient('201', if_sliding_window=if_sliding_window, sw_size=sw_size, reg=reg) p226 = patient('226', if_sliding_window=if_sliding_window, sw_size=sw_size, reg=reg) #add epoch info # start_222_1 = datetime.strptime('Feb 12 2016', '%b %d %Y') # end_222_1 = datetime.strptime('Oct 24 2016', '%b %d %Y') # num_per_epoch_222_1 = 31 start_222 = datetime.strptime('Feb 12 2016', '%b %d %Y') end_222 = datetime.strptime('May 29 2017', '%b %d %Y') num_per_epoch_222 = 31 start_222_2 = datetime.strptime('Oct 26 2016', '%b %d %Y') end_222_2 = datetime.strptime('May 29 2017', '%b %d %Y') num_per_epoch_222_2 = 30 start_222_3 = datetime.strptime('Sep 19 2017', '%b %d %Y') end_222_3 = datetime.strptime('Jan 30 2018', '%b %d %Y') num_per_epoch_222_3 = 31 # start_222 = [start_222_1, start_222_2, start_222_3] # end_222 = [end_222_1, end_222_2, end_222_3] # num_per_epoch_222 = [num_per_epoch_222_1, num_per_epoch_222_2, num_per_epoch_222_3] start_231 = datetime.strptime('Dec 6 2016', '%b %d %Y') end_231 = datetime.strptime('Feb 21 2018', '%b %d %Y') num_per_epoch_231 = 31 # start_231 = datetime.strptime('Feb 7 2017', '%b %d %Y') # end_231 = datetime.strptime('Feb 21 2018', '%b %d %Y') # num_per_epoch_231 = 31 start_241 = datetime.strptime('Nov 14 2017', '%b %d %Y') end_241 = datetime.strptime('Oct 4 2018', '%b %d %Y') num_per_epoch_241 = 29 start_239 = datetime.strptime('Jan 4 2018', '%b %d %Y') end_239 = datetime.strptime('May 24 2019', '%b %d %Y') num_per_epoch_239 = 31 start_225 = datetime.strptime('Jul 19 2016', '%b %d %Y') end_225 = datetime.strptime('Jul 12 2017', '%b %d %Y') num_per_epoch_225 = 33 #5/22/2015 - 1/29/2016, 4/11/2017 - 10/22/2017 start_201 = datetime.strptime('Feb 7 2016', '%b %d %Y') end_201 = datetime.strptime('Oct 22 2017', '%b %d %Y') num_per_epoch_201 = 31 # Apr 26, 2017 to Nov 12, 2017 start_226 = datetime.strptime('Apr 26 2017', '%b %d %Y') end_226 = datetime.strptime('Apr 16 2018', '%b %d %Y') num_per_epoch_226 = 32 # start_239_1 = datetime.strptime('Jul 13 2018', '%b %d %Y') # end_239_1 = datetime.strptime('Jan 31 2019', '%b %d %Y') # num_per_epoch_239_1 = 28 # start_239_2 = datetime.strptime('Jan 4 2018', '%b %d %Y') # end_239_2 = datetime.strptime('Jul 11 2018', '%b %d %Y') # num_per_epoch_239_2 = 31 # start_225_1 = datetime.strptime('Aug 24 2016', '%b %d %Y') # end_225_1 = datetime.strptime('Apr 12 2017', '%b %d %Y') # num_per_epoch_225_1 = 33 # start_225_2 = datetime.strptime('Oct 13 2017', '%b %d %Y') # end_225_2 = datetime.strptime('Jun 5 2018', '%b %d %Y') # num_per_epoch_225_2 = 29 # start_251 = datetime.strptime('Sep 26 2018', '%b %d %Y') # end_251 = datetime.strptime('Apr 28 2019', '%b %d %Y') # num_per_epoch_251 = 30 # start_217 = datetime.strptime('Jul 19 2018', '%b %d %Y') # end_217 = datetime.strptime('May 18 2019', '%b %d %Y') # num_per_epoch_217 = 30 # start_229 = datetime.strptime('Oct 9 2017', '%b %d %Y') # end_229 = datetime.strptime('Feb 13 2019', '%b %d %Y') # num_per_epoch_229 = 27 p231.add_epochinfo(start_231, end_231, num_per_epoch_231) # p222_1.add_epochinfo(start_222_1, end_222_1, num_per_epoch_222_1) # p222_2.add_epochinfo(start_222_2, end_222_2, num_per_epoch_222_2) # p222_3.add_epochinfo(start_222_3, end_222_3, num_per_epoch_222_3) p222.add_epochinfo(start_222, end_222, num_per_epoch_222) # p229.add_epochinfo(start_229, end_229, num_per_epoch_229) p241.add_epochinfo(start_241, end_241, num_per_epoch_241) # p239_1.add_epochinfo(start_239_1, end_239_1, num_per_epoch_239_1) # p239_2.add_epochinfo(start_239_2, end_239_2, num_per_epoch_239_2) # p225_1.add_epochinfo(start_225_1, end_225_1, num_per_epoch_225_1) # p225_2.add_epochinfo(start_225_2, end_225_2, num_per_epoch_225_2) # p251.add_epochinfo(start_251, end_251, num_per_epoch_251) # p217.add_epochinfo(start_217, end_217, num_per_epoch_217) # p229.add_epochinfo(start_229, end_229, num_per_epoch_229) p239.add_epochinfo(start_239, end_239, num_per_epoch_239) p225.add_epochinfo(start_225, end_225, num_per_epoch_225) p201.add_epochinfo(start_201, end_201, num_per_epoch_201) p226.add_epochinfo(start_226, end_226, num_per_epoch_226) #add duration and daily prepath = '../data/' duration_222_1 = pd.read_csv( prepath + 'NY222_3760120_2015-08-11_to_2016-08-11_20180809165417.csv', skiprows=3) duration_222_2 = pd.read_csv( prepath + 'NY222_3760120_2016-08-11_to_2017-08-11_20180809003645.csv', skiprows=3) duration_222_3 = pd.read_csv( prepath + 'NY222_3760120_2017-08-11_to_2018-08-08_20180809004150.csv', skiprows=3) duration_231_1 = pd.read_csv( prepath + 'NY231_4086548_2016-07-05_to_2017-07-05_20180809005536.csv', skiprows=3) duration_231_2 = pd.read_csv( prepath + 'NY231_4086548_2017-07-05_to_2018-08-08_20180809010451.csv', skiprows=3) duration_229_1 = pd.read_csv(prepath + '229_duration.csv', skiprows=3) daily = {} daily['222'] = prep.prep_daily( pd.read_csv(prepath + 'NY222_2015-08-11_to_2018-06-12_daily_20180613153105.csv', skiprows=3)) daily['231'] = prep.prep_daily( pd.read_csv(prepath + 'NY231_2016-07-05_to_2018-06-12_daily_20180613153815.csv', skiprows=3)) # daily['229'] = prep.prep_daily(pd.read_csv(prepath + 'NY229_2017-05-12_to_2018-09-07_daily_20180907183334.csv', skiprows=3)) daily['241'] = prep.prep_daily( pd.read_csv(prepath + 'NY241_2017-06-13_to_2018-10-05_daily_20181005204526.csv', skiprows=3)) daily['239'] = prep.prep_daily( pd.read_csv(prepath + 'NY239_2017-03-28_to_2019-05-24_daily_20190524174640.csv', skiprows=3)) daily['225'] = prep.prep_daily( pd.read_csv(prepath + 'NY225_2016-01-14_to_2019-05-23_daily_20190524174650.csv', skiprows=3)) daily['201'] = prep.prep_daily( pd.read_csv(prepath + '201_daily.csv', skiprows=3)) daily['226'] = prep.prep_daily( pd.read_csv(prepath + 'NY226_2016-02-09_to_2018-10-05_daily_20181005204146.csv', skiprows=3)) # daily['251'] = prep.prep_daily(pd.read_csv(prepath + 'NY251_2018-02-06_to_2019-04-29_daily_20190524174653.csv', skiprows=3)) # daily['217'] = prep.prep_daily(pd.read_csv(prepath + 'NY217_2015-05-14_to_2019-05-18_daily_20190524174658.csv', skiprows=3)) # daily['229'] = prep.prep_daily(pd.read_csv(prepath + 'NY229_2016-05-12_to_2019-05-20_daily_20190524174704.csv', skiprows=3)) #all patients if index == -1: pat_list = [p231, p222_1, p222_2, p229] elif index == 231: pat_list = [p231] elif index == 2221: pat_list = [p222_1] elif index == 241: pat_list = [p241] elif index == 2223: pat_list = [p222_3] elif index == -2: pat_list = [p239, p225, p222] elif index == -3: pat_list = [p231, p222_1, p222_2, p241] elif index == -4: pat_list = [p231, p222, p201, p226] for pat in pat_list: if if_weekly: pat.epoch_info['num_per_epoch'] = 7 if if_2weekly: pat.epoch_info['num_per_epoch'] = 14 if if_PSV: f = h5py.File('../data/features_sync_90' + pat.pat_id + '.mat', 'r') elif freq_idx == 124: f = h5py.File('../data/features_124' + pat.pat_id + '.mat', 'r') elif freq_idx == 90: f = h5py.File('../data/features_90' + pat.pat_id + '.mat', 'r') else: sys.exit(1) # use daily file to identify the label for each epoch or each ECog pat.add_daily(daily[pat.pat_id], log=log, reg=reg) # if use random label if if_yrandom: prev_dict = pat.epoch_label_dict pat.prev_dict = prev_dict n = len(prev_dict) print('prev_dict: ', prev_dict) new_dict = {} tf = np.array([True, False]) if pat.id == '241': np.random.seed(40) new_vals = np.random.choice( tf, size=n, ) np.random.seed(42) for i, key in enumerate(prev_dict): new_dict[key] = new_vals[i] print('new_dict', new_dict) pat.epoch_label_dict = new_dict pat.add_features(f, if_PSV=if_PSV) if if_shuffle_label: label_list = list(pat.features.label) np.random.shuffle(label_list) pat.features.label = label_list pat.ngood = pat.features.loc[pat.features['label'] == True].shape[0] pat.nbad = pat.features.loc[pat.features['label'] == False].shape[0] pat.ndata = pat.features.shape[0] pat.print_features_property() if len(pat_list) == 1: return pat_list[0] return tuple(pat_list)
doctors = doctorList() procedures = procedureList() doc1 = doctor(1, 'Ольга', 'Яновская', 'Андреевна', 'Психолог', 'высшая категория') doc2 = doctor(2, 'Елена', 'Дорофеева', 'Борисовна', 'Психолог', '1 категория') doctors.appendList(doc1) doctors.appendList(doc2) r1 = procedure(0, 'тыкунть носом', 500, doc1) r2 = procedure(0, 'консультация', 3500, doc2) r3 = procedure(0, 'консультация2', 100, doc2) procedures.appendList(r1) procedures.appendList(r2) procedures.appendList(r3) p1 = patient(1, 'Кирилл', 'Вторцев', 'Дмитриевич', '21.11.2001', 50) p2 = patient(2, 'Марк', 'Захаров', '', '08.05.2001', -90) patients.appendList(p1) patients.appendList(p2) d1 = deal(1, '02.11.2020', 'что-то там 1', p1, [r1]) d2 = deal(2, '03.11.2020', 'что-то там 2', p2, [r1, r2]) d3 = deal(3, '11.11.2020', 'что-то там 3', p1, [r3]) #d1.setPatient(p1) #d2.setPatient(p2) deals.appendList(d1) deals.appendList(d2) deals.appendList(d3) print(procedures)
import file_manager import patient import datetime p1 = patient.patient () p1.given_name = 'John' p1.family_name = 'Smith' p1.date = datetime.datetime.now () p1.id = '12345678910' fm = file_manager.FileManager () print "\n" print "////////////////////// Starting Test 1 /////////////////////" print "\n" print "calling fm.create_clinic_dir ('my_clinic', '.')" print "\n" fm.create_clinic_dir ('my_clinic', '.') print "calling fm.get_clinic_dir ()" print "\n" print "clinic_dir = ", fm.get_clinic_dir () print "\n" print "saving patient John Smith's files" print ("calling fm.save_patient_files ", "(p1, 'tmp.pkl', 'tmp.docx', 'tmp.csv', 'tmp2.img')")
def get_list_data(rows): return [patient(*row) for row in rows]