diff --git a/Dockerfile b/Dockerfile index 99ca9dc..e5fdce4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,6 +39,7 @@ COPY --from=server-build /workspace/deploy /app COPY --from=client-build /workspace/deploy /app/public COPY src/Server/data /app/data +# setting this env variable disables file logging ENV GENPRES_PROD="" WORKDIR /app EXPOSE 8085 diff --git a/TODO.md b/TODO.md index e7c5963..d32e5e0 100644 --- a/TODO.md +++ b/TODO.md @@ -12,7 +12,7 @@ * ~~Add cont med preparation popus~~ * Add ventilation tab * ~~Responsive design for tablets and smartphones~~ -* Add navigation to allow opening with age and weight in url +* ~~Add navigation to allow opening with age and weight in url~~ * Sliders for mobile input * Add protocols tab * Allow for preparation calculation with multiple concentrations @@ -39,3 +39,10 @@ * Make tables sortable * ~~Automate setting of build version~~ * Refactor navbar, use burger and menu + +## Ideas +* ~~Disable MinIncrMax to ValueSet~~ +* Apply constraints, first Increment then ValueSet instead +* Remove exception throwing from Solver when too many values or expensive calculation + + diff --git a/src/Informedica.GenOrder.Lib/Order.fs b/src/Informedica.GenOrder.Lib/Order.fs index 32d862a..14e5c49 100644 --- a/src/Informedica.GenOrder.Lib/Order.fs +++ b/src/Informedica.GenOrder.Lib/Order.fs @@ -907,7 +907,7 @@ module Order = (c.OrderableQuantity |> Quantity.toOrdVar |> OrderVariable.getVar).Values ) ] - |> List.choose (Variable.ValueRange.getIncr) + |> List.choose Variable.ValueRange.getIncr |> List.minBy (fun i -> i |> Variable.ValueRange.Increment.toValueUnit @@ -1438,27 +1438,38 @@ module Order = let solveOrder printErr logger = solve false printErr logger - let minIncrMaxToValues (ord: Order) = - let mutable flag = false - let ovars = - ord - |> toOrdVars - |> List.map (fun ovar -> - if flag || ovar.Constraints.Incr |> Option.isNone then ovar - else - flag <- true - let n = - match ord.Prescription with - | Continuous -> 100 - | Discontinuous _ -> 50 - | Timed _ -> 5 - - ovar - |> OrderVariable.minIncrMaxToValues n - ) + let minIncrMaxToValues logger (ord: Order) = + let rec loop runAgain ord = + if not runAgain then ord + else + let mutable flag = false + let ovars = + ord + |> toOrdVars + |> List.map (fun ovar -> + if flag || + ovar.Constraints.Incr |> Option.isNone || + ovar.Variable.Values |> ValueRange.isMinIncrMax |> not then ovar + else + flag <- true + let n = + match ord.Prescription with + | Continuous -> 100 + | Discontinuous _ -> 50 + | Timed _ -> 5 + + ovar + |> OrderVariable.minIncrMaxToValues n + ) + + ord + |> fromOrdVars ovars + |> solveOrder false logger + |> function + | Ok ord -> loop flag ord + | Error _ -> ord - ord - |> fromOrdVars ovars + loop true ord // |> fun ord -> // let s = ord |> toString |> String.concat "\n" // printfn $"min incr max to values:\n{s}" diff --git a/src/Informedica.GenSolver.Lib/Solver.fs b/src/Informedica.GenSolver.Lib/Solver.fs index 9971e7f..8c84761 100644 --- a/src/Informedica.GenSolver.Lib/Solver.fs +++ b/src/Informedica.GenSolver.Lib/Solver.fs @@ -60,8 +60,8 @@ module Solver = /// a list of replaced `Equation` and a list /// of unchanged `Equation` /// - /// The list of `Variable` to replace - /// The list of `Equation` to replace in + /// The list of `Variable` to replace + /// The list of `Equation` to replace in let replace vars eqs = let rpl, rst = eqs diff --git a/src/Informedica.GenSolver.Lib/Variable.fs b/src/Informedica.GenSolver.Lib/Variable.fs index de0dae1..3203524 100644 --- a/src/Informedica.GenSolver.Lib/Variable.fs +++ b/src/Informedica.GenSolver.Lib/Variable.fs @@ -3196,7 +3196,8 @@ module Variable = /// Calculate a ValueSet for a Variable if the Value of the /// Variable is a MinIncrMax /// - /// + /// The variable to change min incr max to a ValueSet + /// Prune the ValueSet to n /// A Variable with a ValueSet if this can be calculated let minIncrMaxToValues n var = if var |> isMinIncrMax |> not then var diff --git a/src/Server/ScenarioResult.fs b/src/Server/ScenarioResult.fs index 6e8d5bd..bf0c167 100644 --- a/src/Server/ScenarioResult.fs +++ b/src/Server/ScenarioResult.fs @@ -342,11 +342,15 @@ Scenarios: {sc.Scenarios |> Array.length} let calcMinIncrMaxToValues (ord : Order) = + if Env.getItem "GENPRES_PROD" |> Option.isNone then + let path = $"{__SOURCE_DIRECTORY__}/log.txt" + OrderLogger.logger.Start (Some path) OrderLogger.Level.Informative + try ord |> mapFromOrder |> Order.Dto.fromDto - |> Order.minIncrMaxToValues + |> Order.minIncrMaxToValues OrderLogger.logger.Logger |> Order.Dto.toDto |> mapToOrder |> Ok