import mysql.
connector as mycon
# Database Connection
con = [Link](host="localhost", user="root", passwd="123456", database="hospital",
port="3307")
# MAIN MENU
def showmenu():
while True:
print("*" * 50)
print("----------- HOSPITAL MANAGEMENT SYSTEM -----------")
print("*" * 50)
print("1 - Add New Patient")
print("2 - View All Patients")
print("3 - View Appointments")
print("4 - Add Doctor")
print("5 - View Doctors")
print("6 - Exit")
print("*" * 50)
choice = int(input("Enter your choice: "))
if choice == 1:
addPatient()
elif choice == 2:
viewPatients()
elif choice == 3:
viewAppointments()
elif choice == 4:
addDoctor()
elif choice == 5:
viewDoctors()
elif choice == 6:
print("*" * 50)
print("------ THANK YOU FOR USING HOSPITAL MANAGEMENT SYSTEM ------")
print("*" * 50)
break
# Add a New Patient
def addPatient():
print(" --- ENTER PATIENT DETAILS --- ")
pname = input("Enter Patient Name: ")
age = int(input("Enter Age: "))
gender = input("Enter Gender: ")
contact = input("Enter Contact Number: ")
diagnosis = input("Enter Diagnosis: ")
room_no = int(input("Enter Room Number: "))
q = "INSERT INTO patients (pname, age, gender, contact, diagnosis, room_no) VALUES ('{}', {}, '{}',
'{}', '{}', {})".format(pname, age, gender, contact, diagnosis, room_no)
cr1 = [Link]()
[Link](q)
[Link]()
print("--- Patient Added Successfully ---")
# View All Patients
def viewPatients():
q = "SELECT * FROM patients"
cr1 = [Link]()
[Link](q)
res = [Link]()
if res == []:
print("No patients in the database.")
else:
for row in res:
print(row)
# View Appointments
def viewAppointments():
q = "SELECT pname, age, gender, diagnosis FROM patients"
cr1 = [Link]()
[Link](q)
res = [Link]()
if res == []:
print("No appointments available.")
else:
for row in res:
print(row)
# Add Doctor
def addDoctor():
print(" --- ENTER DOCTOR DETAILS --- ")
dname = input("Enter Doctor Name: ")
specialty = input("Enter Specialty: ")
contact = input("Enter Contact Number: ")
q = "INSERT INTO doctors (dname, specialty, contact) VALUES ('{}', '{}', '{}')".format(dname,
specialty, contact)
cr1 = [Link]()
[Link](q)
[Link]()
print("--- Doctor Added Successfully ---")
# View Doctors
def viewDoctors():
q = "SELECT * FROM doctors"
cr1 = [Link]()
[Link](q)
res = [Link]()
if res == []:
print("No doctors in the database.")
else:
for row in res:
print(row)
if con.is_connected():
showmenu()