Medication Calculation Model
A more complex calcultation model involves calculation of medication
A prescription of a drug can have a frequency, quantity and total or/and a rate, quantity and time in which the drug is administered. A drug can contain one or more components and each component can contain multiple substances.
This gives rise to the following model:
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: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: |
|
For a 'simple' one component, one substance drug like a paracetamol supp, the following equantions are generated:
1: 2: 3: 4: 5: |
|
drug.total<0N..> = supp.comp.qty<0N..> * supp.comp.total<0N..> drug.total<0N..> = supp.drug.qty<0N..> paracetamol.dose.qty<0N..> = paracetamol.dose.rate<0N..> * time<0N..> paracetamol.dose.qty<0N..> = paracetamol.drug.conc<0N..> * prescr.qty<0N..> paracetamol.dose.qty<0N..> = paracetamol.dose.qty.wght<0N..> * weight<0N..> paracetamol.dose.qty<0N..> = paracetamol.dose.qty.bsa<0N..> * bsa<0N..> paracetamol.dose.rate<0N..> = paracetamol.drug.conc<0N..> * prescr.rate<0N..> paracetamol.dose.rate<0N..> = paracetamol.dose.rate.wght<0N..> * weight<0N..> paracetamol.dose.rate<0N..> = paracetamol.dose.rate.bsa<0N..> * bsa<0N..> paracetamol.dose.total<0N..> = paracetamol.dose.qty<0N..> * freq<0N..> paracetamol.dose.total<0N..> = paracetamol.drug.conc<0N..> * prescr.total<0N..> paracetamol.dose.total<0N..> = paracetamol.dose.total.wght<0N..> * weight<0N..> paracetamol.dose.total<0N..> = paracetamol.dose.total.bsa<0N..> * bsa<0N..> paracetamol.drug.qty<0N..> = paracetamol.drug.conc<0N..> * drug.total<0N..> paracetamol.drug.qty<0N..> = paracetamol.supp.comp.conc<0N..> * supp.drug.qty<0N..> paracetamol.supp.comp.qty<0N..> = paracetamol.supp.comp.conc<0N..> * supp.comp.total<0N..> prescr.qty<0N..> = prescr.rate<0N..> * time<0N..> prescr.total<0N..> = prescr.qty<0N..> * freq<0N..> prescr.total<0N..> = drug.total<0N..> * drug.qty<0N..> supp.dose.qty<0N..> = supp.dose.rate<0N..> * time<0N..> supp.dose.qty<0N..> = supp.drug.conc<0N..> * prescr.qty<0N..> supp.dose.qty<0N..> = supp.dose.qty.wght<0N..> * weight<0N..> supp.dose.qty<0N..> = supp.dose.qty.bsa<0N..> * bsa<0N..> supp.dose.rate<0N..> = supp.drug.conc<0N..> * prescr.rate<0N..> supp.dose.rate<0N..> = supp.dose.rate.wght<0N..> * weight<0N..> supp.dose.rate<0N..> = supp.dose.rate.bsa<0N..> * bsa<0N..> supp.dose.total<0N..> = supp.dose.qty<0N..> * freq<0N..> supp.dose.total<0N..> = supp.drug.conc<0N..> * prescr.total<0N..> supp.dose.total<0N..> = supp.dose.total.wght<0N..> * weight<0N..> supp.dose.total<0N..> = supp.dose.total.bsa<0N..> * bsa<0N..> supp.drug.qty<0N..> = supp.drug.conc<0N..> * drug.total<0N..> ----- Real: 00:00:00.036, CPU: 00:00:00.031, GC gen0: 0, gen1: 0, gen2: 0
Using the model
Next we can start using the model.
A paracetamol supp can have a set of quanities, like: 50, 60, 120, 240, 500 and 1000 mg. And a supp has a total of 1. As the drug contains only the supp, the drug total equals the compoment total and is 1.
1: 2: 3: 4: |
|
Lets assume that patients normally tolerate one supp at a time. So, the prescription quantity can be set to 1. Also, the frequency of administration will be around, 1,2,3,4 or 6 times daily.
1: 2: |
|
The maximum paracetamol dose is 4000 mg/day. For children the dose is weight adjusted and should not exceed 90 mg/kg/day
1: 2: |
|
Suppose we want to prescribe paracetamol with this setup to a child of 6 kg. With a frequency of 3 or 4 times/day.
1: 2: 3: |
|
drug.total[1] = supp.drug.qty[1] drug.total[1] = supp.comp.qty[1] * supp.comp.total[1] paracetamol.dose.qty[50, 60, 120] = paracetamol.dose.rate<0N..> * time<0N..> paracetamol.dose.qty[50, 60, 120] = paracetamol.dose.qty.bsa<0N..> * bsa<0N..> paracetamol.dose.qty[50, 60, 120] = paracetamol.drug.conc[50, 60, 120] * prescr.qty[1] paracetamol.dose.qty[50, 60, 120] = paracetamol.dose.qty.wght[25/3, 10, 20] * weight[6] paracetamol.dose.rate<0N..> = paracetamol.dose.rate.bsa<0N..> * bsa<0N..> paracetamol.dose.rate<0N..> = paracetamol.dose.rate.wght<0N..> * weight[6] paracetamol.dose.rate<0N..> = paracetamol.drug.conc[50, 60, 120] * prescr.rate<0N..> paracetamol.dose.total[150, 180, 200, 240, 360, 480] = paracetamol.dose.qty[50, 60, 120] * freq[3, 4] paracetamol.dose.total[150, 180, 200, 240, 360, 480] = paracetamol.dose.total.bsa<0N..> * bsa<0N..> paracetamol.dose.total[150, 180, 200, 240, 360, 480] = paracetamol.drug.conc[50, 60, 120] * prescr.total[3, 4] paracetamol.dose.total[150, 180, 200, 240, 360, 480] = paracetamol.dose.total.wght[25, 30, 100/3, 40, 60, 80] * weight[6] paracetamol.drug.qty[50, 60, 120] = paracetamol.drug.conc[50, 60, 120] * drug.total[1] paracetamol.drug.qty[50, 60, 120] = paracetamol.supp.comp.conc[50, 60, 120] * supp.drug.qty[1] paracetamol.supp.comp.qty[50, 60, 120] = paracetamol.supp.comp.conc[50, 60, 120] * supp.comp.total[1] prescr.qty[1] = prescr.rate<0N..> * time<0N..> prescr.total[3, 4] = prescr.qty[1] * freq[3, 4] prescr.total[3, 4] = drug.total[1] * drug.qty[3, 4] supp.dose.qty[1] = supp.drug.conc[1] * prescr.qty[1] supp.dose.qty[1] = supp.dose.rate<0N..> * time<0N..> supp.dose.qty[1] = supp.dose.qty.bsa<0N..> * bsa<0N..> supp.dose.qty[1] = supp.dose.qty.wght[1/6] * weight[6] supp.dose.rate<0N..> = supp.dose.rate.bsa<0N..> * bsa<0N..> supp.dose.rate<0N..> = supp.drug.conc[1] * prescr.rate<0N..> supp.dose.rate<0N..> = supp.dose.rate.wght<0N..> * weight[6] supp.dose.total[3, 4] = supp.dose.qty[1] * freq[3, 4] supp.dose.total[3, 4] = supp.drug.conc[1] * prescr.total[3, 4] supp.dose.total[3, 4] = supp.dose.total.bsa<0N..> * bsa<0N..> supp.dose.total[3, 4] = supp.dose.total.wght[1/2, 2/3] * weight[6] supp.drug.qty[1] = supp.drug.conc[1] * drug.total[1] ----- Real: 00:00:00.092, CPU: 00:00:00.109, GC gen0: 3, gen1: 1, gen2: 1
From the output it can be deduced that:
- The supp's that can be used are the 50, 60 and 120 mg supps
- The maximum total dose is 480 mg/day
- The maximum weight adjusted total dose is 80 mg/kg/day
from Informedica.GenSolver
Public funtions to use the library
Full name: Medication.procss
module String
from Informedica.GenSolver.Utils
Helper functions for `System.String`
--------------------
module String
from Microsoft.FSharp.Core
Full name: Informedica.GenSolver.Utils.String.replace
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
Full name: Medication.printEqs
Full name: Informedica.GenSolver.Api.printEqs
Format a set of equations to print.
Using **f** to allow additional processing
of the string.
Full name: Medication.solve
Full name: Informedica.GenSolver.Api.solve
Solve an `Equations` list with
* f: function used to process string message
* n: the name of the variable to be updated
* p: the property of the variable to be updated
* vs: the values to update the property of the variable
* eqs: the list of equations to solve
Full name: Medication.init
Full name: Informedica.GenSolver.Api.init
Initialize the solver returning a set of equations
Full name: Medication.nonZeroNegative
Full name: Informedica.GenSolver.Api.nonZeroNegative
Make a list of `Equation`
to contain only positive
values as solutions
Full name: Medication.eqs
Full name: Medication.tms
Full name: Medication.add
Full name: Medication.time
Full name: Medication.freq
Full name: Medication.total
Full name: Medication.qty
Full name: Medication.rate
Full name: Medication.drug_total
Full name: Medication.drug_qty
Full name: Medication.wght
Full name: Medication.bsa
Full name: Medication.compSub
Full name: Medication.comp
module List
from Informedica.GenSolver.Utils
Helper functions for `List`
--------------------
module List
from Microsoft.FSharp.Collections
--------------------
type List<'T> =
| ( [] )
| ( :: ) of Head: 'T * Tail: 'T list
interface IEnumerable
interface IEnumerable<'T>
member Head : 'T
member IsEmpty : bool
member Item : index:int -> 'T with get
member Length : int
member Tail : 'T list
static member Cons : head:'T * tail:'T list -> 'T list
static member Empty : 'T list
Full name: Microsoft.FSharp.Collections.List<_>
Full name: Microsoft.FSharp.Collections.List.append
Full name: Microsoft.FSharp.Collections.List.collect
Full name: Medication.drug
Full name: Microsoft.FSharp.Collections.List.fold
Full name: Medication.paracetamol
Full name: Microsoft.FSharp.Core.Operators.ignore