Calculate active medication (need time of input and half life formula)

Hi all,
I’m trying to build a simple webapp to register medication and to show taken medication and active dosages. I’m trying to build an MVP with the following:

  • One number field to enter a dosage with one decimal.
  • A submit button to submit your dosage.
  • A number field that shows your current active dose. I want to calculate the dose based on half life. For that I need to register the amount of minutes since the last dose. For example, if a dose halves every 4 hours the formula would be:
  • A small table with all taken dosages the last 24 hours.

I’ve got the input field to register a taken dosage, but I’m currently stuck trying to find:

  • How to register the time of input or the amount of minutes since the last input
  • How to calculate the current dose variable based on the input variable and formula to calculate current dose.

This all assumes one single medicine taken, after that I’d like to add categories with different half lifes etc, but first things first :slight_smile:

Can anyone point me in the right direction here?

Hi @dd66
If i understood well,

  • When you do submit, you are creating an entry in database it will have “created date” & “modified date” by default maybe you can use them to solve your situation…

  • For calculation of formula you need to enable “Expression parentheses” by going to app settings → Version tab…

Hi @viquarahmed07 ,

Thanks for replying, I don’t really know where to start exactly though, do you have any tutorials or similar to follow that point me in the right direction?

This topic was automatically closed after 70 days. New replies are no longer allowed.