arslanasghar6637's picture
Create Main.py
ddef4e2 verified
def main():
while True:
print("\nDoctor Appointment App")
print("1. Book Appointment")
print("2. View Appointments")
print("3. Cancel Appointment")
print("4. Exit")
choice = input("Enter your choice: ")
if choice == '1':
patient_name = input("Enter patient name: ")
doctor_name = input("Enter doctor name: ")
date = input("Enter date (YYYY-MM-DD): ")
time = input("Enter time (HH:MM): ")
appointment = Appointment(patient_name, doctor_name, date, time)
appointment.save()
print("Appointment booked successfully!")
elif choice == '2':
appointments = Appointment.get_all()
if appointments:
print("\nAppointments:")
for appt in appointments:
print(f"ID: {appt[0]}, Patient: {appt[1]}, Doctor: {appt[2]}, Date: {appt[3]}, Time: {appt[4]}")
else:
print("No appointments found.")
elif choice == '3':
appointment_id = input("Enter appointment ID to cancel: ")
Appointment.cancel(appointment_id)
print("Appointment canceled successfully!")
elif choice == '4':
print("Exiting...")
break
else:
print("Invalid choice. Please try again.")
if __name__ == "__main__":
main()