Copy link to clipboard
Copied
I want my "Total Activity Requested" to be the sum of all "Requested Dose" (i.e. fields R1-R10)
Mathematically I'd want:
Total Activity Requested = R1 + Sum of (Rx/exp(-0.00632*(Ax-Cal)) (where Rx = Fields R2-R10 and Ax = Fields A2-A10))
Ax-Cal is the time difference between the two fields in minutes
Using the above image as an example:
For example R1 = 200 Cal: 11/02/2025 09:00 R2 = 250 A2 = 11/02/2025 10:00 R3 = 120 A3 = 11/02/2025 11:00
The "Total Activity Requested" can be calculated to be = 200 + 250/exp(-0.00632*60) + 120/exp(-0.00632*120)
I am expecting the answer to be 821.
I hope this makes sense.
Copy link to clipboard
Copied
- Calculation of time difference: This was discussed here many times in the past, including complete code examples.
Since your values contain the full date it should not be too difficult. You just need to convert them to Date variables (use the util.scand method), then deduct the latter from the former (using the getTime method of both variables), and convert the result from milliseconds to minutes.
- JS has a built-in command to calculate exponents: Math.exp(x)
which returns e raised to the power of x.
The rest of your calculation requires simple mathematical operators and should not be too difficult to implement.