def rating_center(center): if current_user.authority == "provider": return redirect(url_for("provider")) success = None cm = health_center.Center_management() rm = rating_record.Rating_Management() if (cm.get_center(center) == None): success = False else: if request.method == "POST": val = request.form["rating"] rating = rating_record.Rating(current_user.email, val, centre=center) if (rm.update_rating(rating)): success = True else: success = False return render_template( "rating.html", current_user=current_user, success=success, currRating=rating_record.Rating_Management().get_rating( current_user.email, centre=center))
def patient(): if current_user.authority == "provider": return redirect(url_for("provider")) cm = health_center.Center_management() list = cm.get_all_list() if request.method == "POST": name = request.form["name"] type = request.form["type"] if type == "name": return redirect(url_for("search_name", name=name)) if type == "suburb": return redirect(url_for("search_suburb", name=name)) if type == "service": return redirect(url_for("search_service", name=name)) if type == "provider": return redirect(url_for("search_provider", name=name)) # return render_template("patient_welcome.html",name=username) else: return render_template("patient.html", current_user=current_user, LIST=list, name=current_user.id, authority=current_user.authority, rating=rating_record.Rating_Management())
def book(name, center): if current_user.authority == "provider": return redirect(url_for("provider")) cm = health_center.Center_management() uc = login_check.user_check() rm = appointment_record.record_management() errorMsg = [] center_data = cm.get_center(center) provider_data = uc.get_user(name) if (center_data == None): errorMsg.append("Center name not exist!") if (provider_data == None): errorMsg.append("Provider name not exist!") if (provider_data.authority == "patient"): errorMsg.append("Wrong authority") workingTime = cm.get_workingTime(provider_data, center_data) if workingTime == False: errorMsg.append("The provider are not working for the center") bookingMsg = [] def check_time(timeVal): sec = timeVal.strftime('%S') min = timeVal.strftime('%M') if (sec != "00"): return False if (min != "00" and min != "30"): return False return True if request.method == "POST": try: r = appointment_record.Record(current_user, provider_data, center_data, request.form["reason"], request.form["start_time"], request.form["end_time"], "", "") if (check_time(r.start_time) and check_time(r.end_time)): checkValue = rm.update_record(r) if (checkValue == False): bookingMsg.append( "Can not book appointment - please check your start time and end time" ) else: bookingMsg.append("Booking success!") else: bookingMsg.append("time are separate to 30min periods!") except: bookingMsg.append("You need enter time in correct format") return render_template("booking.html", errorMsg=errorMsg, bookingMsg=bookingMsg, center_data=center_data, provider_data=provider_data, workingTime=workingTime)
def centres_list(name): cm = health_center.Center_management() center_data = cm.get_center(name) if (center_data != None): provider_data = cm.get_provider_list(center_data.name) else: provider_data = [] return render_template("center.html", current_user=current_user, center_data=center_data, provider_data=provider_data, rating=rating_record.Rating_Management(), get_workingTime=cm.get_workingTime)
def providers_list(name): cm = health_center.Center_management() uc = login_check.user_check() provider_data = uc.get_user(name) if (provider_data != None): center_data = cm.get_center_list(provider_data.email) else: center_data = [] return render_template("providers.html", current_user=current_user, c=center_data, p=provider_data, rating=rating_record.Rating_Management(), get_workingTime=cm.get_workingTime)
def search_provider(name): provider_data = [] center_data = [] f_provider = csv_manage("provider.csv") provider_data = f_provider.search_data([[0, name]], 0, 1) cm = health_center.Center_management() uc = login_check.user_check() class_list_provider = [] class_list_center = [] for line in provider_data: class_list_provider.append(uc.get_user(line[0])) for line in center_data: class_list_center.append(cm.get_center(line[2])) return render_template("search_result.html", provider_data=class_list_provider, center_data=class_list_center, rating=rating_record.Rating_Management(), get_workingTime=cm.get_workingTime)
def test_appointment_record(): #test: Record class ar = appointment_record rec = ar.Record rm = appointment_record.record_management() user = login_check.user_check().get_user center = health_center.Center_management().get_center #test1: right data new_record1 = rec(user("*****@*****.**"), user("*****@*****.**"), center("Hospital1"), "test", ar.strToTime("8-11-2018 05:00:00"), ar.strToTime("8-11-2018 07:00:00")) assert (new_record1.check() == True) assert (new_record1.write_check() == True) if (True): #test2: wrong patient name new_record2 = rec(user("pd"), user("*****@*****.**"), center("Hospital1"), "test", ar.strToTime("8-11-2018 05:00:00"), ar.strToTime("8-11-2018 07:00:00")) assert (new_record2.check() == False) assert (new_record2.write_check() == False) #test3 wrong provider name new_record3 = rec(user("*****@*****.**"), user("com"), center("Hospital1"), "test", ar.strToTime("8-11-2018 05:00:00"), ar.strToTime("8-11-2018 07:00:00")) assert (new_record3.check() == False) assert (new_record3.write_check() == False) #test4 wrong center name new_record4 = rec(user("*****@*****.**"), user("*****@*****.**"), center("Ho"), "test", ar.strToTime("8-11-2018 05:00:00"), ar.strToTime("8-11-2018 07:00:00")) assert (new_record4.check() == False) assert (new_record4.write_check() == False) #test5 start time > end time new_record5 = rec(user("*****@*****.**"), user("*****@*****.**"), center("Hospital1"), "test", ar.strToTime("8-11-2018 07:00:00"), ar.strToTime("8-11-2018 05:00:00")) assert (new_record5.check() == False) assert (new_record5.write_check() == False) #test6 not same year new_record6 = rec(user("*****@*****.**"), user("*****@*****.**"), center("Hospital1"), "test", ar.strToTime("8-11-2018 05:00:00"), ar.strToTime("8-11-2019 07:00:00")) assert (new_record6.check() == False) assert (new_record6.write_check() == False) #test7 not in provider valid time new_record7 = rec(user("*****@*****.**"), user("*****@*****.**"), center("Hospital1"), "test", ar.strToTime("8-11-2018 02:00:00"), ar.strToTime("8-11-2018 07:00:00")) assert (new_record7.check() == False) assert (new_record7.write_check() == False) #test10: previous record new_record10 = rec(user("*****@*****.**"), user("*****@*****.**"), center("Hospital1"), "test", ar.strToTime("8-11-2017 05:00:00"), ar.strToTime("8-11-2017 07:00:00")) assert (new_record10.check() == True) assert (new_record10.write_check() == False) #test: save valid record assert (rm.update_record(new_record1) == True) assert (rm.search_edit([[0, "*****@*****.**"], [1, "*****@*****.**"], [2, "Hospital1"]]) != []) #test9 overlap with saved record new_record9 = rec(user("*****@*****.**"), user("*****@*****.**"), center("Hospital1"), "test", ar.strToTime("8-11-2018 06:30:00"), ar.strToTime("8-11-2018 07:00:00")) assert (new_record9.check() == True) assert (new_record9.write_check() == False) #test: record_management #test: exist record #exist assert (rm.exist_record(user("*****@*****.**"), user("*****@*****.**")) == True) #not exist assert (rm.exist_record(user("*****@*****.**"), user("*****@*****.**")) == False) assert (rm.exist_record(user("*****@*****.**"), user("*****@*****.**")) == False) #test: update sucess new_record1 = rec(user("*****@*****.**"), user("*****@*****.**"), center("Hospital1"), "test", ar.strToTime("8-11-2018 05:00:00"), ar.strToTime("8-11-2018 07:00:00"), "some text", "some text") assert (rm.update_record(new_record1) == True) test_record1 = rm.get_record_by_provider(user("*****@*****.**")) assert (test_record1[0].get_list() == new_record1.get_list()) new_record2 = rec(user("*****@*****.**"), user("*****@*****.**"), center("Hospital1"), "test", ar.strToTime("9-11-2018 05:00:00"), ar.strToTime("9-11-2018 07:00:00"), "some text", "some text") assert (rm.update_record(new_record2) == True) new_record3 = rec(user("*****@*****.**"), user("*****@*****.**"), center("Hospital1"), "test", ar.strToTime("9-11-2018 06:00:00"), ar.strToTime("9-11-2018 07:00:00"), "some text", "some text") assert (rm.update_record(new_record3) == True) new_record4 = rec(user("*****@*****.**"), user("*****@*****.**"), center("Hospital2"), "test", ar.strToTime("10-11-2018 09:30:00"), ar.strToTime("10-11-2018 10:00:00"), "some text", "some text") print(new_record4.get_list()) print(new_record4.check()) print(new_record4.write_check()) assert (rm.update_record(new_record4) == True) new_record1 = rec(user("*****@*****.**"), user("*****@*****.**"), center("Hospital1"), "test", ar.strToTime("8-11-2018 05:00:00"), ar.strToTime("8-11-2018 07:00:00"), "some tsdext", "some adtext") assert (rm.update_record(new_record1, user("*****@*****.**")) == True) test_record1 = rm.get_record_by_provider(user("*****@*****.**")) assert (test_record1[0].get_list() == new_record1.get_list()) #test: update a record which have different provider (False assert (rm.update_record(new_record1, user("*****@*****.**")) == False) test_record1 = rm.get_record_by_provider(user("*****@*****.**")) assert (test_record1[0].get_list() == new_record1.get_list()) #test:get_record_by_patient #not exist assert (rm.get_record_by_patient(user("*****@*****.**")) == []) #exist test_patient_data = rm.get_record_by_patient(user("*****@*****.**")) assert (len(test_patient_data) == 3) assert (test_patient_data[0].get_list() == new_record1.get_list()) assert (test_patient_data[1].get_list() == new_record3.get_list()) assert (test_patient_data[2].get_list() == new_record4.get_list()) #test:get_record_by_provider #not exist assert (rm.get_record_by_provider(user("*****@*****.**")) == []) #exist test_provider_data = rm.get_record_by_provider( user("*****@*****.**")) assert (len(test_provider_data) == 3) assert (test_provider_data[0].get_list() == new_record1.get_list()) assert (test_provider_data[1].get_list() == new_record2.get_list()) assert (test_provider_data[2].get_list() == new_record4.get_list()) #test:get_record_by_center #not exist assert (rm.get_record_by_center(center("Sydney Children Hospital")) == []) #exist test_center_data = rm.get_record_by_center(center("Hospital1")) assert (len(test_center_data) == 3) assert (test_center_data[0].get_list() == new_record1.get_list()) assert (test_center_data[1].get_list() == new_record2.get_list()) assert (test_center_data[2].get_list() == new_record3.get_list())
new_provider2 = user_class.Provider("*****@*****.**", "123456", "Mark", "0456789", "1234567", "GP") new_provider2.update(add=True) new_center1 = health_center.Center("Hospital", "1111", "Sydney Children Hospital", "93821111", "Randwick") new_center1.save() new_center2 = health_center.Center("Hospital", "1112", "Hospital1", "93821112", "Randwick") new_center2.save() new_center3 = health_center.Center("Hospital", "1113", "Hospital2", "93821113", "Randwick") new_center3.save() cm = health_center.Center_management() cm.save("*****@*****.**", "Hospital1", datetime.datetime.strptime("05:00:00", "%H:%M:%S"), datetime.datetime.strptime("07:00:00", "%H:%M:%S")) cm.save("*****@*****.**", "Hospital1", datetime.datetime.strptime("06:00:00", "%H:%M:%S"), datetime.datetime.strptime("8:30:00", "%H:%M:%S")) cm.save("*****@*****.**", "Hospital1", datetime.datetime.strptime("11:00:00", "%H:%M:%S"), datetime.datetime.strptime("18:30:00", "%H:%M:%S")) cm.save("*****@*****.**", "Hospital2", datetime.datetime.strptime("09:00:00", "%H:%M:%S"), datetime.datetime.strptime("12:00:00", "%H:%M:%S"))