0% found this document useful (0 votes)
24 views47 pages

CS Prject

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)
24 views47 pages

CS Prject

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
You are on page 1/ 47

Project on hospital management system

Project Report
IN
COMPUTER SCIENCE FOR CLASS XII
(2024-2025)
Submitted in partial fulfillment of the requirement cbse ,Delhi
BY:
Enrollment No:
UNDER THE GUIDANCE OF
MS. S. KRUTHIK KSHAMA
BHAARATH PUBLIC SCHOOL – CBSE
(Senior Secondary School), PALANI

1
BHAARATH PUBLIC SCHOOL – CBSE
(Senior Secondary School)
PALANI
COMPUTER SCIENCE
2024 – 2025
BONAFIDE CERTIFICATE
This is to certify that this project entitled “HOSPITAL
MANAGEMENT SYSTEM” is a record bonafide work carried
out By R.Tameemul Rahman in COMPUTER SCIENCE
prescribed by BHAARATH PUBLIC SCHOOL-CBSE(Senior
Secondary School), PALANI.
ROLL NUMBER: DATE:

INTERNAL EXAMINER EXTERNAL EXAMINER PRINCIPAL

2
ACKNOWLEDGMENT

I would like to express my deepest gratitude to my


principal, Mrs. Meena Kumari, for her unwavering
support throughout this project. My sincere thanks
also go to my vice principal,
Mr. S. Gobi, for his valuable guidance. I am grateful to
my coordinator Mr. Annaraja for his continued
assistance, and to my computer teacher,Ms. Kruthik
Kshama, whose expertise has been instrumental in the
project’s success. In conclusion, I deeply appreciate
the collective guidance and encouragement from
everyone involved, which has been pivotal in
completing this work.

3
SERIAL NO. CONTENTS PAGE NO.

1 Introduction 5

2 System 6
Requirements

3 Flow Chart 7

4 Project 20
Description

5 Source Code 21

Output 32
6 Screenshots

7 Conclusion 45

8 Bibliography 46

TABLE OF CONTENT

4
1.INTRODUCTION:
Managing a hospital's day-to-day operations requires handling a vast amount
of data related to patients, doctors, appointments, billing, and more. To
streamline these processes, we've developed a Hospital Management
System using Python and MySQL. This system serves as a comprehensive
solution to manage and organize critical information efficiently, ensuring that
healthcare providers can focus more on patient care rather than
administrative tasks. The system is designed to be user-friendly and offers a
robust database backend powered by MySQL, coupled with Python for
seamless integration and interaction. By leveraging CRUD (Create, Read,
Update, Delete) operations, this system allows for the efficient management
of all essential hospital functions. The core features include patient
management, doctor scheduling, appointment booking, and billing
processes.

5
2.SYSTEM REQUIREMENTS
2.1 SOFTWARE REQUIREMENTS
PLATFORM: windows 7 and above
SOFTWARE: python 3.7 and Above
2.2 HARDWARE REQUIREMENTS
PROCESSOR: Pentium-IV
RAM: 1gb
HARD DISK: 40gb

6
3.FLOW CHART

7
8
9
10
11
12
13
14
15
16
17
18
STOP

19
4.Project Description:
The Hospital Management System is a Python-based
application integrated with MySQL to streamline
hospital operations, including patient care, doctor
management, appointment scheduling, and billing.
Designed for efficiency and accuracy, the system
automates key processes, ensuring seamless data
management and improved healthcare services.
Modules used
1. Patient Management: Add, view, update, and delete patient
records with complete details like name, age, and disease.
2. Doctor Management: Maintain doctor profiles, including
specialization, availability, and contact details.
3. Appointment Scheduling: Link patients to doctors, ensuring no
scheduling conflicts and organized workflows.
4. Billing System: Generate bills for patients, detailing treatments,
costs, and payment statuses.
5. Search & Filter: Search patients by disease or check doctor
availability for specific dates.

20
5.SOURCE CODE
import pymysql
from datetime import datetime

# Establish database connection


def create_connection():
try:
connection = pymysql.connect(
host="localhost",
user="root", # Replace with your MySQL username
password="dbuser", # Replace with your MySQL
password
database="HospitalDB"
)
print("Connected to MySQL database.")
return connection
except pymysql.MySQLError as e:
print(f"Error connecting to MySQL: {e}")
return None

# Menu functions

21
def add_patient(connection):
name = input("Enter patient name: ")
age = int(input("Enter patient age: "))
gender = input("Enter gender (Male/Female): ")
disease = input("Enter disease: ")
admission_date = input("Enter admission date (YYYY-MM-
DD): ")

query = f"""
INSERT INTO Patients (name, age, gender, disease,
admission_date)
VALUES ('{name}', {age}, '{gender}', '{disease}',
'{admission_date}');
"""
execute_query(connection, query)
print("Patient added successfully.")

def view_patients(connection):
query = "SELECT * FROM Patients;"
results = execute_read_query(connection, query)
print("\nPatient Records:")

22
for row in results:
print(row)

def add_doctor(connection):
name = input("Enter doctor name: ")
specialization = input("Enter specialization: ")
phone = input("Enter phone number: ")

query = f"""
INSERT INTO Doctors (name, specialization, phone)
VALUES ('{name}', '{specialization}', '{phone}');
"""
execute_query(connection, query)
print("Doctor added successfully.")

def view_doctors(connection):
query = "SELECT * FROM Doctors;"
results = execute_read_query(connection, query)
print("\nDoctor Records:")
for row in results:
print(row)
23
def schedule_appointment(connection):
patient_id = int(input("Enter patient ID: "))
doctor_id = int(input("Enter doctor ID: "))
appointment_date = input("Enter appointment date (YYYY-
MM-DD): ")
appointment_time = input("Enter appointment time
(HH:MM): ")
reason = input("Enter reason for appointment: ")

query = f"""
INSERT INTO Appointments (patient_id, doctor_id,
appointment_date, appointment_time, reason)
VALUES ({patient_id}, {doctor_id}, '{appointment_date}',
'{appointment_time}', '{reason}');
"""
execute_query(connection, query)
print("Appointment scheduled successfully.")

def add_billing_record(connection):
patient_id = int(input("Enter patient ID: "))
total_amount = float(input("Enter total amount: "))

24
billing_date = input("Enter billing date (YYYY-MM-DD): ")

query = f"""
INSERT INTO Billing (patient_id, total_amount, billing_date)
VALUES ({patient_id}, {total_amount}, '{billing_date}');
"""
execute_query(connection, query)
print("Billing record added successfully.")

def generate_bill(connection):
patient_id = int(input("Enter patient ID: "))
query = f"SELECT * FROM Billing WHERE patient_id =
{patient_id};"
results = execute_read_query(connection, query)
print("\nBilling Details:")
for row in results:
print(row)

def update_patient(connection):
patient_id = int(input("Enter patient ID to update: "))
name = input("Enter new name: ")

25
age = int(input("Enter new age: "))
gender = input("Enter new gender (Male/Female): ")
disease = input("Enter new disease: ")
admission_date = input("Enter new admission date (YYYY-
MM-DD): ")
discharge_date = input("Enter new discharge date (YYYY-
MM-DD): ")

query = f"""
UPDATE Patients
SET name = '{name}', age = {age}, gender = '{gender}',
disease = '{disease}',
admission_date = '{admission_date}', discharge_date =
'{discharge_date}'
WHERE patient_id = {patient_id};
"""
execute_query(connection, query)
print("Patient updated successfully.")

def delete_patient(connection):
patient_id = int(input("Enter patient ID to delete: "))

26
query = f"DELETE FROM Patients WHERE patient_id =
{patient_id};"
execute_query(connection, query)
print("Patient deleted successfully.")

def search_patients_by_disease(connection):
disease = input("Enter disease to search for: ")
query = f"SELECT * FROM Patients WHERE disease =
'{disease}';"
results = execute_read_query(connection, query)
print("\nPatients with specified disease:")
for row in results:
print(row)

def check_appointment_availability(connection):
doctor_id = int(input("Enter doctor ID: "))
query = f"SELECT * FROM Appointments WHERE doctor_id
= {doctor_id};"
results = execute_read_query(connection, query)
print("\nAppointments for Doctor ID", doctor_id)
for row in results:

27
print(row)

# Query execution helpers


def execute_query(connection, query):
cursor = connection.cursor()
try:
cursor.execute(query)
connection.commit()
except pymysql.MySQLError as e:
print(f"Error: {e}")

def execute_read_query(connection, query):


cursor = connection.cursor()
try:
cursor.execute(query)
return cursor.fetchall()
except pymysql.MySQLError as e:
print(f"Error: {e}")
return []

# Main function
28
def main():
connection = create_connection()
if not connection:
return

while True:
print("\nHospital Management System")
print("1. Add Patient")
print("2. View Patients")
print("3. Add Doctor")
print("4. View Doctors")
print("5. Schedule Appointment")
print("6. Add Billing Record")
print("7. Generate Bill")
print("8. Update Patient")
print("9. Delete Patient")
print("10. Search Patients by Disease")
print("11. Check Appointment Availability")
print("12. Exit")

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


29
if choice == 1:
add_patient(connection)
elif choice == 2:
view_patients(connection)
elif choice == 3:
add_doctor(connection)
elif choice == 4:
view_doctors(connection)
elif choice == 5:
schedule_appointment(connection)
elif choice == 6:
add_billing_record(connection)
elif choice == 7:
generate_bill(connection)
elif choice == 8:
update_patient(connection)
elif choice == 9:
delete_patient(connection)
elif choice == 10:
search_patients_by_disease(connection)
30
elif choice == 11:
check_appointment_availability(connection)
elif choice == 12:
print("Exiting system. Goodbye!")
break
else:
print("Invalid choice. Please try again.")

# Run the program


if __name__ == "__main__":
main()

31
6.OUTPUT SCREENSHOTS
STARTING THE INTERFACE :

32
6.1 ADDING PATIENT

33
6.2 VIEW PATIENTS

34
6.3 ADD DOCTOR

35
6.4 VIEW DOCTORS

36
6.5 SCHEDULE APPOINTMENT

37
6.6 ADD BILLING RECORD

38
6.7 GENERATE BILL

39
6. 8 UPDATE PATIENT

40
6.9 DELETE PATIENT

41
6.10 SEARCH PATIENTS BY DISEASE

42
6.11CHECK APPOINTMENT AVAILABILITY

43
6.12 EXIT

44
7.CONCLUSION
The Hospital Management System project demonstrates a comprehensive
solution for efficiently managing hospital operations, including patient and
doctor records, appointment scheduling, and billing processes. By integrating
a MySQL database with Python's functionality, this system ensures data
integrity, accessibility, and streamlined workflows. The project emphasizes
user-friendly design, error handling, and scalability, making it adaptable for
real-world applications. This endeavor showcases the potential of technology
to enhance healthcare management, ensuring better organization and
improved patient care.

45
8.BIBLIOGRAPHY
 Computer science with python by Sumita Arora
 https://www.geeksforgeeks.org/sleep-in-python/
 https://en.wikipedia.org/
 https://www.cbse.gov.in/

46
47

You might also like