예제 #1
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))
예제 #2
0
def patients():
    '''Works'''
    if request.method == 'GET':
        patient_list = fdb.query_db_get_all('SELECT * FROM ' + _PATIENTS_TABLE)
        print(patient_list)
        return jsonify(patient_list)
    elif request.method == 'POST':
        fName = request.form['first_name']
        lName = request.form['last_name']
        Name = fName + " " + lName
        eMail = request.form['e_mail']
        _date = request.form['date']
        address = request.form['address']
        healthcardno = request.form['healthcardno']
        p1 = -1
        p2 = -1
        p3 = -1
        p4 = -1
        result = fdb.query_db_change(
            'INSERT INTO ' + _PATIENTS_TABLE +
            '(firstname, lastname, name, email, date_, address, healthcardno, p1, p2, p3, p4) VALUES ({0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0})'
            .format(_PLACEHOLDER), (fName, lName, Name, eMail, _date, address,
                                    healthcardno, p1, p2, p3, p4))
        if result == None:
            print("Could not insert new record into", _PATIENTS_TABLE)
        return render_template('p1.html', ptid=result)
예제 #3
0
def autocompletebyhealthcard():
    search = request.args.get('q')
    query = 'SELECT * FROM ' + _PATIENTS_TABLE + ' WHERE CAST(healthcardno AS TEXT) LIKE ?'
    args = ('%' + search + '%')
    patient_list = fdb.query_db_get_all(query, (args, ))
    patients = []
    for patient in patient_list:
        name = patient["firstname"] + " " + patient["lastname"]
        patients.append(name)
    return jsonify(patients)
예제 #4
0
def autocompletebyname():
    search = request.args.get('q')
    query = 'SELECT * FROM ' + _PATIENTS_TABLE + ' WHERE firstname LIKE ? OR lastname LIKE ?'
    args = ('%' + search + '%', '%' + search + '%')
    patient_list = fdb.query_db_get_all(query, args)
    patients = []
    for patient in patient_list:
        name = patient["firstname"] + " " + patient["lastname"]
        patients.append(name)
    return jsonify(patients)
예제 #5
0
def summary_notes():
    patient_list = fdb.query_db_get_all('SELECT * FROM ' + _PATIENTS_TABLE)
    dic = {
        "rountineCare": [0, 0, 0, 0],
        "activeMonitoring": [0, 0, 0, 0],
        "planAction": [0, 0, 0, 0],
        "actNow": [0, 0, 0, 0]
    }
    for patient in patient_list:
        if patient['p1'] > -1:
            if patient['p1'] == 0:
                dic["rountineCare"][0] = dic["rountineCare"][0] + 1
            elif patient['p1'] == 1:
                dic["activeMonitoring"][0] = dic["activeMonitoring"][0] + 1
            elif patient['p1'] == 2:
                dic["planAction"][0] = dic["planAction"][0] + 1
            else:
                dic["actNow"][0] = dic["actNow"][0] + 1
        if patient['p2'] > -1:
            if patient['p2'] == 0:
                dic["rountineCare"][1] = dic["rountineCare"][1] + 1
            elif patient['p2'] == 1:
                dic["activeMonitoring"][1] = dic["activeMonitoring"][1] + 1
            elif patient['p2'] == 2:
                dic["planAction"][1] = dic["planAction"][1] + 1
            else:
                dic["actNow"][1] = dic["actNow"][1] + 1
        if patient['p3'] > -1:
            if patient['p3'] == 0:
                dic["rountineCare"][2] = dic["rountineCare"][2] + 1
            elif patient['p3'] == 1:
                dic["activeMonitoring"][2] = dic["activeMonitoring"][2] + 1
            elif patient['p3'] == 2:
                dic["planAction"][2] = dic["planAction"][2] + 1
            else:
                dic["actNow"][2] = dic["actNow"][2] + 1
        if patient['p4'] > -1:
            if patient['p4'] == 0:
                dic["rountineCare"][3] = dic["rountineCare"][3] + 1
            elif patient['p4'] == 1:
                dic["activeMonitoring"][3] = dic["activeMonitoring"][3] + 1
            elif patient['p4'] == 2:
                dic["planAction"][3] = dic["planAction"][3] + 1
            else:
                dic["actNow"][3] = dic["actNow"][3] + 1
    return render_template('summary_notes.html', summary=dic)
예제 #6
0
def user():
    user_results = fdb.query_db_get_all('SELECT * FROM Users')
    print(user_results)
    return jsonify(user_results)
예제 #7
0
def provider_list():
    provider_list = fdb.query_db_get_all('SELECT * FROM ' + _PROVIDERS_TABLE)
    return render_template('provider_list.html', providers=provider_list)
예제 #8
0
def patient_list():
    patient_list = fdb.query_db_get_all('SELECT * FROM ' + _PATIENTS_TABLE)
    return render_template('patient_list.html', patients=patient_list)