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

Computer Science Investigatorymysql (2)

Uploaded by

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

Computer Science Investigatorymysql (2)

Uploaded by

jithu710123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

PM SHRI

KENDRIYA VIDYALAYA
OTTAPALAM

COMPUTER SCIENCE PROJECT


2024-25

TOPIC :- HOSPITAL MANAGEMENT SYSTEM

BY AVINASH NV
XII A
ROLL NO.___________
CERTIFICATE

This is to certified to be the Bonafide work of the student


AVINASH NV of class XII A in Computer Science in the
Academic Year 2024-2025

External examiner Internal examiner

Principal
Acknowledgement

undertook this Project work, as the part of my XII-Computer Science

I course. I had tried to apply my best of knowledge and experience, gained


during the study and class work experience. However, developing
software system is generally a quite complex and time-consuming process.
It requires a systematic study, insight vision and professional approach
during the design and development. Moreover, the developer always feels
the need, the help and good wishes of the people near you, who have
considerable experience and idea.

I would like to extend my sincere thanks and gratitude to my teacher Mr.


Jimmy John. I am very much thankful to our Principal Mr. Santosh Kumar
for giving valuable time and moral support to develop this software.

I would like to take the opportunity to extend my sincere thanks and


gratitude to my father Sri VINODKUMAR N, and my mother Mrs. RESMI
VINOD for being a source of inspiration and providing time and freedom
to develop this software project.

[NAME]

Class XII
TABLE OF CONTENTS

1. introduction ………………………. 1
2. Objective and scope………….. 2
3. software development
Tools used ………………………….. 3
4. database design………………. 5
5. soURce code ………………………. 8
6. OUTPUT SCREENS……………………. 15
7. System ReqUiRements…………. 18
8. ReFeRences………………………….. 19
1. Introduction

This software is developed to automate the working of


a Hospital system. The purpose of this software is to provide
a Management Information System (MIS) to provide facilities
to store the information about the Doctors and patients. It
also stores the information about appointments and billing.

This software was developed using MySQL as a back-


end for storing the data and the front-end used was Python.
Both the software's are free and open-source and so the cost
of creating the project was kept to a minimum. Both the
software provides robust platform which are easy for
developing user-friendly software.

P age |1
2. objective and scope
The objectives of the project are:

 To develop an MIS system for automating the working of a


Hospital records
 To provide facility for managing the details of doctors,
patients, staff, appointments.
 To provide the facility of managing the users of the software

The Hospital Management System streamlines hospital


operations by efficiently managing patient records, doctor
schedules, appointments, billing, and staff information. It
reduces administrative workload, minimizes errors, and
improves patient care. This scalable project is crucial for
hospitals, clinics, and healthcare facilities aiming to digitize
and optimize workflows, enhance data security, and provide
seamless healthcare management.

P age |2
3. software development tools used
The following software development tools were used:

Python:

The front-end of the project has been developed in Python language. Python
is free and open source and many libraries exist for performing different kinds of
work with it.

Python is an interpreted, high-level, general-purpose programming


language. Created by Guido van Rossum and first released in 1991, Python's design
philosophy emphasizes code readability with its notable use of significant
whitespace. Its language constructs and object-oriented approach aim to help
programmers write clear, logical code for small and large-scale projects.

Python interpreters are available for many operating systems. A global


community of programmers develops and maintains CPython, an open source
implementation. Python is a multi-paradigm programming language. Object-
oriented programming and structured programming are fully supported, and many
of its features support functional programming and aspect-oriented programming.
Python was designed to be highly extensible. This compact modularity has made it
particularly popular as a means of adding programmable interfaces to existing
applications.

P age |3
MySQL:

MySQL is an open-source relational database management system (RDBMS).


It is one of the most popular and widely used open source platforms for storing
enterprise data.

MySQL works on many hardware and software platform. It supports good


developer interfaces and the documentation and support from various user-driven
communities is also good. It is a fast, stable and true multi-user, multi-threaded
SQL database server.

It supports many useful programming features such as cross-platform


support, stored procedures, triggers, cursors online data definition language (DDL),
updateable views and a performance schema that collects and aggregates statistics
about server execution and query performance for monitoring purposes.

Anaconda:

Anaconda is a free and open source integrated development environment


(IDE) for development of Python programming language. It simplifies the package
management and deployment for Python programming language. It comes with
more than 1500 packages as well as the conda package and virtual environment
manager. It also includes a GUI, the Anaconda Navigator, which is a graphical
alternative to the command line interface of Python.

P age |4
4. DATABASE DESIGN
The following tables were created in MySQL:

USE HOSPITALMANAGEMENT;
CREATE TABLE patients (
patient_id INTEGER PRIMARY KEY AUTO_INCREMENT,
name TEXT NOT NULL,
age INTEGER,
gender TEXT,
phone TEXT,
address TEXT
);

CREATE TABLE doctors (


doctor_id INTEGER PRIMARY KEY AUTO_INCREMENT,
name TEXT NOT NULL,
specialization TEXT,
phone TEXT,
email TEXT
);

P age |5
CREATE TABLE appointments (
appointment_id INTEGER PRIMARY KEY AUTO_INCREMENT,
patient_id INTEGER,
doctor_id INTEGER,
appointment_date TEXT,
status TEXT,
FOREIGN KEY (patient_id) REFERENCES patients (patient_id),
FOREIGN KEY (doctor_id) REFERENCES doctors (doctor_id)
);

CREATE TABLE staff (


staff_id INTEGER PRIMARY KEY AUTO_INCREMENT,
name TEXT NOT NULL,
role TEXT,
phone TEXT,
email TEXT
);

P age |6
CREATE TABLE billing (
bill_id INTEGER PRIMARY KEY AUTO_INCREMENT,
patient_id INTEGER,
total_amount REAL,
payment_status TEXT,
billing_date TEXT,
FOREIGN KEY (patient_id) REFERENCES patients (patient_id)
);

P age |7
5. SOURCE CODE
import sqlite3
from datetime import datetime

# Database connection
conn = sqlite3.connect('hospital_management.db')
cursor = conn.cursor()

# Create tables if not exists


def create_tables():
cursor.execute('''CREATE TABLE IF NOT EXISTS patients (
patient_id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
age INTEGER,
gender TEXT,
phone TEXT,
address TEXT
)''')

cursor.execute('''CREATE TABLE IF NOT EXISTS doctors (


doctor_id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
specialization TEXT,
phone TEXT,
email TEXT
)''')

P age |8
cursor.execute('''CREATE TABLE IF NOT EXISTS appointments (
appointment_id INTEGER PRIMARY KEY AUTOINCREMENT,
patient_id INTEGER,
doctor_id INTEGER,
appointment_date TEXT,
status TEXT,
FOREIGN KEY (patient_id) REFERENCES patients (patient_id),
FOREIGN KEY (doctor_id) REFERENCES doctors (doctor_id)
)''')

cursor.execute('''CREATE TABLE IF NOT EXISTS staff (


staff_id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
role TEXT,
phone TEXT,
email TEXT
)''')

cursor.execute('''CREATE TABLE IF NOT EXISTS billing (


bill_id INTEGER PRIMARY KEY AUTOINCREMENT,
patient_id INTEGER,
total_amount REAL,
payment_status TEXT,
billing_date TEXT,
FOREIGN KEY (patient_id) REFERENCES patients (patient_id)
)''')
P age |9
conn.commit()

# Add patient function


def add_patient(name, age, gender, phone, address):
cursor.execute('''INSERT INTO patients (name, age, gender, phone, address)
VALUES (?, ?, ?, ?, ?)''', (name, age, gender, phone, address))
conn.commit()
print("Patient added successfully!")

# View patients
def view_patients():
cursor.execute("SELECT * FROM patients")
patients = cursor.fetchall()
for patient in patients:
print(patient)

# Add doctor
def add_doctor(name, specialization, phone, email):
cursor.execute('''INSERT INTO doctors (name, specialization, phone, email)
VALUES (?, ?, ?, ?)''', (name, specialization, phone, email))
conn.commit()
print("Doctor added successfully!")

P a g e | 10
# View doctors
def view_doctors():
cursor.execute("SELECT * FROM doctors")
doctors = cursor.fetchall()
for doctor in doctors:
print(doctor)

# Book appointment
def book_appointment(patient_id, doctor_id, appointment_date):
cursor.execute('''INSERT INTO appointments (patient_id, doctor_id,
appointment_date, status)
VALUES (?, ?, ?, ?)''', (patient_id, doctor_id, appointment_date,
'Scheduled'))
conn.commit()
print("Appointment booked successfully!")

# View appointments
def view_appointments():
cursor.execute('''SELECT a.appointment_id, p.name AS patient_name, d.name AS
doctor_name, a.appointment_date, a.status
FROM appointments a
JOIN patients p ON a.patient_id = p.patient_id
JOIN doctors d ON a.doctor_id = d.doctor_id''')
appointments = cursor.fetchall()
for appointment in appointments:
P a g e | 11
print(appointment)

# Generate bill
def generate_bill(patient_id, total_amount):
billing_date = datetime.now().strftime("%Y-%m-%d")
cursor.execute('''INSERT INTO billing (patient_id, total_amount, payment_status,
billing_date)
VALUES (?, ?, ?, ?)''', (patient_id, total_amount, 'Unpaid', billing_date))
conn.commit()
print("Bill generated successfully!")

# View billing
def view_billing():
cursor.execute("SELECT * FROM billing")
bills = cursor.fetchall()
for bill in bills:
print(bill)

# Main menu
def main_menu():
create_tables()
while True:
print("\n--- Hospital Management System ---")
print("1. Add Patient")

P a g e | 12
print("2. View Patients")
print("3. Add Doctor")
print("4. View Doctors")
print("5. Book Appointment")
print("6. View Appointments")
print("7. Generate Bill")
print("8. View Billing")
print("9. Exit")
choice = input("Enter your choice: ")

if choice == '1':
name = input("Enter patient name: ")
age = int(input("Enter patient age: "))
gender = input("Enter patient gender: ")
phone = input("Enter patient phone: ")
address = input("Enter patient address: ")
add_patient(name, age, gender, phone, address)
elif choice == '2':
view_patients()
elif choice == '3':
name = input("Enter doctor name: ")
specialization = input("Enter specialization: ")
phone = input("Enter phone: ")
email = input("Enter email: ")
add_doctor(name, specialization, phone, email)
elif choice == '4':
view_doctors()
P a g e | 13
elif choice == '5':
patient_id = int(input("Enter patient ID: "))
doctor_id = int(input("Enter doctor ID: "))
appointment_date = input("Enter appointment date (YYYY-MM-DD): ")
book_appointment(patient_id, doctor_id, appointment_date)
elif choice == '6':
view_appointments()
elif choice == '7':
patient_id = int(input("Enter patient ID: "))
total_amount = float(input("Enter total amount: "))
generate_bill(patient_id, total_amount)
elif choice == '8':
view_billing()
elif choice == '9':
break
else:
print("Invalid choice! Please try again.")

conn.close()

# Run the program


if __name__ == "__main__":
main_menu()

P a g e | 14
6. OUTPUT SCREENS
1. Add Patient’s details:
--- Hospital Management System ---
1. Add Patient
2. View Patients
3. Add Doctor
4. View Doctors
5. Book Appointment
6. View Appointments
7. Generate Bill
8. View Billing
9. Exit
Enter your choice: 1
Enter patient name: Raj
Enter patient age: 24
Enter patient gender: male
Enter patient phone: 9087564312
Enter patient address: B-52 skyline, street no. 23, delhi
Patient added successfully!

2. Add Doctor’s details:


--- Hospital Management System ---
1. Add Patient
2. View Patients
3. Add Doctor
4. View Doctors
5. Book Appointment
6. View Appointments
7. Generate Bill
8. View Billing
9. Exit
Enter your choice: 3
Enter doctor name: Sriya
Enter specialization: Neurosurgeon
Enter phone: 8907564312
Enter email: [email protected]
Doctor added successfully!

P a g e | 15
3. Book appointment:
--- Hospital Management System ---
1. Add Patient
2. View Patients
3. Add Doctor
4. View Doctors
5. Book Appointment
6. View Appointments
7. Generate Bill
8. View Billing
9. Exit
Enter your choice: 5
Enter patient ID: 132436
Enter doctor ID: 5372536
Enter appointment date (YYYY-MM-DD): 2024-11-23
Appointment booked successfully!

4. Generate billing
--- Hospital Management System ---
1. Add Patient
2. View Patients
3. Add Doctor
4. View Doctors
5. Book Appointment
6. View Appointments
7. Generate Bill
8. View Billing
9. Exit
Enter your choice: 7
Enter patient ID: 132436
Enter total amount: 2000
Bill generated successfully!

P a g e | 16
5. View patient:
--- Hospital Management System ---
1. Add Patient
2. View Patients
3. Add Doctor
4. View Doctors
5. Book Appointment
6. View Appointments
7. Generate Bill
8. View Billing
9. Exit
Enter your choice: 2
(1, 'raj', 24, 'male', '9087564312', 'B-52 skyline, street no. 23, delhi')

6. View doctor:
--- Hospital Management System ---
1. Add Patient
2. View Patients
3. Add Doctor
4. View Doctors
5. Book Appointment
6. View Appointments
7. Generate Bill
8. View Billing
9. Exit
Enter your choice: 4
(1, 'Sriya', 'Neurosurgeon ', '8907564312', '[email protected]')

P a g e | 17
7. SYSTEM REQUIREMENTS

HARDWARE:
 11th Gen Intel(R) Core(TM) i3-1115G4 @ 3.00GHz
3.00 GHz
 8 GB RAM

SOFTWARE:

 Windows 11 64 bit
 Spyder Version 6.0.0
 MySQL Version 8.0.0

P a g e | 18
8. REFERENCES

The following resources were referred to in the preparation


of this project:
 Learned connecting SQL and python from Coder’s corner
 www.anaconda.com

P a g e | 19

You might also like