From 36be98a068135ead7177342809fb92138533d99a Mon Sep 17 00:00:00 2001 From: Casper Bollen Date: Fri, 10 Nov 2023 21:03:28 +0100 Subject: [PATCH] fix: dose unit for shape, need to add unit to ordervariable --- src/Informedica.GenForm.Lib/DoseRule.fs | 2 +- src/Informedica.GenForm.Lib/Mapping.fs | 8 ++++---- src/Informedica.GenForm.Lib/Product.fs | 10 +++++----- src/Informedica.GenForm.Lib/SolutionRule.fs | 2 +- src/Informedica.GenForm.Lib/Types.fs | 11 +++++++++++ src/Informedica.GenForm.Lib/Utils.fs | 4 ++-- src/Informedica.GenOrder.Lib/DrugOrder.fs | 2 ++ src/Informedica.GenOrder.Lib/Order.fs | 2 +- src/Informedica.GenOrder.Lib/Scripts/Api2.fsx | 13 +++++++++---- 9 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/Informedica.GenForm.Lib/DoseRule.fs b/src/Informedica.GenForm.Lib/DoseRule.fs index 32b6424..3e999c4 100644 --- a/src/Informedica.GenForm.Lib/DoseRule.fs +++ b/src/Informedica.GenForm.Lib/DoseRule.fs @@ -352,7 +352,7 @@ module DoseRule = let private get_ () = - Web.getDataFromSheet Web.dataUrlId2 "DoseRules" + Web.getDataFromSheet Web.dataUrlIdGenPres "DoseRules" |> fun data -> let getColumn = data diff --git a/src/Informedica.GenForm.Lib/Mapping.fs b/src/Informedica.GenForm.Lib/Mapping.fs index b3cd180..aafce11 100644 --- a/src/Informedica.GenForm.Lib/Mapping.fs +++ b/src/Informedica.GenForm.Lib/Mapping.fs @@ -8,7 +8,7 @@ module Mapping = let routeMapping = - Web.getDataFromSheet Web.dataUrlId2 "Routes" + Web.getDataFromSheet Web.dataUrlIdGenPres "Routes" |> fun data -> let getColumn = data @@ -27,7 +27,7 @@ module Mapping = ) let unitMapping = - Web.getDataFromSheet Web.dataUrlId2 "Units" + Web.getDataFromSheet Web.dataUrlIdGenPres "Units" |> fun data -> let getColumn = data @@ -67,7 +67,7 @@ module Mapping = let mappingRouteShape = - Web.getDataFromSheet Web.dataUrlId2 "ShapeRoute" + Web.getDataFromSheet Web.dataUrlIdGenPres "ShapeRoute" |> fun data -> let inline getColumn get = data @@ -84,7 +84,7 @@ module Mapping = Route = getStr "Route" Shape = getStr "Shape" Unit = getStr "Unit" - DoseUnit = getStr "Unit" + DoseUnit = getStr "DoseUnit" MinDoseQty = getFlt "MinDoseQty" MaxDoseQty = getFlt "MaxDoseQty" Timed = getStr "Timed" |> String.equalsCapInsens "true" diff --git a/src/Informedica.GenForm.Lib/Product.fs b/src/Informedica.GenForm.Lib/Product.fs index 6ccf5c2..06ccecf 100644 --- a/src/Informedica.GenForm.Lib/Product.fs +++ b/src/Informedica.GenForm.Lib/Product.fs @@ -52,7 +52,7 @@ module Product = let private get_ () = - Web.getDataFromSheet Web.dataUrlId2 "ShapeRoute" + Web.getDataFromSheet Web.dataUrlIdGenPres "ShapeRoute" |> fun data -> let getColumn = @@ -102,7 +102,7 @@ module Product = // ExpansionVol // Diluents let private get_ () = - Web.getDataFromSheet Web.dataUrlId2 "Reconstitution" + Web.getDataFromSheet Web.dataUrlIdGenPres "Reconstitution" |> fun data -> let getColumn = @@ -167,7 +167,7 @@ module Product = module Parenteral = let private get_ () = - Web.getDataFromSheet Web.dataUrlId2 "ParentMeds" + Web.getDataFromSheet Web.dataUrlIdGenPres "ParentMeds" |> fun data -> let getColumn = data @@ -249,7 +249,7 @@ module Product = let isSol = ShapeRoute.isSolution (ShapeRoute.get ()) fun () -> - Web.getDataFromSheet Web.dataUrlId2 "Formulary" + Web.getDataFromSheet Web.dataUrlIdGenPres "Formulary" |> fun data -> let getColumn = data @@ -364,7 +364,7 @@ module Product = ) Divisible = // TODO: need to map this to a config setting - if gp.Shape |> String.contains "DRUPPEL" then Some 20N + if gp.Shape |> String.containsCapsInsens "druppel" then Some 20N else if isSol gp.Shape then 10N |> Some else Some 1N diff --git a/src/Informedica.GenForm.Lib/SolutionRule.fs b/src/Informedica.GenForm.Lib/SolutionRule.fs index 9f7cc0c..7edc887 100644 --- a/src/Informedica.GenForm.Lib/SolutionRule.fs +++ b/src/Informedica.GenForm.Lib/SolutionRule.fs @@ -34,7 +34,7 @@ module SolutionRule = let private get_ () = - Web.getDataFromSheet Web.dataUrlId2 "SolutionRules" + Web.getDataFromSheet Web.dataUrlIdGenPres "SolutionRules" |> fun data -> let getColumn = data diff --git a/src/Informedica.GenForm.Lib/Types.fs b/src/Informedica.GenForm.Lib/Types.fs index 3547eb3..c890efd 100644 --- a/src/Informedica.GenForm.Lib/Types.fs +++ b/src/Informedica.GenForm.Lib/Types.fs @@ -7,16 +7,27 @@ module Types = open MathNet.Numerics + /// Associate a Route and a Shape + /// setting default values for the other fields type RouteShape = { + /// The Route Route : string + /// The pharmacological Shape Shape : string + /// The Unit of the Shape Unit : string + /// The Dose Unit to use for Dose Limits DoseUnit : string + /// The minimum Dose quantity MinDoseQty : float option + /// The maximum Dose quantity MaxDoseQty : float option + /// Whether a Dose runs over a Time Timed : bool + /// Whether the Shape needs to be reconstituted Reconstitute : bool + /// Whether the Shape is a solution IsSolution : bool } diff --git a/src/Informedica.GenForm.Lib/Utils.fs b/src/Informedica.GenForm.Lib/Utils.fs index 274ef52..958ff7a 100644 --- a/src/Informedica.GenForm.Lib/Utils.fs +++ b/src/Informedica.GenForm.Lib/Utils.fs @@ -17,10 +17,10 @@ module Utils = //https://docs.google.com/spreadsheets/d/1nny8rn9zWtP8TMawB3WeNWhl5d4ofbWKbGzGqKTd49g/edit?usp=sharing - let [] dataUrlId = "1nny8rn9zWtP8TMawB3WeNWhl5d4ofbWKbGzGqKTd49g" + let [] dataUrlIdConstraints = "1nny8rn9zWtP8TMawB3WeNWhl5d4ofbWKbGzGqKTd49g" //https://docs.google.com/spreadsheets/d/1AEVYnqjAbVniu3VuczeoYvMu3RRBu930INhr3QzSDYQ/edit?usp=sharing - let [] dataUrlId2 = "1AEVYnqjAbVniu3VuczeoYvMu3RRBu930INhr3QzSDYQ" + let [] dataUrlIdGenPres = "1AEVYnqjAbVniu3VuczeoYvMu3RRBu930INhr3QzSDYQ" let getDataFromSheet urlId sheet = diff --git a/src/Informedica.GenOrder.Lib/DrugOrder.fs b/src/Informedica.GenOrder.Lib/DrugOrder.fs index 69bb47e..17f9b33 100644 --- a/src/Informedica.GenOrder.Lib/DrugOrder.fs +++ b/src/Informedica.GenOrder.Lib/DrugOrder.fs @@ -262,6 +262,7 @@ module DrugOrder = let cdto = Order.Orderable.Component.Dto.dto d.Id d.Name p.Name p.Shape cdto.ComponentQuantity.Constraints.ValsOpt <- p.Quantities |> createValueUnitDto ou + if p.Divisible.IsSome then cdto.OrderableQuantity.Constraints.IncrOpt <- 1N / p.Divisible.Value |> createSingleValueUnitDto ou if d.Products |> List.length = 1 then @@ -270,6 +271,7 @@ module DrugOrder = cdto.OrderableConcentration.Constraints.ValsOpt <- 1N |> createSingleValueUnitDto cu if p.Divisible.IsSome then + orbDto.Dose.Quantity.Constraints.IncrOpt <- 1N / p.Divisible.Value |> createSingleValueUnitDto ou cdto.Dose.Quantity.Constraints.IncrOpt <- 1N / p.Divisible.Value |> createSingleValueUnitDto ou cdto.Items <- [ diff --git a/src/Informedica.GenOrder.Lib/Order.fs b/src/Informedica.GenOrder.Lib/Order.fs index ee183f3..2249a39 100644 --- a/src/Informedica.GenOrder.Lib/Order.fs +++ b/src/Informedica.GenOrder.Lib/Order.fs @@ -1792,7 +1792,7 @@ module Order = let orbQty = ord.Orderable.OrderableQuantity |> Quantity.toOrdVar // the increments used to increase let incrs u = - [ 1N/10N; 1N/2N; 1N; 5N; 10N; 20N ] + [ 1N/20N; 1N/10N; 1N/2N; 1N; 5N; 10N; 20N ] |> List.map (ValueUnit.singleWithUnit u) |> List.map ValueRange.Increment.create // only increase incr for volume units diff --git a/src/Informedica.GenOrder.Lib/Scripts/Api2.fsx b/src/Informedica.GenOrder.Lib/Scripts/Api2.fsx index 929a491..6a6262c 100644 --- a/src/Informedica.GenOrder.Lib/Scripts/Api2.fsx +++ b/src/Informedica.GenOrder.Lib/Scripts/Api2.fsx @@ -131,20 +131,25 @@ let createScenarios () = |> run n ) +open Informedica.GenForm.Lib + +Mapping.mappingRouteShape + startLogger () stopLogger () + Patient.teenager |> fun p -> { p with VenousAccess = CVL } |> PrescriptionRule.get //|> Array.filter (fun pr -> pr.DoseRule.Products |> Array.isEmpty |> not) |> Array.filter (fun pr -> - pr.DoseRule.Generic = "trimethoprim/sulfamethoxazol" && - pr.DoseRule.Route = "iv" //&& + pr.DoseRule.Generic = "tramadol" && + pr.DoseRule.Route = "or" //&& // pr.DoseRule.Indication |> String.startsWith "vassopressie" ) -|> Array.item 0 //|> Api.evaluate (OrderLogger.logger.Logger) -|> fun pr -> pr |> Api.createDrugOrder (pr.SolutionRules[0] |> Some) //|> printfn "%A" +|> Array.item 1 //|> Api.evaluate (OrderLogger.logger.Logger) +|> fun pr -> pr |> Api.createDrugOrder None// (pr.SolutionRules[0] |> Some) //|> printfn "%A" |> DrugOrder.toOrderDto |> Order.Dto.fromDto //|> Order.toString |> List.iter (printfn "%s") |> Order.applyConstraints |> Order.toString |> List.iter (printfn "%s")