Skip to content

Commit

Permalink
chore: implementing new valueunit use in genform
Browse files Browse the repository at this point in the history
  • Loading branch information
Casper Bollen authored and Casper Bollen committed Dec 2, 2023
1 parent f079824 commit 1f7a941
Show file tree
Hide file tree
Showing 23 changed files with 1,583 additions and 3,998 deletions.
300 changes: 187 additions & 113 deletions src/Informedica.GenForm.Lib/DoseRule.fs

Large diffs are not rendered by default.

50 changes: 8 additions & 42 deletions src/Informedica.GenForm.Lib/Filter.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace Informedica.GenForm.Lib



module Filter =


Expand All @@ -11,16 +12,8 @@ module Filter =
Generic = None
Shape = None
Route = None
Department = None
Diagnoses = [||]
Gender = AnyGender
AgeInDays = None
WeightInGram = None
HeightInCm = None
GestAgeInDays = None
PMAgeInDays = None
DoseType = AnyDoseType
Location = AnyAccess
Patient = Patient.patient
}


Expand All @@ -36,42 +29,15 @@ module Filter =
|> Patient.calcPMAge

{ filter with
Department = pat.Department |> Some
Diagnoses = pat.Diagnoses
Gender = pat.Gender
AgeInDays = pat.AgeInDays
WeightInGram = pat.WeightInGram
HeightInCm = pat.HeightInCm
GestAgeInDays = pat.GestAgeInDays
PMAgeInDays = pat.PMAgeInDays
Location = pat.VenousAccess
}


/// <summary>
/// Extract a Patient from a Filter.
/// </summary>
/// <param name="filter">The Filter</param>
/// <returns>The Patient</returns>
let getPatient (filter : Filter) =
{ Patient.patient with
Department = filter.Department |> Option.defaultValue ""
Diagnoses = filter.Diagnoses
Gender = filter.Gender
AgeInDays = filter.AgeInDays
WeightInGram = filter.WeightInGram
HeightInCm = filter.HeightInCm
GestAgeInDays = filter.GestAgeInDays
PMAgeInDays = filter.PMAgeInDays
VenousAccess = filter.Location
Patient = pat
}


let calcPMAge (filter : Filter) =
{ filter with
PMAgeInDays =
filter
|> getPatient
Patient =
filter.Patient
|> Patient.calcPMAge
|> fun pat -> pat.PMAgeInDays
}
}


2 changes: 1 addition & 1 deletion src/Informedica.GenForm.Lib/Informedica.GenForm.Lib.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<ItemGroup>
<Compile Include="Types.fs" />
<Compile Include="Utils.fs" />
<Compile Include="VenousAccess.fs" />
<Compile Include="Mapping.fs" />
<Compile Include="MinMax.fs" />
<Compile Include="Patient.fs" />
<Compile Include="DoseType.fs" />
<Compile Include="Product.fs" />
Expand Down
45 changes: 38 additions & 7 deletions src/Informedica.GenForm.Lib/Mapping.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Mapping =

open Informedica.Utils.Lib
open Informedica.Utils.Lib.BCL
open Informedica.GenUnits.Lib


/// Mapping of long Z-index route names to short names
Expand Down Expand Up @@ -86,17 +87,48 @@ module Mapping =
let getStr = getColumn Csv.getStringColumn r
let getFlt = getColumn Csv.getFloatOptionColumn r

let un = getStr "Unit" |> Units.fromString |> Option.defaultValue NoUnit
{
Route = getStr "Route"
Shape = getStr "Shape"
Unit = getStr "Unit"
DoseUnit = getStr "DoseUnit"
MinDoseQty = getFlt "MinDoseQty"
MaxDoseQty = getFlt "MaxDoseQty"
Unit = un
DoseUnit = getStr "DoseUnit" |> Units.fromString |> Option.defaultValue NoUnit
MinDoseQty =
if un = NoUnit then None
else
getFlt "MinDoseQty"
|> Option.bind BigRational.fromFloat
|> Option.map (ValueUnit.singleWithUnit un)
MaxDoseQty =
if un = NoUnit then None
else
getFlt "MaxDoseQty"
|> Option.bind BigRational.fromFloat
|> Option.map (ValueUnit.singleWithUnit un)
Timed = getStr "Timed" |> String.equalsCapInsens "true"
Reconstitute = getStr "Reconstitute" |> String.equalsCapInsens "true"
IsSolution = getStr "IsSolution" |> String.equalsCapInsens "true"
}
|> fun rs ->
match rs.DoseUnit with
| NoUnit -> rs
| du ->
{ rs with
MinDoseQty =
getFlt "MinDoseQty"
|> Option.bind (fun v ->
v
|> BigRational.fromFloat
|> Option.map (ValueUnit.singleWithUnit du)
)
MaxDoseQty =
getFlt "MaxDoseQty"
|> Option.bind (fun v ->
v
|> BigRational.fromFloat
|> Option.map (ValueUnit.singleWithUnit du)
)
}
)


Expand All @@ -116,9 +148,8 @@ module Mapping =
xs.Route |> mapRoute |> Option.map (String.equalsCapInsens (rte |> String.trim)) |> Option.defaultValue false
let eqsShp = shape |> String.isNullOrWhiteSpace || shape |> String.trim |> String.equalsCapInsens xs.Shape
let eqsUnt =
unt |> String.isNullOrWhiteSpace ||
unt |> String.trim |> String.equalsCapInsens xs.Unit ||
xs.Unit |> mapUnit |> Option.map (String.equalsCapInsens (unt |> String.trim)) |> Option.defaultValue false
unt = NoUnit ||
unt |> Units.eqsUnit xs.Unit
eqsRte && eqsShp && eqsUnt
)

Expand Down
87 changes: 0 additions & 87 deletions src/Informedica.GenForm.Lib/MinMax.fs

This file was deleted.

Loading

0 comments on commit 1f7a941

Please sign in to comment.