コード例 #1
0
ファイル: routes.py プロジェクト: djlad/patientrecordproject
def save_entry():
    req = request.get_json()
    entryType = req['entryType']
    entry = req['entry']

    if entryType == 'patient':
        pm = PatientModel()
        pm.change_patient_info(entry['name'],
                           entry['weight'],
                           entry['address'],
                           entry['phone'],
                           entry['insurance'],
                           entry['height'],
                           entry['medicalhistory'],
                           entry['patientID'])
    elif entryType == 'doctor':
        dm = DoctorModel()
        print(entry)
        dm.change_doctor_info(entry['name'], 
                           entry['specialty'], 
                           entry['location'],
                           entry['doctorID'])
    elif entryType == 'appointment':
        am = AppointmentModel()
        tosave = 'appointmentID' in entry
        if tosave:
            am.change_appointment(entry['appointmentID'],
                                entry["time"])
        else:
            am.make_appointment(entry['doctorID'], entry['patientID'], entry['time'])
            print('save new appointment')
    elif entryType == 'prescription':
        pm = PrescriptionModel()
        tosave = 'prescriptionID' in entry
        if tosave:
            pm.change_prescription(entry['prescriptionID'], entry['prescription'])
        else:
            pm.add_prescription(entry['doctorID'], entry['patientID'], entry['prescription'])
        print(entry)
    return 'save finished'
コード例 #2
0
ファイル: routes.py プロジェクト: djlad/patientrecordproject
def addEntry():
    entryType = request.form['entryType']
    if entryType == 'patient':
        '''
        1. create usermodel object
        2. add a new user
        3. get just added user
        4. create patientmodel object
        5. add a default patient entry
        return
        '''
        um = UserModel()
        um.add_user(None,random_garbage(),random_garbage(),"patient", 3)
        lastEntry = um.get_last_entry()
        pm = PatientModel()
        pm.add_patient(lastEntry['userID'],"",0,0,"",0,"","","","","1111-11-11")
    elif entryType == "doctor":
        '''
        1. create usermodel object
        2. add a new user
        3. get just added user
        4. create doctormodel object
        5. add a default doctor entry
        return
        '''
        um = UserModel()
        um.add_user(None,random_garbage(),random_garbage(),"doctor", 2)
        lastEntry = um.get_last_entry()
        dm = DoctorModel()
        dm.add_doctor(lastEntry['userID'],"","","")
    elif entryType == 'prescription':
        pm = PrescriptionModel()
        pm.add_prescription(0,0,"")
    elif entryType == 'appointment':
        am = AppointmentModel()
        am.make_appointment(0,0,"1111-11-11 11:11:11")
    return 'entry saved'