Skip to content

Instantly share code, notes, and snippets.

@mpacific
Last active August 22, 2021 15:18
Show Gist options
  • Save mpacific/33d0f19a14a0aa666fc8e351eadecc60 to your computer and use it in GitHub Desktop.
Save mpacific/33d0f19a14a0aa666fc8e351eadecc60 to your computer and use it in GitHub Desktop.
Medication Taper Schedule
const Moment = require('moment')
const startDate = new Moment('2021-08-20')
const dosageUnit = 'mg'
const startDosage = 40
const pillDosage = 10
const taperDays = 7
const taperAmount = 5
let currentWeek = 0
let currentDosage = startDosage
while (currentDosage > 0) {
for (let currentDay = 0; currentDay < taperDays; currentDay++) {
const currentDate = startDate.clone().add(currentWeek, 'weeks').add(currentDay, 'days')
console.log(`${currentDate.format('dddd, MMMM D')}\t${currentDosage / pillDosage} pills\t${currentDosage} ${dosageUnit}`)
}
console.log('\r\n')
currentWeek++
currentDosage -= taperAmount
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment