Experiment11python
Experiment11python
Aim- A hospital wants to create a database regarding its indoor patients. The information to store
includes a) Name of the patient b) Date of admission c) Disease d) Date of discharge. Create a
structure to store the date (year, month and date as its members). Create a base class to store the
above information. The member function should include functions to enter information and
display a list of all the patients in the database. Create a derived class to store the age of the
patients. List the information about to store the age of the patients. List the information about all
the paediatric patients.
Theory- A hospital database system is essential for maintaining patient records efficiently. In
this experiment, we use Object-Oriented Programming (OOP) concepts in Python to create a
structured database for storing indoor patient details. The system includes patient names,
admission and discharge dates, diseases, and their ages. Additionally, paediatric patients (aged
below 12 years) are filtered from the database.
Code- class Date: def init(self, year, month, day): self.year = year self.month = month self.day =
day
def __str__(self):
return f"{self.year}-{self.month:02d}-{self.day:02d}"
class Patient: def init(self, name, admission_date, disease, discharge_date): self.name = name
self.admission_date = admission_date self.disease = disease self.discharge_date = discharge_date
def display_patient_info(self):
print(f"Name: {self.name}")
print(f"Admission Date: {self.admission_date}")
print(f"Disease: {self.disease}")
print(f"Discharge Date: {self.discharge_date}")
def display_paediatric_info(self):
self.display_patient_info()
print(f"Age: {self.age}\n")
def is_paediatric(self):
return self.age < 12
def main(): patients = [] num_patients = int(input("Enter number of patients: "))
for i in range(num_patients):
print(f"\nEnter details for Patient {i+1}:")
name = input("Enter Patient Name: ")
Output:
Conclusion- In this experiment, we successfully designed and implemented a Hospital Indoor
Patient Database System using Object-Oriented Programming (OOP) concepts in Python. The
system effectively stores and manages patient details, including name, disease, admission date,
discharge date, and age.