0% found this document useful (0 votes)
9 views

CSC Project Hospital Management System (2)

Uploaded by

Kaushik Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

CSC Project Hospital Management System (2)

Uploaded by

Kaushik Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

ADVERTISEMENT

TABLE OF CONTENTS

SL.NO TITLE

1. ABSTRACT

2. REQUIREMENT ANALYSIS

3. APPLICATION

4. DESIGN

5. FLOWCHART

6. ALGORITHM

7. SOURCE CODE

8. EXECUTION SCREENSHOTS/OUTPUTS

9. FUTURE ENHANCEMENTS

10. BIBLIOGRAPHY/REFERENCES
ABSTRACT

The "Hospital Management System" is a streamlined Python-based application


designed to simplify administrative tasks within a hospital environment, managing
both staff and patient records effectively. Developed using MySQL for backend
data storage, the program establishes a secure connection with a database and
dynamically creates necessary tables for "patients," "doctors," "nurses," "workers,"
and "users." The system introduces a user-friendly interface for new user sign-up,
login, and password management, ensuring secure access and smooth operation.

This application provides a structured approach to hospital management by


enabling administrators to view, add, and delete records for various hospital
personnel, such as doctors, nurses, and other workers. In addition to managing
staff, the system also offers options for patient admissions, record viewing, and
discharge. A randomly generated patient ID ensures uniqueness for each admitted
patient, while the discharge process incorporates a billing check for efficient
handling of patient payments.

The system is built with robust input handling and provides role-specific
functionalities that streamline hospital operations. Staff records include essential
details such as name, age, department, salary, and contact information. Patient
records capture admission details, along with doctor recommendations, age, and
contact information. This Python and MySQL-based solution optimizes hospital
management by providing a scalable and adaptable tool that enhances operational
efficiency and data organization in a medical environment.
REQUIREMENT ANALYSIS

1. Hardware Requirement

Computer/Laptop

4 GB RAM Minimum

free disk space of 5GB

2. Software Requirement

Python

MySQL

Windows 7 or above
APPLICATION

The Hospital Management System (HMS) is a powerful tool that enhances patient
management by streamlining the entire process, from admission to discharge. It
allows hospitals to store and manage patient details securely, including personal
information, medical history, and recommended doctors. This enables seamless
patient care and supports continuity during follow-ups, ensuring that all patient
data is easily accessible to authorized staff.

In addition to patient care, the HMS simplifies staff management by maintaining


detailed records for doctors, nurses, and other hospital personnel. Administrators
can use the system to add new staff members, update records, view details, and
handle payroll. With this centralized access to staff information, hospitals can
make better decisions regarding staffing, shifts, and resource allocation.

A dedicated billing and financial module within the HMS improves accuracy in
billing by calculating fees based on services rendered. This reduces billing errors
and enhances patient satisfaction by ensuring that payments and billing statuses are
managed efficiently. Furthermore, the streamlined discharge process incorporates
payment verification, making the entire patient journey smoother.

Data security is a priority in healthcare, and the HMS addresses this by restricting
access to authorized users only. With a secure login and password functionality,
patient and staff information is protected from unauthorized access, thus preserving
privacy and maintaining data integrity. This ensures compliance with healthcare
regulations and boosts trust among patients and staff.
Operational efficiency is a major advantage of the HMS. By centralizing data
storage, the system minimizes paperwork, reducing the administrative burden and
allowing staff to focus on critical tasks. This not only speeds up hospital operations
but also improves the utilization of resources, ultimately enhancing the quality of
care.

Quick retrieval of information is another key feature of the HMS. With organized
data storage, it becomes easy to access records related to patients, staff, or
operational aspects of the hospital. This facilitates informed decision-making,
improves patient follow-up processes, and aids in maintaining compliance with
regulatory standards.

Finally, the system aids in resource planning and management by providing


insights into patient intake, staff workload, and financial transactions. With this
data, administrators can ensure that staff, equipment, and other resources are
allocated efficiently to meet the hospital's needs. This optimizes hospital
functionality and enhances the overall experience for both patients and staff.
DESIGN

1) BLOCK DIAGRAM

2) EXPLANATION
User runs the program, sign in or sign up according to requirement. in the
case of sign in- fill in username and password and proceed to fill up the asked
fields. The changes will be reflected in the database(MySQL).
FLOW CHART
ALGORITHM

(1)Importing mysql.connector module


(2)Connect into MySQl and create cursor object
(3)Sign up or log in
● Admin task
1. Show Details
2. Add new member
3. Delete existing member
4. Exit
● Patient
1. Show patient
2. Admit new
3. Discharge Patient
4. Exit
● Change password
(4) Reflect the change in database (MySQL)
SOURCE CODE

import mysql.connector as ms
import random

##PRINTING WELCOME MESSAGE

print("""
================================
Welcome to City Hospital
================================
""")
##Establishing connection and creating database along with required tables

pd=str(input("Enter Database Password:"))

cn=ms.connect(host="localhost",user="root",passwd=pd)
cur=cn.cursor()
#creating database for hospital
cur.execute("create database if not exists city_hospital")
cur.execute("use city_hospital")
cur.execute("create table if not exists patients\
(pid int(10) primary key,\
name varchar(30) not null,\
mobile varchar(10),\
age int(3),\
city varchar(50),\
doc_rec varchar(30))")
cur.execute("create table if not exists doctors\
(name varchar(30) primary key,\
department varchar(40),\
age int(2),\
city varchar(30),\
mobile varchar(15),\
fees int(10),\
salary int(10))")
cur.execute("create table if not exists nurses\
(name varchar(30) primary key,\
age int(2),\
city varchar(30),\
mobile varchar(15),\
salary int(10))")
cur.execute("create table if not exists workers\
(name varchar(30) primary key,\
age int(2),\
city varchar(30),\
mobile varchar(15),\
salary int(10))")
#login or signup option for users
#creating table for storing the username and password of the new user
cur.execute("create table if not exists users\
(username varchar(30) primary key,\
password varchar(30) default'000')")
def sign_up():
print("""

============================================
!!!!!!!Please enter new user details!!!!!!!!
============================================
""")
u=input("Enter New User Name!!:")
p=input("Enter password (Combination of Letters, Digits etc.):")
#ENTERING THE ENTERED VALUE TO THE USER_DATA TABLE
cur.execute("insert into users values('"+u+"','"+p+"')")
cn.commit()
print("""

========================================================
!!!!!!!!Congratulations!!!, New User Created...!!!!!!!!

========================================================
""")

def login():

#Login with username and password


print("""

==========================================================
!!!!!!!! {{Loginwith username and password }} !!!!!!!!!!

===========================================================
""")
un=input("Username!!:")
ps=input("Password!!:")
pid=0
cur.execute("select password from users where username='"+un+"'")
rec=cur.fetchall()
for i in rec:
a=list(i)
if a[0]==str(ps):
while(True):
#Menu for Administrative Tasks
print("""
1.Admin Tasks
2.Patient (Admit and Discharge)
3.Sign Out

""")
#prompt message for the task from user
a=int(input("Enter your choice:"))
#Admin tasks
if a==1:
print("""
1. Show Details
2. Add new member
3. Delete existing member
4. Exit
""")
b=int(input("Eter your choice:"))
#Showing details of doctors, nurses and workers
if b==1:
print("""
1. Doctors
2. Nurses
3. Workers
""")

#Prompt Message for users to show details


c=int(input("ENTER YOUR CHOICE:"))
#See the details of doctors
if c==1:
cur.execute("select * from doctors")
rec=cur.fetchall()
for i in rec:
b=0
v=list(i)

k=["NAME","DEPARTEMNT","AGE","CITY","MOBILE","FEES","SALARY"]
d=dict(zip(k,v))
for i in d:
print(i,":",d[i])
print()
#See the details of nurses
elif c==2:
cur.execute("select * from nurses")
rec=cur.fetchall()
for i in rec:
v=list(i)
k=["NAME","AGE","CITY","MOBILE","SALARY"]
d=dict(zip(k,v))
for i in d:
print(i,":",d[i])
print()
#See the details of workers
elif c==3:
cur.execute("select * from workers")
rec=cur.fetchall()
for i in rec:
v=list(i)
k=["NAME","AGE","CITY","MOBILE","SALARY"]
d=dict(zip(k,v))
for i in d:
print(i,":",d[i])
print()
#Add new member into hosptial team
elif b==2:
print("""

1. Doctor
2. Nurse
3. Worker
""")
c=int(input("Enter your choice:"))
#New doctor details
if c==1:
#Prompt messages for doctor details
name=input("Enter name of doctor:")
dep=input("Enter department:")
age=input("Enter age:")
city=input("Enter city doctor belongs to:")
mno=input("Enter 10 digit mobile no.:")
fees=input("Enter fees:")
sal=input("Enter Salary of doctor:")
#Insert values into doctors table
cur.execute("insert into doctors
values('"+name+"','"+dep+"','"+age+"','"+city+"','"+mno+"','"+fees+"','"+sal+"')")
cn.commit()
print("New doctor details has been added successfully. ")
#New nurse details
elif c==2:
#Prompt message for nurse details
name=input("Enter name of nurse:")
age=input("Enter age:")
city=input("Enter city nurse belongs to:")
mno=input("Enter mobile no.:")
sal=int(input("Enter salary:"))
#Insert value into nurses table
cur.execute("insert into nurses
values('"+name+"','"+age+"','"+city+"','"+mno+"','"+str(sal)+"')")
cn.commit()
print("New nurse details has been added successfully.")
#New worker details
elif c==3:
#Prompt message for worker details
name=input("Enter name of worker:")
age=input("Enter Age:")
city=input("Enter city:")
mno=input("Enter mobile no:")
ms=input("Enter Salary:")
#Insert worker details into doctors table
cur.execute("insert into workers
values('"+name+"','"+age+"','"+city+"','"+mno+"','"+ms+"')")
cn.commit()
print("SUCCESSFULLY ADDED")
#Menu for delete data
elif b==3:
print("""
1. Doctors
2. Nurses
3. Workers
""")
c=int(input("Enter your choice:"))
#deleting doctor's details
if c==1:
name=input("Enter doctor name to delete:")
cur.execute("select * from doctors where name='"+name+"'")
rec=cur.fetchall()
print(rec)
p=input("you really wanna delete this data? (y/n):")
if p=="y":
cur.execute("delete from doctors where
name='"+name+"'")
cn.commit()
print("Doctor has been deleted successfully")
else:
print("Error in deletion....")

#deleting nurse details


elif c==2:
name=input("Enter name of nurse:")
cur.execute("select * nurses where name='"+name+"'")
rec=cur.fetchall()
print(rec)
p=input("Are you really wanna delete this data? (y/n):")
if p=="y":
cur.execute("delete from nurses where name='"+name+"'")
cn.commit()
print("Nurse has been deleted successfully.")
else:
print("Error in deletion")
#deleting worker details
elif c==3:
name=input("Enter name of worker:")
cur.execute("select * from workers where
name='"+name+"'")
rec=cur.fetchall()
print(rec)
p=input("Are you really wanna delete this data? (y/n):")
if p=="y":
cur.execute("delete from workers where
name='"+name+"'")
cn.commit()
print("Worker has been deleted.")
else:
print("Error in deletion.")
elif b==4:
print("Thank you! See you again! Have nice Day!")
break

#entering the patient details table


elif a==2:

print("""
1. Show patient record
2. Admit new patient
3. Discharge Patient
4. Exit
""")
b=int(input("ENTER YOUR CHOICE:"))
#showing the existing details of patients
#See the details of patient
if b==1:
cur.execute("select * from patients")
rec=cur.fetchall()
for i in rec:
b=0
v=list(i)
k=["NAME","GENDER","AGE","CITY","MOBILE NO"]
d=dict(zip(k,v))
for i in d:
print(i,":",d[i])
#Admit a new patient
elif b==2:
pid=random.randint(1000,99999)
name=str(input("Enter name of patient: "))
age=str(input("Enter age: "))
city=str(input("Enter City: "))
mn=str(input("Enter Mobile no.: "))
cur.execute("select name from doctors")
rec=cur.fetchall()
print(rec)
dr=str(input("Enter doctorname to be recommended:"))
cur.execute ("insert into patients
values('"+str(pid)+"','"+str(name)+"','"+str(mn)+"','"+str(age)+"','"+str(city)+"','"+st
r(dr)+"')")
cn.commit()

print("""
====================================
!!!!!!!New patient admitted!!!!!!
====================================
""")
#dischare a patient
elif b==3:
name=input("Enter the name of patient to discharge:")
cur.execute("select * from patients where name='"+name+"'")
rec=cur.fetchall()
print(rec)
bill=input("Bill payemt (y/n):")
if bill=="y":
cur.execute("delete from patients where name
like'%"+name+"%'")
cn.commit()
elif bill=="n":
print("Please pay your pending bill amount to discahrge
patient.")
else:
print("Bill payment status is unknown....")
#if user wants to exit
elif b==4:
break
###SIGN OUT
elif a==3:
break
def change_pass():
cur.execute("select username from users")
rec=cur.fetchall()
for i in rec:
v=list(i)
k=["USERNAME"]
d=dict(zip(k,v))
print(d)
u=input("Enter username to change password from above:")
if u in d.values():
pd=input("Enter New Password:")
pd1=input("Renter New Password again:")
if pd==pd1:
cur.execute("update users set password='"+pd+"'where username='"+u+"'")
cn.commit()
print("Password Changed Successfully.")
else:
print("Password did not match...")
else:
print("Username not found")

#Main Menu
r=0
while r!=4:
print("""
1. Sign Up (New User)
2. Log In
3. Change Password
4. Exit
""")

r=int(input("Enter your choice:"))


#New User Registration
if r==1:
sign_up()
elif r==2:
login()
elif r==3:
change_pass()
elif r==4:
print("Thank you for using City Hospital App, Have a nice day!")
break
EXECUTION SCREENSHOTS / OUTPUTS
FUTURE ENHANCEMENTS

Enhanced User Roles and Permissions: Introduce role-based access


control, allowing for varied permissions among administrators, doctors,
nurses, and other staff. This would enhance security and ensure data privacy
by restricting data access based on roles.

Automated Billing and Payments Module: Integrate a billing system that


automatically calculates fees based on the patient's treatment and doctor
consultations. Add support for digital payments, enabling patients to pay
online for a streamlined discharge process.

Appointment Scheduling System: Add a feature for patients to schedule


appointments with doctors, integrating doctor availability and patient
preferences to manage time slots effectively. This system can send reminders
to both doctors and patients.

Medical Record Management: Implement a comprehensive medical records


system that maintains patient history, treatment records, medications
prescribed, and test results. This would allow for continuity of care and easy
access to patient information during follow-up visits.

Reporting and Analytics: Incorporate data analysis tools to generate reports


on hospital performance metrics such as patient intake, staff efficiency, and
financial summaries. This data could assist hospital administrators in making
data-driven decisions.
Inventory and Pharmacy Management: Add a module to track the
hospital’s inventory of medicines, medical equipment, and supplies. This
could prevent stockouts and streamline pharmacy services within the
hospital.

Telemedicine and Virtual Consultations: Develop a telemedicine module


that allows for remote consultations, enabling patients to connect with
doctors online. This is especially valuable for routine check-ups and
follow-up appointments.

BIBLIOGRAPHY/REFERENCES
1. Sumita Arora

2. Class 12 NCERT (CS)

3. https://www.geeksforgeeks.org/connect-mysql-database-usin
g-mysql-connector-python/

4. https://www.youtube.com/watch?v=_uQrJ0TkZlc

5. https://www.instagram.com/python.learning/

You might also like