Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
2.5 kB
2
Indexable
Never
class Patient:
    def __init__(self):
        self.name = ""
        self.age = 0
        self.hospital_number = ""

    def input_patient_details(self):
        self.name = input("Enter patient name: ")
        self.age = int(input("Enter patient age: "))
        self.hospital_number = input("Enter hospital number: ")

    def display_patient_details(self):
        print("Patient Name: ", self.name)
        print("Patient Age: ", self.age)
        print("Hospital Number: ", self.hospital_number)


class Inpatient(Patient):
    def __init__(self):
        super().__init__()
        self.department_name = ""
        self.admission_date = ""
        self.room_type = ""

    def input_inpatient_details(self):
        self.input_patient_details()
        self.department_name = input("Enter department name: ")
        self.admission_date = input("Enter admission date (dd/mm/yyyy): ")
        self.room_type = input("Enter room type (S/SP/G): ")

    def display_inpatient_details(self):
        self.display_patient_details()
        print("Department Name: ", self.department_name)
        print("Admission Date: ", self.admission_date)
        print("Room Type: ", self.room_type)


class Billing(Inpatient):
    def __init__(self):
        super().__init__()
        self.discharge_date = ""

    def input_billing_details(self):
        self.input_inpatient_details()
        self.discharge_date = input("Enter discharge date (dd/mm/yyyy): ")

    def display_billing_details(self):
        self.display_inpatient_details()
        print("Discharge Date: ", self.discharge_date)

    def calculate_total_amount(self):
        room_rent = 0
        consultancy_charges = 0
        if self.room_type == "S":
            room_rent = 200
            consultancy_charges = 1000
        elif self.room_type == "SP":
            room_rent = 100
            consultancy_charges = 500
        elif self.room_type == "G":
            room_rent = 50
            consultancy_charges = 100
        total_amount = (datetime.datetime.strptime(self.discharge_date, "%d/%m/%Y") -
                         datetime.datetime.strptime(self.admission_date, "%d/%m/%Y")).days * room_rent + consultancy_charges
        return total_amount

    def display_total_amount(self):
        print("Total Amount: ", self.calculate_total_amount())


def main():
    billing = Billing()
    billing.input_billing_details()
    billing.display_billing_details()
    billing.display_total_amount()


if __name__ == "__main__":
    main()
Leave a Comment