Example #1
0
class Run(object):
    """
    Run the hospital flow.
    """
    def flow(self):
        """
        Run the patients through the system:
            * Get data for all 100 patients.
            * Add them to hospital to get patient objects.
            * Add procedures to the patient object.
            * Generate and print hospital patient summary.
        """

    hospital = Hospital()
    #Print format for Item Desciptions at top of list.
    print("%-5s%-10s%10s%15s%18s%18s" %
          ("#", "ID:", "Ins:", "INP / OUTP:", "Total:", "Liability:"))

    n = 1
    #Generating through 100 Patient Profiles to add to hospital.
    for patient in patients(100):
        added_patient = hospital.add_patient(patient["patient_id"],
                                             patient["has_insurance"],
                                             patient["kind"])
        for procedure in patient["procedures"]:
            added_patient.add_procedure(procedure)
            info_list = added_patient.summary()
        print("%-5d%-10d%10s%15s%18.2f%18.2f" %
              (n, info_list[0], info_list[1], info_list[2], info_list[3],
               info_list[4]))
        n += 1
Example #2
0
    def test_summary(self):
        """
        Check that the summary calculates correctly and handles promotions.
        """
        patient_list = patients.patients(100)
        hospital_list = Hospital()
        for index in patient_list:
            patient = hospital_list.add_patient(index["patient_id"],
                                                index["has_insurance"],
                                                index["kind"])
            for item in index["procedures"]:
                patient.add_procedure(item)

            self.assertIsInstance(patient, Patient)
            self.assertIsNotNone(patient.total_liability)
            self.assertIsNotNone(patient.total_cost)
            self.assertGreaterEqual(patient.total_cost,
                                    patient.total_liability)

            count = 0
            for procedure in patient.procedure_list:
                try:
                    pass
                except KeyError:
                    count += 1
                else:
                    continue
            length = len(patient.procedure_list) - count

            if length >= 3:
                og_total_liability = patient.total_liability
                patient.total_liability *= .8
                self.assertLessEqual(patient.total_liability,
                                     og_total_liability)
Example #3
0
 def test_add_procedure(self):
     """
     Check procedure addition.
     """
     patient_list = patients.patients(100)
     hospital_list = Hospital()
     for index in patient_list:
         patient = hospital_list.add_patient(index["patient_id"],
                                             index["has_insurance"],
                                             index["kind"])
         self.assertIsNotNone(patient.procedure_list)
         self.assertIsInstance(patient, Patient)
    def test_add_patient(self):
        """
        Make sure hospital adds the right kind of patient.
        """
        hospital = Hospital()

        for patient in patients(100):
            self.added_patient = hospital.add_patient(patient["patient_id"],
                                                      patient["has_insurance"],
                                                      patient["kind"])
            if patient["kind"] is "outpatient":
                self.assertEqual(
                    patient["kind"],
                    hospital.add_patient("56398", "true", "outpatient"))
 def test_patient_summary(self):
     """
     Confirm that the summary returns info on all patients.
     """
     hospital = Hospital()
     for patient in patients(100):
         added_patient = hospital.add_patient(patient["patient_id"],
                                              patient["has_insurance"],
                                              patient["kind"])
         for procedure in patient["procedures"]:
             self.added_patient = hospital.add_patient(
                 patient["patient_id"], patient["has_insurance"],
                 patient["kind"])
             info_list = added_patient.summary()
             self.assertAlmostEquals(info_list, patient["patient_id"])
Example #6
0
 def test_add_patient(self):
     """
     Check patient addition.
     """
     patient_list = patients.patients(100)
     hospital_list = Hospital()
     for index in patient_list:
         patient = hospital_list.add_patient(index["patient_id"],
                                             index["has_insurance"],
                                             index["kind"])
         if index["kind"] == "outpatient":
             self.assertIsInstance(patient, _OutPatient)
         elif index["kind"] == "inpatient":
             self.assertIsInstance(patient, _InPatient)
         else:
             self.fail()
Example #7
0
 def test_patient_summary(self):
     """
     Confirm that the summary returns info on all patients.
     """
     patient_list = patients.patients(100)
     hospital_list = Hospital()
     for index in patient_list:
         patient = hospital_list.add_patient(index["patient_id"],
                                             index["has_insurance"],
                                             index["kind"])
         self.assertIsNotNone(patient.patient_id)
         self.assertIsNotNone(patient.has_insurance)
         self.assertIsNotNone(patient.total_cost)
         self.assertIsNotNone(patient.total_liability)
     self.assertEqual(len(hospital_list.hospital_list), 100)
     self.assertIsNotNone(hospital_list.hospital_list)
Example #8
0
    def flow(self):
        """
        Run the patients through the system:
            * Get data for all 100 patients.
            * Add them to hospital to get patient objects.
            * Add procedures to the patient object.
            * Generate and print hospital patient summary.
        """
        hospital_key = Hospital()
        NUMBER_OF_PATIENTS = 100

        for index in patients(NUMBER_OF_PATIENTS):
            new_patient = hospital_key.add_patient(index["patient_id"],
                                                   index["has_insurance"],
                                                   index["kind"])
            for item in index["procedures"]:
                new_patient.add_procedure(item)
        hospital_key.patient_summary()