Skip to content

Commit

Permalink
refact: optional string in genform as option
Browse files Browse the repository at this point in the history
  • Loading branch information
Casper Bollen authored and Casper Bollen committed Feb 20, 2024
1 parent e6087a0 commit 029f0bc
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 21 deletions.
4 changes: 3 additions & 1 deletion src/Informedica.GenForm.Lib/DoseRule.fs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,9 @@ module DoseRule =
Indication = r.Indication
Generic = r.Generic
Shape = r.Shape
Brand = r.Brand
Brand =
if r.Brand |> String.isNullOrWhiteSpace then None
else r.Brand |> Some
GPKs = r.GPKs
Route = r.Route
ScheduleText = r.ScheduleText
Expand Down
27 changes: 19 additions & 8 deletions src/Informedica.GenForm.Lib/SolutionRule.fs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,13 @@ module SolutionRule =
let du = r.Unit |> Units.fromString
{
Generic = r.Generic
Shape = r.Shape
Shape =
if r.Shape |> String.isNullOrWhiteSpace then None
else r.Shape |> Some
Route = r.Route
Department = r.Department
Department =
if r.Department |> String.isNullOrWhiteSpace then None
else r.Department |> Some
Location =
if r.CVL = "x" then CVL
else
Expand Down Expand Up @@ -155,7 +159,11 @@ module SolutionRule =
Product.get ()
|> Array.filter (fun p ->
p.Generic = sr.Generic &&
p.Shape = sr.Shape
sr.Shape
|> Option.map (fun s ->
s |> String.equalsCapInsens p.Shape
)
|> Option.defaultValue true
)

}
Expand All @@ -182,18 +190,17 @@ module SolutionRule =
let eqs a (b : string) =
a
|> Option.map (fun x ->
b |> String.isNullOrWhiteSpace ||
x = b
x |> String.equalsCapInsens b
)
|> Option.defaultValue true

[|
fun (sr : SolutionRule) -> sr.Generic |> eqs filter.Generic
fun (sr : SolutionRule) ->
PatientCategory.checkAgeWeightMinMax filter.Patient.Age filter.Patient.Weight sr.Age sr.Weight
fun (sr : SolutionRule) -> sr.Shape |> eqs filter.Shape
fun (sr : SolutionRule) -> sr.Shape |> Option.map (eqs filter.Shape) |> Option.defaultValue true
fun (sr : SolutionRule) -> filter.Route |> Option.isNone || sr.Route |> Mapping.eqsRoute filter.Route
fun (sr : SolutionRule) -> sr.Department |> eqs filter.Patient.Department
fun (sr : SolutionRule) -> sr.Department |> Option.map (eqs filter.Patient.Department) |> Option.defaultValue true
fun (sr : SolutionRule) ->
match filter.DoseType, sr.DoseType with
| AnyDoseType, _
Expand Down Expand Up @@ -222,8 +229,11 @@ module SolutionRule =
/// Get all the distinct Generics from the given SolutionRules.
let generics = getMember _.Generic

let shapes = getMember _.Shape
let shapes =
getMember _.Shape
>> Array.choose id


let routes = getMember _.Route


Expand Down Expand Up @@ -371,6 +381,7 @@ module SolutionRule =
else
(r, r.rules |> Array.groupBy _.Department)
||> Array.fold (fun acc (dep, rs) ->
let dep = dep |> Option.defaultValue ""
{| acc with
md = acc.md + (department_md dep)
rules = rs
Expand Down
6 changes: 3 additions & 3 deletions src/Informedica.GenForm.Lib/Types.fs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ module Types =
/// The pharmacological Shape of the DoseRule
Shape : string
/// The brand of the doserule
Brand : string
Brand : string option
/// Specific GPKs
GPKs : string array
/// The Route of administration of the DoseRule
Expand Down Expand Up @@ -292,13 +292,13 @@ module Types =
/// The Generic of the SolutionRule
Generic : string
/// The Shape of the SolutionRule
Shape : string
Shape : string option
/// The Route of the SolutionRule
Route : string
/// The DoseType of the SolutionRule
DoseType : DoseType
/// The Department of the SolutionRule
Department : string
Department : string option
/// The Venous Access Location of the SolutionRule
Location : VenousAccess
/// The MinMax Age range of the SolutionRule
Expand Down
4 changes: 1 addition & 3 deletions src/Informedica.GenOrder.Lib/Api.fs
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,7 @@ module Api =
generic
|> Option.map ((=) sr.Generic)
|> Option.defaultValue true &&
shape
|> Option.map ((=) sr.Shape)
|> Option.defaultValue true &&
shape = sr.Shape &&
route
|> Option.map ((=) sr.Route)
|> Option.defaultValue true
Expand Down
6 changes: 3 additions & 3 deletions src/Informedica.GenOrder.Lib/Scripts/Api2.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,18 +210,18 @@ Product.get ()
|> Array.filter (fun p -> p.Generic |> String.equalsCapInsens "nicu mix")


Patient.newBorn
Patient.child
|> fun p ->
{ p with
VenousAccess = [VenousAccess.CVL]
Department = Some "ICK"
Age =
Units.Time.year
|> ValueUnit.singleWithValue 0N
|> ValueUnit.singleWithValue 8N
|> Some
Weight =
Units.Weight.kiloGram
|> ValueUnit.singleWithValue (3N)
|> ValueUnit.singleWithValue (30N)
|> Some
}
//|> fun p -> { p with VenousAccess = CVL; AgeInDays = Some 0N }
Expand Down
17 changes: 14 additions & 3 deletions src/Informedica.ZIndex.Lib/Scripts/Script.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ printfn "Loading Substance"
Substance.load ()


GenPresProduct.filter "magnesiumsulfaat" "" ""
GenPresProduct.filter "bictegravir/emtricitabine/tenofovir alafenamide" "" ""
|> Array.collect (_.GenericProducts)
|> Array.map (fun gp ->
let subst = gp.Substances |> Array.distinctBy _.SubstanceId
Expand Down Expand Up @@ -410,8 +410,19 @@ GenPresProduct.filter "" "drank" ""
printfn $"{lbl}\t{shp}"
)

GenPresProduct.findByBrand "Mycofenolaat mofetil"
|> Array.map (fun gpp -> gpp.Name |> String.toLower)

GenPresProduct.findByBrand "Qvar"
|> Array.collect (_.GenericProducts)
|> Array.map (fun gp ->
let subst = gp.Substances |> Array.distinctBy _.SubstanceId
gp.Id, gp.Name, gp.Shape, gp.Route,
subst[0].SubstanceName,
$"{subst[0].SubstanceQuantity} {subst[0].SubstanceUnit}"
)
|> Array.iter (fun (id, lbl, shp, rte, sn, sq) ->
let rte = rte |> String.concat ", "
printfn $"{id}\t{lbl}\t{shp}\t{rte}\t{sn}\t{sq}"
)


GenPresProduct.findByGPK 9962
Expand Down

0 comments on commit 029f0bc

Please sign in to comment.