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

Ryan International School, Sanpada

The document is a Computer Science project by Lloyd Joseph Tomson from Ryan International School, detailing the development of a Hospital Management System in Python. It includes sections on code breakdown, flow of operations, and the actual code for functionalities such as patient management, doctor registration, appointment scheduling, and billing. The project emphasizes originality and acknowledges the support received from teachers and family.

Uploaded by

indrajeetk98760
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)
6 views20 pages

Ryan International School, Sanpada

The document is a Computer Science project by Lloyd Joseph Tomson from Ryan International School, detailing the development of a Hospital Management System in Python. It includes sections on code breakdown, flow of operations, and the actual code for functionalities such as patient management, doctor registration, appointment scheduling, and billing. The project emphasizes originality and acknowledges the support received from teachers and family.

Uploaded by

indrajeetk98760
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/ 20

RYAN INTERNATIONAL SCHOOL,

SANPADA

COMPUTER SCIENCE PROJECT


Name : Lloyd Joseph Tomson

Class / Division : XII B

Roll No. : 15

Date of submission : 06/09/2023

Teacher’s name : Ms. Janet Lobo

Teacher’s Signature :

Teacher’s Remark :

1
Certificate
This is to certify that , a student of class XII-B, has

successfully completed the project under the guidance of

Ms. Janet Lobo.

This project is genuine and does not involve any plagiarism

of any kind. References taken in making this project have

been declared at the end of the report.

External signature: Internal

signature:

Principal's Signature Stamp: School Stamp:

2
Acknowledgement

I would like to express my special gratitude to our Principal

Ma'am Mrs. Rajni Nair of Ryan International School,

Sanpada for always encouraging us to excel in all that we

do.

I would like to thank my teacher Ms. Janet Lobo for his

continuous encouragement and immense motivation which

sustain my efforts at all stages of this project.

Lastly, I would like to thank my family and friends for

helping me in the completion of this project.

3
Index
S.No Topic Page
number

1 Breakdown of Code for Hospital 5

2 Flow of code 6

3 Code for a functioning hospital 7

4 Output 16

4
Breakdown of Code for Hospital

Running a hospital involves handling several complex


systems like patient management, staff management,
appointment scheduling, inventory, billing, and more. To
simplify the task, I created a basic Hospital Management
System in Python. This system will include patient
registration, doctor assignment, appointment scheduling,
and billing.

Here’s a breakdown of what we can cover in this hospital


system:

1. Patient Management: Register new patients, view


patient details.
2. Doctor Management: Register doctors, assign doctors
to patients.
3. Appointment Scheduling: Schedule appointments
between patients and doctors.
4. Billing System: Generate bills for patients after
treatment.
5. Inventory Management: Manage the stock of
medicines (optional for now).

5
Flow of Code

1. Register Patients: Register new patients with their


information.
2. Register Doctors: Register doctors with their name and
specialty.
3. Schedule Appointment:
● Displays a list of available patients and doctors,
showing their IDs.
● Operator selects IDs and provides the date and time for
the appointment.
4. Generate Bill: Breaks down the treatments cost and
shows total amount needed to be paid by the patient
after insurance coverage
5. List Appointments: Displays all scheduled
appointments.

6
Code For a Functioning Hospital

from datetime import datetime


#register patient
class Patient:
def __init__(self, patient_id, name, age, address,
phone):
self.patient_id = patient_id
self.name = name
self.age = age
self.address = address
self.phone = phone

def __repr__(self):
return f"Patient(Name: {self.name}, Age: {self.age},
Phone: {self.phone})"

#register doctor
class Doctor:
def __init__(self, doctor_id, name, specialty):
self.doctor_id = doctor_id
self.name = name
self.specialty = specialty

def __repr__(self):
return f"Doctor(Name: {self.name}, Specialty:
{self.specialty})"

#register appointment

7
class Appointment:
def __init__(self, appointment_id, patient, doctor,
date, time):
self.appointment_id = appointment_id
self.patient = patient
self.doctor = doctor
self.date = date
self.time = time

def __repr__(self):
return f"Appointment(Patient: {self.patient.name},
Doctor: {self.doctor.name}, Date: {self.date}, Time:
{self.time})"

#register bill
class Billing:
def __init__(self, patient, doctor, services,
insurance_coverage=0):
self.patient = patient
self.doctor = doctor
self.services = services # List of (service, cost) tuples
self.insurance_coverage = insurance_coverage #
Percentage of cost covered by insurance
self.bill_date = datetime.now().strftime("%Y-%m-%d
%H:%M:%S")

def generate_bill(self):
total_cost = sum(cost for _, cost in self.services)
covered_amount = total_cost *
(self.insurance_coverage / 100)
final_amount = total_cost - covered_amount

8
#making detailed bill
bill_summary = f"\n--- Bill Summary ---\n"
bill_summary += f"Patient Name:
{self.patient.name}\n"
bill_summary += f"Doctor Name: {self.doctor.name}
(Specialty: {self.doctor.specialty})\n"
bill_summary += f"Date: {self.bill_date}\n\n"
bill_summary += "Services Provided:\n"

for service, cost in self.services:


bill_summary += f"- {service}: ${cost:.2f}\n"

bill_summary += f"\nTotal Cost: ${total_cost:.2f}\n"


if self.insurance_coverage > 0:
bill_summary += f"Insurance Coverage
({self.insurance_coverage}%):
-${covered_amount:.2f}\n"
bill_summary += f"Final Amount Due:
${final_amount:.2f}\n"
bill_summary += f"--- End of Bill ---\n"

return bill_summary

#lists to hold value


class Hospital:
def __init__(self, name):
self.name = name
self.patients = []
self.doctors = []

9
self.appointments = []
self.patient_id_counter = 1
self.doctor_id_counter = 1
self.appointment_id_counter = 1

#register patient
def register_patient(self):
name = input("Enter patient name: ")
age = int(input("Enter patient age: "))
address = input("Enter patient address: ")
phone = input("Enter patient phone number: ")
new_patient = Patient(self.patient_id_counter, name,
age, address, phone)
self.patients.append(new_patient)
self.patient_id_counter += 1
print(f"Patient {new_patient.name} registered
successfully.")
return new_patient

# register patient
def register_doctor(self):
name = input("Enter doctor name: ")
specialty = input("Enter doctor's specialty: ")
new_doctor = Doctor(self.doctor_id_counter, name,
specialty)
self.doctors.append(new_doctor)
self.doctor_id_counter += 1
print(f"Doctor {new_doctor.name} registered
successfully.")
return new_doctor

10
#scheduling appt
def schedule_appointment(self):
print("\nScheduling an appointment:")
if not self.patients or not self.doctors:
print("Error: You need to register patients and
doctors first.")
return

#patient id
print("\nAvailable Patients:")
for patient in self.patients:
print(f"Patient ID: {patient.patient_id}, Name:
{patient.name}")

#doctor id
print("\nAvailable Doctors:")
for doctor in self.doctors:
print(f"Doctor ID: {doctor.doctor_id}, Name:
{doctor.name}, Specialty: {doctor.specialty}")

#input patient and doctor id


patient_id = int(input("Enter patient ID: "))
doctor_id = int(input("Enter doctor ID: "))
date = input("Enter appointment date (YYYY-MM-DD):
")
time = input("Enter appointment time (HH:MM
AM/PM): ")

patient = self.get_patient_by_id(patient_id)

11
doctor = self.get_doctor_by_id(doctor_id)

if patient and doctor:


new_appointment =
Appointment(self.appointment_id_counter, patient,
doctor, date, time)
self.appointments.append(new_appointment)
self.appointment_id_counter += 1
print(f"Appointment scheduled:
{new_appointment}")
else:
print("Invalid patient or doctor ID.")

#generating bill
def generate_bill(self):
print("\nGenerating a bill:")
if not self.patients or not self.doctors:
print("Error: You need to register patients and
doctors first.")
return

#display patient ids


print("\nAvailable Patients:")
for patient in self.patients:
print(f"Patient ID: {patient.patient_id}, Name:
{patient.name}")

# Display available doctor IDs


print("\nAvailable Doctors:")
for doctor in self.doctors:

12
print(f"Doctor ID: {doctor.doctor_id}, Name:
{doctor.name}, Specialty: {doctor.specialty}")

#input patient and doc id


patient_id = int(input("Enter patient ID: "))
doctor_id = int(input("Enter doctor ID: "))

patient = self.get_patient_by_id(patient_id)
doctor = self.get_doctor_by_id(doctor_id)

if not patient or not doctor:


print("Invalid patient or doctor ID.")
return

#more than one service


services = []
while True:
service_name = input("Enter service/treatment
name: ")
service_cost = float(input(f"Enter cost for
{service_name}: $"))
services.append((service_name, service_cost))

another = input("Add another service? (y/n):


").lower()
if another != 'y':
break

#insurance

13
insurance_coverage = float(input("Enter insurance
coverage percentage (0 if none): "))

bill = Billing(patient, doctor, services,


insurance_coverage)
print(bill.generate_bill())

#patient id
def get_patient_by_id(self, patient_id):
for patient in self.patients:
if patient.patient_id == patient_id:
return patient
return None

#doctor id
def get_doctor_by_id(self, doctor_id):
for doctor in self.doctors:
if doctor.doctor_id == doctor_id:
return doctor
return None

#list of all appt


def list_appointments(self):
print("\nListing all appointments:")
for appointment in self.appointments:
print(appointment)

#main menu
def run(self):

14
while True:
print("\n--- Hospital Management System ---")
print("1. Register Patient")
print("2. Register Doctor")
print("3. Schedule Appointment")
print("4. Generate Bill")
print("5. List Appointments")
print("6. Exit")

choice = input("Enter your choice (1-6): ")

if choice == '1':
self.register_patient()
elif choice == '2':
self.register_doctor()
elif choice == '3':
self.schedule_appointment()
elif choice == '4':
self.generate_bill()
elif choice == '5':
self.list_appointments()
elif choice == '6':
print("Thank you for Visiting Lloyd’s Hospital")
break
else:
print("Invalid choice, please try again.")

#run

15
print(‘Welcome to Lloyd’s Hospital’)
hospital = Hospital("City Hospital")
hospital.run()

Output

16
17
18
19

You might also like