def show_single_patient_posts(patient_id): """Show a patient's posts.""" user_type = get_user_type_from_session() page = request.args.get("page", 1, type=int) filter_date = request.args.get("date", None) filter_dates = get_months_years_of_patient_posts(patient_id) posts = get_single_patients_posts(patient_id, page, filter_date) patient = Patient.query.get(patient_id) if user_type == "dietitian": diet_and_pats = get_dietitian_and_patients_list() return render_template("dietitian-home-patient-posts.html", dietitian=diet_and_pats["dietitian"], patients=diet_and_pats["sorted_patients"], patient=patient, posts=posts, dates=filter_dates, date=filter_date) dietitian = patient.dietitian return render_template("patient-posts.html", patient=patient, dietitian=dietitian, posts=posts, dates=filter_dates, date=filter_date)
def show_patient_registration_form(): """Show form for new patient registration.""" diet_and_pats = get_dietitian_and_patients_list() return render_template("patient-registration.html", dietitian=diet_and_pats["dietitian"], patients=diet_and_pats["sorted_patients"])
def view_reset_dietitian_password_form(dietitian_id): """Reset a dietitian's password.""" diet_and_pats = get_dietitian_and_patients_list() return render_template("dietitian-resetpw.html", dietitian=diet_and_pats["dietitian"], patients=diet_and_pats["sorted_patients"])
def view_edit_dietitian_information(dietitian_id): """Edit a dietitian's account information.""" diet_and_pats = get_dietitian_and_patients_list() return render_template("dietitian-account-edit.html", dietitian=diet_and_pats["dietitian"], patients=diet_and_pats["sorted_patients"])
def show_dietitian_account(dietitian_id): """Show a dietitian their account information""" diet_and_pats = get_dietitian_and_patients_list() return render_template("dietitian-account.html", dietitian=diet_and_pats["dietitian"], patients=diet_and_pats["sorted_patients"])
def customize_patient_post_form(patient_id): """Allow dietitian to select form fields available on a patient's post.""" diet_and_pats = get_dietitian_and_patients_list() patient = Patient.query.get(patient_id) return render_template("dietitian-customize-post-form.html", dietitian=diet_and_pats["dietitian"], patients=diet_and_pats["sorted_patients"], patient=patient)
def view_edit_patient_information_form(patient_id): """Edit a patient's basic information.""" user_type = get_user_type_from_session() patient = Patient.query.get(patient_id) if user_type == "dietitian": diet_and_pats = get_dietitian_and_patients_list() return render_template("dietitian-home-patient-edit.html", dietitian=diet_and_pats["dietitian"], patients=diet_and_pats["sorted_patients"], patient=patient) return render_template("patient-account-edit.html", patient=patient)
def show_single_patient_overview(patient_id): """Show information about a single patient.""" user_type = get_user_type_from_session() patient = Patient.query.get(patient_id) if user_type == "dietitian": diet_and_pats = get_dietitian_and_patients_list() return render_template("dietitian-home-patient-overview.html", dietitian=diet_and_pats["dietitian"], patients=diet_and_pats["sorted_patients"], patient=patient) return render_template("patient-account.html", patient=patient)
def get_ratings_chart_template(patient_id): """Shows page containing rating chart div.""" user_type = get_user_type_from_session() patient = Patient.query.get(patient_id) if user_type == "dietitian": diet_and_pats = get_dietitian_and_patients_list() return render_template("dietitian-ratings-chart.html", dietitian=diet_and_pats["dietitian"], patients=diet_and_pats["sorted_patients"], patient=patient) return render_template("patient-ratings-chart.html", patient=patient)
def show_dietitian_homepage(dietitian_id): """Show a dietitian's homepage.""" page = request.args.get("page", 1, type=int) diet_and_pats = get_dietitian_and_patients_list() filter_date = request.args.get("date", None) filter_dates = get_months_years_posts_for_dietitian(dietitian_id) posts = get_all_patients_posts(diet_and_pats["dietitian"], page, filter_date) return render_template("dietitian-home-posts.html", dietitian=diet_and_pats["dietitian"], patients=diet_and_pats["sorted_patients"], posts=posts, date=filter_date, dates=filter_dates)
def show_patient_goals(patient_id): """Show goals for a patient and allow dietitian to update goals.""" user_type = get_user_type_from_session() page = request.args.get("page", 1, type=int) goals = get_patients_goals_dict(patient_id, page) patient = Patient.query.get(patient_id) if user_type == "dietitian": diet_and_pats = get_dietitian_and_patients_list() return render_template("dietitian-home-patient-goals.html", dietitian=diet_and_pats["dietitian"], patients=diet_and_pats["sorted_patients"], patient=patient, current_goal=goals["current_goal"], past_goals=goals["past_goals"]) return render_template("patient-goals.html", patient=patient, goals=goals["all_goals"])