Skip to content

Commit

Permalink
chore: removed some dead code from zform
Browse files Browse the repository at this point in the history
  • Loading branch information
Casper Bollen authored and Casper Bollen committed Nov 7, 2023
1 parent 248b330 commit 43bae6e
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 82 deletions.
2 changes: 1 addition & 1 deletion src/Informedica.GenForm.Lib/Product.fs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ module Product =
|> Array.map (fun (gpp, gp) ->
let atc =
gp.ATC
|> ATCGroup.findByATC5 ()
|> ATCGroup.findByATC5
let su =
gp.Substances[0].ShapeUnit
|> String.toLower
Expand Down
1 change: 0 additions & 1 deletion src/Informedica.ZForm.Lib/Informedica.ZForm.Lib.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<Compile Include="Markdown.fs" />
<Compile Include="Mapping.fs" />
<Compile Include="ValueUnit.fs" />
<Compile Include="Product.fs" />
<Compile Include="PatientCategory.fs" />
<Compile Include="DoseRule.fs" />
<Compile Include="GStand.fs" />
Expand Down
19 changes: 0 additions & 19 deletions src/Informedica.ZForm.Lib/Product.fs

This file was deleted.

47 changes: 0 additions & 47 deletions src/Informedica.ZForm.Lib/Types.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,6 @@ module Types =
type MinMax = Informedica.GenCore.Lib.Ranges.MinIncrMax


/// A product is a medical substance or
/// substances with a specific shape
type Product =
{
// The name of the product which is the generic
// substance of the product or a concatenation of
// generic substance names or a 'name'.
Name : string
/// The pharmacological shape of a product.
DisplayName : string
Synonyms : string list
Shape : string
/// The route of a product
Unit : string
Routes : Route list
Pharmacologic : string list
/// The display name of the generic
DivisibleBy : Divisibility
GenericProducts : GenericProduct List
}

and Divisibility = NoDiv | Div of bigint

and GenericProduct =
{
Id : int
Label : string
/// The substances on which the concentration and dosing is based.
Substances : Substance list
TradeProducts : TradeProduct list
}

and Substance =
{
Name : string
Concentration : ValueUnit
}

and TradeProduct =
{
Id : int
Names : string
Label : string
Quantity : ValueUnit
}


type PatientCategory =
{
GestAge : MinMax
Expand Down
25 changes: 22 additions & 3 deletions src/Informedica.ZIndex.Lib/ATCGroup.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module ATCGroup =
open Informedica.Utils.Lib


/// Create a ATC group.
let create atc1 ang ange atc2 thg thge atc3 ths thse atc4 phg phge atc5 sub sube gen shp rts =
{
ATC1 = atc1
Expand All @@ -30,9 +31,14 @@ module ATCGroup =
}


/// An empty ATC group.
let empty = create "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""


/// <summary>
/// Parse the BST801T records into ATC groups.
/// </summary>
/// <param name="gpks">A list of GPKs for which to parse ATC groups</param>
let parse gpks =
query {
for gpk in Zindex.BST711T.records () do
Expand Down Expand Up @@ -163,19 +169,32 @@ module ATCGroup =
|> StopWatch.clockFunc "Getting ATC groups"


/// <summary>
/// Get all ATC groups.
/// </summary>
/// <remarks>
/// This function is memoized.
/// </remarks>
let get : unit -> ATCGroup [] = Memoization.memoize _get


let findByATC5 all atc =
get all
/// <summary>
/// Find ATC groups by ATC5 code.
/// </summary>
/// <param name="all"></param>
/// <param name="atc"></param>
let findByATC5 atc =
get ()
|> Array.filter (fun g ->
g.ATC5 |> String.equalsCapInsens atc
)


/// Load the ATC groups in memory.
let load () = get () |> ignore


/// Create a CSV file for an array of GenPresProducts.
let productCSV (gpps : GenPresProduct[]) =
// create product file
gpps
Expand All @@ -185,7 +204,7 @@ module ATCGroup =
gp.Substances
|> Array.collect (fun s ->
gp.ATC
|> findByATC5 ()
|> findByATC5
|> Array.map (fun atc ->
{|
GPK = gp.Id
Expand Down
47 changes: 36 additions & 11 deletions src/Informedica.ZIndex.Lib/RuleFinder.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,20 @@ namespace Informedica.ZIndex.Lib

module RuleFinder =

open Informedica.Utils.Lib.BCL

type MinMax = RuleMinMax



/// Create a route from a string
let createRoute = Route.fromString (Route.routeMapping ())


/// Check if a route exists.
let eqsRoute = Route.routeExists (Route.routeMapping ())


type AgeInMo = decimal Option


type WeightInKg = decimal Option


type BSAInM2 = decimal Option


/// Check whether a float n is in range of a MinMax.
let inRange n { Min = min; Max = max } =
if n |> Option.isNone then true
else
Expand All @@ -35,6 +28,7 @@ module RuleFinder =
| Some min, Some max -> n >= min && n <= max


/// An empty Filter.
let filter =
{
Patient = { Age = None; Weight = None; BSA = None }
Expand All @@ -44,6 +38,16 @@ module RuleFinder =
}


/// <summary>
/// Create a filter.
/// </summary>
/// <param name="age">Age</param>
/// <param name="wght">Weight</param>
/// <param name="bsa">Body Surface Area</param>
/// <param name="gpk">Generic Product Id</param>
/// <param name="gen">Generic name</param>
/// <param name="shp">Shape</param>
/// <param name="rte">Route</param>
let createFilter age wght bsa gpk gen shp rte =
let pat = { Age = age; Weight = wght; BSA = bsa }
let prod =
Expand All @@ -62,10 +66,21 @@ module RuleFinder =
}


/// <summary>
/// Create a Filter for GPK, Route.
/// </summary>
/// <param name="gpk">The Generic Product Id</param>
/// <param name="rte">The Route</param>
let createGPKRouteFilter gpk rte = createFilter None None None gpk "" "" rte


let find gpks { Filter.Patient = pat; Product = prod } =
/// <summary>
/// Find all DoseRules for a list of GPKs and a Filter.
/// </summary>
/// <param name="gpks">The GPKs</param>
/// <param name="filter">The Filter</param>
let find gpks filter =
let { Filter.Patient = pat; Product = prod } = filter
let r =
match prod with
| GPKRoute (_, route) -> route
Expand Down Expand Up @@ -94,6 +109,7 @@ module RuleFinder =
)


/// Create a RuleResult.
let createResult gpp drs ds =
{
Product = gpp
Expand All @@ -102,6 +118,7 @@ module RuleFinder =
}


/// Create a FrequencyDose.
let createFreqDose freq norm abs normKg absKg normM2 absM2 un =
{
Freq = freq
Expand All @@ -115,6 +132,14 @@ module RuleFinder =
}


/// <summary>
/// Convert a list of DoseRules to a RuleResult.
/// </summary>
/// <param name="drs">The DoseRules</param>
/// <remarks>
/// If the DoseRules are not for the same GenPresProduct then
/// None is returned.
/// </remarks>
let convertToResult (drs : DoseRule []) =

// Get the min max weight if there is one min weight or max weight
Expand Down

0 comments on commit 43bae6e

Please sign in to comment.