Skip to content

Commit

Permalink
chore: working on GenOrder added some comments and removed dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
Casper Bollen authored and Casper Bollen committed Nov 1, 2023
1 parent b800621 commit cb659d7
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 87 deletions.
2 changes: 1 addition & 1 deletion src/Informedica.GenOrder.Lib/OrderLogger.fs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ module OrderLogger =
let printLogger : Logger = { Log = (printMsg None >> (printfn "%s")) }


// Create the logger agent
// the logger agent
let logger =

let write path i t ms m =
Expand Down
4 changes: 2 additions & 2 deletions src/Informedica.GenOrder.Lib/OrderVariable.fs
Original file line number Diff line number Diff line change
Expand Up @@ -762,11 +762,11 @@ module OrderVariable =
|> Total


/// Turn a `Quantity` to a string
/// Turn a `Total` to a string
let toString = toOrdVar >> (toString false)


/// Print a `Quantity` as a value unit string list
/// Print a `Total` as a value unit string list
let toValueUnitStringList = toValueUnitStringList toOrdVar


Expand Down
154 changes: 93 additions & 61 deletions src/Informedica.GenOrder.Lib/Types.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace Informedica.GenOrder.Lib

[<AutoOpen>]
module Types =

open System
open MathNet.Numerics

Expand All @@ -14,11 +15,10 @@ module Types =
type Patient = Informedica.GenForm.Lib.Types.Patient


/// A `VariableUnit` is the combination of
/// an `Informedica.GenSolver.Lib.Variable` with
/// an `Informedica.GenUnits.Lib.Unit`
/// The `Variable` stores the base values according
/// to the `Unit`
/// <summary>
/// An OrderVariable represents the combination
/// of a Variable and Constraints
/// </summary>
type OrderVariable =
{
Constraints : Constraints
Expand All @@ -34,77 +34,69 @@ module Types =
}


/// <summary>
/// An order equation is either a product equation or a
/// sum equation
/// </summary>
type OrderEquation =
| OrderProductEquation of OrderVariable * OrderVariable list
| OrderSumEquation of OrderVariable * OrderVariable list


/// Time "tme"
/// Type that represents a time
type Time = Time of OrderVariable


/// Count "cnt"
/// Type that represents a count
type Count = Count of OrderVariable


/// Count / Time "frq"
/// Type that represents a frequency
type Frequency = Frequency of OrderVariable


/// Quantity "qty"
/// Type that represents a quantity
type Quantity = Quantity of OrderVariable


//// Quantity / Time "ptm"
/// Type that represents a quantity per time
type PerTime = PerTime of OrderVariable

/// Quantity / Time "rte"
/// Type that represents a rate
type Rate = Rate of OrderVariable


/// Quantity "tot"
/// Type that represents a total
type Total = Total of OrderVariable


/// Quantity / Quantity "cnc"
/// Type that represents a concentration
type Concentration = Concentration of OrderVariable


/// Quantity / Adjust "qty_adj"
/// Type that represents a adjusted quantity
type QuantityAdjust = QuantityAdjust of OrderVariable


/// Quantity / Adjust / Time "ptm_adj"
/// Type that represents a adjusted quantity per time
type PerTimeAdjust = PerTimeAdjust of OrderVariable


/// Quantity / Adjust / Time "rte_adj"
/// Type that represents a adjusted quantity per time
type RateAdjust = RateAdjust of OrderVariable


/// Quantity / Adjust "tot_adj"
/// Type that represents a adjusted total
type TotalAdjust = TotalAdjust of OrderVariable



/// An Id is represented by a string
type Id = Id of string


/// <summary>
/// Represents a Dose
/// </summary>
type Dose =
{
Quantity : Quantity
Expand All @@ -121,25 +113,25 @@ module Types =
/// Models an `Item` in a `Component`
type Item =
{
/// The name of the item
// The name of the item
Name: Name
/// The quantity of an `Item` in a `Component`
// The quantity of an `Item` in a `Component`
ComponentQuantity: Quantity
/// The quantity of an `Item` in an `Orderable`
// The quantity of an `Item` in an `Orderable`
OrderableQuantity: Quantity
/// The `Item` concentration in a `Component`
// The `Item` concentration in a `Component`
ComponentConcentration: Concentration
/// The `Item` concentration in an `Orderable`
// The `Item` concentration in an `Orderable`
OrderableConcentration: Concentration
/// The `Item` `Dose`, i.e. quantity, total and rate of `Item` administered
// The `Item` `Dose` of `Item` administered
Dose: Dose
}


/// Models in a `Component` in and `Orderable`
type Component =
{
Id : Id //TODO: remove
Id : Id
/// The name of a `Component`
Name: Name
// The shape of an component
Expand All @@ -156,8 +148,7 @@ module Types =
OrderCount: Count
/// The concentration of a `Component` in an `Orderable`
OrderableConcentration: Concentration
// The `Component` `Dose`,
/// i.e. quantity, total and rate of `Component` administered
// The `Component` `Dose` of `Component` administered
Dose: Dose
/// The `Item`s in a `Component`
Items: Item list
Expand Down Expand Up @@ -200,7 +191,7 @@ module Types =
Adjust: Quantity
/// That what can be ordered
Orderable: Orderable
/// How the orderable is prescribed
/// How the Orderable is prescribed
Prescription: Prescription
/// The route of administration of the order
Route: string // Route
Expand All @@ -220,6 +211,7 @@ module Types =
| Timed of Frequency * Time


/// A string list that represents either a product or sum equation
type EquationMapping =
| ProductMapping of string list
| SumMapping of string list
Expand All @@ -234,44 +226,48 @@ module Types =
| TimedOrder


/// Shorthand for a Informedica.GenForm.Lib.Types.MinMax
type MinMax = Informedica.GenForm.Lib.Types.MinMax
/// Shorthand for a Informedica.GenForm.Lib.Types.DoseLimit
type DoseLimit = Informedica.GenForm.Lib.Types.DoseLimit
/// Shorthand for a Informedica.GenForm.Lib.Types.SolutionLimit
type SolutionLimit = Informedica.GenForm.Lib.Types.SolutionLimit


/// The representation of a drug order that
/// can be derived by a drug product inventory
/// and the related dose rule
/// and the related dose rule. A DrugOrder maps
/// to an Orderable and a Prescription.
type DrugOrder =
{
/// Identifies the specific drug order
// Identifies the specific drug order
Id: string
/// The name of the order
// The name of the order
Name : string
/// The list of drug products that can be used for the order
// The list of drug products that can be used for the order
Products : ProductComponent list
/// The quantities of the drug order
// The quantities of the drug order
Quantities : BigRational list
/// The unit the `DrugOrder` is measured in,
/// i.e. of the `Quantities`
// The unit the `DrugOrder` is measured in,
// i.e. of the `Quantities`
Unit : string
/// The route by which the order is applied
// The route by which the order is applied
Route : string
// The type of order
OrderType : OrderType
/// The list of possible frequency values
// The list of possible frequency values
Frequencies : BigRational list
/// The time unit to be used when using a frequency
// The time unit to be used when using a frequency
FreqUnit : string
/// The list of possible rate values
// The list of possible rate values
Rates : BigRational list
/// The time unit to be used when using a rate
// The time unit to be used when using a rate
RateUnit : string
/// The min and/or max time for the infusion time
// The min and/or max time for the infusion time
Time : MinMax
/// The time unit for infusion time (duration)
// The time unit for infusion time (duration)
TimeUnit : string
/// The dose limits for an drugorder
// The dose limits for an drugorder
Dose : DoseLimit option
// The amount of orderable that will be given each time
DoseCount : BigRational option
Expand All @@ -280,71 +276,107 @@ module Types =
// The adjust unit
AdjustUnit : string
}
/// The product components that are used by the drug order
/// The product components that are used by the drug order.
/// A product component maps to a Component in an Orderable.
and ProductComponent =
{
/// The name of the product
// The name of the product
Name : string
/// The shape of the product
// The shape of the product
Shape : string
/// The quantities of the product
/// Note: measured in the same unit as
/// the `DrugOrder` unit
// The quantities of the product
// Note: measured in the same unit as
// the `DrugOrder` unit
Quantities : BigRational list
/// The "divisibility" of the products
// The "divisibility" of the products
Divisible : BigRational option
/// The time unit used for frequency
// The time unit used for frequency
TimeUnit : string
/// The time unit used for rate
// The time unit used for rate
RateUnit : string
/// The list of substances contained in the product
// The list of substances contained in the product
Substances: SubstanceItem list
}
/// A substance in a product. A substance maps to an Item in a Component.
and SubstanceItem =
{
/// The name of the substance
// The name of the substance
Name : string
/// The possible concentrations of the substance
/// in the products
// The possible concentrations of the substance
// in the products
Concentrations : BigRational list
/// The unit by which the substance is
/// measured.
// The unit by which the substance is
// measured.
Unit : string
/// The time unit used for the frequency
// The time unit used for the frequency
TimeUnit : string
/// The dose limits for a substance
// The dose limits for a substance
Dose : DoseLimit option
/// The solution limits for a solution
// The solution limits for a solution
Solution : SolutionLimit option
}


/// <summary>
/// The representation of an order with a
/// <list type="bullet">
/// <item>Prescription</item>
/// <item>Preparation</item>
/// <item>Administration</item>
/// </list>
///
/// </summary>
type Scenario =
{
// the id of the scenario
No : int
// the indication for the the order
Indication : string
// the dose type of the order
DoseType : string
// the name of the order
Name : string
// the shape of the order
Shape : string
// the route of the order
Route : string
// the prescription of the order
Prescription : string
// the preparation of the order
Preparation : string
// the administration of the order
Administration : string
// the order itself
Order : Order option
}


/// <summary>
/// The main communication object to transfer the
/// results of the solver to the client. The fields
/// are used to select the correct scenario.
/// </summary>
type ScenarioResult =
{
// the list of indications to select from
Indications: string []
// the list of generics to select from
Generics: string []
// the list of routes to select from
Routes: string []
// the list of shapes to select from
Shapes: string []
// the selected indication
Indication: string option
// the selected generic
Generic: string option
// the selected route
Route: string option
// the selected shape
Shape: string option
// the patient
Patient: Patient
// the list of scenarios
Scenarios: Scenario []
}

Expand Down
Loading

0 comments on commit cb659d7

Please sign in to comment.