def appointment(): form = AppointmentForm(request.form) if request.method == 'POST' and form.validate(): # def init(self, username, fullname, password, email): date = form.date.data timee = form.timee.data # password = sha256_crypt.encrypt(str(form.password.data)) #encryption ifUserExists = root.child('appt').order_by_child('date').equal_to(date).get() print(ifUserExists) for k, v in ifUserExists.items(): print(k, v) else: user = Appointment(date, timee) user_db = root.child('appt') user_db.push( { 'date': user.get_date(), 'timee': user.get_timee(), } ) flash('Appointment booked. Waiting for reply from doctor.', 'success') return redirect(url_for('appointment')) else: return render_template('appointment.html', form=form) return render_template('appointment.html', form=form)
class TestAppointment(TestCase): def setUp(self): self.app = Appointment() self.j_doc_list = json.loads('[{"dept_code":"1050201","dept_name":"产科门诊","doctor_code":"3347","doctor_name":"翟洪波","doctor_position":"主任医师","clinic_date":"2016-08-05","clinic_type":"4"}]') self.doctors = [Doctor(u'翟洪波', u'3347', u'2016-08-05')] def tearDown(self): pass def test_process(self): #self.fail() pass def test_post_request(self): #self.fail() pass def test_login_with_hashed_pwd(self): #self.fail() pass def test_query_visible_departments(self): #self.fail() pass def test_query_visible_doctors(self): #self.fail() pass def test_parse_json_list(self): parsed_doctors = self.app.parse_json_list(self.j_doc_list, Doctor) self.assertSequenceEqual(self.doctors, parsed_doctors, 'error pass visible doctors') pass def test_reorder_doctors(self): doctors = [Doctor(u'翟洪波', u'3347', u'2016-08-05'), Doctor(u'翟洪波2', u'3348', u'2016-08-05'), Doctor(u'翟洪波3', u'3349', u'2016-08-05')] pri_list = [u'3348', u'111111'] sorted_doctors = [Doctor(u'翟洪波2', u'3348', u'2016-08-05'), Doctor(u'翟洪波', u'3347', u'2016-08-05'), Doctor(u'翟洪波3', u'3349', u'2016-08-05')] pri_list2 = [u'3349', u'123456', u'3348'] sorted_doctors2 = [Doctor(u'翟洪波3', u'3349', u'2016-08-05'), Doctor(u'翟洪波2', u'3348', u'2016-08-05'), Doctor(u'翟洪波', u'3347', u'2016-08-05')] ret_doctors = self.app.reorder_doctors(doctors, pri_list) ret_doctors2 = self.app.reorder_doctors(doctors, pri_list2) self.assertSequenceEqual(sorted_doctors, ret_doctors, 'error reorder doctors') self.assertSequenceEqual(sorted_doctors2, ret_doctors2, 'error reorder doctors') def test_query_visible_appointments(self): #self.fail() pass def test_submit_appointments(self): #self.fail() pass def test_try_submit_appointment(self): #self.fail() pass
def test_getPatientHist(): patient_1 = HASUser('Username_1', 'Password_1', 'patient', 'Name_1') patient_1._appointments = [ Appointment('Name_1', 'Doc_1', '14:00/03/02/16', 'Fever'), Appointment('Name_1', 'Doc_0', '10:30/03/09/17', 'Flu') ] assert len( patient_1._appointments) != 0, "Error! Could not find patient history." assert (patient_1.get_appointment() == patient_1._appointments)
def test_freeTime3(self): timeslots = [TimeSlot.fromString("06:00 - 11:00"), TimeSlot.fromString("13:00 - 14:00"), TimeSlot.fromString("16:00 - 20:00")] day1 = Day("30.01.2021", timeslots, []) self.assertEqual(day1.freeTimeInMinutes(), 600, "Free Time is incorrect at the start. Maybe a test-issue?") app1 = Appointment("Multi-Appointment", TimeSlot.fromString("13:30 - 17:30")) # Multioverlap day1.addAppointment(app1) self.assertEqual(day1.freeTimeInMinutes(), 480, "Free Time is incorrect after MULTI-OVERLAP") app2 = Appointment("Containing-Appointment", TimeSlot.fromString("05:00 - 18:00")) # Multicontaining day1.addAppointment(app2) self.assertEqual(day1.freeTimeInMinutes(), 120, "Free Time is incorrect after MULTI-CONTAINING")
def test_freeTime2(self): timeslots = [TimeSlot.fromString("06:00 - 11:00"), TimeSlot.fromString("13:00 - 14:00"), TimeSlot.fromString("16:00 - 20:00")] day1 = Day("13.09.2021", timeslots, []) self.assertEqual(day1.freeTimeInMinutes(), 600, "Free Time is incorrect at the start. Maybe a test-issue?") app1 = Appointment("Some-Appointment", TimeSlot.fromString("12:00 - 14:00")) # Scenario {[]}, tight end day1.addAppointment(app1) self.assertEqual(day1.freeTimeInMinutes(), 540, "Free Time is incorrect after CASE 1") app2 = Appointment("Some-Appointment", TimeSlot.fromString("06:00 - 11:00")) # Scenario {[]}, EQUAL day1.addAppointment(app2) self.assertEqual(day1.freeTimeInMinutes(), 240, "Free Time is incorrect after CASE 2")
def wat(): wat = root.child('appt').get() list = [] if wat == None: return render_template('aftappt.html') for pubid in wat: eachupdate = wat[pubid] appointment = Appointment(eachupdate['date'], eachupdate['timee']) appointment.set_pubid(pubid) print('ID : {}, Date: {}, Time: {}'.format(appointment.get_pubid, appointment.get_date, appointment.get_timee())) list.append(appointment) return render_template('aftappt.html', wat=list)
def addAppointment(self, userManager, provider_email, patient_email, time, date, reason): # check that date isn't in the past datetime_object = datetime.strptime(date, "%m/%d/%Y") if (datetime_object - datetime.now()).total_seconds() < 0: return "Date in the past" # check that the patient email isn't a provider if (userManager.getID(patient_email).isPatient() == False): return "Provider making appointment" appointment = Appointment(provider_email, patient_email, date, time, reason) users = userManager.getUsers() for user in users: if self.checkPreviousAppointment(user, appointment, patient_email, provider_email) == False: if user.isPatient() == True and user.get_id() == patient_email: user.addAppointment(appointment) elif user.isPatient() == False and user.get_id( ) == provider_email: user.addAppointment(appointment) else: return "Time Slot Taken" # return that there was an error return True # return that it succeeded
def test_freeTime4(self): timeslots = [TimeSlot.fromString("06:00 - 11:00"), TimeSlot.fromString("13:00 - 14:00"), TimeSlot.fromString("16:00 - 20:00")] day1 = Day("24.02.2021", timeslots, []) self.assertEqual(day1.freeTimeInMinutes(), 600, "Free Time is incorrect at the start. Maybe a test-issue?") app1 = Appointment("Bonus-Appointment", TimeSlot.fromString("08:30 - 18:00")) day1.addAppointment(app1) self.assertEqual(day1.freeTimeInMinutes(), 270, "Free Time is incorrect after BONUS-Appointment")
def main(): scheduler = Calendar() print( "Welcome to your appointment Scheduler! \n - To add a new appointment, enter add \n - To remove an existing appointment, enter remove \n - To view your scheduled appointments for a specific day, enter show day \n - To view all scheduled appointments for the week, enter show week \n - To exit the scheduler, enter exit" ) func = input() while func != "exit": if func == "add": new = input( "Please enter the title of your appointment, the day, starting time and end time (HH:MM).\n" ) title, day, start, end = new.split(" ") #within appointment we can check for valid time. newAppointment = Appointment(title.lower().capitalize(), start, end) scheduler.week[day.lower().capitalize()].add_appointment( newAppointment) #if new == "exit": #sys.exit(0) #do capitalize and lower for titles too. if func == "remove": remove = input( "Please enter the title, the day, starting and ending time of the appointment you wish to delete: (Example: Gym Monday 11:00 13:00)\n" ) title, day, start, end = remove.split(" ") appointment = Appointment(title.lower().capitalize(), start, end) scheduler.week[day.lower().capitalize()].remove_appointment( appointment) if func == "show day": show_day = input("Please enter the day you wish to view.\n") print(scheduler.week[show_day.lower().capitalize()].__str__()) if func == "show week": print(scheduler.__str__()) func = input()
def test_appointment(self): day1 = Day(arrow.get("01.01.2021", "DD.MM.YYYY"), [], []) app1 = Appointment("Test-Appointment", TimeSlot.fromString("09:00 - 12:30")) day1.addAppointment(app1) self.assertIn(app1, day1.appointments, "Appointment not added correctly to empty day") apps = [ Appointment("Alpha-Appointment", TimeSlot.fromString("09:00 - 12:30")), Appointment("Beta-Appointment", TimeSlot.fromString("14:00 - 16:30")), # Overlapping appointments are okay Appointment("Gamma-Appointment", TimeSlot.fromString("13:00 - 15:30")) ] day2 = Day(arrow.get("01.12.2021", "DD.MM.YYYY"), [], apps) self.assertEqual(apps, day2.appointments, "Appointments are not initialised correctly") app2 = Appointment("Test-Appointment", TimeSlot.fromString("18:00 - 21:30")) day2.addAppointment(app2) self.assertIn(app2, day2.appointments, "Appointment was not added correctly to semi-filled day")
def makeAppointment(self, startTime): dateString = startTime.strftime("%m/%d/%Y") if dateString in self.appointments_by_day: raise AlreadyBookedException( 'Patient already has an appointment on ' + dateString) else: self.appointments_by_day[dateString] = Appointment( startTime, startTime + datetime.timedelta(minutes=30)) return self.appointments_by_day[dateString]
def fromDict(valueDict: dict, globalTasks=None): parsedDate = util.dateStringToArrow(valueDict["dateString"]).date() timeSlots = [ TimeSlot.fromDict(t, globalTasks=globalTasks) for t in valueDict["timeSlots"] ] appointments = [ Appointment.fromDict(appDict) for appDict in valueDict["appointments"] ] isSpecial = valueDict["special"] return Day(parsedDate, timeSlots, appointments, special=isSpecial)
def test_freeTime(self): timeslots = [TimeSlot.fromString("09:00 - 12:30"), TimeSlot.fromString("13:00 - 14:00"), TimeSlot.fromString("18:00 - 23:00")] day1 = Day("04.09.2021", timeslots, []) self.assertEqual(day1.timeInMinutes(), day1.freeTimeInMinutes(), "Time and FreeTime should be equal when there are no appointments") self.assertEqual(day1.freeTimeInMinutes(), 570, "Free Time is incorrect at the start. Maybe a test-issue?") app1 = Appointment("Gamma-Appointment", TimeSlot.fromString("13:00 - 15:30")) # Scenario {[]}, tight start day1.addAppointment(app1) self.assertEqual(day1.freeTimeInMinutes(), 510, f"Free time should have accounted for Appointment overlap; Expected 510, Got {day1.freeTimeInMinutes()}") app2 = Appointment("Yolo-Appointment", TimeSlot.fromString("13:30 - 14:30")) day1.addAppointment(app2) app3 = Appointment("Yana-Appointment", TimeSlot.fromString("04:00 - 7:30")) day1.addAppointment(app3) self.assertEqual(day1.freeTimeInMinutes(), 510, "Free Time should not have changed after non-overlapping appointments were added!") app4 = Appointment("Intermediate-Appointment", TimeSlot.fromString("10:00 - 10:30")) # Scenario [{}] day1.addAppointment(app4) self.assertEqual(day1.freeTimeInMinutes(), 480, "Free Time not calculated correctly after in-the-middle appointment was added") app5 = Appointment("Ending-Appointment", TimeSlot.fromString("12:00 - 13:30")) # Scenario [{]} day1.addAppointment(app5) self.assertEqual(day1.freeTimeInMinutes(), 450, "Free Time not calculated correctly after end-overlapping appointment was added") app6 = Appointment("Starting-Appointment", TimeSlot.fromString("08:00 - 09:30")) # Scenario {[}] day1.addAppointment(app6) self.assertEqual(day1.freeTimeInMinutes(), 420, "Free Time not calculated correctly after end-overlapping appointment was added")
def freeTimeSlots( self, before=None, after=None ) -> [TimeSlot ]: # Returns a NEW DEEPCOPIED LIST containing new objects / copies # At this point, priority could be used to determine if appointments should get thrown out blocking_appointments = self.appointments.copy() virtualAppointments = [ ] # Blocking appointments to simulate some constraint, i.e. after/before if before is not None and before != Time(23, 59): before = Appointment("VIRTUAL_APP_BEFORE", TimeSlot(before, Time(23, 59))) virtualAppointments.append(before) if after is not None and after != Time(0, 0): after = Appointment("VIRTUAL_APP_AFTER", TimeSlot(Time(0, 0), after)) virtualAppointments.append(after) blocking_appointments += virtualAppointments freeSlots = [] for timeSlot in self.timeSlots: # TimeSlots with a TaskOrAppointment assigned to it are not free if timeSlot.taskOrAppointment is not None: continue # Calculate overlap with appointments and perhaps split up TimeSlots as necessary currentTimeSlots = [timeSlot.copy()] for appointment in blocking_appointments: newTimeSlots = [] for currentTimeSlot in currentTimeSlots: newTimeSlots += currentTimeSlot.nonOverlap( appointment.timeSlot) currentTimeSlots = newTimeSlots.copy( ) # .copy() is very important; mutation danger freeSlots += currentTimeSlots.copy() return freeSlots
def get_appointments_from_workbook(self, appointment_meta) -> List[Appointment]: appointments_in_workbook: List[Appointment] = [] previous_appointments: List[Appointment] = [] for cell in iter(self): current_appointments: List[Appointment] = [] for title in cell.titles: title = title.strip() appointment: Union[Appointment, None] = None for previous_appointment in previous_appointments: if previous_appointment.title == title and previous_appointment.type == cell.type: appointment = previous_appointment appointment.end_time = cell.end_time previous_appointments.remove(previous_appointment) break if appointment is None: try: meta = appointment_meta[title] except KeyError: meta = AppointmentMeta(title=title) appointment_meta[title] = meta appointment = Appointment(meta, cell.type, cell.begin_time, cell.end_time) current_appointments.append(appointment) appointments_in_workbook += previous_appointments previous_appointments = current_appointments appointments_in_workbook += previous_appointments return appointments_in_workbook
def map_list_of_data_to_appointment_list(data_list: list): appointments = [] for row in data_list: appointment = Appointment(*row) appointments.append(appointment) return appointments
def main(): """ Demonstrate use of the Appointment class. """ appt1 = Appointment("Physics meeting", (9, 30), (10, 45)) appt2 = Appointment("Brunch", (10, 30), (11, 00)) appt3 = Appointment("English study session", (13, 00), (14, 00)) if appt1.overlaps(appt2): print(f"{appt1.name} overlaps with {appt2.name}") else: print(f"{appt1.name} does not overlap with {appt2.name}") if appt1.overlaps(appt3): print(f"{appt1.name} overlaps with {appt3.name}") else: print(f"{appt1.name} does not overlap with {appt3.name}") assert appt1.overlaps(appt2) assert appt2.overlaps(appt1) assert not appt1.overlaps(appt3) assert not appt3.overlaps(appt1) assert not appt2.overlaps(appt3) assert not appt3.overlaps(appt2)
class TestAppointment(TestCase): def setUp(self): self.app = Appointment() self.j_doc_list = json.loads( '[{"dept_code":"1050201","dept_name":"产科门诊","doctor_code":"3347","doctor_name":"翟洪波","doctor_position":"主任医师","clinic_date":"2016-08-05","clinic_type":"4"}]' ) self.doctors = [Doctor(u'翟洪波', u'3347', u'2016-08-05')] def tearDown(self): pass def test_process(self): #self.fail() pass def test_post_request(self): #self.fail() pass def test_login_with_hashed_pwd(self): #self.fail() pass def test_query_visible_departments(self): #self.fail() pass def test_query_visible_doctors(self): #self.fail() pass def test_parse_json_list(self): parsed_doctors = self.app.parse_json_list(self.j_doc_list, Doctor) self.assertSequenceEqual(self.doctors, parsed_doctors, 'error pass visible doctors') pass def test_reorder_doctors(self): doctors = [ Doctor(u'翟洪波', u'3347', u'2016-08-05'), Doctor(u'翟洪波2', u'3348', u'2016-08-05'), Doctor(u'翟洪波3', u'3349', u'2016-08-05') ] pri_list = [u'3348', u'111111'] sorted_doctors = [ Doctor(u'翟洪波2', u'3348', u'2016-08-05'), Doctor(u'翟洪波', u'3347', u'2016-08-05'), Doctor(u'翟洪波3', u'3349', u'2016-08-05') ] pri_list2 = [u'3349', u'123456', u'3348'] sorted_doctors2 = [ Doctor(u'翟洪波3', u'3349', u'2016-08-05'), Doctor(u'翟洪波2', u'3348', u'2016-08-05'), Doctor(u'翟洪波', u'3347', u'2016-08-05') ] ret_doctors = self.app.reorder_doctors(doctors, pri_list) ret_doctors2 = self.app.reorder_doctors(doctors, pri_list2) self.assertSequenceEqual(sorted_doctors, ret_doctors, 'error reorder doctors') self.assertSequenceEqual(sorted_doctors2, ret_doctors2, 'error reorder doctors') def test_query_visible_appointments(self): #self.fail() pass def test_submit_appointments(self): #self.fail() pass def test_try_submit_appointment(self): #self.fail() pass
def add_new_appointment(self, host_id, guest_id, date_offered): new_appointment = Appointment(host_id, guest_id, date_offered) self.all_appointments.append(new_appointment)
def setUp(self): self.app = Appointment() self.j_doc_list = json.loads( '[{"dept_code":"1050201","dept_name":"产科门诊","doctor_code":"3347","doctor_name":"翟洪波","doctor_position":"主任医师","clinic_date":"2016-08-05","clinic_type":"4"}]' ) self.doctors = [Doctor(u'翟洪波', u'3347', u'2016-08-05')]
def setUp(self): self.app = Appointment() self.j_doc_list = json.loads('[{"dept_code":"1050201","dept_name":"产科门诊","doctor_code":"3347","doctor_name":"翟洪波","doctor_position":"主任医师","clinic_date":"2016-08-05","clinic_type":"4"}]') self.doctors = [Doctor(u'翟洪波', u'3347', u'2016-08-05')]
def run_CSV(self, ed): with ed as ed_file: unique_appt_ids = [] results = [] header_row = True # prepare to skip to data rows ed_reader = csv.reader(ed_file, delimiter=',', quotechar='"') for row in ed_reader: if not row[0] and not row[1]: # blank or end of document print("{0} records found".format( self.__record_count)) print("{0} unique appointments found".format( self.__unique_appointments)) print("{0} valid emails found".format( self.__valid_email_count)) print("{0} duplicates found".format( self.__duplicate_count)) break elif header_row: headers = list(row) i_fname = headers.index(fieldMap['FirstName']) i_mname = headers.index(fieldMap['MiddleName']) i_lname = headers.index(fieldMap['LastName']) i_email = headers.index(fieldMap['Email']) i_date = headers.index(fieldMap['Date']) i_start = headers.index(fieldMap['Start']) i_end = headers.index(fieldMap['End']) i_location = headers.index(fieldMap['Location']) i_type = headers.index(fieldMap['Type']) i_appt_id = headers.index(fieldMap['ApptID']) i_provider = headers.index(fieldMap['Provider']) i_street = headers.index(fieldMap['Street']) i_city = headers.index(fieldMap['City']) i_state = headers.index(fieldMap['State']) i_zip = headers.index(fieldMap['PostalCode']) header_row = False else: valid_email = validate_email(row[i_email]) self.__record_count += 1 if row[i_appt_id] in unique_appt_ids: print('Duplicate ignored - Appt ID: ' + row[i_appt_id]) self.__duplicate_count += 1 pass else: unique_appt_ids.append(row[i_appt_id]) a = Appointment(ApptID=row[i_appt_id], Type=row[i_type], Location=row[i_location], Date=row[i_date], Start=row[i_start], End=row[i_end], Provider=row[i_provider], sf_instance=self.sf) p = Patient(FirstName=row[i_fname], MiddleName=row[i_mname], LastName=row[i_lname], Email=row[i_email], Street=row[i_street], City=row[i_city], State=row[i_state], PostalCode=row[i_zip], ValidEmail=valid_email, LeadSource='Call Center', Appointment=a.__dict__, sf_instance=self.sf) if valid_email: self.__valid_email_count += 1 self.__unique_appointments += 1 p_response = p.insert() a.setPatientID(p.sfid) a_response = a.insert() entry = {'Patient': p_response, 'Appt': a_response} results.append(entry) return results
def make_appointment(self, patient, time, message): new_appointment = Appointment(patient, self, time, message) self._appointments.append(new_appointment) self._appointments.sort(key=lambda x: x.time, reverse=False) # sort appointments return new_appointment
from appointment import Appointment from doctor import Doctor from patient import Patient # To Convert time def calculateTime(availableFrom): availableFrom = availableFrom.split(":") availableFrom = (int(availableFrom[0]) * 60) + int(availableFrom[1]) return availableFrom if __name__ == "__main__": system1 = Appointment() while True: # Menu print("\n\t\t\tMENU") print("\t\t1. Add Doctor") print("\t\t2. Add Patient") print("\t\t3. Exit") choice = int(input("\tEnter your choice: ")) if choice == 1: name = input("\n\tEnter Name: ") #Print Specializations print("\n\t\t1. Pediatrician\n\t\t2. ENT\n\t\t3. GP") doctorSpec = int(input("\tEnter Specialization: ")) #Print Days print( "\n\t\t1. Monday\n\t\t2. Tuesday\n\t\t3. Wednesday\n\t\t4. Thursday\n\t\t5. Friday\n\t\t6. Saturday\n\t\t7. Sunday"