def make_appointment():
    #  identify patient; choose doctor; show availability; choose availability; remove from doctor's availability; create appointment;
    #  insert appointment
    # identify patient
    print "who is the patient?"
    patient = select_a_patient()
    print "which doctor do you want to schedule an appointment with?"
    doctor = make_a_selection(get_doctor_list())
    selected_availability = select_a_timeslot(doctor)
    appointment = create_appointment(patient, selected_availability)
    print "congrats! you made an appointment."
    print "appointment details:"
    print_dict_list([appointment])
    insert_appointment(appointment)
Пример #2
0
def display_appointments_of_a_patient(patient):
    # get appointment list
    appointment_info_list = []
    cnx = get_connection()
    cursor = cnx.cursor()
    query = ("SELECT \
    Appointment.Appointment_Id, \
    MedicalOfficeId, \
    Doctor_Id, \
    `Appointment Date`, \
    `Appointment Time`, \
    Diagnosis.Description, \
    Medical_Condition.Condition_Name, \
    Prescription.ISDN, \
    Medication.Medication_Name, \
    Medication.Medication_Strength, \
    Prescription.Quantity, \
    Prescription.Prescribed_Dose, \
    Prescription.Frequency, \
    Prescription.Pharmacy_Id \
FROM \
    Appointment \
        JOIN \
    Diagnosis ON Diagnosis.Appointment_Id = Appointment.Appointment_Id \
        JOIN \
    Medical_Condition ON Medical_Condition.Condition_Id = Diagnosis.Condition_Id \
        JOIN \
    Prescription ON Prescription.Diagnosis_Id = Diagnosis.Diagnosis_Id \
        JOIN \
    Medication ON Medication.ISDN = Prescription.ISDN \
    WHERE Appointment.PatientID = %(Person_Id)s")
    cursor.execute(query, patient)
    for (
            appointment_id, medical_office_id, doctor_id, appointment_date, appointment_time, diagnosis_description,
            medical_condition_name, isdn, medication_name, medication_strength, quantity, prescribed_dose, frequency,
            pharmacy_id
    ) in cursor:
        appointment_info_list.append(
            {'Appointment_Id': appointment_id, 'MedicalOfficeId': medical_office_id, 'Doctor_Id': doctor_id,
             'Appointment Date': appointment_date, 'Appointment Time': appointment_time,
             'Description': diagnosis_description, 'medical_condition_name': medical_condition_name,
             'ISDN': isdn, 'Medication_Name': medication_name, 'Medication_Strength': medication_strength,
             'Quantity': quantity, 'Prescribed_Dose': prescribed_dose, 'Frequency': frequency,
             'Pharmacy_Id': pharmacy_id})
    cursor.close()
    cnx.close()
    print_dict_list(appointment_info_list)
Пример #3
0
def create_person():
    # get basic info
    person = {}
    while True:
        try:
            fname = raw_input('please input first name: ')
            if fname == '':
                raise Exception('first name cannot be empty')
            person['First_Name'] = fname
            break
        except Exception as e:
            print e.message
    while True:
        try:
            lname = raw_input('please input last name: ')
            if lname == '':
                raise Exception('last name cannot be empty')
            person['Last_Name'] = lname
            break
        except Exception as e:
            print e.message
    while True:
        try:
            date_of_birth_str = raw_input('please input date of birth(yyyy/mm/dd): ')
            person['Date_Of_Birth'] = datetime.datetime.strptime(date_of_birth_str, '%Y/%m/%d').date()
            break
        except ValueError as e:
            print e.message
    while True:
        try:
            deceased = raw_input('is this person deceased?(Y/N) ')
            deceased = deceased.upper()
            if deceased != 'Y' and deceased != 'N':
                raise Exception('please input Y or N')
            person['Deceased'] = deceased
            break
        except Exception as e:
            print e.message

    # select primary physician
    print 'select a primary physician for this person'
    person['Primary_Physician'] = make_a_selection(get_doctor_list())['Doctor_Id']
    # print person['First_Name'], person['Last_Name'], person['Date_Of_Birth'], person['Deceased']
    print 'a summary of this person:'
    print_dict_list([person])
    return person
Пример #4
0
def display_prescription_account():
    # get start date time and end date time
    time_period = {}
    while True:
        try:
            datetime_str = raw_input('specify start date time(yyyy/mm/dd HH:MM:SS)  ')
            time_period['start_time'] = datetime.datetime.strptime(datetime_str, '%Y/%m/%d %H:%M:%S')
            break
        except ValueError as e:
            print e.message
    while True:
        try:
            datetime_str = raw_input('specify end date time(yyyy/mm/dd HH:MM:SS)  ')
            time_period['end_time'] = datetime.datetime.strptime(datetime_str, '%Y/%m/%d %H:%M:%S')
            break
        except ValueError as e:
            print e.message
    # get prescription count
    prescription_count_info_list = []
    cnx = get_connection()
    cursor = cnx.cursor()
    query = ("SELECT COUNT(Prescription.Prescription_No), Appointment.Doctor_Id, Medication.ISDN, "
             "Medication.Medication_Name, Person.First_Name, Person.Last_Name  FROM Prescription \
	JOIN Diagnosis ON Diagnosis.Diagnosis_Id = Prescription.Diagnosis_Id \
    JOIN Appointment ON Appointment.Appointment_Id = Diagnosis.Appointment_Id \
    JOIN Medication ON Medication.ISDN = Prescription.ISDN \
    JOIN Person ON Person.Person_Id = Appointment.Doctor_Id \
	WHERE TIMESTAMP(Appointment.`Appointment Date`, Appointment.`Appointment Time`) > %(start_time)s AND \
		TIMESTAMP(Appointment.`Appointment Date`, Appointment.`Appointment Time`) < %(end_time)s \
	GROUP BY Appointment.Doctor_Id, Medication.ISDN;")
    cursor.execute(query, time_period)
    for (prescription_count, doctor_id, isdn, medication_name, doctor_fname, doctor_lname) in cursor:
        prescription_count_info_list.append(
            {'prescription_count': prescription_count, 'Doctor_Id': doctor_id, 'ISDN': isdn,
             'Medication_Name': medication_name, 'doctor_fname': doctor_fname, 'doctor_lname': doctor_lname})
    cursor.close()
    cnx.close()
    # display schedule list
    print_dict_list(prescription_count_info_list)
Пример #5
0
def create_insurance_coverage(person_id):
    insurance_coverage = {}
    while True:
        try:
            date_str = raw_input('please input start date of insurance coverage(yyyy/mm/dd): ')
            insurance_coverage['Coverage_Start_Date'] = datetime.datetime.strptime(date_str, '%Y/%m/%d').date()
            break
        except ValueError as e:
            print e.message
    while True:
        try:
            date_str = raw_input('please input end date of insurance coverage(yyyy/mm/dd): ')
            insurance_coverage['Coverage_End_date'] = datetime.datetime.strptime(date_str, '%Y/%m/%d').date()
            break
        except ValueError as e:
            print e.message
    # select insurer
    print 'which inserer?'
    insurance_coverage['Insurer_Id'] = make_a_selection(get_insurer_list())['Insurer_Id']
    insurance_coverage['Person_Id'] = person_id
    print 'a summary of insurance coverage'
    print_dict_list([insurance_coverage])
    return insurance_coverage
Пример #6
0
def display_schedules():
    # get schecule list
    schedule_list = []
    cnx = get_connection()
    cursor = cnx.cursor()
    query = ("SELECT \
    Doctor_Id, \
    p1.First_Name AS doctor_fname, \
    p1.Last_Name AS doctor_lname, \
    `Appointment Date`, \
    `Appointment Time`, \
    MedicalOfficeId, \
    Organization.`Name` AS medical_office_name, \
    PatientID, \
    p2.First_Name AS patient_fname, \
    p2.Last_Name  AS patient_lname \
FROM \
    Appointment \
        JOIN \
    Organization ON Organization.Org_Id = Appointment.MedicalOfficeId \
        JOIN \
    Person AS p1 ON p1.Person_Id = Appointment.Doctor_Id \
		JOIN \
    Person AS p2 ON p2.Person_Id = Appointment.PatientID")
    cursor.execute(query)
    for (
            doctor_id, doctor_fname, doctor_lname, appointment_date, appointment_time, medical_office_id,
            medical_office_name,
            patient_id, patient_fname, patient_lname) in cursor:
        schedule_list.append({'Doctor_Id': doctor_id, 'doctor_fname': doctor_fname, 'doctor_lname': doctor_lname,
                              'Appointment Date': appointment_date, 'Appointment Time': appointment_time,
                              'MedicalOfficeId': medical_office_id, 'medical_office_name': medical_office_name,
                              'PatientID': patient_id, 'patient_fname': patient_fname, 'patient_lname': patient_lname})
    cursor.close()
    cnx.close()
    # display schedule list
    print_dict_list(schedule_list)
Пример #7
0
from medical_system.display_info import display_schedules, display_patient_summary, display_prescription_account
from medical_system.manage_appointment import make_appointment
from medical_system.manage_diagnosis import add_appointment_result
from medical_system.manage_patient import create_person, add_new_patient

if __name__ == '__main__':
    func_list = [add_new_patient, make_appointment, add_appointment_result, display_schedules, display_patient_summary,
                 display_prescription_account]
    func_select_dic = {0: 'Add a new patient to the system',
                       1: 'Make an appointment for a person with a doctor at a medical office',
                       2: 'Record the results of an appointment',
                       3: 'Display the schedule of appointments for a doctor for a day at a medical office',
                       4: 'Display a patient summary, showing appointments for a period of time, diagnoses, and prescriptions',
                       5: 'Display the prescription count, by medication, by doctor for a period of time.'}

    print 'welcome to medical system'
    print '=' * 20
    print 'choose a function to perform'
    pp = pprint.PrettyPrinter(indent=4)
    print_dict_list([func_select_dic])
    selected = None
    while True:
        try:
            selection = int(raw_input('please select an option by index number:   '))
            if selection < 0:
                raise Exception('selection must be positive')
            func_list[selection]()
            break
        except Exception as e:
            print e.message