hospital.py
hospital.py
try:
choice = int(input("Enter your choice: "))
if choice == 1:
show_patients(cursor)
elif choice == 2:
register_patient(cursor, conn)
elif choice == 3:
delete_patient(cursor, conn)
elif choice == 4:
return
else:
print("Invalid choice! Please choose a valid option.")
except ValueError:
print("Invalid input! Only numbers are allowed.")
# Patient functionalities
def patient_menu(cursor, conn):
while True:
print("\nPATIENT MENU")
print("1. Search for Doctors")
print("2. Register Yourself")
print("3. Exit")
try:
choice = int(input("Enter your choice: "))
if choice == 1:
search_doctor(cursor)
elif choice == 2:
register_patient(cursor, conn)
elif choice == 3:
return
else:
print("Invalid choice! Please choose a valid option.")
except ValueError:
print("Invalid input! Only numbers are allowed.")
# Register a patient
def register_patient(cursor, conn):
if rows:
print_table(rows, ['Name', 'Specialization', 'Phone', 'Timing'])
else:
print(f"No records found for doctor: {d_name}")
print('-' * len(header_row))
# Main program
def main():
conn = connect_to_database()
cursor = conn.cursor()
while True:
print("Welcome to the Hospital Management System")
print("1. Admin")
print("2. Doctor")
print("3. Patient")
print("4. Exit")
try:
role = int(input("Enter your role (1/2/3/4): "))
if role == 1:
username = input("Enter Admin Username: ").strip()
password = input("Enter Admin Password: ").strip()
if username == "admin" and password == "admin123":
admin_menu(cursor, conn)
else:
print("Invalid Admin credentials!")
elif role == 2:
doctor_menu(cursor, conn)
elif role == 3:
patient_menu(cursor, conn)
elif role == 4:
print("Thank you for using Hospital management system!!!!")
break
else:
print("Invalid choice! Please choose a valid role.")
except ValueError:
print("Invalid input! Only numbers are allowed.")
cursor.close()
conn.close()
if __name__ == "__main__":
main()