if option==0: pickle.dump(patient,c) # Dumping the patient's list in to the clinic file pickle.dump(doctor,c) # Dumping the Doctor's list into the clinic file pickle.dump(appointment,c) # writing the appointment's list into the clinic file break elif option==1: patnt=Patient() patnt.name=input("Enter the patient name:") patnt.age=eval(input("Enter the age of a pateint:")) patnt.idnumber=input("Enter the id number of the patient:") patnt.adress=input("Enter the address of a patient:") patnt.visit=input("Enter the number of visit:") patient.append(str(patnt)) elif option==2: doc=Doctor() doc.name=input("Enter the doctor's name:") doc.address=input("Enter the address of the doctor:") doc.Id=input("Enter the Doctor's ID:") doctor.append(str(doc)) elif option==3: appoint=Appointment() appoint.pid=input("Enter the patient's ID:") appoint.did=input("Enter the Doctor's ID:") appoint.memo=input("Enter the memo:") appoint.day=input("Enter the day of the appointment:") appointment.append(str(appoint)) elif option==4: for i in patient: print(i) elif option==5: for i in doctor:
print("5: Display Doctors") print("6: Display appointments") print("7: Search") print("8: QUIT") option = eval(input("Enter the option:")) if option == 1: patnt = Patient() patnt.name = input("Enter the patient name:") # name iherited from person patnt.age = eval(input("Enter the age of a pateint:")) # age inherited from person patnt.idnumber = input("Enter the id number of the patient:") # the patient is given the id number patnt.adress = input("Enter the address of a patient:") patnt.visit = input("Enter the number of visit:") patient.append(str(patnt)) # The whole patient class is appended into the list elif option == 2: doc = Doctor() doc.name = input("Enter the doctor's name:") # The doctor is given the name,address and Id number doc.address = input("Enter the address of the doctor:") doc.Id = input("Enter the Doctor's ID:") doctor.append(str(doc)) # The whole doctor class is aasigned into the list elif option == 3: appoint = Appointment() appoint.pid = input( "Enter the patient's ID:" ) # The appointment is assigned doctor's id, when the appointment is and is also assigne the discription of the appointment appoint.did = input("Enter the Doctor's ID:") # did=Doctor's id appoint.memo = input("Enter the memo:") appoint.day = input("Enter the day of the appointment:") appointment.append(str(appoint)) # The whole appointment class is assigned to the list elif option == 4: for i in patient: # Going throught Patient list print(i)
def main(): patients,doctors,appointments=[],[],[] while True: print("Welcome to the Clinic. Please select an option:\n") option=int(input("1.Add a doctor, patient or create an appointment.\n2.Search and dispay all patients, doctors or appointments.\n3.Search all appointments for a patient or a doctor.\n0.Quit.\n")) if option==0:break elif option==1: option1=int(input("1.Add a doctor.\n2.Add Patient.\n3.Create appointment.\n")) if option1==1: #Adding a doctor d=Doctor() d.name=input("Please enter doctor's name.\n") d.age=input("Please enter doctor's age.\n") d.doctor_id_no=input("Please enter doctor's I.D number.\n") d.doctor_address=input("Please enter doctor's address.\n") doctors.append(d) elif option1==2: #Adding patient p=Patient() p.name=input("Please enter patient's name.\n") p.age=input("Please enter patient's age.\n") p.patient_id_no=input("Please enter patient's I.D number.\n") p.patient_address=input("Please enter patient's address.\n") patients.append(p) elif option1==3: #creating an appointment a=Appointment() a.doc_id=input("Please enter doctor's I.D number.\n") a.pat_id=input("Please enter patient's I.D number.\n") a.time=input("Please enter date and time for the appointment(yyyy/mm/dd hh:mm)\n") a.memo() appointments.append(a) elif option==2: option2=int(input("1.Display doctors.\n2.Display patients.\n3.Display appointments.\n")) if option2==1: for i in doctors: print(i.display()) elif option2==2: for i in patients: print(i.display()) elif option2==3: for i in appointments: print(i.display()) elif option==3: option3=int(input("1.Search for doctor's appointments.\n2.Search for patient's appointments")) if option3==1: doctor_id=input("Enter doctor's I.D number") for i in doctors: if i.doctor_id_no==doctor_id: print(i.name) break for j in doctors: for k in appointments: if j.doctor_id_no==k.doc_id: print(k.display()) elif option3==2: patient_id=input("Enter patient's I.D number") for i in doctors: if i.patient_id_no==patient_id: print(i.name) break for j in patients: for k in appointments: if j.patient_id_no==k.pat_id: print(k.display())
def main(): """ three lists to store patients, doctors and appointments """ patients = [] doctors = [] appointments = [] while True: print() """ options choose from """ print("*****Clinic******") print("1. To add a patient") print("2. To add a doctor") print("3. To make an appointment") print("4. To display all patients") print("5. To display all doctors") print("6. To display all appointments") print("7. To display appointments for a specific individual (doctor or patient)") print("0. To quit") print() response = input() # getting an input from the user if response == "0": break elif response == "1": patient = Patient() patient.name = input("Enter the name of the patient? \n") patient.age = input("Enter age of the patient? \n") patient.identity = input("The patients ID number? \n") patient.address = input("The patients address? \n") patient.number_of_visits = input("The patients number of visits? \n") patients.append(patient) elif response == "2": doctor = Doctor() # creating an object variable doctor """ getting object variables """ doctor.name = input("Enter the name of the doctor? \n") doctor.age = input("Enter age of the doctor? \n") doctor.identity = input("The doctors ID number? \n") doctor.address = input("The doctors address? \n") doctors.append(doctor) # appending the object doctor to a list doctors elif response == "3": appointment = Appointment() appointment.patients_identity = input("Enter patient's ID number? \n") appointment.doctors_identity = input("Enter doctor's ID number? \n") appointment.timestamp = input("Enter date and time? \n") appointment.memo = input("Enter memorundum of the appointment? \n") appointments.append(appointment) # adding the oject appointment to list appointments elif response == "4": control = 1 for item in patients: print("Patient No.", control) item.display() control +=1 print() elif response == "5": control = 1 for item in doctors: print("Doctor No.", control) item.display() control +=1 print() elif response == "6": for item in appointments: print(item) print() elif response == "7": user_id = input("Enter ID number for which you want to check appointments scheduled? \n ") print("Scheduled appointment(s) for", user_id, "are as follows: ") """ looping through the list appointment and comparing id's""" for item in appointments: if user_id == item.patients_identity: print(item.timestamp) elif user_id == item.doctors_identity: print(item) else: print("The value entered is not in the option manu.") print("Please enter value available in the menu")
print("Could not find a doctor with that identity number.") elif user_input == 8: # option to find appointments app = input("Enter the date of the appointment (yy-mm-dd hours:minutes:00): ") for s in Appointments_1: if s ==appointment: app.append(s) pickle.dump(app,AppointmentFile) elif user_input == 9: a = Patient() # create object a.name = patient_name a.age = age a.patient_address = address a.patient_identity_no = ID_number a.display() for i in Patients_1: # take dictionary keys to make them one list pp.append(i) pickle.dump(pp,PatientFile) elif user_input == 10: b = Doctor() # create object b.name = doctor_name b.age = age b.doctor_address = address b.doctor_identity_no = dr_ID_number b.display() for k in Doctors_1: drr.append(k) pickle.dump(drr,DoctorFile) PatientFile.close() DoctorFile.close() AppointmentFile.close()