Exemplo n.º 1
0
 def feed_medicine(cls):
     """
     Takes in user input of medicine choice from three, and feeds
     medicine to the pet to reset its health level back to 100/100
     """
     medicine_choice = input(f'Which medicine would you choose?\n'
                             f' 1. {Medicine.medicine_dict["1"]}\n'
                             f' 2. {Medicine.medicine_dict["2"]}\n'
                             f' 3. {Medicine.medicine_dict["3"]}\n'
                             f'  :')
     if not cls.update_status():
         return False
     if medicine_choice in ['1', '2', '3']:
         Medicine.feed(cls.pet)
         print(f'{cls.pet.get_name()} says: '
               f'{cls.pet.get_message()["after_medicine_msg"]}'
               f' (pet health is now 100/100)\n')
     else:
         print('No such medicine choice!\n')
     return True
Exemplo n.º 2
0
 def updateInventory(self, item):
     print("Stock order is placed successfully for your store!")
     print("Billing will be done at your store.")
     print("\n\n")
     print("Updating your inventory>>>")
     for i in item:
         med_obj = Medicine(i[1])
         med_obj.updateQty(int(i[2]))
         date = i[3].split('-')
         y = int(date[0])
         m = int(date[1])
         d = int(date[2])
         med_obj.updateExp(datetime.date(y, m, d))
     print("Inventory successfully updated")
Exemplo n.º 3
0
 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)
Exemplo n.º 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_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))
Exemplo n.º 5
0
 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)
Exemplo n.º 6
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))
Exemplo n.º 7
0
    for i in range(len(my_list)):
        if i != 0:
            my_str = my_str + " " + str(my_list[i])
        else:
            my_str = str(my_list[i])

    return my_str


def outputToFile(output):
    f = open("schedule.txt", "w")
    f.write(output)
    f.close()


med_1 = Medicine(1, 86, 106, 0, [], -1)
med_2 = Medicine(2, 64, 80, 0, [], -1)
med_3 = Medicine(3, 129, 159, 0, [], -1)
med_4 = Medicine(4, 259, 317, 0, [], -1)

medicines = [med_1, med_2, med_3, med_4]

for med in medicines:
    med.takeMedicine(0, daily)
    med.takenTimes.append(0)
    med.intervalsTaken.append(getTimeInterval(1))

# output = "0800 4 1 2 3 4\n"
output = "0800 4 1 2 3 4\n"

# test_range = 100
Exemplo n.º 8
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
Exemplo n.º 9
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), [])