Skip to content

Commit

Permalink
feat: dose with selected substance
Browse files Browse the repository at this point in the history
  • Loading branch information
Casper Bollen authored and Casper Bollen committed Mar 7, 2024
1 parent 4b69d4b commit 9902360
Show file tree
Hide file tree
Showing 4 changed files with 167 additions and 86 deletions.
19 changes: 13 additions & 6 deletions src/Client/App.fs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module private Elmish =
Scenarios: Deferred<ScenarioResult>
SelectedScenarioOrder : (Scenario * Order) option
CalculatedOrder : Deferred<(bool * Order) option>
SelectedSubstance : string option
Formulary: Deferred<Formulary>
Parenteralia: Deferred<Parenteralia>
Localization : Deferred<string [][]>
Expand All @@ -52,7 +53,7 @@ module private Elmish =
| UpdateScenarios of ScenarioResult
| SelectOrder of (Scenario * Order option)
| UpdateScenarioOrder
| LoadOrder of Order
| LoadOrder of string option * Order
| CalculateOrder of AsyncOperationStatus<Result<Order, string>>
| LoadFormulary of AsyncOperationStatus<Result<Formulary, string>>
| UpdateFormulary of Formulary
Expand Down Expand Up @@ -195,6 +196,7 @@ module private Elmish =
Products = HasNotStartedYet
Scenarios = HasNotStartedYet
CalculatedOrder = HasNotStartedYet
SelectedSubstance = None
SelectedScenarioOrder = None
Formulary = HasNotStartedYet
Parenteralia = HasNotStartedYet
Expand Down Expand Up @@ -517,21 +519,24 @@ module private Elmish =
},
Cmd.ofMsg (CalculateOrder Started)

| LoadOrder o ->
| LoadOrder (s, o) ->
let load =
async {
let! order = o |> serverApi.solveOrder
return Finished order |> CalculateOrder
}

{ state with CalculatedOrder = InProgress }, Cmd.fromAsync load
{ state with SelectedSubstance = s; CalculatedOrder = InProgress }, Cmd.fromAsync load

| CalculateOrder Started ->
match state.CalculatedOrder with
| Resolved (Some order) ->
let load =
async {
let! order = order |> snd |> serverApi.calcMinIncrMax
let! order =
order
|> snd
|> serverApi.calcMinIncrMax
return Finished order |> CalculateOrder
}
{ state with CalculatedOrder = InProgress }, Cmd.fromAsync load
Expand All @@ -551,7 +556,9 @@ module private Elmish =
|> Option.map (fun o ->
match state.SelectedScenarioOrder with
| None -> false, o
| Some (sc, _) -> sc.UseAdjust, o
| Some (sc, _) ->

sc.UseAdjust, o
)
|> Resolved
// show only the calculated order scenario
Expand Down Expand Up @@ -745,7 +752,7 @@ let View () =
parenteralia = state.Parenteralia
updateParenteralia = UpdateParenteralia >> dispatch
selectOrder = SelectOrder >> dispatch
order = state.CalculatedOrder
order = state.CalculatedOrder |> Deferred.map (Option.map (fun (b, o) -> b, state.SelectedSubstance, o))
loadOrder = LoadOrder >> dispatch
updateScenarioOrder = (fun () -> UpdateScenarioOrder |> dispatch)
page = state.Page
Expand Down
4 changes: 2 additions & 2 deletions src/Client/Pages/GenPres.fs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ module GenPres =
scenarioResult: Deferred<ScenarioResult>
updateScenario : ScenarioResult -> unit
selectOrder : (Scenario * Order option) -> unit
order : Deferred<(bool * Order) option>
loadOrder : Order -> unit
order: Deferred<(bool * string option * Order) option>
loadOrder: (string option * Order) -> unit
updateScenarioOrder : unit -> unit
formulary: Deferred<Formulary>
updateFormulary : Formulary -> unit
Expand Down
Loading

0 comments on commit 9902360

Please sign in to comment.