-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRxrefill.py
40 lines (32 loc) · 2.22 KB
/
Rxrefill.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import datetime
import decimal
InputDatePrescribed= input("When was prescription written? (year-month-day): ")
InputPillPatchRefillCount = input("How many pills/inhalers in this refill?: ")
InputPillsPerday = input("How many pills can be taken in a day?: ")
InputPatchDuration = input("How often is the inhaler used (hours)?: ")
# Written in standard Year, month,day 2008-8-2
YearMonthDayInput = InputDatePrescribed.split('-')#split this in arguments using"-", then input that
InputYear,InputMonth,InputDay = InputDatePrescribed.split('-')
DatePrescribed = datetime.date (int(InputYear), int(InputMonth),int(InputDay))
def PillRefillDuration (InputPillPatchRefillCount,InputPillsPerday): #STATES HOW MANY DAYS IT SHOULD LAST AS READABLE OUTPUT
PillRefillDuration = decimal.Decimal(decimal.Decimal(InputPillPatchRefillCount)/decimal.Decimal(InputPillsPerday))
return PillRefillDuration
def PillDeltaDueDate (InputPillPatchRefillCount, InputPillsPerday): #RETURNS A TIMEDELTA OBJECT IN DAYS WHICHS ALLOWS MANIPULATION
return datetime.timedelta (float(PillRefillDuration(InputPillPatchRefillCount, InputPillsPerday)))#Need to do this since timedelta doesn't take Decimal type
def PatchRefillDuration (InputPillPatchRefillCount,InputPatchDuration):
PatchRefillDuration = decimal.Decimal(decimal.Decimal(InputPatchDuration)/decimal.Decimal(24)) *decimal.Decimal(InputPillPatchRefillCount)
return PatchRefillDuration
def PatchDeltaDueDue (InputPillPatchRefillCount, InputPatchDuration):
return datetime.timedelta (float (PatchRefillDuration(InputPillPatchRefillCount, InputPatchDuration)))
if InputPatchDuration == "":
a = PillRefillDuration (InputPillPatchRefillCount, InputPillsPerday)
print ("It shoud last ", a, " days.")
print ("It was prescrbied", DatePrescribed)
DueDate = DatePrescribed + PillDeltaDueDate (InputPillPatchRefillCount, InputPillsPerday)
print ("It is due on", DueDate)
if InputPillsPerday == "":
a = PatchRefillDuration(InputPillPatchRefillCount, InputPatchDuration)
print ("It shoud last ", a, " days.")
print ("It was prescrbied", DatePrescribed)
DueDate = DatePrescribed + PatchDeltaDueDue (InputPillPatchRefillCount, InputPatchDuration)
print ("It is due on", DueDate)