コード例 #1
0
    def prepare_data(self, prescA, prescB, prescC):
        patient = Patient()
        medA = Medicine("A")
        medB = Medicine("B")
        medC = Medicine("C")

        medA.add_prescription(prescA)
        medB.add_prescription(prescB)
        medC.add_prescription(prescC)

        patient.add_medicine(medA)
        patient.add_medicine(medB)
        patient.add_medicine(medC)
        return patient
コード例 #2
0
    def test_clash_with_two_patients(self):
        prescA = Prescription(date(2020, 7, 1), 20)
        prescB = Prescription(date(2020, 7, 10), 4)
        prescC = Prescription(date(2020, 7, 10), 10)
        medA = Medicine("A")
        medB = Medicine("B")
        medC = Medicine("C")

        medA.add_prescription(prescA)
        medB.add_prescription(prescB)
        medC.add_prescription(prescC)

        patientA = Patient()
        patientB = Patient()
        patientA.add_medicine(medA)
        patientB.add_medicine(medA)
        patientB.add_medicine(medB)
        patientA.add_medicine(medC)
        patientB.add_medicine(medC)
        self.assertEqual(patientA.clash(["A", "B"], 90), [])
コード例 #3
0
class PatientTest(unittest.TestCase):
    
    def setUp(self):
        self.patient = Patient()
        self.codeine = Medicine("Codeine")
        self.prozac = Medicine("Prozac")
        self.patient.add_medicine(self.codeine)
        self.patient.add_medicine(self.prozac)
    
    def test_clash_when_one_medicine_taken_continuously(self):
        self.codeine.add_prescription(Prescription(dispense_date=(date.today() - timedelta(days=30)), days_supply=30))
        self.codeine.add_prescription(Prescription(dispense_date=(date.today() - timedelta(days=60)), days_supply=30))
        self.codeine.add_prescription(Prescription(dispense_date=(date.today() - timedelta(days=90)), days_supply=30))
        self.assertEquals(90, len(self.patient.clash([self.codeine], 90)))

    def test_clash_when_one_medicine_taken_on_some_of_the_days(self):
        self.codeine.add_prescription(Prescription(dispense_date=(date.today() - timedelta(days=30)), days_supply=30))
        self.codeine.add_prescription(Prescription(dispense_date=(date.today() - timedelta(days=60)), days_supply=30))
        self.assertEquals(60, len(self.patient.clash([self.codeine], 90)))

    def test_two_medicines_taken_in_a_partially_overlapping_period(self):
        self.codeine.add_prescription(Prescription(dispense_date=(date.today() - timedelta(days=30)), days_supply=30))
        self.prozac.add_prescription(Prescription(dispense_date=(date.today() - timedelta(days=40)), days_supply=30))
        self.assertEquals(20, len(self.patient.clash([self.codeine, self.prozac], 90)))

    def test_two_medicines_taken_overlapping_current_date(self):
        self.codeine.add_prescription(Prescription(dispense_date=(date.today() - timedelta(days=1)), days_supply=30))
        self.prozac.add_prescription(Prescription(dispense_date=(date.today() - timedelta(days=5)), days_supply=30))
        self.assertEquals(set([date.today() - timedelta(days=1)]), self.patient.clash([self.codeine, self.prozac], 90))
コード例 #4
0
class PatientTest(unittest.TestCase):
    def setUp(self):
        self.patient = Patient()
        self.codeine = Medicine("Codeine")
        self.prozac = Medicine("Prozac")
        self.patient.add_medicine(self.codeine)
        self.patient.add_medicine(self.prozac)

    def test_no_clash_when_no_overlap(self):
        self.codeine.add_prescription(
            Prescription(days_ago(30), days_supply=30))
        self.prozac.add_prescription(Prescription(days_ago(90),
                                                  days_supply=30))
        self.assertEquals(
            0, len(self.patient.clash([self.codeine, self.prozac], 90)))

    def test_no_clash_when_not_taking_both_medicines(self):
        self.codeine.add_prescription(
            Prescription(days_ago(30), days_supply=30))
        self.assertEquals(
            0, len(self.patient.clash([self.codeine, self.prozac], 90)))

    def test_clash_when_medicines_taken_continuously(self):
        self.codeine.add_prescription(
            Prescription(days_ago(30), days_supply=30))
        self.codeine.add_prescription(
            Prescription(days_ago(60), days_supply=30))
        self.codeine.add_prescription(
            Prescription(days_ago(90), days_supply=30))
        self.prozac.add_prescription(Prescription(days_ago(30),
                                                  days_supply=30))
        self.prozac.add_prescription(Prescription(days_ago(60),
                                                  days_supply=30))
        self.prozac.add_prescription(Prescription(days_ago(90),
                                                  days_supply=30))
        self.assertEquals(90, len(self.patient.clash(["Codeine", "Prozac"],
                                                     90)))

    def test_clash_when_one_medicine_taken_on_some_of_the_days(self):
        self.codeine.add_prescription(
            Prescription(days_ago(30), days_supply=30))
        self.codeine.add_prescription(
            Prescription(days_ago(60), days_supply=30))
        self.prozac.add_prescription(Prescription(days_ago(30),
                                                  days_supply=30))
        self.prozac.add_prescription(Prescription(days_ago(60),
                                                  days_supply=30))
        self.prozac.add_prescription(Prescription(days_ago(90),
                                                  days_supply=30))
        self.assertEquals(60, len(self.patient.clash(["Codeine", "Prozac"],
                                                     90)))

    def test_two_medicines_taken_in_a_partially_overlapping_period(self):
        self.codeine.add_prescription(
            Prescription(days_ago(30), days_supply=30))
        self.prozac.add_prescription(Prescription(days_ago(40),
                                                  days_supply=30))
        self.assertEquals(20, len(self.patient.clash(["Codeine", "Prozac"],
                                                     90)))

    def test_two_medicines_taken_overlapping_current_date(self):
        self.codeine.add_prescription(Prescription(days_ago(1),
                                                   days_supply=30))
        self.prozac.add_prescription(Prescription(days_ago(5), days_supply=30))
        self.assertEquals(set([days_ago(1)]),
                          self.patient.clash(["Codeine", "Prozac"], 90))

    def test_two_medicines_taken_overlapping_start_of_period(self):
        self.codeine.add_prescription(
            Prescription(days_ago(91), days_supply=30))
        self.prozac.add_prescription(
            Prescription(days_ago(119), days_supply=30))
        self.assertEquals(set([days_ago(90)]),
                          self.patient.clash(["Codeine", "Prozac"], 90))