Ejemplo n.º 1
0
 def test_clash_overlaping_today(self):
     patient = Patient(prescriptions=[
         Prescription(
             "Codeine", dispense_date=days_ago(days=2), days_supply=3),
         Prescription(
             "Prozac", dispense_date=days_ago(days=2), days_supply=3)
     ])
Ejemplo n.º 2
0
 def test_initial_dispense_date(self):
     self.medicine.add_prescription(
         Prescription(dispense_date=date(2009, 11, 1), days_supply=30))
     self.medicine.add_prescription(
         Prescription(dispense_date=date(2009, 11, 30), days_supply=30))
     self.assertEquals(date(2009, 11, 1),
                       self.medicine.initial_dispense_date())
Ejemplo n.º 3
0
 def test_clash_overlapping_today(self):
      patient = Patient(prescriptions=[Prescription('Codeine',
                                                   dispense_date = days_ago(days=2),
                                                   days_supply=2),
                                      Prescription('Codeine',
                                                   dispense_date = days_ago(days=3),
                                                   days_supply=2)])
Ejemplo n.º 4
0
 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)))
Ejemplo n.º 5
0
 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))
Ejemplo n.º 6
0
 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)))
Ejemplo n.º 7
0
 def test_number_of_days_prescribed(self):
     when(self.medicine)._possession_effective_range(90).thenReturn(
         [date(2009, 10, 3) + timedelta(days=i) for i in range(75)])
     self.medicine.add_prescription(
         Prescription(dispense_date=date(2009, 10, 3), days_supply=30))
     self.medicine.add_prescription(
         Prescription(dispense_date=date(2009, 11, 17), days_supply=30))
     self.assertEquals(60, self.medicine.number_of_days_prescribed(90))
 def test_dates_taken_when_dates_overlap(self):
     prescriptions = [Prescription(dispense_date=date(2009, 12, 1),
                                   days_supply = 2),
                      Prescription(dispense_date=date(2009, 12, 2),
                                   days_supply = 2))
     self.assertEquals([date(2009, 12, 1),
                        date(2009, 12, 2),
                        date(2009, 12, 3)],
                       self.medicine.dates_taken_in_past_x_days(5))
Ejemplo n.º 9
0
 def test_clash_with_two_prescriptions_for_same_medication(self):
     patient = Patient(prescriptions=[Prescription('Codeine',
                                                   dispense_date = days_ago(days=2),
                                                   days_supply=2),
                                      Prescription('Codeine',
                                                   dispense_date = days_ago(days=3),
                                                   days_supply=2)])
     self.assertSetEqual({days_ago(days=3), days_ago(days=2), days_ago(days=1)},
                         patient.clash(['Codeine']))
Ejemplo n.º 10
0
 def test_dates_prescribed_when_dates_overlap(self):
     self.medicine.add_prescription(
         Prescription(dispense_date=date(2009, 12, 1), days_supply=2))
     self.medicine.add_prescription(
         Prescription(dispense_date=date(2009, 12, 2), days_supply=2))
     self.assertEquals(
         [date(2009, 12, 1),
          date(2009, 12, 2),
          date(2009, 12, 3)], self.medicine.dates_prescribed(5))
Ejemplo n.º 11
0
 def test_clash_overlapping_today(self):
     patient = Patient(prescriptions=[
         Prescription(
             "Codeine", dispense_date=days_ago(days=2), days_supply=3),
         Prescription(
             "Prozac", dispense_date=days_ago(days=2), days_supply=3)
     ])
     self.assertSetEqual(
         {days_ago(days=2), days_ago(days=1)},
         patient.clash(["Codeine", "Prozac"]))
Ejemplo n.º 12
0
 def test_clash_with_two_prescriptions_for_same_medication(self):
     patient = Patient(prescriptions=[
         Prescription("Codeine", dispense_date=days_ago(2), days_supply=2),
         Prescription("Codeine", dispense_date=days_ago(3), days_supply=2)
     ])
     assert patient.clash(["Codeine"]) == {
         days_ago(days=3),
         days_ago(days=2),
         days_ago(days=1)
     }
Ejemplo n.º 13
0
 def test_clash_with_two_different_prescriptions(self):
     patient = Patient(prescriptions=[
         Prescription(
             "Codeine", dispense_date=days_ago(days=2), days_supply=2),
         Prescription(
             "Prozac", dispense_date=days_ago(days=2), days_supply=2)
     ])
     assert patient.clash(["Codeine", "Prozac"
                           ]) == {days_ago(days=2),
                                  days_ago(days=1)}
Ejemplo n.º 14
0
 def test_days_taking(self):
     patient = Patient(prescriptions=[
         Prescription("Codeine", dispense_date=days_ago(2), days_supply=2),
         Prescription("Codeine", dispense_date=days_ago(3), days_supply=2)
     ])
     assert patient.days_taking("Codeine") == {
         days_ago(days=3),
         days_ago(days=2),
         days_ago(days=1)
     }
Ejemplo n.º 15
0
 def test_days_taking(self):
     patient = Patient(prescriptions=[Prescription('Codeine',
                                                   dispense_date = days_ago(days=2),
                                                   days_supply=2),
                                      Prescription('Codeine',
                                                   dispense_date = days_ago(days=3),
                                                   days_supply=2)])
     self.assertSetEqual({days_ago(days=3),
                          days_ago(days=2),
                          days_ago(days=1)},patient.days_taking('Codeine'))
Ejemplo n.º 16
0
 def test_prescriptions_in_range(self):
     when(self.medicine).possession_effective_end_date().thenReturn(
         date(2009, 12, 15))
     p1 = Prescription(dispense_date=date(2009, 8, 1), days_supply=30)
     p2 = Prescription(dispense_date=date(2009, 11, 1), days_supply=30)
     p3 = Prescription(dispense_date=date(2009, 12, 1), days_supply=30)
     self.medicine.add_prescription(p1)
     self.medicine.add_prescription(p2)
     self.medicine.add_prescription(p3)
     self.assertEquals([p2, p3], self.medicine.prescriptions_in_range(90))
Ejemplo n.º 17
0
 def test_clash_when_medecines_in_history_any_order(self):
     prescA = Prescription(date(2020, 7, 1), 20)
     prescB = Prescription(date(2020, 7, 10), 4)
     prescC = Prescription(date(2020, 7, 10), 10)
     patient = self.prepare_data(prescA, prescB, prescC)
     self.assertEqual(patient.clash(["B", "A"], 20), [
         date(2020, 7, 13),
         date(2020, 7, 12),
         date(2020, 7, 11),
         date(2020, 7, 10)
     ])
Ejemplo n.º 18
0
 def test_clash_AB_outofrange_C(self):
     prescA = Prescription(date(2020, 7, 15), 5)
     prescB = Prescription(date(2020, 7, 15), 5)
     prescC = Prescription(date(2020, 7, 10), 5)
     patient = self.prepare_data(prescA, prescB, prescC)
     self.assertEqual(patient.clash(["A", "B"], 6), [
         date(2020, 7, 19),
         date(2020, 7, 18),
         date(2020, 7, 17),
         date(2020, 7, 16),
         date(2020, 7, 15)
     ])
     self.assertEqual(patient.clash(["A", "B", "C"], 6), [])
Ejemplo n.º 19
0
 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)))
Ejemplo n.º 20
0
 def test_one_clash_with_one_prescription(self):
     patient = Patient(prescriptions=[
         Prescription(
             "Codeine", dispense_date=days_ago(days=2), days_supply=2)
     ])
     self.assertSetEqual(
         {days_ago(days=2), days_ago(days=1)}, patient.clash(["Codeine"]))
 def test_dates_taken_in_past_x_days(self):
     prescription = Prescription( \
         dispense_date=(date.today() - timedelta(days=2)),
         days_supply=4)
     self.assertEquals(set([date.today() - timedelta(days=2),
                            date.today() - timedelta(days=1)]),
                       prescription.dates_taken_in_past_x_days(2))
Ejemplo n.º 22
0
 def test_days_supply(self):
     prescription = Prescription(dispense_date=date.today(), days_supply=3)
     self.assertEquals([
         date.today(),
         date.today() + timedelta(days=1),
         date.today() + timedelta(days=2)
     ], prescription.days_taken())
Ejemplo n.º 23
0
 def test_dates_prescribed_in_effective_range(self):
     self.medicine.add_prescription(
         Prescription(dispense_date=date.today() - timedelta(days=2),
                      days_supply=4))
     self.assertEquals([
         date.today() - timedelta(days=2),
         date.today() - timedelta(days=1)
     ], self.medicine.dates_prescribed_in_effective_range(2))
Ejemplo n.º 24
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), [])
def prescriptions():
    st.header('PRESCRIPTIONS')
    option_list = ['', 'Add prescription', 'Update prescription', 'Delete prescription', 'Show prescriptions of a particular patient']
    option = st.sidebar.selectbox('Select function', option_list)
    m = Prescription()
    if (option == option_list[1] or option == option_list[2] or option == option_list[3]) and verify_dr_mls_access_code():
        if option == option_list[1]:
            st.subheader('ADD PRESCRIPTION')
            m.add_prescription()
        elif option == option_list[2]:
            st.subheader('UPDATE PRESCRIPTION')
            m.update_prescription()
        elif option == option_list[3]:
            st.subheader('DELETE PRESCRIPTION')
            m.delete_prescription()
    elif option == option_list[4]:
        st.subheader('PRESCRIPTIONS OF A PARTICULAR PATIENT')
        m.prescriptions_by_patient()
Ejemplo n.º 26
0
 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)))
Ejemplo n.º 27
0
 def test_completion_date(self):
     prescription = Prescription(dispense_date=date.today() -
                                 timedelta(days=15),
                                 days_supply=30)
     self.assertEquals(date.today() + timedelta(days=15),
                       prescription.completion_date())
Ejemplo n.º 28
0
 def test_days_taken_excludes_future_dates(self):
     prescription = Prescription("Codeine",
                                 dispense_date=days_ago(days=2),
                                 days_supply=4)
     self.assertListEqual([days_ago(2), days_ago(1)],
                          list(prescription.days_taken()))
Ejemplo n.º 29
0
 def test_days_taking_for_irrelevant_prescription(self):
     patient = Patient(prescriptions=[
         Prescription(
             "Codeine", dispense_date=days_ago(days=2), days_supply=2)
     ])
     assert patient.days_taking("Prozac") == set()
Ejemplo n.º 30
0
 def test_clash_with_one_irrevelevant_prescription(self):
     patient = Patient(prescriptions=[
         Prescription(
             "Codeine", dispense_date=days_ago(days=2), days_supply=2)
     ])
     assert patient.clash(["Adderal"]) == set()