@@ -8,30 +8,27 @@ System.Environment.SetEnvironmentVariable("GENPRES_URL_ID", "1IZ3sbmrM4W4OuSYELR
8
8
9
9
open MathNet.Numerics
10
10
open Informedica.Utils .Lib
11
- open Informedica.Utils .Lib .BCL
12
- open Informedica.Utils .Lib .BCL
13
- open Informedica.GenForm .Lib
14
11
open Informedica.GenUnits .Lib
15
- open Informedica.GenSolver .Lib
12
+ open Informedica.GenForm .Lib
16
13
open Informedica.GenOrder .Lib
17
- open Informedica. GenSolver . Lib . Variable . Operators
14
+
18
15
19
16
// TODO: could be used to precalc all possible
20
17
// prescriptions for a patient
21
- let createScenarios ( pr : PrescriptionResult ) =
18
+ let createScenarios ( pr : PrescriptionContext ) =
22
19
let getRules filter =
23
- { pr with Filter = filter } |> PrescriptionResult .getRules
20
+ { pr with Filter = filter } |> PrescriptionContext .getRules
24
21
25
22
let print pr =
26
23
let g = pr.Filter.Generic
27
24
let i = pr.Filter.Indication
28
25
let r = pr.Filter.Route
29
26
let d = pr.Filter.DoseType
30
- printfn $" === no evalution of {g} {i} {r} {d} ==="
27
+ printfn $" === no evaluation of {g} {i} {r} {d} ==="
31
28
pr
32
29
33
30
let eval pr s =
34
- printfn $" evaluting {s}... "
31
+ printfn $" evaluating {s}"
35
32
try
36
33
let pr = pr |> Api.evaluate
37
34
@@ -47,42 +44,44 @@ let createScenarios (pr: PrescriptionResult) =
47
44
let pr , rules = { pr.Filter with Generic = Some g } |> getRules
48
45
49
46
if rules |> Array.isEmpty |> not then
50
- $ " evaluting {g}... " |> eval pr
47
+ g |> eval pr
51
48
52
49
else
53
50
for i in pr.Filter.Indications do
54
51
let pr , rules = { pr.Filter with Indication = Some i } |> getRules
55
52
56
53
if rules |> Array.isEmpty |> not then
57
- $" evaluting {g} {i}... " |> eval pr
54
+ $" {g}, {i}" |> eval pr
58
55
59
56
else
60
57
for r in pr.Filter.Routes do
61
58
let pr , rules = { pr.Filter with Route = Some r } |> getRules
62
59
63
60
if rules |> Array.isEmpty |> not then
64
- $" evaluting {g} {i} {r}... " |> eval pr
61
+ $" {g}, {i}, {r}" |> eval pr
65
62
66
63
else
67
64
for d in pr.Filter.DoseTypes do
68
65
let pr , rules = { pr.Filter with DoseType = Some d } |> getRules
69
66
70
67
if rules |> Array.isEmpty |> not then
71
- $" evaluting {g} {i} {r} {d}... " |> eval pr
68
+ $" {g}, {i}, {r}, {d}" |> eval pr
72
69
73
70
else pr |> print
74
71
]
75
72
76
73
77
-
78
- let pr = Patient.infant |> PrescriptionResult.create
74
+ let pr =
75
+ { Patient.infant with
76
+ Weight = Some ([| 10 N |] |> ValueUnit.withUnit Units.Weight.kiloGram)
77
+ }|> PrescriptionContext.create
79
78
80
79
81
- { pr with PrescriptionResult .Filter.Generic = pr.Filter.Generics |> Array.tryItem 10 }
82
- |> PrescriptionResult .getRules
80
+ { pr with PrescriptionContext .Filter.Generic = pr.Filter.Generics |> Array.tryItem 10 }
81
+ |> PrescriptionContext .getRules
83
82
84
83
let scenarios =
85
- pr |> createScenarios
84
+ pr |> createScenarios |> ignore
86
85
87
86
88
87
scenarios
@@ -92,14 +91,14 @@ scenarios
92
91
|> List.length
93
92
94
93
// cidofovir
95
- { pr with PrescriptionResult .Filter.Generic = Some " cidofovir" }
96
- |> PrescriptionResult .getRules
94
+ { pr with PrescriptionContext .Filter.Generic = Some " cidofovir" }
95
+ |> PrescriptionContext .getRules
97
96
|> fun ( pr , _ ) ->
98
- { pr with PrescriptionResult .Filter.Indication = pr.Filter.Indications |> Array.tryHead }
99
- |> PrescriptionResult .getRules
97
+ { pr with PrescriptionContext .Filter.Indication = pr.Filter.Indications |> Array.tryHead }
98
+ |> PrescriptionContext .getRules
100
99
|> fun ( pr , _ ) ->
101
- { pr with PrescriptionResult .Filter.DoseType = pr.Filter.DoseTypes |> Array.tryHead }
102
- |> PrescriptionResult .getRules
100
+ { pr with PrescriptionContext .Filter.DoseType = pr.Filter.DoseTypes |> Array.tryHead }
101
+ |> PrescriptionContext .getRules
103
102
|> snd
104
103
|> Array.tryHead
105
104
|> Option.map DrugOrder.fromRule
@@ -111,17 +110,17 @@ scenarios
111
110
112
111
113
112
// TPV
114
- { pr with PrescriptionResult .Filter.Indication = Some " TPV" }
115
- |> PrescriptionResult .getRules
113
+ { pr with PrescriptionContext .Filter.Indication = Some " TPV" }
114
+ |> PrescriptionContext .getRules
116
115
|> fun ( pr , _ ) ->
117
- { pr with PrescriptionResult .Filter.Indication = pr.Filter.Indications |> Array.tryHead }
118
- |> PrescriptionResult .getRules
116
+ { pr with PrescriptionContext .Filter.Indication = pr.Filter.Indications |> Array.tryHead }
117
+ |> PrescriptionContext .getRules
119
118
|> fun ( pr , _ ) ->
120
- { pr with PrescriptionResult .Filter.DoseType = pr.Filter.DoseTypes |> Array.tryHead }
121
- |> PrescriptionResult .getRules
119
+ { pr with PrescriptionContext .Filter.DoseType = pr.Filter.DoseTypes |> Array.tryHead }
120
+ |> PrescriptionContext .getRules
122
121
|> fun ( pr , _ ) ->
123
- { pr with PrescriptionResult .Filter.SelectedComponents = pr.Filter.Components |> Array.skip 1 }
124
- |> PrescriptionResult .getRules
122
+ { pr with PrescriptionContext .Filter.SelectedComponents = pr.Filter.Components |> Array.skip 1 }
123
+ |> PrescriptionContext .getRules
125
124
|> snd
126
125
|> Array.tryHead
127
126
|> Option.map DrugOrder.fromRule
@@ -133,19 +132,19 @@ scenarios
133
132
134
133
135
134
{ pr with
136
- PrescriptionResult .Filter.Generic = Some " natriumfosfaat" }
135
+ PrescriptionContext .Filter.Generic = Some " natriumfosfaat" }
137
136
|> Api.evaluate
138
137
139
138
140
139
let tpvRule =
141
- { pr with PrescriptionResult .Filter.Indication = Some " TPV" }
142
- |> PrescriptionResult .getRules
140
+ { pr with PrescriptionContext .Filter.Indication = Some " TPV" }
141
+ |> PrescriptionContext .getRules
143
142
|> fun ( pr , _ ) ->
144
- { pr with PrescriptionResult .Filter.Indication = pr.Filter.Indications |> Array.tryHead }
145
- |> PrescriptionResult .getRules
143
+ { pr with PrescriptionContext .Filter.Indication = pr.Filter.Indications |> Array.tryHead }
144
+ |> PrescriptionContext .getRules
146
145
|> fun ( pr , _ ) ->
147
- { pr with PrescriptionResult .Filter.DoseType = pr.Filter.DoseTypes |> Array.tryHead }
148
- |> PrescriptionResult .getRules
146
+ { pr with PrescriptionContext .Filter.DoseType = pr.Filter.DoseTypes |> Array.tryHead }
147
+ |> PrescriptionContext .getRules
149
148
|> snd
150
149
|> Array.head
151
150
@@ -154,19 +153,16 @@ tpvRule.DoseRule.DoseLimits
154
153
|> Array.map _. Component
155
154
156
155
let norRule =
157
- { pr with PrescriptionResult .Filter.Generic = Some " noradrenaline" }
158
- |> PrescriptionResult .getRules
156
+ { pr with PrescriptionContext .Filter.Generic = Some " noradrenaline" }
157
+ |> PrescriptionContext .getRules
159
158
|> fun ( pr , _ ) ->
160
- { pr with PrescriptionResult .Filter.Indication = pr.Filter.Indications |> Array.tryHead }
161
- |> PrescriptionResult .getRules
159
+ { pr with PrescriptionContext .Filter.Indication = pr.Filter.Indications |> Array.tryHead }
160
+ |> PrescriptionContext .getRules
162
161
|> fun ( pr , _ ) ->
163
- { pr with PrescriptionResult .Filter.DoseType = pr.Filter.DoseTypes |> Array.tryHead }
164
- |> PrescriptionResult .getRules
162
+ { pr with PrescriptionContext .Filter.DoseType = pr.Filter.DoseTypes |> Array.tryHead }
163
+ |> PrescriptionContext .getRules
165
164
|> snd
166
165
|> Array.head
167
166
168
167
norRule.DoseRule.DoseLimits
169
- |> Array.map _. Component
170
-
171
-
172
- [| " a" ; " b" ; " c" |] = [| " a" ; " b" ; " c" |]
168
+ |> Array.map _. Component
0 commit comments