Exemplo n.º 1
0
def measurement(ptid, mid):
    patient_info = fdb.query_db_get_one(
        'SELECT * FROM ' + _PATIENTS_TABLE +
        ' WHERE id={0}'.format(_PLACEHOLDER), (ptid, ))
    pt_msmt = fdb.query_db_get_one(
        'SELECT id, systolic, diastolic, pulse, time_recorded FROM ' +
        _MEASUREMENTS_TABLE + ' WHERE id = {0}'.format(_PLACEHOLDER), (mid, ))
    return render_template('measurement.html',
                           patient=patient_info,
                           measurement=pt_msmt)
Exemplo n.º 2
0
def patient(ptid):
    '''Works '''
    if request.method == 'GET':
        patient_info = fdb.query_db_get_one(
            'SELECT * FROM ' + _PATIENTS_TABLE +
            ' WHERE id={0}'.format(_PLACEHOLDER), (ptid, ))
        #retrieve measurements
        query = 'SELECT * FROM ' + _MEASUREMENTS_TABLE + ' WHERE patient_id={0}'.format(
            _PLACEHOLDER)  # this IS good enough@
        #no need to join - keeping the patient and measurements dictionary separate, makes it easier/more intuitive to write the template code
        #query='SELECT * FROM '+_MEASUREMENTS_TABLE+' as v JOIN (SELECT * FROM Patients WHERE id={0}) as p ON v.patient_id=p.id'.format(_PLACEHOLDER)
        patient_measurements = fdb.query_db_get_all(query, (ptid, ))
        return render_template('patient.html',
                               patient=patient_info,
                               measurements=patient_measurements)

    elif request.method == 'POST':
        systolic = request.form['systolic']
        diastolic = request.form['diastolic']
        pulse = request.form['pulse']
        fdb.query_db_change(
            'INSERT INTO ' + _MEASUREMENTS_TABLE +
            '(systolic, diastolic, pulse, patient_id) VALUES ({0}, {0}, {0}, {0})'
            .format(_PLACEHOLDER), (systolic, diastolic, pulse, ptid))
        return redirect(url_for('patient', ptid=ptid))
Exemplo n.º 3
0
def search():
    patient_info = fdb.query_db_get_one(
        'SELECT * FROM ' + _PATIENTS_TABLE +
        ' WHERE id={0}'.format(_PLACEHOLDER), (ptid, ))
    if request.method == 'POST' and patient_info.validate_on_submit():
        return redirect((url_for('search_results',
                                 query=patient_info.search.data)))
    return render_template('search.html', form=patient_info)
Exemplo n.º 4
0
def load_user(id):
    first_match = fdb.query_db_get_one(
        'SELECT id, username, password, email_address FROM Users WHERE id = {0}'
        .format(_PLACEHOLDER), (id, ))

    if first_match == None:
        return None
    else:
        user = User(first_match['id'], first_match['username'],
                    first_match['password'], first_match['email_address'])
        return user
Exemplo n.º 5
0
def lookup_user(username, password):
    first_match = fdb.query_db_get_one(
        'SELECT id, username, password, email_address FROM Users WHERE username = {0}'
        .format(_PLACEHOLDER), (username, ))
    if first_match == None:
        return None
    else:
        user = User(first_match['id'], first_match['username'],
                    first_match['password'], first_match['email_address'])
        if check_password_hash(user.password, password):
            return user
        else:
            return None
Exemplo n.º 6
0
def searchbyname():
    search = request.args.get('q')
    query = 'SELECT * FROM ' + _PATIENTS_TABLE + ' WHERE name=?'
    args = (search)
    patient = fdb.query_db_get_one(query, (args, ))
    return jsonify(patient)