a question about coding calendar dates

new topic     » topic index » view thread      » older message » newer message

I wish to write a simple console utility for my windows desktop. Its purpose is to accept as input various particulars about a prescription i've written for one of my patients, and output the earliest date on which s/he will need a new script (so that i can write it in good time for when it'll be needed).

Every script has the following particulars: date_of_script (eg 3 December 2013); drug_name (eg Amoraphene); dose_per_tablet (eg 5mg); tablets_per_day (eg 4 tabs/day); tablets_per_pack (eg 75 tabs/pack); repeats_per_script (eg 2 repeats). The drug_name and dose aren't really needed for this app. The effect of prescribing repeats is that s/he gains access to the original pack (of 75 tabs) plus the repeats (ie 2 * 75 tabs), ie 225 tabs in all. In this example, s/he will run out of tablets in 56 days at the earliest [ (75 + (2 * 75)) / 4, using integer division ]. Assume that s/he starts taking their tablets from the date of the prescription, and doesn't miss any doses or take any extra doses, and doesn't delay getting any repeats, so there are no delays or surprises or other complications. I'd like the app to tell me that the next script will be due no earlier than 29 January 2014 (ie 8 weeks from the script date).

When i tried to write this app i ran into difficulties with the change of year, and maybe also with due dates that fall on a leap year. I find working with calendars difficult, but this problem might be simple for those in the know. If so, i'd be grateful for your guidance.

Thank you,

Alex Caracatsanis

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu