示例#1
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)
示例#2
0
def add(username):
    form = PatientForm()
    if form.validate_on_submit():
        patient = Patient(
            name=form.name.data,
            age=form.age.data,
            hospital=form.hospital.data,
            mrn=form.mrn.data,
            height=form.height.data,
            weight=form.weight.data,
            user_id=User.query.filter_by(username=username).first().id)
        patient.set_bmi()
        patient.set_bsa()
        patient.set_ecoli()
        patient.set_vincristine()
        patient.set_daunorubicin()
        patient.set_methotrexate()
        patient.set_pegaspargase()
        patient.set_prednisolone()
        patient.set_cotrimoxazole()
        db.session.add(patient)
        db.session.commit()
        flash('Patient added!')
        return redirect(url_for('edit', username=username, name=patient.name))
    return render_template('patient.html', title='Patient', form=form)
示例#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)
示例#4
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)
        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)
示例#5
0
def patient_form():
    form = PatientForm()
    if form.validate_on_submit():
        c = db.connection.cursor()
        data = c.execute(
            "INSERT INTO patient (first_name, last_name, email, address, phone_no, occuptation, added_by) "
            "VALUES (%s, %s, %s, %s, %s, %s, %s)",
            (form.first_name.data, form.last_name.data, form.email.data,
             form.address.data, form.phone_no.data, form.occupation.data,
             int(session['user_id'])))
        db.connection.commit()
        #db.connection.close()
        flash("Patient created with name {}".format(form.first_name.data))
        return redirect(url_for('home'))
    return render_template('patient_form.html', title='New Patient', form=form)
示例#6
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:
        return render_template('patient_details.html', patient={}, form=form)
示例#7
0
def edit_patient_form(id):
    c = db.connection.cursor()
    data = c.execute("select * from patient where id={}".format(id))
    data = c.fetchone()
    form = PatientForm(formdata=request.form, obj=data)
    if data:
        if form.validate_on_submit():
            c.execute(
                "update patient set first_name=%s, last_name=%s, email=%s, address=%s, phone_no=%s,"
                " occuptation=%s where id={}".format(int(id)),
                (form.first_name.data, form.last_name.data, form.email.data,
                 form.address.data, form.phone_no.data, form.occupation.data))
            db.connection.commit()
            c.close()
            flash("edit successful for patient {}".format(id))
            return redirect(url_for('view_patient'))
    return render_template('edit_patient_form.html',
                           title="edit patient",
                           form=form,
                           data=data)
示例#8
0
def patient_details(id):
    """Display the full patient details form for an existing user."""
    patient = Patient.query.get(id)
    form = 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
        )