コード例 #1
0
ファイル: views.py プロジェクト: rmoorman/rva-screening
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
    )
コード例 #2
0
ファイル: views.py プロジェクト: mishmosh/rva-screening
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
        )
    else:
        if request.method == 'GET':
            # If this patient has a referral to the current organization in SENT status,
            # update it to RECEIVED
            sent_referrals = [
                r for r in patient.referrals
                if r.to_service_id == current_user.service_id
                and r.in_sent_status()
            ]
            for referral in sent_referrals:
                referral.mark_received()
            if sent_referrals:
                db.session.commit()

            patient.update_stats()

        return render_template(
            'patient_details.html',
            patient=patient,
            form=form,
            save_message=False
        )
コード例 #3
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)