Professional Documents
Culture Documents
HOSPITAL
MANAGEMENT
SYSTEM
PYTHON – MYSQL PROJECT
This Hospital Management System is specially designed
for the students who are preparing for Computer
Science XII, Informatics Practices XII, BCA, BSc (CS), BSc
(IT), and PGDCA. It contains different modules to
manage Books, Members, Book Issue, Book Return and
many Search options. This project also has provision of
Chart for Data Visualization.
Website : www.techtipnow.in
YouTube : www.youtube.com/c/techtipnow
Email : techtipnow@gmail.com
support@techtipnow.in
telegram : https://t.me/CBSE_IP_Class_12
https://t.me/CBSE_Computer_Science
SANJAYKUMAR
TECHTIPNOW COMPUTER EDUCATION AND PROGRAMMING
1/1/2023
Website: www.techtipnow.in
YouTube: www.youtube.com/c/techtipnow
DATABASE DESIGN-
OPD
OPDNO INT (PRIMARY KEY)
PNAME VARCHAR
DNAME VARCHAR
FEE INT
DOCTOR
DNAME VARCHAR
DEPARTMENT VARCHAR
APPOINT
OPDNO INT
DOA DATE
PNAME VARCHAR
DNAME VARCHAR
SYMPTOM VARCHAR
TREATMENT VARCHAR
PATIENT
PID INT (PRIMARY KEY)
PNAME VARCHAR
PADD VARCHAR
PMOB VARCHAR
1
Website: www.techtipnow.in
YouTube: www.youtube.com/c/techtipnow
CODE-
‘MAIN’ MODULE-
import os
import doctor
import appointment
import opd
import report
while(True):
#os.system('cls')
print("="*80)
print("\t\t\t------Hospital Management System------\n")
print("="*80)
print("\t\t\t\tEnter your choice")
print("\t\t\t\t1. OPD\n\t\t\t\t2. Doctor Details\n\t\t\t\t3. Appointment\n\t\t\t\t4.
Reports\n\t\t\t\t5. Exit\n")
print("="*80)
choice=int(input())
os.system('cls')
if choice == 1:
while(True):
print("\t\t\t\tSelect the Action")
print("\t\t\t\t1. New OPD\n\t\t\t\t2. Edit OPD\
\n\t\t\t\t3. Delete OPD\n\t\t\t\t4. Search OPD\
\n\t\t\t\t5. Back to Main Menu")
choice=int(input())
if choice==1:
opd.opd_input()
print("Successfully Added")
elif choice == 2:
opd.opd_edit()
elif choice ==3:
opd.opd_delete()
elif choice == 4:
opd.opd_search()
print()
elif choice ==5:
break
3
Website: www.techtipnow.in
YouTube: www.youtube.com/c/techtipnow
report.patient_history()
elif choice == 5:
report.opd_list()
elif choice == 6:
report.col_chart()
elif choice == 7:
break
elif choice == 5:
break
‘OPD’ MODULE-
import pandas as pd
import mysql.connector as sqlt
from tabulate import tabulate
con = sqlt.connect(host = "localhost", user = "root", passwd = "sanjay", database = "hospital")
cursor = con.cursor()
def opd_input():
4
Website: www.techtipnow.in
YouTube: www.youtube.com/c/techtipnow
cursor.execute(qry1)
t = cursor.fetchone()
if not t[0]:
pid = 1
else:
pid = t[0] + 1
print(pid)
qry2 = "insert into patient values({},'{}','{}','{}')".format(pid,pname,padd,pmob)
cursor.execute(qry2)
con.commit()
print("Successfully Added")
#cursor.close()
def opd_edit():
x=int(input("Enter OPD No"))
qry="select * from opd where opdno = {};".format(x)
cursor.execute(qry)
r=cursor.fetchone()
#con.commit()
if r:
#print("Exist")
fee = int(input("Enter New Price"))
qry = "update opd set fee = {} where opdno = {};".format(fee,x)
cursor.execute(qry)
con.commit()
print("updated")
else:
print("Wrong OPD No")
#cursor.close()
def opd_delete():
x=int(input("Enter OPD No"))
qry="select * from opd where opdno = {};".format(x)
cursor.execute(qry)
r=cursor.fetchone()
#con.commit()
if r:
#print("Exist")
ch = input("Are you sure you want to delete y/n")
if ch == 'y':
qry = "delete from opd where opdno = {};".format(x)
5
Website: www.techtipnow.in
YouTube: www.youtube.com/c/techtipnow
cursor.execute(qry)
con.commit()
print("Successfully Deleted")
else:
print("Wrong OPD No")
#cursor.close()
def opd_search():
try:
x=int(input("Enter OPD No"))
qry="select * from OPD where opdno = {};".format(x)
df=pd.read_sql(qry,con)
#print(df,"\n")
print(tabulate(df , headers = 'keys',tablefmt = 'psql', showindex = False))
except:
print("Error...Please check OPD No")
‘DOCTOR’ MODULE-
import pandas as pd
import mysql.connector as sqlt
from tabulate import tabulate
con = sqlt.connect(host = "localhost", user = "root", passwd = "sanjay", database = "hospital")
cursor = con.cursor()
def doctor_input():
print(did)
6
Website: www.techtipnow.in
YouTube: www.youtube.com/c/techtipnow
con.commit()
print("Successfully Added")
#cursor.close()
def doctor_edit():
x=int(input("Enter Doctor ID"))
qry="select * from doctor where did = {};".format(x)
cursor.execute(qry)
r=cursor.fetchone()
#con.commit()
if r:
#print("Exist")
d = input("Enter New Dept")
qry = "update doctor set department = '{}' where did = {};".format(d,x)
cursor.execute(qry)
con.commit()
print("Successfull updated")
else:
print("Wrong DoctorID")
#cursor.close()
def doctor_delete():
x=int(input("Enter Doctor ID"))
qry="select * from doctor where did = {};".format(x)
cursor.execute(qry)
r=cursor.fetchone()
#con.commit()
if r:
#print("Exist")
ch = input("Are you sure you want to delete y/n")
if ch == 'y':
qry = "delete from doctor where did = {};".format(x)
cursor.execute(qry)
con.commit()
print("Successfully Deleted")
else:
print("Wrong Doctor ID")
#cursor.close()
def doctor_search():
x=int(input("Enter Doctor ID"))
qry="select * from doctor where did = {};".format(x)
7
Website: www.techtipnow.in
YouTube: www.youtube.com/c/techtipnow
df=pd.read_sql(qry,con)
#print(df,"\n")
print(tabulate(df , headers = 'keys',tablefmt = 'psql', showindex = False))
‘APPOINTMENT’ MODULE-
import pandas as pd
import mysql.connector as sqlt
from tabulate import tabulate
con = sqlt.connect(host = "localhost", user = "root", passwd = "sanjay", database = "hospital")
cursor = con.cursor()
def appointment():
def appointment_edit():
x=input("Enter Doctor Name")
qry="select * from appoint where dname = '{}';".format(x)
cursor.execute(qry)
r=cursor.fetchone()
#con.commit()
if r:
8
Website: www.techtipnow.in
YouTube: www.youtube.com/c/techtipnow
#print("Exist")
d = input("Enter treatment")
qry = "update appoint set treatment = '{}' where dname = '{}';".format(d,x)
cursor.execute(qry)
con.commit()
print("Successfull updated")
else:
print("Wrong Doctor Name")
#cursor.close()
‘REPORT’ MODULE-
import pandas as pd
import mysql.connector as sqlt
import matplotlib.pyplot as plt
from tabulate import tabulate
con = sqlt.connect(host = "localhost", user = "root", passwd = "sanjay", database = "hospital")
cursor = con.cursor()
def doctor_list():
qry = "select * from doctor;"
df=pd.read_sql(qry,con)
#cursor.execute(qry)
#x=cursor.fetchall()
#print(x)
#print(df.to_string(index = False))
print(tabulate(df , headers = 'keys',tablefmt = 'psql', showindex = False))
print()
def patient_list():
qry = "select * from patient;"
df=pd.read_sql(qry,con)
#cursor.execute(qry)
#x=cursor.fetchall()
#print(x)
#df = df.to_string(index = False)
print(tabulate(df , headers = 'keys',tablefmt = 'psql', showindex = False))
print()
def doctor_treatment():
x=input("Enter Doctor Name")
qry="select * from appoint where dname = '{}';".format(x)
df=pd.read_sql(qry,con)
9
Website: www.techtipnow.in
YouTube: www.youtube.com/c/techtipnow
def opd_list():
bdate = input("Enter Beginning Date")
edate = input("Enter End Date")
qry = "select opd.opdno, doa, pname, dname, symptom, treatment, fee from opd where doa
between '{}' and '{}';".format(bdate, edate)
df=pd.read_sql(qry,con)
print(tabulate(df , headers = 'keys',tablefmt = 'psql', showindex = False))
print()
def patient_history():
df = pd.read_sql("select * from appoint, opd where opd.opdno = appoint.opdno;",con)
#print(df.to_string(index = False))
#df=pd.read_sql(qry,con)
print(tabulate(df , headers = 'keys',tablefmt = 'psql', showindex = False))
print()
def col_chart():
qry = "select symptom, count(symptom) as total_cases from appoint group by symptom;"
df = pd.read_sql(qry,con)
#print(df.to_string(index = False))
print(tabulate(df , headers = 'keys',tablefmt = 'psql', showindex = False))
plt.bar(df.symptom, df.total_cases)
plt.title("Bimaari")
plt.xlabel("Problem")
plt.ylabel("Total Cases")
plt.xticks(df.symptom)
plt.show()
10
Website: www.techtipnow.in
YouTube: www.youtube.com/c/techtipnow
MCQs
Class 12 Computer Science MCQs
https://techtipnow.in/class-12-computer-science-mcqs/
SQL MCQ
https://techtipnow.in/sql-mcq-class-12/
11
Website: www.techtipnow.in
YouTube: www.youtube.com/c/techtipnow
https://techtipnow.in/python-pandas-series-mcq/
https://techtipnow.in/cuet-mcq-computer-science-informatics-practices/
Comprehensive Notes
Informatics Practices Class 12
12
Website: www.techtipnow.in
YouTube: www.youtube.com/c/techtipnow
13
Website: www.techtipnow.in
YouTube: www.youtube.com/c/techtipnow
IT-802 Class 11
RDBMS Notes
https://techtipnow.in/rdbms-class-11-notes/
Fundamentals of Java
https://techtipnow.in/fundamentals-of-java-class-11/
14
Website: www.techtipnow.in
YouTube: www.youtube.com/c/techtipnow
IT-802 Class 12
15
Website: www.techtipnow.in
YouTube: www.youtube.com/c/techtipnow
Class 12 IP Practical VIVA Question | Python Viva Questions | SQL Viva Questions
https://techtipnow.in/class-12-ip-viva-questions/
Textbook Solutions
NCERT Text Book Solution IP Class 12:
https://techtipnow.in/ncert-solution-ip-class-12/
17