Skip to content

Commit 469cbbb

Browse files
Casper BollenCasper Bollen
Casper Bollen
authored and
Casper Bollen
committed
feat: added row selection of treatment plan
1 parent 973b386 commit 469cbbb

File tree

19 files changed

+118
-197
lines changed

19 files changed

+118
-197
lines changed

src/Client/Components/ResponsiveTable.fs

+11
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ module ResponsiveTable =
116116
rowCreate : string[] -> obj
117117
height : string
118118
onRowClick : string -> unit
119+
selectedRows : string []
120+
onSelectChange: string [] -> unit
119121
|}) =
120122
let state, setState = React.useState [||]
121123

@@ -157,6 +159,12 @@ module ResponsiveTable =
157159
fun pars ->
158160
pars?id |> string |> props.onRowClick
159161

162+
let onSelectionChange =
163+
fun pars ->
164+
(pars |> string).Split ","
165+
|> Array.filter (String.IsNullOrWhiteSpace >> not)
166+
|> props.onSelectChange
167+
160168
let rows =
161169
props.rows
162170
|> Array.filter (fun r ->
@@ -199,6 +207,9 @@ module ResponsiveTable =
199207
</Box>
200208
<div style={ {| height =props.height; width = "100%" |} }>
201209
<DataGrid
210+
checkboxSelection
211+
rowSelectionModel = {props.selectedRows}
212+
onRowSelectionModelChange = {onSelectionChange}
202213
rows={rows}
203214
slots={ {| toolbar = toolbar |} }
204215
onRowClick={onRowClick}

src/Client/Views/ContinuousMeds.fs

+2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ module ContinuousMeds =
8888
rowCreate = rowCreate
8989
height = "70vh"
9090
onRowClick = ignore
91+
selectedRows = [||]
92+
onSelectChange = ignore
9193
|})
9294
}
9395
</Box>

src/Client/Views/EmergencyList.fs

+2
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ module EmergencyList =
111111
rowCreate = rowCreate
112112
height = "70vh"
113113
onRowClick = ignore
114+
selectedRows = [||]
115+
onSelectChange = ignore
114116
|})
115117

116118

src/Client/Views/Nutrition.fs

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ module Nutrion =
7272
rowCreate = rowCreate
7373
height = "50vh"
7474
onRowClick = ignore
75+
selectedRows = [||]
76+
onSelectChange = ignore
7577
|})
7678
}
7779
</Box>

src/Client/Views/TreatmentPlan.fs

+30-1
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,41 @@ module TreatmentPlan =
197197
setModalOpen true
198198
| _ -> ()
199199

200+
let filterOrders ids =
201+
match props.treatmentPlan with
202+
| Resolved tp ->
203+
{ tp with
204+
Filtered =
205+
if ids |> Array.isEmpty then [||]
206+
else
207+
tp.Scenarios
208+
|> Array.filter (fun os ->
209+
os.Order
210+
|> OrderState.getOrder
211+
|> _.Id
212+
|> fun id -> ids |> Array.exists ((=) id)
213+
)
214+
}
215+
|> props.updateTreatmentPlan
216+
| _ -> ()
217+
218+
let selectedRows =
219+
match props.treatmentPlan with
220+
| Resolved tp ->
221+
tp.Filtered
222+
|> Array.map _.Order
223+
|> Array.map OrderState.getOrder
224+
|> Array.map _.Id
225+
| _ -> [||]
226+
200227
let updatePrescriptionResult (pr : PrescriptionContext) =
201228
match props.treatmentPlan with
202229
| Resolved tp ->
203230
match pr.Scenarios |> Array.tryExactlyOne with
204231
| None -> ()
205232
| Some os ->
206233
{ tp with
207-
Selected = os |> Some
234+
Selected = Some os
208235
Scenarios =
209236
tp.Scenarios
210237
|> Array.map (fun sc ->
@@ -229,6 +256,8 @@ module TreatmentPlan =
229256
rowCreate = rowCreate
230257
height = "50vh"
231258
onRowClick = selectOrder
259+
selectedRows = selectedRows
260+
onSelectChange = filterOrders
232261
|})
233262
}
234263
<Modal open={modalOpen} onClose={handleModalClose} >

src/Informedica.GenForm.Lib/Scripts/Check.fsx

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ Environment.SetEnvironmentVariable("GENPRES_PROD", "1")
1010
#load "../Types.fs"
1111
#load "../Utils.fs"
1212
#load "../Mapping.fs"
13-
#load "../VenousAccess.fs"
1413
#load "../Patient.fs"
1514
#load "../LimitTarget.fs"
1615
#load "../DoseType.fs"

src/Informedica.GenForm.Lib/Scripts/DoseRule.fsx

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Environment.SetEnvironmentVariable("GENPRES_URL_ID", dataUrlId)
1313
#load "../Types.fs"
1414
#load "../Utils.fs"
1515
#load "../Mapping.fs"
16-
#load "../VenousAccess.fs"
1716
#load "../Mapping.fs"
1817
#load "../Patient.fs"
1918
#load "../LimitTarget.fs"

src/Informedica.GenForm.Lib/Scripts/RenalRule.fsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ Environment.SetEnvironmentVariable("GENPRES_URL_ID", dataUrlId)
1212
#load "../Types.fs"
1313
#load "../Utils.fs"
1414
#load "../Mapping.fs"
15-
#load "../VenousAccess.fs"
1615
#load "../Mapping.fs"
1716
#load "../Patient.fs"
1817
#load "../LimitTarget.fs"
@@ -39,7 +38,4 @@ RenalRule.get ()
3938

4039
Web.getDataFromSheet dataUrlId "RenalRules"
4140

42-
Web.GoogleSheets.createUrl "RenalRules" (Web.getDataUrlIdGenPres ())
43-
44-
45-
41+
Web.GoogleSheets.createUrl "RenalRules" (Web.getDataUrlIdGenPres ())

src/Informedica.GenForm.Lib/Scripts/Scripts.fsx

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Environment.SetEnvironmentVariable("GENPRES_URL_ID", dataUrlId)
1313
#load "../Types.fs"
1414
#load "../Utils.fs"
1515
#load "../Mapping.fs"
16-
#load "../VenousAccess.fs"
1716
#load "../Patient.fs"
1817
#load "../LimitTarget.fs"
1918
#load "../DoseType.fs"

src/Informedica.GenForm.Lib/Scripts/SolutionRule.fsx

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ Environment.SetEnvironmentVariable("GENPRES_URL_ID", dataUrlId)
1212
#load "../Types.fs"
1313
#load "../Utils.fs"
1414
#load "../Mapping.fs"
15-
#load "../VenousAccess.fs"
1615
#load "../Patient.fs"
1716
#load "../LimitTarget.fs"
1817
#load "../DoseType.fs"

src/Informedica.GenForm.Lib/Scripts/Update.fsx

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#load "../Types.fs"
66
#load "../Utils.fs"
77
#load "../Mapping.fs"
8-
#load "../VenousAccess.fs"
98
#load "../Patient.fs"
109
#load "../LimitTarget.fs"
1110
#load "../DoseType.fs"

src/Informedica.GenOrder.Lib/Api.fs

+11-1
Original file line numberDiff line numberDiff line change
@@ -506,11 +506,21 @@ module Api =
506506
| i, Ok (ord, pr) ->
507507
OrderScenario.create i pr ord
508508
|> Some
509-
| _, Error (_, _, errs) ->
509+
| _, Error (ord, prctx, errs) ->
510510
errs
511511
|> List.map string
512512
|> String.concat "\n"
513513
|> writeErrorMessage
514+
515+
ord
516+
|> Order.toString
517+
|> String.concat "\n"
518+
|> writeWarningMessage
519+
520+
prctx
521+
|> sprintf "%A"
522+
|> writeWarningMessage
523+
514524
None
515525
)
516526

src/Informedica.GenOrder.Lib/Scripts/Scenarios.fsx

+45-49
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,27 @@ System.Environment.SetEnvironmentVariable("GENPRES_URL_ID", "1IZ3sbmrM4W4OuSYELR
88

99
open MathNet.Numerics
1010
open Informedica.Utils.Lib
11-
open Informedica.Utils.Lib.BCL
12-
open Informedica.Utils.Lib.BCL
13-
open Informedica.GenForm.Lib
1411
open Informedica.GenUnits.Lib
15-
open Informedica.GenSolver.Lib
12+
open Informedica.GenForm.Lib
1613
open Informedica.GenOrder.Lib
17-
open Informedica.GenSolver.Lib.Variable.Operators
14+
1815

1916
// TODO: could be used to precalc all possible
2017
// prescriptions for a patient
21-
let createScenarios (pr: PrescriptionResult) =
18+
let createScenarios (pr: PrescriptionContext) =
2219
let getRules filter =
23-
{ pr with Filter = filter } |> PrescriptionResult.getRules
20+
{ pr with Filter = filter } |> PrescriptionContext.getRules
2421

2522
let print pr =
2623
let g = pr.Filter.Generic
2724
let i = pr.Filter.Indication
2825
let r = pr.Filter.Route
2926
let d = pr.Filter.DoseType
30-
printfn $"=== no evalution of {g} {i} {r} {d} ==="
27+
printfn $"=== no evaluation of {g} {i} {r} {d} ==="
3128
pr
3229

3330
let eval pr s =
34-
printfn $"evaluting {s}..."
31+
printfn $"evaluating {s}"
3532
try
3633
let pr = pr |> Api.evaluate
3734

@@ -47,42 +44,44 @@ let createScenarios (pr: PrescriptionResult) =
4744
let pr, rules = { pr.Filter with Generic = Some g } |> getRules
4845

4946
if rules |> Array.isEmpty |> not then
50-
$"evaluting {g}..." |> eval pr
47+
g |> eval pr
5148

5249
else
5350
for i in pr.Filter.Indications do
5451
let pr, rules = { pr.Filter with Indication = Some i } |> getRules
5552

5653
if rules |> Array.isEmpty |> not then
57-
$"evaluting {g} {i}..." |> eval pr
54+
$"{g}, {i}" |> eval pr
5855

5956
else
6057
for r in pr.Filter.Routes do
6158
let pr, rules = { pr.Filter with Route = Some r } |> getRules
6259

6360
if rules |> Array.isEmpty |> not then
64-
$"evaluting {g} {i} {r}..." |> eval pr
61+
$"{g}, {i}, {r}" |> eval pr
6562

6663
else
6764
for d in pr.Filter.DoseTypes do
6865
let pr, rules = { pr.Filter with DoseType = Some d } |> getRules
6966

7067
if rules |> Array.isEmpty |> not then
71-
$"evaluting {g} {i} {r} {d}..." |> eval pr
68+
$"{g}, {i}, {r}, {d}" |> eval pr
7269

7370
else pr |> print
7471
]
7572

7673

77-
78-
let pr = Patient.infant |> PrescriptionResult.create
74+
let pr =
75+
{ Patient.infant with
76+
Weight = Some ([| 10N |] |> ValueUnit.withUnit Units.Weight.kiloGram)
77+
}|> PrescriptionContext.create
7978

8079

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
8382

8483
let scenarios =
85-
pr |> createScenarios
84+
pr |> createScenarios |> ignore
8685

8786

8887
scenarios
@@ -92,14 +91,14 @@ scenarios
9291
|> List.length
9392

9493
// cidofovir
95-
{ pr with PrescriptionResult.Filter.Generic = Some "cidofovir" }
96-
|> PrescriptionResult.getRules
94+
{ pr with PrescriptionContext.Filter.Generic = Some "cidofovir" }
95+
|> PrescriptionContext.getRules
9796
|> 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
10099
|> 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
103102
|> snd
104103
|> Array.tryHead
105104
|> Option.map DrugOrder.fromRule
@@ -111,17 +110,17 @@ scenarios
111110

112111

113112
// TPV
114-
{ pr with PrescriptionResult.Filter.Indication = Some "TPV" }
115-
|> PrescriptionResult.getRules
113+
{ pr with PrescriptionContext.Filter.Indication = Some "TPV" }
114+
|> PrescriptionContext.getRules
116115
|> 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
119118
|> 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
122121
|> 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
125124
|> snd
126125
|> Array.tryHead
127126
|> Option.map DrugOrder.fromRule
@@ -133,19 +132,19 @@ scenarios
133132

134133

135134
{ pr with
136-
PrescriptionResult.Filter.Generic = Some "natriumfosfaat" }
135+
PrescriptionContext.Filter.Generic = Some "natriumfosfaat" }
137136
|> Api.evaluate
138137

139138

140139
let tpvRule =
141-
{ pr with PrescriptionResult.Filter.Indication = Some "TPV" }
142-
|> PrescriptionResult.getRules
140+
{ pr with PrescriptionContext.Filter.Indication = Some "TPV" }
141+
|> PrescriptionContext.getRules
143142
|> 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
146145
|> 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
149148
|> snd
150149
|> Array.head
151150

@@ -154,19 +153,16 @@ tpvRule.DoseRule.DoseLimits
154153
|> Array.map _.Component
155154

156155
let norRule =
157-
{ pr with PrescriptionResult.Filter.Generic = Some "noradrenaline" }
158-
|> PrescriptionResult.getRules
156+
{ pr with PrescriptionContext.Filter.Generic = Some "noradrenaline" }
157+
|> PrescriptionContext.getRules
159158
|> 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
162161
|> 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
165164
|> snd
166165
|> Array.head
167166

168167
norRule.DoseRule.DoseLimits
169-
|> Array.map _.Component
170-
171-
172-
[| "a"; "b"; "c" |] = [| "a"; "b"; "c" |]
168+
|> Array.map _.Component

src/Informedica.GenSolver.Lib/Variable.fs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1691,7 +1691,7 @@ module Variable =
16911691
let incr = incrOpt |> Option.map (Increment.toString false) |> Option.defaultValue ""
16921692
let max = maxOpt |> Option.map (Maximum.toString false) |> Option.defaultValue ""
16931693
let vs = vs |> ValueUnit.toStringDutchShort
1694-
printfn $"filter with %s{min}, %s{incr}, %s{max} and %s{vs} gives empty set"
1694+
writeWarningMessage $"filter with min = '%s{min}', incr = '%s{incr}', max = '%s{max}' and vs = '%s{vs}' gives empty set"
16951695
raise e
16961696

16971697

0 commit comments

Comments
 (0)