Logo GenPRES

Medication Module

Creates the medications of a prescription rule, one for each solution rule or a single medication when the rule has no solution rules, each with its product components, substance items and limits, and builds an order from a medication.

Nested modules

Modules Description

Dto

Holds the serializable shape of a medication, used for the medication text and its schema, and converts a medication to and from the Dto. Reading a Dto returns every error with the path of its field. A missing value is null or an empty array, and a number is written as its exact text. A limit has no target field; the target follows from where the limit is placed. The Dto classes allow null, so the serializer can leave a missing field out of the text.

OrderBuilder

Builds an order from a medication: first the structure, then one pass for each kind of constraint, each pass changing only its own part.

ProductComponent

Holds an empty product component, creates a product component from its parts and tells whether a product can be made from given substances.

SubstanceItem

Holds an empty substance item and creates a substance item from its name, quantities, concentrations, dose limit and dilution limit.

UnitValidation

Checks that the unit of a dose limit field has the adjust unit and the time unit the field needs.

Functions and values

Function or value Description

addSolutionRule logger solRule med

Full Usage: addSolutionRule logger solRule med

Parameters:
Returns: Medication

Applies a solution rule, when there is one, to a medication. The medication gets the drip rate as a dose rate in mL, the volumes, the Div and the dose count of the rule, and a component for the first diluent. Each substance and component gets its dilution limit.

logger : Logger
solRule : SolutionRule option
med : Medication
Returns: Medication

allLackNeededDiluent meds

Full Usage: allLackNeededDiluent meds

Parameters:
Returns: bool

Whether there are medications and each one is given undiluted while its concentration limit allows none of its product concentrations.

meds : Medication[]
Returns: bool

componentsInUnitGroups med

Full Usage: componentsInUnitGroups med

Parameters:
Returns: (string * Unit) list

The name and unit of each component with a quantity, when those components are in more than one unit group, otherwise an empty list.

med : Medication
Returns: (string * Unit) list

concentrationsWithinDilutionLimit si

Full Usage: concentrationsWithinDilutionLimit si

Parameters:
Returns: ValueUnit option

Returns the concentrations of a substance that its dilution concentration limit allows, with the bounds that withItemDilution sets. A substance without concentrations or without a concentration limit keeps its concentrations. So does a substance with concentrations in another unit group than the limit, such as a molar concentration against a mass limit, because the bounds are compared on base values.

si : SubstanceItem
Returns: ValueUnit option

create logger patientData dose dr solRule

Full Usage: create logger patientData dose dr solRule

Parameters:
Returns: Medication

Creates a medication from the patient data, the dose limit, a dose rule and an optional solution rule. The medication adjusts by the adjust unit of the dose rule, else that of the solution rule, and not at all when neither rule has one. Without a solution rule the dose count is 1.

logger : Logger
patientData : PatientData
dose : DoseLimit option
dr : DoseRule
solRule : SolutionRule option
Returns: Medication

createComponents logger limits

Full Usage: createComponents logger limits

Parameters:
Returns: ProductComponent list

Creates a product component for every component limit, with its dose limit, products and substances. The values of a list in more than one unit group keep only the largest group, with a warning. A product that cannot be made of the substances of the component is left out.

logger : Logger
limits : ComponentLimit[]
Returns: ProductComponent list

fromRule logger pr

Full Usage: fromRule logger pr

Parameters:
Returns: Medication[]

Creates a medication for every solution rule of the prescription rule, or one medication when it has no solution rules, and logs each medication.

logger : Logger
pr : PrescriptionRule
Returns: Medication[]

predilutionOf p

Full Usage: predilutionOf p

Parameters:
Returns: ComponentPredilution option

Returns the predilution a product was made with; None for a product that is not pre-diluted.

p : Product
Returns: ComponentPredilution option

productComponent

Full Usage: productComponent

Returns: ProductComponent

reconstitutionOf p

Full Usage: reconstitutionOf p

Parameters:
Returns: ComponentReconstitution option

Returns the reconstitution a product was made with: the single reconstitution of a product that requires reconstitution. Returns None for a product that requires no reconstitution, or that does not have exactly one reconstitution.

p : Product
Returns: ComponentReconstitution option

setDilutionLimit dls items

Full Usage: setDilutionLimit dls items

Parameters:
Returns: SubstanceItem list

Sets on each substance item the dilution limit whose target is that substance.

dls : DilutionLimit[]
items : SubstanceItem list
Returns: SubstanceItem list

substanceItem

Full Usage: substanceItem

Returns: SubstanceItem
Returns: SubstanceItem

template

Full Usage: template

Returns: Medication

An empty medication record.

Returns: Medication

toOrder start med

Full Usage: toOrder start med

Parameters:
Returns: Result<Order, Message>

Builds an Order from a Medication, or returns OrderCouldNotBeCreated with the reason. The caller gives the start in UTC. A medication given undiluted at a concentration that its dilution limit does not allow is refused, because no diluent can bring it within the limit. A medication with components in different unit groups is refused, because the components add up to the orderable.

start : DateTime
med : Medication
Returns: Result<Order, Message>

toOrderDto start med

Full Usage: toOrderDto start med

Parameters:
Returns: Dto

Converts a Medication to an Order Dto. Raises the exception with the reason when the medication cannot be ordered; toOrder returns the same failure as a value.

start : DateTime
med : Medication
Returns: Dto

undilutedOutsideDilutionLimit med

Full Usage: undilutedOutsideDilutionLimit med

Parameters:
Returns: SubstanceItem list

Returns the substances of a medication given undiluted whose dilution limit allows none of the product concentrations. Only a medication with one component is given undiluted; with more components the solver calculates the orderable concentration.

med : Medication
Returns: SubstanceItem list

Type something to start searching.