def prepare_patients(): # Attributes data = pd.DataFrame() patient_list = [] confidence = 100 id_n = 0 code = 33 # Prepare files = [ f for f in listdir("./datasets/data/") if isfile(join("./datasets/data", f)) and not f.startswith('.') ] sorted_files = sorted(files, key=lambda item: (int(item.partition(' ')[0]) if item[0].isdigit() else float('inf'), item)) # Iterate through files and create patient for each given file # This will be altered upon integration of a real-time OR quasi-real-time system for i in sorted_files[:70]: # increment id index id_n += 1 # create dataframe df fullpath = "./datasets/data/" + i df = pd.read_csv( fullpath, # or delim_whitespace=True, #separator is whitespace header=None, # no header names=['DATE', 'TIME', 'CODE', 'VALUE']) # set columns names # create patient object and append into patient list patient = pt.Patient(id_n, df, confidence) patient_list.append(patient) return patient_list
def main(): patient1 = patient.Patient("Joe", "Harold", "Smith", "123 Main St.", \ "Beverly Hills", "California", "90210", \ "123-456-7890", "Sally Smith", "987-654-3210") procedure1 = procedure.Procedure("Physical Exam", "03/17/2020", \ "Dr. Irvine", 250.00) procedure2 = procedure.Procedure("X-ray", "03/17/2020", \ "Dr. Jamison", 500.00) procedure3 = procedure.Procedure("Blood test", "03/17/2020", \ "Dr. Smith", 200.00) print("---------------Patient Information--------------") print(patient1) print("--------------------Procedures------------------") print(procedure1) print(procedure2) print(procedure3) total_charges = procedure1.get_charges() + procedure2.get_charges() + \ procedure3.get_charges() print("----------------------Charges-------------------") print("Total Charges: $" + format(total_charges, ",.2f"))
def main(): # patient instance patient1 = patient.Patient('Victoria', 'Tori', 'Mendoza', '123 Road', 'Waco', 'TX', '76706', '(123)456-7891', 'Mom Mendoza', '(234)567-8910') patient1.display_patient() # procedure 1 procedure1 = patient.Procedure('Physical Exam', f"{datetime.datetime.now():%m-%d-%Y}", 'Dr. Irvine', '${:,.2f}'.format(250.00)) procedure1.display_procedure() # procedure 2 procedure2 = patient.Procedure('X-ray', f"{datetime.datetime.now():%m-%d-%Y}", 'Dr. Jamison', '${:,.2f}'.format(500.00)) procedure2.display_procedure() # procedure 3 procedure3 = patient.Procedure('Blood Test', f"{datetime.datetime.now():%m-%d-%Y}", 'Dr. Smith', '${:,.2f}'.format(200.00)) procedure3.display_procedure()
def main(): now = datetime.now() procList = [] patientFirst = patient.Patient('Alex', 'Nore', 'Kor', 'Kvitucha str 30', 'Kyiv', 'Kyiv region', '01001', '12345678', 'Anna', '98214566') procedure1 = procedure.Procedure('Physical Exam', now, 'Dr. Irvine', 250.00) procedure2 = procedure.Procedure('X-ray', now, 'Dr. Jamison', 500.00) procedure3 = procedure.Procedure('Blood test', now, 'Dr. Smith', 200.00) total = procedure1.get_charge() + procedure2.get_charge() + procedure3.get_charge() print(patientFirst) print() print(procedure1) print() print(procedure2) print() print(procedure3) print() print("Total fee: ", total)
def info(name, address, telephone, contact): print('\nИнформация о пациенте:') info_patient = patient.Patient(name, address, telephone, contact) print('имя, отчество и фамилия:', info_patient.get_name_patronymic_surname()) print('адрес, город, область и почтовый индекс:', info_patient.get_address_city_region_zip()) print('телефонный номер:', info_patient.get_number_telephone()) print('имя и телефон контактного лица для экстренной связи:', info_patient.get_name_telephone_emergency()) print() for i in range(1, 4): print('Процедура №', i, sep='') name_procedure = input('Название процедуры: ') date_procedure = input('Дата: ') name_doctor_performed_procedure = input('Врач: ') cost_procedure = float(input('Стоимость: ')) my_procedure = procedure.Procedure(name_procedure, date_procedure, name_doctor_performed_procedure, cost_procedure) print('Название процедуры:', '\n', my_procedure.get_name_procedure()) print('Дата:', my_procedure.get_date_procedure()) print('Врач:', my_procedure.get_name_doctor_performed_procedure()) print('Стоимость:', my_procedure.get_cost_procedure()) print() print('-' * 76)
def get_markov_chain_for_each(model, obs, lengths, patients, col_index): print("obs.shape: ", obs.shape) obs = utils.preprocess_data(obs, THREADHOLD[col_index]) start_index = 0 for i in range(0, len(lengths)): patient_id = lengths[i, 0] end_index = start_index + lengths[i, 1] states = model.predict(obs[start_index:end_index, :]) # print("states: ", states) state_frequency = np.bincount(states) state_frequency = np.pad(state_frequency, (0, N_COMPONENTS - state_frequency.shape[0]), 'constant', constant_values=0) if USE_PROPORTION: state_proportion = state_frequency / np.sum(state_frequency) else: state_proportion = state_frequency # print("state_frequency: ", state_frequency) if patient_id in patients: patients[patient_id].add_state_proportion(state_proportion, col_index) else: patients[patient_id] = Patient.Patient(patient_id) patients[patient_id].add_state_proportion(state_proportion, col_index) start_index = end_index
def get_trends(patients, trend_types=TREND_TYPE): for trend_type in trend_types: filename = "../data_" + LABEL + "/" + trend_type + "_predict.csv" trend_records = pd.read_csv(filename, sep=',', header=0).values[:, 1:] for trend_record in trend_records: patient_id = trend_record[0] if patient_id in patients: patients[patient_id].add_trend(trend_record[1], trend_type) else: patients[patient_id] = Patient.Patient(patient_id) patients[patient_id].add_trend(trend_record[1], trend_type)
def add_patient(self): gender = raw_input('\nEnter patient gender (m/f/x) -- ') height = input('Enter patient height (inches) -- ') new_patient = patient.Patient(gender, height) print 'Patient with ID {} and ventilator score {} created'.format( new_patient.patient_id, new_patient.ventilator_score ) self.patients[new_patient.patient_id] = new_patient print 'Patient is currently unassigned.' return new_patient
def addshortcuts(self): f = Frame(self.master, bd=1, relief=SUNKEN) f.pack() photo = PhotoImage(file="./images/bill.png") b = Button(f, image=photo, text="bill", compound=BOTTOM, width=100, height=100, command=lambda: bill.Bill()) b.pack(side=LEFT) b.image = photo photo = PhotoImage(file="./images/purchase.png") b = Button(f, image=photo, text="purchase", compound=BOTTOM, width=100, height=100, command=lambda: purchase.addStock()) b.pack(side=LEFT) b.image = photo photo = PhotoImage(file="./images/patient.png") b = Button(f, image=photo, text="patient", compound=BOTTOM, width=100, height=100, command=lambda: patient.Patient()) b.pack(side=LEFT) b.image = photo photo = PhotoImage(file="./images/donor.png") b = Button(f, image=photo, text="donor", compound=BOTTOM, width=100, height=100, command=lambda: donor.Donor()) b.pack(side=LEFT) b.image = photo photo = PhotoImage(file="./images/new.png") b = Button(f, image=photo, text="Services", compound=BOTTOM, width=100, height=100, command=lambda: service.Inv()) b.pack(side=LEFT) b.image = photo
def addshortcuts(self): f = Frame(self, bd=1, relief=SUNKEN) f.pack() photo = PhotoImage(file="./images/bill.png") b = Button(f, image=photo, text="bill", compound=BOTTOM, width=100, height=100, command=lambda x=self: bill.Bill(x)) b.pack(side=LEFT) b.image = photo photo = PhotoImage(file="./images/purchase.png") b = Button(f, image=photo, text="purchase", compound=BOTTOM, width=100, height=100, command=lambda x=self: purchase.addStock(x)) b.pack(side=LEFT) b.image = photo photo = PhotoImage(file="./images/return.png") b = Button(f, image=photo, text="cancel", compound=BOTTOM, width=100, height=100, command=lambda x=self: cancel.Cancel(x)) b.pack(side=LEFT) b.image = photo photo = PhotoImage(file="./images/new.png") b = Button(f, image=photo, text="new", compound=BOTTOM, width=100, height=100, command=lambda: new.adder()) b.pack(side=LEFT) b.image = photo photo = PhotoImage(file="./images/patient.png") b = Button(f, image=photo, text="patient", compound=BOTTOM, width=100, height=100, command=lambda: patient.Patient()) b.pack(side=LEFT) b.image = photo
def createobjects(): patient0 = patient.Patient('John', 'Pika', 'Doe', 'Nice street 30', 'New York', 'NY', 'NY10503', '12341234', 'Yeadsgfd', '13241235') procedure1 = procedure.Procedure('Laser αμφιβλιστροϊδή', '5/5/1990', 'Dr. Μπαμπης Παπαδημητρίου', '30.000 δρχ.') procedure2 = procedure.Procedure('Αφαιρεση Χολής', '10/9/2000', 'Dr Μαρία Τσακαλώτου', '500 ευρώ') procedure3 = procedure.Procedure('Βλαστοκυτταρική αναγέννηση', '23/12/2018', 'Dr Frankenstein', '50.000 ευρώ') return (patient0, procedure1, procedure2, procedure3)
def process_patient_file(): patient_dict = {} patient_file = open("patients.txt", 'r') for patient_inp in patient_file: patient_split = patient_inp.rstrip().split('#') patient_obj = patient.Patient(patient_split[0], patient_split[1], patient_split[2], patient_split[3], patient_split[4], patient_split[5], patient_split[6], patient_split[7], patient_split[8], patient_split[9], patient_split[10]) patient_dict[patient_split[0]] = patient_obj return patient_dict
def main(): Patient1 = patient.Patient("James", "Edward", "Jones", "123 Main Street", "Billings", "Montana", 59000, "406-555-1212", "Jerry Jones", "406-555-1213") Procedure1 = procedure.Procedure(1, 250.00) # creates procedure 1 object Procedure2 = procedure.Procedure(2, 500.00) # creates procedure 2 object Procedure3 = procedure.Procedure(3, 200.00) # creates procedure 3 object printPatient(Patient1) # prints the patient details Procedure1.printProcedure() # prints the procedure details Procedure2.printProcedure() # prints the procedure details Procedure3.printProcedure() # prints the procedure details return # end program
def user_info(): # asks for user information print("What is your first, middle, and last name?") name = input() print("What is your full address?") address = input() print("What is your phone number?") phone = int(input()) print("What is the name of your emergency contact and number?") emergency = input() # sends user info to the patient class info = patient.Patient(name, address, phone, emergency) # return info return info
def get_all_patients(path): patients = [] records = open(path) header = [] for record in records: if not header: header = record.split(",") for item_idx in range(len(header)): if header[item_idx] == '222': id_loc = item_idx break else: patient_info = record.split(",") # patient_id = patient_info[-1][:-1] patient_id = patient_info[id_loc] curr_patient = patient.Patient(patient_id) curr_patient_diseases = {} curr_patient_symptoms = {} curr_patient_medications = {} for info_idx in range(len(header)): if header[info_idx] in disease_mapping: curr_patient_diseases[header[info_idx]] = int(patient_info[info_idx]) elif header[info_idx] in medication_mapping: curr_patient_medications[header[info_idx]] = int(patient_info[info_idx]) elif header[info_idx] in symptom_mapping: curr_patient_symptoms[header[info_idx]] = int(patient_info[info_idx]) elif header[info_idx] in meta_mapping: # TODO : check what is 222 if meta_mapping[header[info_idx]] == "First Name": curr_patient.first_name = patient_info[info_idx] elif meta_mapping[header[info_idx]] == "Last Name": curr_patient.last_name = patient_info[info_idx] elif meta_mapping[header[info_idx]] == "Gender": curr_patient.gender = patient_info[info_idx] elif meta_mapping[header[info_idx]] == "Date of Birth": curr_patient.date_of_birth = patient_info[info_idx] elif meta_mapping[header[info_idx]] == "Place": curr_patient.place = patient_info[info_idx] curr_patient.diseases = curr_patient_diseases curr_patient.symptoms = curr_patient_symptoms curr_patient.medications = curr_patient_medications patients.append(curr_patient) return patients
def patient_profile(email): email = utils.unquote(email) if not check_login(): return redirect(url_for('login')) pt = patient.Patient(email) book_history = pt.query_book() for item in book_history: item['provider_email_quote'] = utils.quote(item['provider_email']) item['center_name_quote'] = utils.quote(item['center_name']) if session['role'] == 'patient': return render_template('patient_profile.html', patient_email=email, book_history=book_history, patient_mode=True) else: return render_template('patient_profile.html', patient_email=email, book_history=book_history, patient_mode=False)
def logowanie(self): statements.Stat.log_in() funkcja = input().upper() if funkcja == 'D': print('Logging to doctor\'s account') pesel = input("Enter PESEL number: ") haslo = input("Enter password: "******"Select * from lekarze where pesel_lek = %s and haslo_lek = %s", (pesel, haslo)) results_lekarze = self.kursor.fetchall() if (len(results_lekarze) == 1): print("Login succeeded") doctor.Doctor(pesel, self.kursor, self.polaczenie) else: print("Wrong PESEL number or password") self.logowanie() elif funkcja == 'P': print('Logging to patient account') pesel = input("Enter PESEL number: ") haslo = input("Enter password: "******"Select * from pacjenci where pesel = %s and haslo = %s", (pesel, haslo)) results_pacjenci = self.kursor.fetchall() if (len(results_pacjenci) == 1): print("Login Succeeded") patient.Patient(pesel, self.kursor, self.polaczenie) print("Program closed") else: print("Wrong PESEL number or password") self.logowanie() elif funkcja == 'X': print("Program closed") else: print("Entered data do not exist. Please try again. ") self.logowanie()
def index(): if not check_login(): return redirect(url_for('login')) if session['role'] != 'patient': return redirect('/provider_profile/' + utils.quote(session['email'])) pt = patient.Patient(session['email']) center_v = "" provider_v = "" service_v = "" if request.method == "GET": results = pt.search(center=center_v, provider=provider_v, service=service_v) for res in results: pvd = provider.Provider(res['provider_email']) ct = center.Center(res['health_centre_name']) res['center_rate'] = ct.get_rate() res['provider_rate'] = pvd.get_rate() res['health_centre_name_quote'] = utils.quote( res['health_centre_name']) res['provider_email_quote'] = utils.quote(res['provider_email']) return render_template('index.html', patient_email=session['email'], result_list=results) center_v = request.form["center"] provider_v = request.form["provider"] service_v = request.form["service"] results = pt.search(center=center_v, provider=provider_v, service=service_v) for res in results: pvd = provider.Provider(res['provider_email']) ct = center.Center(res['health_centre_name']) res['center_rate'] = ct.get_rate() res['provider_rate'] = pvd.get_rate() res['health_centre_name_quote'] = utils.quote( res['health_centre_name']) res['provider_email_quote'] = utils.quote(res['provider_email']) return render_template('index.html', patient_email=session['email'], result_list=results)
def book(): tp = [ str(i).zfill(2) + ":" + str(j).zfill(2) for i in range(24) for j in [0, 30] ] if not check_login(): return redirect(url_for('login')) if request.method == 'GET': qs = request.query_string query_info = utils.parse_query_string(qs) query_info['patient'] = session['email'] return render_template('make_appointment.html', qs=qs, service_time=query_info['time'], patient_email_quote=utils.quote( query_info['patient']), patient_email=query_info['patient'], center_name=query_info['center'], provider_email=query_info['provider'], success=False, tp=tp) else: begin = request.form["begin-time"] end = request.form["end-time"] comment = request.form["comment"] provider = request.form["provider"] center = request.form["center"] pt = patient.Patient(session['email']) flag = pt.book(provider, center, begin, end, comment) qs = request.query_string query_info = utils.parse_query_string(qs) query_info['patient'] = session['email'] return render_template('make_appointment.html', qs=qs, service_time=query_info['time'], patient_email_quote=utils.quote( query_info['patient']), patient_email=query_info['patient'], center_name=query_info['center'], provider_email=query_info['provider'], success=flag, tp=tp)
def main(): today = "Febraury 22, 2021" patientInfo = patient.Patient("Ruben", "Abdias", "Nunez", "15555 10th street", "Somewhere", "Missouri", "64030", "(816) 799-5111", "John Locke", "(816) 800-5112") physicalExam = procedure.Procedure("Physical Exam", today, "Dr. Irvine", 250.0) xRay = procedure.Procedure("X-ray", today, "Dr. Jamison", 500.0) bloodTest = procedure.Procedure("Blood Test", today, "Dr. Smith", 200.0) print(patientInfo, "\n") print(physicalExam, "\n") print(xRay, "\n") print(bloodTest, "\n") totalCharges = physicalExam.getCharge() + xRay.getCharge( ) + bloodTest.getCharge() print("Total charge for all tests:", totalCharges)
def main(argv): try: opts, args = getopt.getopt(argv, "hd:") except getopt.GetoptError: print "wtf" sys.exit(2) directory = None for opt, arg in opts: if opt == '-h': print 'wtf' sys.exit() elif opt == '-d': directory = arg.replace('\\', '/') assert os.path.isdir(directory), "Please select a valid directory." print 'Using directory %s' % directory os.chdir(directory) csv_files = [f for f in glob.glob(u'*.csv') if u'output.csv' not in f] patients = [p.Patient(directory, cf) for cf in csv_files] boundary = list() for patient in patients: patient.get_all_roi_val() boundary += [ max(patient.norm_all_roi_value), min(patient.norm_all_roi_value) ] min_val, max_val = min(boundary), max(boundary) bins = numpy.arange( math.floor(min_val * 10) / 10, math.ceil(max_val * 10) / 10, 0.1) output_file = directory + "/output.csv" with open(output_file, 'a') as f: writer = csv.writer(f, delimiter=',') writer.writerow(["Name"] + list(bins)) for patient in patients: patient.bins = bins patient.get_histogram() patient.output_csv = output_file patient.write_histogram_to_csv() print "Finish writing patient: %s" % patient.name.encode( 'ascii', 'ignore').replace('=', '')
def csv_dict_reader(path): with open(path, 'r') as file_obj: childs = list() reader = csv.DictReader(file_obj, delimiter=',') for line in reader: tempDoc = doctor.Doctor(line["doctor_first_name"], line["doctor_last_name"], line["doctor_middle_name"]) doctors.append(tempDoc) for doc in doctors: if doc.doctor_first_name == tempDoc.doctor_first_name and doc.doctor_last_name == tempDoc.doctor_last_name and doc.doctor_middle_name == tempDoc.doctor_middle_name and tempDoc != doc: doctors.remove(tempDoc) tempDoc = doc break # print(line["child_first_name"]), childs.append( patient.Patient( line["mother_first_name"], line["mother_last_name"], line["mother_middle_name"], line["father_first_name"], line["father_last_name"], line["father_middle_name"], line["child_first_name"], line["child_last_name"], line["child_middle_name"], line["age"], tempDoc)) return childs
def login(): if request.method == "GET": return render_template('login.html', succeed=True) else: email = request.form["email"] password = request.form["password"] mode = request.form["role"] if mode == "provider": pvd = provider.Provider(email) if pvd.authenticater(password): session['email'] = email session['role'] = mode return redirect('/provider_profile/' + utils.quote(session['email'])) else: return render_template('login.html', succeed=False) else: pt = patient.Patient(email) if pt.authenticater(password): session['email'] = email session['role'] = mode return redirect(url_for('index')) else: return render_template('login.html', succeed=False)
def genesis(Parameters, xDimension, yDimension): PImmune = 0.0 #Pre-Immune can also be viewed as Population Density InfP = range(int(Parameters[1])-3, int(Parameters[1])+4) IncP = range(int(Parameters[3])-3, int(Parameters[3])+4) RecP = range(int(Parameters[6])-3, int(Parameters[6])+4) #PATIENTS Dossier = dict() ID = 0 Pos2Pat = np.zeros((yDimension, xDimension)) for x in range(xDimension): for y in range(yDimension): ID += 1 Dossier[ID] = patient.Patient(x, y, PImmune, IncP, InfP, RecP) Pos2Pat[y,x] = ID #GENERATING PATIENT ZERO x = xDimension/2 y = yDimension/2 Dossier[Pos2Pat[y,x]].Status = "INFECTIOUS" Record = copy.deepcopy(Dossier) return Dossier, Record, Pos2Pat, ID
def log_reg(formula, df): try: model1 = smf.logit(formula=formula, data=df).fit() print model1.summary() except Exception: print "+" * 40 print "bad formula" print "+" * 40 if __name__ == '__main__': path = '/Users/chadleonard/Repos/DAT3_project/data/' dg_name = 'Dog_4' dog = pat.Patient(dg_name, path) print dog.name df = pd.read_csv(dog.patpath + '/mat_dir.csv_24_30') # print df.head() cols = [col for col in df.columns if col.split('_')[0] == 'NVC1202'] # There are 24 versions of each channel. Things to try: # 1) Split each version into 3 sets of 8 channels. i.e. _f1 thru _f8, _f9 thru _f16, and _f17 thru _f24 # 2) add each set to the logit formula "ictal_ind ~ _f1 + ... _f8" etc. # 3) pass forula to log_reg function # 4) Use "try/catch" to capture any exception and write some message to a file. formula2 = 'x' # all of this is to create the logit formula
def display_info(self): for p in self.patients: print "Patient: ", p.name print "Allergy:", p.allergy print "Bed number:", p.bed_number print "" return self def __repr__(self): return "<Hopital object {} Capacity: {}>".format( self.name, self.capacity) if __name__ == "__main__": p1 = patient.Patient("p1", "Dodo", "Milk") p2 = patient.Patient("p2", "CoCo", "Coffe") p3 = patient.Patient("p3", "Sodo", "Cheese") p4 = patient.Patient("p4", "FoFo", "Banana") p5 = patient.Patient("p5", "Vodo", "Apple") h = Hospital("Ever Green", 3) h.admit(p1, "bed101") h.admit(p2, "bed201") h.admit(p3, "bed1234") h.admit(p4, "bed1235") h.admit(p5, "bed1236") h.discharge("p3") h.display_info()
def __init__(self): self.p = pt.Patient() self.iterations = pt.Config().iterations self.meds = 7 self.med_reward = [0, 0, 0, 0, 0, 0, 0] self.bar = np.arange(7)
def SaveWave2csv(pid, v=False, extension='raw', inOneCSV=False, nfilterCoeff=4001): printINFO(v, "Patient ID: {}".format(pid)) p = patient.Patient(pid, '') if p.pre_test is not None: printINFO(v, "Extracting waves for pre_test!") preprocessing.extractWaves(p.pre_test, n=nfilterCoeff, samplingRate=256, wave='all') printINFO(v, "Extracting waves for intermediate_tests!") for i in range(len(p.intermediate_tests)): preprocessing.extractWaves(p.intermediate_tests[i], n=nfilterCoeff, samplingRate=256, wave='all') if p.post_test is not None: printINFO(v, "Extracting waves for post_test!") preprocessing.extractWaves(p.post_test, n=nfilterCoeff, samplingRate=256, wave='all') printINFO(v, "Saving extracting waves to files!") if (inOneCSV): if p.pre_test is not None: # Save pre_test to csv fname = "".join([pid, 'a_waves.', extension]) fpath = os.path.join(path, fname) tmp = list(p.pre_test.waves.values()) for j in range(len(tmp) - 1): tmp[j].drop('time', axis=1, inplace=True) df = pd.concat(tmp, axis=1) printINFO(v, "Saving file: {}".format(fpath)) df.to_csv(fpath, index=False) # Save intermediate_tests to csv nintermediate = len(p.intermediate_tests) for i in range(nintermediate): fname = "".join([pid, getLetter(i + 1), '_waves.', extension]) fpath = os.path.join(path, fname) tmp = list(p.intermediate_tests[i].waves.values()) for j in range(len(tmp) - 1): tmp[j].drop('time', axis=1, inplace=True) df = pd.concat(tmp, axis=1) printINFO(v, "Saving file: {}".format(fpath)) df.to_csv(fpath, index=False) if p.post_test is not None: # Save post_test to csv fname = "".join( [pid, getLetter(nintermediate + 1), '_waves.', extension]) fpath = os.path.join(path, fname) tmp = list(p.post_test.waves.values()) for j in range(len(tmp) - 1): tmp[j].drop('time', axis=1, inplace=True) df = pd.concat(tmp, axis=1) printINFO(v, "Saving file: {}".format(fpath)) df.to_csv(fpath, index=False) else: # Will create one csv file for each waveform for wave in waves: if p.pre_test is not None: # save pre_test to csv fname = "".join([pid, 'a_', wave, '.', extension]) fpath = os.path.join(path, fname) printINFO(v, "Saving file: {}".format(fpath)) p.pre_test.waves[wave].to_csv(fpath, index=False) # save intermediate_tests to csv nintermediate = len(p.intermediate_tests) for i in range(len(p.intermediate_tests)): fname = "".join( [pid, getLetter(i + 1), '_', wave, '.', extension]) fpath = os.path.join(path, fname) printINFO(v, "Saving file: {}".format(fpath)) p.intermediate_tests[i].waves[wave].to_csv(fpath, index=False) if p.post_test is not None: # save post_end to csv fname = "".join([ pid, getLetter(nintermediate + 1), '_', wave, '.', extension ]) fpath = os.path.join(path, fname) printINFO(v, "Saving file: {}".format(fpath)) p.post_test.waves[wave].to_csv(fpath, index=False)
import patient person_instance = patient.Person(12, 170, 120, 21, "male") def test_person(): assert isinstance(person_instance, patient.Person) def test_person_str(): assert isinstance(str(person_instance), str) print(person_instance) patient_instance = patient.Patient(12, 170, 120, 25, "male", "1", "SomeDisease") def test_patient(): assert isinstance(patient_instance, patient.Person) assert isinstance(patient_instance, patient.Patient) def test_patient_str(): assert isinstance(str(patient_instance), str) print(patient_instance)
import data_structure as ds import bluetooth import patient as p from datetime import datetime import sys if __name__ == "__main__": file_path='' print('name of subject:') name = input() print('sex:') sex=input() print('birthday:') birthday=input() # MM/DD/YYYY patient = p.Patient(name,sex,birthday) try: time = datetime.now().strftime("%d%m%Y-%H-%M-%S") print(time) file_path = patient.name+"_"+time+".csv" print(file_path) open(file_path, 'w+').close() except Exception as e: print("ERROR CREATING CSV DATA FILE!!") print(e) sys.exit(1) print ("\n"+"-"*50+"\nStarting in 1 seconds...") sleep(1) print ("Running")