0% found this document useful (0 votes)
23 views32 pages

Hospital Management System Project

The document outlines a project titled 'Hospital Management System' developed by Jay Biru Dutta as part of his academic requirements. It details the project's objectives, software requirements, and the implementation using Python and MySQL, including source code for various functionalities such as patient registration and doctor management. The system aims to automate hospital operations, improve data accuracy, and enhance patient care through a user-friendly interface.

Uploaded by

sanjay1909dutta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views32 pages

Hospital Management System Project

The document outlines a project titled 'Hospital Management System' developed by Jay Biru Dutta as part of his academic requirements. It details the project's objectives, software requirements, and the implementation using Python and MySQL, including source code for various functionalities such as patient registration and doctor management. The system aims to automate hospital operations, improve data accuracy, and enhance patient care through a user-friendly interface.

Uploaded by

sanjay1909dutta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

COMPUTER

PROJECT

Project Titled: Hospital Management


System
Submitted by: Jay Biru Dutta
Class: XII D
School: St. Karen’s Secondary School
Roll:
Session: 2025–2026
INDEX
SERIAL CONTENT PAGE
NO. NO.
01 CERTIFICATE 1
02 2
ACKNOWLEDGMENT
03 INTRODUCTION 3
04 OBJECTIVE 4
05 ALL ABOUT PYTHON 5
06 SOFTWARE 6
REQUIREMENT
07 FUNCTION 7
CREATED
08 MY SQL SOURCE 8-9
CODE
09 PYTHON SOURCE 10-21
CODE
10 OUTPUT 22-24
11 FUTURE 25
APPLICATION
12 BIBLIOGRAPHY 26

CERTIFICATE
This is to certify that Jai Biru Dutta, a
student of XII D of St. Karen’s
Secondary School has successfully
completed the project titled “Hospital
Management System” under the
supervision of Mr. Pankaj Kumar
during the academic year 2025–2026

Signature of External
Signature of Subject
Examiner
Teacher
Signature of
Principal

Acknowledgment
I express my heartfelt gratitude to my
Computer Science teacher, Pankaj Kumar
Sir, for his invaluable guidance and
support throughout this project. I would
also like to sincerely thank our respected
Principal Ma’am for giving this project
that helped me to understand the
practical applications of programming and
database management in this project.
INTRODUCTION
The Hospital Management System project
focuses on computerizing hospital front-
office operations such as patient
registration, record maintenance, and
staff management. Each patient is
assigned a unique ID, and their personal
and medical details are securely stored in
the database. The system provides search
options to check room availability, doctor
schedules, and patient information using
the ID. Access is restricted to
administrators and receptionists, who can
add or update records through a
username and password login. The
interface is user-friendly, making data
entry and retrieval simple and efficient.
By automating these processes, the
system ensures faster data processing,
improved accuracy, and enhanced
information security. Overall, it helps
hospitals manage patient details,
diagnosis records, and administrative
tasks effectively while reducing manual
effort and cost.

OBJECTIVE
The main objectives of developing this
project are:
 To design a robust system for
managing hospital records digitally.
 To enhance patient care through
accurate data handling.
 To simplify the doctor–patient
relationship by maintaining accessible
patient histories.
 To monitor room allocation,
occupancy, and availability efficiently.
 To generate reports on admissions,
discharges, and treatments.
 To replace manual systems with a
reliable, computerized framework that
reduces workload and errors.

ALL ABOUT PYTHON


Python is a high-level, interpreted
programming language known for its
simplicity, readability, and versatility. It is
widely used in application development,
data handling, and database
management.
Key features include:
Easy syntax and readability, making code
simple to understand and maintain.
Extensive standard libraries that support
tasks like file handling, error
management, and database interaction.
Strong MySQL connectivity using the
[Link] module, allowing smooth
data exchange between Python and
MySQL.
Cross-platform compatibility, ensuring the
program runs on different operating
systems without modification.
Object-oriented structure, making the
system modular, scalable, and easier to
manage.
In this project, Python manages user input
and database interaction, serving as the
core control unit to ensure hospital
records are handled efficiently and
securely.
SOFT WARE
REQUIREMENT
Frontend: Python 3.10+
Backend: MySQL Server
Libraries: [Link], csv,
datetime
IDE: VS Code / PyCharm
OS: Windows 10 or higher
FUNCTION
CREATED
FUNCTION NAME DESCRIPTION

connect_ db() Establishes


connection to MySQL
add_doctor() Adds doctor details
list_doctors() Lists all doctors
register_patient() Registers a new
patient
view_patients() Displays all patient
records
search_by_doctor() Filters patients by
doctor
Updates medication
update_medication() for a patient
delete_patient() Deletes a patient
record
doctor_summary() Shows doctor-wise
patient count
export_to_csv() Exports patient data
to CSV

MYSQL SOURCE CODE


CREATE DATABASE IF NOT EXISTS
HospitalDB;
USE HospitalDB;
CREATE TABLE Doctors (
doctor_id INT AUTO_INCREMENT
PRIMARY KEY,
name VARCHAR(100),
specialization VARCHAR(100),
contact VARCHAR(20)
);
CREATE TABLE Patients (
patient_id INT AUTO_INCREMENT
PRIMARY KEY,
name VARCHAR(100),
age INT,
gender ENUM('Male', 'Female', 'Other'),
room_number VARCHAR(10),
doctor_id INT,
blood_group VARCHAR(5),
incubation_period INT,
medication_prescribed TEXT,
diagnosis TEXT,
treatment TEXT,
surgery_required BOOLEAN,
date_of_admit DATE,
date_of_discharge DATE,
previous_diagnostics TEXT,
recheckup_date DATE,
FOREIGN KEY (doctor_id) REFERENCES
Doctors(doctor_id)
);

PYTHON SOUCE CODE


import [Link]
import csv
from datetime import datetime
# ---------------------- Database Connection
----------------------
def connect_db():
return [Link](
host="localhost",
user="root",
password="jai1234omega12341",
database="HospitalDB"
)
# ---------------------- Doctor Operations
----------------------
def add_doctor():
name = input("Doctor Name: ")
specialization = input("Specialization:
")
contact = input("Contact Number: ")
conn = connect_db()
cursor = [Link]()
[Link](
"INSERT INTO Doctors (name,
specialization, contact) VALUES (%s, %s,
%s)",
(name, specialization, contact)
)
[Link]()
[Link]()
print("Doctor added successfully.")
def list_doctors():
conn = connect_db()
cursor = [Link]()
[Link]("SELECT * FROM
Doctors")
doctors = [Link]()
[Link]()
print("\n--- Doctor List ---")
for doc in doctors:
print(f"ID: {doc[0]}, Name: Dr.
{doc[1]}, Specialization: {doc[2]},
Contact: {doc[3]}")
return doctors
# ---------------------- Patient Operations
----------------------
def register_patient():
print("\n--- Register New Patient ---")
name = input("Name: ")
age = int(input("Age: "))
gender = input("Gender
(Male/Female/Other): ")
room = input("Room Number: ")
list_doctors()
doctor_id = int(input("Doctor ID: "))

blood = input("Blood Group: ")


incubation = int(input("Incubation
Period (days): "))
medication = input("Medication
Prescribed: ")
diagnosis = input("Diagnosis: ")
treatment = input("Treatment: ")
surgery = input("Surgery Required
(yes/no): ").lower() == 'yes'
admit = input("Date of Admit (YYYY-
MM-DD): ")
discharge = input("Date of Discharge
(YYYY-MM-DD): ")
history = input("History of Previous
Diagnostics: ")
recheck = input("Date for Recheck-up
(YYYY-MM-DD): ")
conn = connect_db()
cursor = [Link]()
query = """
INSERT INTO Patients (
name, age, gender, room_number,
doctor_id, blood_group,
incubation_period,
medication_prescribed, diagnosis,
treatment, surgery_required,
date_of_admit,
date_of_discharge,
previous_diagnostics, recheckup_date
) VALUES (%s, %s, %s, %s, %s, %s,
%s, %s, %s, %s, %s, %s, %s, %s, %s)
"""
values = (
name, age, gender, room, doctor_id,
blood, incubation,
medication, diagnosis, treatment,
surgery, admit,
discharge, history, recheck
)
[Link](query, values)
[Link]()
[Link]()
print("Patient registered successfully.")
def view_patients():
conn = connect_db()
cursor = [Link]()

[Link]("""
SELECT p.patient_id, [Link], [Link],
[Link], p.room_number, [Link],
p.blood_group,
p.incubation_period,
p.medication_prescribed,
[Link], [Link],
p.surgery_required, p.date_of_admit,
p.date_of_discharge,
p.previous_diagnostics, p.recheckup_date
FROM Patients p
JOIN Doctors d ON p.doctor_id =
d.doctor_id
""")
rows = [Link]()
[Link]()
print("\n--- Patient Records ---")
for row in rows:
print(row)
def search_by_doctor():
doc_name = input("Enter Doctor Name:
")
conn = connect_db()
cursor = [Link]()
[Link]("""
SELECT [Link], [Link], [Link],
p.room_number, [Link]
FROM Patients p
JOIN Doctors d ON p.doctor_id =
d.doctor_id
WHERE [Link] = %s
""", (doc_name,))
rows = [Link]()
[Link]()
print(f"\n--- Patients under Dr.
{doc_name} ---")
for row in rows:
print(row)
def update_medication():
pid = int(input("Enter Patient ID: "))
new_med = input("Enter new
medication: ")
conn = connect_db()
cursor = [Link]()
[Link](
"UPDATE Patients SET
medication_prescribed = %s WHERE
patient_id = %s",
(new_med, pid)
)
[Link]()
[Link]()
print("Medication updated.")
def delete_patient():
pid = int(input("Enter Patient ID to
delete: "))
conn = connect_db()
cursor = [Link]()
[Link]("DELETE FROM Patients
WHERE patient_id = %s", (pid,))
[Link]()
[Link]()
print("Patient record deleted.")

# ---------------------- Reporting and Export


----------------------
def doctor_summary():
conn = connect_db()
cursor = [Link]()
[Link]("""
SELECT [Link], COUNT(*)
FROM Patients p
JOIN Doctors d ON p.doctor_id =
d.doctor_id
GROUP BY [Link]
""")
rows = [Link]()
[Link]()

print("\n--- Doctor-wise Patient Count


---")
for doc, count in rows:
print(f"Dr. {doc}: {count} patients")
def export_to_csv():
conn = connect_db()
cursor = [Link]()
[Link]("SELECT * FROM
Patients")
rows = [Link]()
headers = [desc[0] for desc in
[Link]]
with open("[Link]", "w",
newline='') as f:
writer = [Link](f)
[Link](headers)
[Link](rows)
[Link]()
print("Exported patient data to
[Link]")
# ---------------------- Main Menu
----------------------
def main():
while True:
print("\nHospital Management
System")
print("1. Add Doctor")
print("2. Register Patient")
print("3. View All Patients")
print("4. Search Patients by Doctor")
print("5. Update Medication")
print("6. Delete Patient")
print("7. Doctor Summary Report")
print("8. Export Patient Data to
CSV")
print("9. Exit")
choice = input("Enter your choice: ")
if choice == '1':
add_doctor()
elif choice == '2':
register_patient()
elif choice == '3':
view_patients()
elif choice == '4':
search_by_doctor()
elif choice == '5':
update_medication()
elif choice == '6':
delete_patient()
elif choice == '7':
doctor_summary()
elif choice == '8':
export_to_csv()
elif choice == '9':
print("Exiting system.")
break
else:
print("Invalid choice. Try again.")
if __name__ == "__main__":
main()

OUTPUT
FUTURE
APPLICATIONS
BIBLIOGRAPHY

Python Software Foundation. Python


Documentation. [Link]
MySQL Official Documentation. MySQL
8.0 Reference Manual.
[Link]
GeeksforGeeks. “Python MySQL
Connectivity” and related tutorials.
 TutorialsPoint. “Hospital Management
System Concepts & Database Design.”
W3Schools. Python MySQL Tutorial.
[Link]
n_mysql_getstarted.asp

You might also like