0% found this document useful (0 votes)
2 views20 pages

Priyanka_26624266

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 20

SAINT GIRI SENIOR SECONDARY

SCHOOL
SECTOR-3 ROHINI

COMPUTER SCIENCE PROJECT


(2024-25)

HOSPITAL MANAGEMENT
SYSTEM
SUBMITTED BY: PRIYANKA JOSHI
ROLL NUMBER: 26624266
ACKNOWLEDGEMENT

It is with pleasure that I acknowledge my sincere gratitude


to our teacher, Harshita ma’am 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 Mrs. Sanyogita
Giri 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.
I also acknowledge with a deep sense of reverence, my
gratitude towards my parents, other faculty members of
the school and friends for their valuable suggestions given
to me in completing the project.

2
CERTIFICATE

This is to certify that Priyanka Joshi of class XII B of Saint


Giri Senior Secondary school has done his project on
“hospital management system” under my supervision. 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.

INTERNAL EXAMINER EXTERNAL EXAMINER

3
TECHNOLOGIES USED

• Hardware:
o Computer system
• Software:
o Python 3.12
o MySQL
o Visual Studio Code
o Microsoft Word
o Python modules:
▪ MySQL connector
▪ Date time

4
Introduction to the Hospital
Management System
The Hospital Management System (HMS) is a command-line-
based project designed to streamline and automate the
management of key hospital operations. This system facilitates
the efficient handling of patients, doctors, and appointments,
enabling hospitals to provide better services while reducing
manual effort.

The project leverages Python for its logic and user interface and
MySQL as its backend database for storing and managing the data.
The system allows administrators to perform essential tasks such
as registering patients and doctors, scheduling appointments,
and retrieving relevant information about hospital records
through a simple and intuitive command-line interface.

Key Features:

1. Patient Management:
a. Add and store patient information, including name, age,
gender, and contact details.
b. Retrieve and view a list of all registered patients.
2. Doctor Management:
a. Add doctors with their name, specialization, and
contact details.
5
b. View a list of available doctors and their specializations.
3. Appointment Scheduling:
a. Schedule appointments by assigning a patient to a
doctor on a specified date.
b. Include additional details about the reason for the
appointment.
4. Data Viewing:
a. Retrieve and display all appointments, along with the
associated patient and doctor details.
b. Access comprehensive lists of patients and doctors.

Benefits:

• Improved Efficiency:
The system eliminates manual record-keeping, reducing the
chance of errors and improving data retrieval time.

• Easy Management:
Doctors, patients, and appointments can be added,
managed, and viewed in a centralized database.

• Scalability:
This basic system can be expanded with additional modules
like billing, medical history management, and report
generation.

6
Future Enhancements:
While the current implementation provides basic functionality, it
can be further enhanced with:

A graphical user interface (GUI) for easier navigation.

Advanced features like patient medical records, billing, and


prescription management.

Integration of SMS or email notifications for appointment


reminders.

7
TO BUILD A COMMAND-LINE INTERFACE (CLI) FOR A HOSPITAL
MANAGEMENT SYSTEM USING PYTHON AND MYSQL, YOU NEED
TO:

1. Design the database schema for managing hospital data,


such as patients, doctors, appointments, and departments.
2. Write Python code to interact with the MySQL database for
CRUD operations (Create, Read, Update, Delete).
3. Provide a user-friendly CLI for interacting with the system.

1. Database Schema

We will design a basic schema with the following tables:

• patients: To store patient information.


• doctors: To store doctor information.
• appointments: To store appointment details.
• departments: To group doctors under different medical
specialties.

8
SQL Schema:

9
2. Python Code for CLI

Here is the Python code to implement the CLI for managing the
hospital system:
import mysql.connector
from datetime import datetime

# Connect to MySQL database

def connect_to_db():
return mysql.connector.connect(
host="localhost",
user="root",
password='JintoPoshi1@3',
database="hospital"
)

# Add a new patient


def add_patient():
name = input("Enter patient's name: ")
age = int(input("Enter patient's age: "))
gender = input("Enter patient's gender
(Male/Female/Other): ")
contact_number = input("Enter patient's contact number:
")

conn = connect_to_db()
cursor = conn.cursor()

10
query = "INSERT INTO patients (name, age, gender,
contact_number) VALUES (%s, %s, %s, %s)"
cursor.execute(query, (name, age, gender,
contact_number))

conn.commit()
print(f"Patient '{name}' added successfully!")
cursor.close()
conn.close()

# Add a new doctor


def add_doctor():
name = input("Enter doctor's name: ")
specialization = input("Enter doctor's specialization: ")
contact_number = input("Enter doctor's contact number: ")

conn = connect_to_db()
cursor = conn.cursor()

query = "INSERT INTO doctors (name, specialization,


contact_number) VALUES (%s, %s, %s)"
cursor.execute(query, (name, specialization,
contact_number))

conn.commit()
print(f"Doctor '{name}' added successfully!")
cursor.close()
conn.close()

# Schedule an appointment
def schedule_appointment():

11
patient_id = int(input("Enter patient ID: "))
doctor_id = int(input("Enter doctor ID: "))
appointment_date = input("Enter appointment date (YYYY-
MM-DD): ")
description = input("Enter appointment description: ")

conn = connect_to_db()
cursor = conn.cursor()

query = "INSERT INTO appointments (patient_id, doctor_id,


appointment_date, description) VALUES (%s, %s, %s, %s)"
cursor.execute(query, (patient_id, doctor_id,
appointment_date, description))

conn.commit()
print("Appointment scheduled successfully!")
cursor.close()
conn.close()

# View all appointments


def view_appointments():
conn = connect_to_db()
cursor = conn.cursor()

query = """
SELECT a.appointment_id, p.name AS patient_name, d.name
AS doctor_name,
a.appointment_date, a.description
FROM appointments a
JOIN patients p ON a.patient_id = p.patient_id
JOIN doctors d ON a.doctor_id = d.doctor_id

12
"""
cursor.execute(query)
appointments= cursor.fetchall()

print("\nAppointments:")
for appointment in appointments:
print(f"ID: {appointment[0]}, Patient:
{appointment[1]}, Doctor: {appointment[2]}")
print(f"Date: {appointment[3]}, Description:
{appointment[4]}")
print("-" * 40)

cursor.close()
conn.close()

# View all patients


def view_patients():
conn = connect_to_db()
cursor = conn.cursor()

query = "SELECT * FROM patients"


cursor.execute(query)
patients = cursor.fetchall()

print("\nPatients:")
for patient in patients:
print(f"ID: {patient[0]}, Name: {patient[1]}, Age:
{patient[2]}, Gender: {patient[3]}")
print(f"Contact: {patient[4]}")
print("-" * 40)

13
cursor.close()
conn.close()

# View all doctors


def view_doctors():
conn = connect_to_db()
cursor = conn.cursor()

query = "SELECT * FROM doctors"


cursor.execute(query)
doctors = cursor.fetchall()

print("\nDoctors:")
for doctor in doctors:
print(f"ID: {doctor[0]}, Name: {doctor[1]},
Specialization: {doctor[2]}")
print(f"Contact: {doctor[3]}")
print("-" * 40)

cursor.close()
conn.close()

# Main menu for CLI


def main():
while True:
print("\nHospital Management System")
print("1. Add Patient")
print("2. Add Doctor")
print("3. Schedule Appointment")
print("4. View Appointments")

14
print("5. View Patients")
print("6. View Doctors")
print("7. Exit")

choice = input("Enter your choice: ")

if choice == '1':
add_patient()
elif choice == '2':
add_doctor()
elif choice == '3':
schedule_appointment()
elif choice == '4':
view_appointments()
elif choice == '5':
view_patients()
elif choice == '6':
view_doctors()
elif choice == '7':
print("Exiting the system. Goodbye!")
break
else:
print("Invalid choice. Please try again.")

if __name__ == "__main__":
main()

15
#Output#
1. Adding A Patient

2. Adding A Doctor

16
3. Scheduling An Appointment

4. Viewing Appointments

17
5. Viewing patients

6. Viewing doctors

18
7. Exiting

19
BIBLIOGRAPHY

• Google.com
• Class 11th and 12th textbooks
• GitHub
• GeeksforGeeks
• W3schools
• Stackoverflow

20

You might also like