Example #1
0
def patient_details(id):
    """Display the full patient details form for an existing user."""
    check_patient_permission(id)
    patient = Patient.query.get(id)
    form = (
        get_unsaved_form(request, patient, 'patient_details', PatientForm)
        or PatientForm(obj=patient)
    )

    if request.method == 'POST' and form.validate_on_submit():
        update_patient(patient, form, request.files)
        db.session.commit()
        patient.update_stats()
        return render_template(
            'patient_details.html',
            patient=patient,
            form=form,
            save_message=True
        )

    # Delete empty rows at end of many-to-one tables
    remove_blank_rows(form)

    return render_template(
        'patient_details.html',
        patient=patient,
        form=form,
        save_message=False
    )
Example #2
0
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)
Example #3
0
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)
Example #4
0
def patient_details(id):
    """Display the full patient details form for an existing user."""
    check_patient_permission(id)
    patient = Patient.query.get(id)
    form = (get_unsaved_form(request, patient, 'patient_details', PatientForm)
            or PatientForm(obj=patient))

    if request.method == 'POST' and form.validate_on_submit():
        update_patient(patient, form, request.files)
        db.session.commit()
        patient.update_stats()
        return render_template('patient_details.html',
                               patient=patient,
                               form=form,
                               save_message=True)

    # Delete empty rows at end of many-to-one tables
    remove_blank_rows(form)

    return render_template('patient_details.html',
                           patient=patient,
                           form=form,
                           save_message=False)