def new_patient(): """Display the form for a new patient, and create a new patient after submission.""" form = PatientForm() if form.validate_on_submit(): patient = Patient() update_patient(patient, form, request.files) # If the patient was created by a patient user, link the new patient to the # user account if current_user.is_patient_user(): current_user.patient = patient db.session.add(patient) db.session.commit() return redirect(url_for('screener.patient_details', id=patient.id)) else: index_search = {} if 'first_name' in session and session['first_name']: index_search['first_name'] = session['first_name'] if 'last_name' in session and session['last_name']: index_search['last_name'] = session['last_name'] if 'dob' in session and session['dob']: index_search['dob'] = 'test' if 'ssn' in session and session['ssn']: index_search['ssn'] = session['ssn'] # Delete empty rows at end of many-to-one tables remove_blank_rows(form) return render_template('patient_details.html', patient={}, form=form, index_search=index_search)
def check_patient_permission(patient_id): """If the current user is a patient account, check whether they're viewing the patient linked to their own account. If not, abort. """ if current_user.is_patient_user() and not current_user.is_current_patient(patient_id): abort(403) return
def check_patient_permission(patient_id): """If the current user is a patient account, check whether they're viewing the patient linked to their own account. If not, abort. """ if current_user.is_patient_user( ) and not current_user.is_current_patient(patient_id): abort(403) return
def home_page_redirect(): """Redirect the user to the home page appropriate for their role.""" if not current_user.is_patient_user(): return redirect(url_for('screener.index')) elif current_user.patient_id is not None: return redirect( url_for('screener.patient_details', id=current_user.patient_id)) else: return redirect(url_for('screener.new_patient'))
def home_page_redirect(): """Redirect the user to the home page appropriate for their role.""" if not current_user.is_patient_user(): return redirect(url_for('screener.index')) elif current_user.patient_id is not None: return redirect(url_for( 'screener.patient_details', id=current_user.patient_id )) else: return redirect(url_for('screener.new_patient'))
def new_patient(): """Display the form for a new patient, and create a new patient after submission.""" form = PatientForm() if form.validate_on_submit(): patient = Patient() update_patient(patient, form, request.files) # If the patient was created by a patient user, link the new patient to the # user account if current_user.is_patient_user(): current_user.patient = patient db.session.add(patient) db.session.commit() return redirect(url_for('screener.patient_details', id=patient.id)) else: return render_template('patient_details.html', patient={}, form=form)
def patient_share(patient_id): """Displays the 'Share Patient' page, which includes prescreening results and allows users to send referrals. """ check_patient_permission(patient_id) patient = Patient.query.get(patient_id) patient.update_stats() services = Service.query.all() if not current_user.is_patient_user() and current_user.service: allowed_referral_service_ids = [ service.id for service in current_user.service.can_send_referrals_to ] else: allowed_referral_service_ids = [] # Get ids of services where the patient already has open referrals, # to prevent user from sending duplicates. open_referral_service_ids = [ r.to_service_id for r in patient.referrals if (r.in_sent_status() or r.in_sent_status()) ] return render_template( 'patient_share.html', patient=patient, current_user=current_user, servicesAll=Service.query.all(), services=calculate_pre_screen_results( fpl=patient.fpl_percentage, has_health_insurance=patient.insurance_status, is_eligible_for_medicaid="", service_ids=[s.id for s in services if s.has_screening_yn == 'Y'] ), household_size=patient.household_members.count() + 1, household_income=patient.total_annual_income, fpl=patient.fpl_percentage, has_health_insurance=patient.insurance_status, is_eligible_for_medicaid="", referral_buttons=True, allowed_referral_service_ids=allowed_referral_service_ids, open_referral_service_ids=open_referral_service_ids )
def patient_share(patient_id): """Displays the 'Share Patient' page, which includes prescreening results and allows users to send referrals. """ check_patient_permission(patient_id) patient = Patient.query.get(patient_id) patient.update_stats() services = Service.query.all() if not current_user.is_patient_user() and current_user.service: allowed_referral_service_ids = [ service.id for service in current_user.service.can_send_referrals_to ] else: allowed_referral_service_ids = [] # Get ids of services where the patient already has open referrals, # to prevent user from sending duplicates. open_referral_service_ids = [ r.to_service_id for r in patient.referrals if (r.in_sent_status() or r.in_sent_status()) ] return render_template( 'patient_share.html', patient=patient, current_user=current_user, servicesAll=Service.query.all(), services=calculate_pre_screen_results( fpl=patient.fpl_percentage, has_health_insurance=patient.insurance_status, is_eligible_for_medicaid="", service_ids=[s.id for s in services if s.has_screening_yn == 'Y']), household_size=patient.household_members.count() + 1, household_income=patient.total_annual_income, fpl=patient.fpl_percentage, has_health_insurance=patient.insurance_status, is_eligible_for_medicaid="", referral_buttons=True, allowed_referral_service_ids=allowed_referral_service_ids, open_referral_service_ids=open_referral_service_ids)