SGM International School
Hospital Management System
Project File
Session: 2024-25
Computer Science
Submitted by Under
Guidance of
Name: Shaurya Gupta Mr.
Brijendra Sir
Class :12 Sec :B PGT
Computer Science
Roll no:
CERTIFICATE
This is to certify that Shaurya Gupta class XII B of SGM International
school has done his project on Hospital Management System under my
supervision. He/She has taken interest and has shown at most sincerity in
completion of this project.
I certify this Project up to my expectation & as per guidelines issued by
CBSE, NEW DELHI.
TEACHER INCHARGE
EXAMINER SIGNATURE PRINCIPAL
DATE:
ACKNOWLEDGEMENT
It is with pleasure that I acknowledge my sincere gratitude to our teacher,
Mr. Brijendra Singh who taught and undertook the responsibility of
teaching the subject computer science. I have been greatly benefited from
his classes.
I am especially indebted to our Principal Mr. Sandeep Pathak who has
always been a source of encouragement and support and without whose
inspiration this project would not have been a successful I would like to
place on record heartfelt thanks to him.
Finally, I would like to express my sincere appreciation for all the other
students for my batch their friendship & the fine times that we all shared
together.
THANK YOU…
CONTENTS
About Python
About MYSQL
Hardware & Software Requirements
Introduction
Python Source Code
Output
Bibliography
About Python
Introduction:- It is widely used general purpose, high level
programming language, developed by Guido Van Rossum in 1991.
It is Used for:- Software development, Web Development (Server-
Side), System Scipting.
Features of Python:-
1- Easy to use:- Due to simple syntax rules.
2- Interpreted Language:- Code execution & interpretation line by
line.
3- Cross-Platform Language:- It can run on Windows, Linux,
Macintosh etc equally.
4- Expressive Language:- Less code to be written as it itself express
the purpose of the code.
5- Completeness:- Support wide range of library.
6- Free & Open Source:- Can be download freely and source code
can be modify for improvement.
About MYSQL
Introduction:- MySQL is currently the most popular open
source database software. It is a multiuser, multithreaded database
management system. MySQL is especially popular on the web. It is
one of the parts of the very popular lamp platform. Linux, Windows,
Apache MySQl and PHP or WMIP platform. MySQL was founded
by Michael Widenius(Monty), David Axmark and Allan Larsson in
Sweden in year 1995.
Features of MySQl:-
1- Open Source & Free of Cost:- It is open source and available at
free of cost.
2- Portability:- Small enough in size to install and run it on any types
of hardware and OS like Linux, Windows, MAC etc.
3- Security:- Its databases are secured & protected with password.
4- Connectivity:- Various apps are developed to connect it with
many programming languages.
5- Query Language:- It supports SQL (Structure Query Language)
for handling database.
Hardware & Software Requirements
Here is the details of hardware and software I used to implement
while creating this project.
Operation System – Windows 10
Python 3.8.1 (64-bit) version for programming
MySQL community server- 8.0.18
Mysql-Connector-Python-8.0.18
MS Word 2010 for documentation
Ram – 8 GB
Hard Disk - 1 TB
Processor – Intel Core i3
Hospital Management System
Hospital Management system is computer system that help manage
the information related to health care (Doctors, Patient etc).
SOURCE CODE
while(True):
print("""
=================================================================================
WELCOME TO PRATAP HOSPITALS PVT. LTD.
=================================================================================
""")
##creating database connectivity
import mysql.connector
passwd=str(input("ENTER THE DATABASE PASSWORD:"))
mysql=mysql.connector.connect(host="localhost",user="root",passwd="1234")
mycursor=mysql.cursor()
#creating database
mycursor.execute("create database if not exists pis_hospitals")
mycursor.execute("use pis_hospitals")
#creating the tables we need
mycursor.execute("create table if not exists patient_details(puid int(10) primary key,name varchar(30) not
null,age int(3),address varchar(50),doctor_recommended varchar(30))")
mycursor.execute("create table if not exists doctor_details(name varchar(30) primary key,specialisation
varchar(40),age int(2),address varchar(30),contact varchar(15),fees int(10),monthly_salary int(10))")
mycursor.execute("create table if not exists nurse_details(name varchar(30) primary key,age int(2),address
varchar(30),contact varchar(15),monthly_salary int(10))")
mycursor.execute("create table if not exists other_workers_details(name varchar(30) primary key,age
int(2),address varchar(30),contact varchar(15),monthly_salary int(10))")
#login or signup option
#creating table for storing the username and password of the user
mycursor.execute("create table if not exists user_data(username varchar(30) primary key,password
varchar(30) default'000')")
#printing option
while(True):
print("""
1. SIGN IN (LOGIN)
2. SIGN UP (REGISTER)
""")
r=int(input("enter your choice:"))
#IF USER WANTS TO REGISTER
if r==2:
print("""
=================================================================================
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!PLEASE REGISTER YOURSELF!!!!!!!!!!!!!!!!!!!!!!!!!!!
=================================================================================
""")
u=input("ENTER YOUR PREFERRED USERNAME!!:")
p=input("ENTER YOUR PREFERRED PASSWORD (PASSWORD SHOULD BE STRONG!!!:")
#ENTERING THE ENTERED VALUE TO THE USER_DATA TABLE
mycursor.execute("insert into user_data values('"+u+"','"+p+"')")
mysql.commit()
print("""
=================================================================================
!!!!!!!!!!!!!!!!!!!!!!!!!!!REGISTERED SUCCESSFULLY!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=================================================================================
""")
x=input("enter any key to continue:")
#IF USER WANTS TO LOGIN
elif r==1:
#PRINTING THE SINGIN OPTION AGAIN TO THE USER AFTER REGISTRATION
print("""
=================================================================================
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! {{SIGN IN }} !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=================================================================================
""")
un=input("ENTER THE USERNAME!!:")
ps=input("ENTER THE PASSWORD!!:")
mycursor.execute("select password from user_data where username='"+un+"'")
row=mycursor.fetchall()
for i in row:
a=list(i)
if a[0]==str(ps):
while(True):
##displaying the task you can perform
print("""
1.ADMINISTRATION
2.PATIENT (ADMISSION NAD DISCHARGE PROCESS)
3.SIGN OUT
""")
##asking for the task from user
a=int(input("ENTER YOUR CHOICE:"))
#if user wants to enter administration option
if a==1:
print("""
1. SHOW DETAILS
2. ADD NEW MEMBER
3. DELETE EXISTING ONE
4. EXIT
""")
b=int(input("ENTER YOUR CHOICE:"))
#showing the existing details
if b==1:
print("""
1. DOCTOR DETAILS
2. NURSE DETAILS
3. OTHER WORKERS
""")
#ASKING USER'S CHOICE
c=int(input("ENTER YOUR CHOICE:"))
#if user wants to see the details of doctors
if c==1:
mycursor.execute("select * from doctor_details")
row=mycursor.fetchall()
for i in row:
b=0
v=list(i)
k=["NAME","SPECIALISATION","AGE","ADDRESS","CONTACT","FEES","MONTHLY_SALARY"]
d=dict(zip(k,v))
print(d)
#if user wants to see the details of nurses
elif c==2:
mycursor.execute("select * from nurse_details")
row=mycursor.fetchall()
for i in row:
v=list(i)
k=["NAME","SPECIALISATION","AGE","ADDRESS","CONTACT","MONTHLY_SALARY"]
d=dict(zip(k,v))
print(d)
#if user wants to see the details of other_workers
elif c==3:
mycursor.execute("select * from other_workers_details")
row=mycursor.fetchall()
for i in row:
v=list(i)
k=["NAME","SPECIALISATION","AGE","ADDRESS","CONTACT","MONTHLY_SALARY"]
d=dict(zip(k,v))
print(d)
#IF USER WANTS TO ENTER DETAILS
elif b==2:
print("""
1. DOCTOR DETAILS
2. NURSE DETAILS
3. OTHER WORKERS
""")
c=int(input("ENTER YOUR CHOICE:"))
#FOR ENTERING DETAILS OF DOCTORS
if c==1:
#ASKING THE DETAILS
name=input("ENTER DR. NAME:")
spe=input("ENTER SPECIALISATION:")
age=input("ENTER AGE:")
add=input("ENTER ADDRESS:")
cont=input("ENTER CONTACT NO.:")
fees=input("ENTER FEES:")
ms=input("ENTER MONTHLY_SALARY:")
#INSERTING VALUES ENTERED INTO THE DOCTORS_TABLE
mycursor.execute("insert into doctor_details
values('"+name+"','"+spe+"','"+age+"','"+add+"','"+cont+"','"+fees+"','"+ms+"')")
mysql.commit()
print("SUCCESSFULLY ADDED")
#for entering nurse details
elif c==2:
#ASKING THE DETAILS
name=input("ENTER NURSE NAME:")
age=input("ENTER AGE:")
add=input("ENTER ADDRESS:")
cont=input("ENTER CONTACT NO.:")
ms=int(input("ENTER MONTHLY_SALARY:"))
#INSERTING VALUES ENTERED TO THE TABLE
mycursor.execute("insert into nurse_details
values('"+name+"','"+age+"','"+add+"','"+cont+"','"+str(ms)+"')")
mysql.commit()
print("SUCCESSFULLY ADDED")
#for entering workers details
elif c==3:
#ASKING THE DETAILS
name=input("ENTER WORKER NAME:")
age=input("ENTER AGE:")
add=input("ENTER ADDRESS:")
cont=input("ENTER CONTACT NO.:")
ms=input("ENTER MONTHLY_SALARY:")
#INSERTING VALUES ENTERED TO THE TABLE
mycursor.execute("insert into other_workers_details
values('"+name+"','"+age+"','"+add+"','"+cont+"','"+ms+"')")
mysql.commit()
print("SUCCESSFULLY ADDED")
#if unser wants to delete data
elif b==3:
print("""
1. DOCTOR DETAILS
2. NURSE DETAILS
3. OTHER WORKERS
""")
c=int(input("ENTER YOUR CHOICE:"))
#deleting doctor's details
if c==1:
name=input("ENTER DOCTOR'S NAME:")
mycursor.execute("select * from doctor_details where name=='"+name+"'")
row=mycursor.fetchall()
print(row)
p=input("you really wanna delete this data? (y/n):")
if p=="y":
mycursor.execute("delete from doctor_details where name='"+name+"'")
mysql.commit()
print("SUCCESSFULLY DELETED!!")
else:
print("NOT DELETED")
#deleting nurse details
elif c==2:
name=input("ENTER NURSE NAME:")
mycursor.execute("select * nurse_details where name=='"+name+"'")
row=mycursor.fetchall()
print(row)
p=input("you really wanna delete this data? (y/n):")
if p=="y":
mycursor.execute("delete from nurse_details where name='"+name+"'")
mysql.commit()
print("SUCCESSFULLY DELETED!!")
else:
print("NOT DELETED")
#deleting other_workers details
elif c==3:
name=input("ENTER THE WORKER NAME:")
mycursor.execute("select * from workers_details where name=='"+name+"'")
row=mycursor.fetchall()
print(row)
p=input("you really wanna delete this data? (y/n):")
if p=="y":
mycursor.execute("delete from other_workers_details where name='"+name+"'")
mysql.commit()
print("SUCCESSFULLY DELETED!!")
else:
print("NOT DELETED")
elif b==4:
break
#entering the patient details table
elif a==2:
print("""
1. SHOW PATIENT DETAILS
2. ADD NEW PATIENT
3. DISCHARGE PATIENT
4. EXIT
""")
b=int(input("ENTER YOUR CHOICE:"))
#showing the existing details
#if user wants to see the details of PATIENT
if b==1:
mycursor.execute("select * from patient_details")
row=mycursor.fetchall()
for i in row:
b=0
v=list(i)
k=['PID','NAME','AGE','ADDRESS','DOCTOR RECOMMENDED']
d=dict(zip(k,v))
print(d)
#adding new patient
elif b==2:
puid=int(input("ENTER PATIENT ID:"))
name=str(input("ENTER NAME: "))
age=str(input("ENTER AGE: "))
address=str(input("ADDRESS: "))
doctor_recommended=str(input("DOCTOR NAME: "))
mycursor.execute ("insert into patient_details values('"+str(puid)+"','"+str(name)
+"','"+str(age)+"','"+str(address)+"','"+str(doctor_recommended)+"')")
mysql.commit()
mycursor.execute("select * from patient_details")
for i in mycursor:
v=list(i)
k=['PID','NAME','AGE','ADDRESS','DOCTOR RECOMMENDED']
print(dict(zip(k,v)))
print("""
=================================================================================
!!!!!!!!!!!!!!!!!!!!!!!!!!!REGISTERED SUCCESSFULLY!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=================================================================================
""")
#dischare process
elif b==3:
name=input("ENTER THE PATIENT NAME:")
mycursor.execute("select * from patient_details where name='"+name+"'")
row=mycursor.fetchall()
print(row)
bill=input("HAS HE PAID ALL THE BILLS ? (y/n):")
if bill=="y":
mycursor.execute("delete from patient_details where name='"+name+"'")
mysql.commit()
#if user wants to exit
elif b==4:
break
###SIGN OUT
elif a==3:
break
#IF THE USERNAME AND PASSWORD IS NOT IN THE DATABASE
else:
break
OUTPUT
Login
ENTER DOCTOR DETAILS
ADD PATIENT RECORD
SHOW PATIENT DETAILS
DISCHARGE PATIENT
BIBLIOGRAPHY
Computer Science with Python Book By-Sumita Arora
Computer Science with Python Book By-Preeti Arora
www.pyhton/help.org