def rating_provider(center): if current_user.authority == "provider": return redirect(url_for("provider")) success = None uc = login_check.user_check() rm = rating_record.Rating_Management() if (uc.get_user(center) == None): success = False else: if request.method == "POST": val = request.form["rating"] rating = rating_record.Rating(current_user.email, val, provider=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 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 test_rating_record(): #test: Rating_Management #test1: default rm = rating_record.Rating_Management() assert (rm.get_rating(provider="*****@*****.**") == 5) assert (rm.get_rating(centre="Hospital1") == 5) #test2: adding rating to same center / provider test_rating1 = rating_record.Rating("*****@*****.**", 4, provider="*****@*****.**") rm.update_rating(test_rating1) assert (rm.get_rating(patient="*****@*****.**", provider="*****@*****.**") == 4) test_rating2 = rating_record.Rating("*****@*****.**", 2, provider="*****@*****.**") rm.update_rating(test_rating2) assert (rm.get_rating(patient="*****@*****.**", provider="*****@*****.**") == 2) test_rating3 = rating_record.Rating("*****@*****.**", 4, centre="Hospital1") rm.update_rating(test_rating3) assert (rm.get_rating(patient="*****@*****.**", centre="Hospital1") == 4) test_rating4 = rating_record.Rating("*****@*****.**", 2, centre="Hospital1") rm.update_rating(test_rating4) assert (rm.get_rating(patient="*****@*****.**", centre="Hospital1") == 2) #test 3:average rating test_rating5 = rating_record.Rating("*****@*****.**", 5, centre="Hospital1") rm.update_rating(test_rating5) assert (rm.get_rating(centre="Hospital1") == 3.5) test_rating6 = rating_record.Rating("*****@*****.**", 4, provider="*****@*****.**") rm.update_rating(test_rating6) assert (rm.get_rating(provider="*****@*****.**") == 3)
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)