Ryan International School, Sanpada
Ryan International School, Sanpada
SANPADA
Roll No. : 15
Teacher’s Signature :
Teacher’s Remark :
1
Certificate
This is to certify that , a student of class XII-B, has
signature:
2
Acknowledgement
do.
3
Index
S.No Topic Page
number
2 Flow of code 6
4 Output 16
4
Breakdown of Code for Hospital
5
Flow of Code
6
Code For a Functioning Hospital
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"
return bill_summary
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}")
patient = self.get_patient_by_id(patient_id)
11
doctor = self.get_doctor_by_id(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
12
print(f"Doctor ID: {doctor.doctor_id}, Name:
{doctor.name}, Specialty: {doctor.specialty}")
patient = self.get_patient_by_id(patient_id)
doctor = self.get_doctor_by_id(doctor_id)
#insurance
13
insurance_coverage = float(input("Enter insurance
coverage percentage (0 if none): "))
#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
#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")
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