Priyanka_26624266
Priyanka_26624266
Priyanka_26624266
SCHOOL
SECTOR-3 ROHINI
HOSPITAL MANAGEMENT
SYSTEM
SUBMITTED BY: PRIYANKA JOSHI
ROLL NUMBER: 26624266
ACKNOWLEDGEMENT
2
CERTIFICATE
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:
7
TO BUILD A COMMAND-LINE INTERFACE (CLI) FOR A HOSPITAL
MANAGEMENT SYSTEM USING PYTHON AND MYSQL, YOU NEED
TO:
1. Database Schema
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
def connect_to_db():
return mysql.connector.connect(
host="localhost",
user="root",
password='JintoPoshi1@3',
database="hospital"
)
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()
conn = connect_to_db()
cursor = conn.cursor()
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()
conn.commit()
print("Appointment scheduled successfully!")
cursor.close()
conn.close()
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()
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()
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()
14
print("5. View Patients")
print("6. View Doctors")
print("7. Exit")
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