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(i)
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")