Logo GenPRES

OrderPlan Module

Creates an order plan for a patient, adds, updates and removes its order contexts, checks the links between orders and recalculates the totals.

Nested modules

Modules Description

Dto

Holds the serializable shape of an order plan, with the patient data, the filtered ids, every context, the totals and the norms, and converts a plan to and from the Dto. Reading returns a BrokenLink error for every context with a link error.

Functions and values

Function or value Description

addOrderContext newId context plan

Full Usage: addOrderContext newId context plan

Parameters:
Returns: Result<OrderPlan, OrderPlanError>

Adds a plan context to the plan with a new id. Returns NotNarrowed when the context does not have exactly one scenario, and OrderHeld when the plan already has that order, because a plan with an order twice is refused at signing. The link is not checked here.

newId : unit -> string
context : PlanContext
plan : OrderPlan
Returns: Result<OrderPlan, OrderPlanError>

addOrderContexts newId routeMapping rules main linked plan

Full Usage: addOrderContexts newId routeMapping rules main linked plan

Parameters:
Returns: Result<OrderPlan, OrderPlanError>

Adds a main order and its linked orders to the plan, each with a new id, or none of them when one is refused. The main order gets no link and every linked order gets a link to the main order. An order is refused for the errors of addOrderContext or a link rule error, as OrderRefused with its generic.

newId : unit -> string
routeMapping : RouteMapping array
rules : LinkRule[]
main : PlanContext
linked : PlanContext array
plan : OrderPlan
Returns: Result<OrderPlan, OrderPlanError>

create patientData contexts

Full Usage: create patientData contexts

Parameters:
Returns: OrderPlan

Creates a plan for the patient data with the contexts, an empty filter, empty totals and no norms. The contexts are not evaluated.

patientData : PatientData
contexts : PlanContext[]
Returns: OrderPlan

filtered plan

Full Usage: filtered plan

Parameters:
Returns: PlanContext[]

Returns the contexts whose id is in the plan filter, or all contexts when the filter is empty.

plan : OrderPlan
Returns: PlanContext[]

followPatientData logger provider plan

Full Usage: followPatientData logger provider plan

Parameters:
Returns: OrderPlan

Calculates every order of the plan again on the patient data of the plan. An order keeps its amounts; only its values per kg are solved again. An order that cannot be calculated stays as it was, marked with a notice. A context without an order only gets the patient data.

logger : Logger
provider : IResourceProvider
plan : OrderPlan
Returns: OrderPlan

linkError plan pc

Full Usage: linkError plan pc

Parameters:
Returns: LinkError option

Returns NoSuchMainOrder when the main order of a linked context is not in the plan, and MainOrderLinked when the main order is linked itself, which includes a context linked to itself. Returns None for a context without a link or with a valid link.

plan : OrderPlan
pc : PlanContext
Returns: LinkError option

linkRuleError routeMapping rules plan pc

Full Usage: linkRuleError routeMapping rules plan pc

Parameters:
Returns: LinkError option

Returns the link rule error of a plan context, or None when the link rules allow it. A linked context gives NotAllowed when no rule of its main order links it; a main order counts only with exactly one scenario. A context without a link gives MainOrderRequired when a rule that matches it requires a main order. A main order that is not in the plan is checked by linkError.

routeMapping : RouteMapping array
rules : LinkRule[]
plan : OrderPlan
pc : PlanContext
Returns: LinkError option

linkedOffers routeMapping rules sets evaluate main

Full Usage: linkedOffers routeMapping rules sets evaluate main

Parameters:
Returns: PlanContext array
Type parameters: 'a

Returns the plan contexts the link rules offer to link to the main context when it is narrowed to one order. There is one offer per rule, or for a rule without a generic one offer per generic the dose rules give. Each offer is evaluated for the patient of the main context, with its dose types narrowed to the link side, its category from the rule sets and, for a nutrition category, its lists narrowed to that rule set. When the narrowing leaves one dose type of several, the offer is evaluated again to get the scenarios of that dose type. An offer is left out when the rules refuse it, its evaluation fails, or it has no dose type of the link side.

routeMapping : RouteMapping array
rules : LinkRule[]
sets : RuleSet[]
evaluate : RuleSet option -> PlanContext -> Result<Outcome<PlanContext>, 'a>
main : PlanContext
Returns: PlanContext array

orders plan

Full Usage: orders plan

Parameters:
Returns: OrderScenario array

Returns the order scenario of every context with exactly one scenario, in context order.

plan : OrderPlan
Returns: OrderScenario array

recalculate routeMapping formRoutes totalsData plan

Full Usage: recalculate routeMapping formRoutes totalsData plan

Parameters:
Returns: OrderPlan

Calculates the totals of every context and of the plan again for the patient data of the plan. Each total is checked against the norm of the plan with the name of its Totals row, or else against the standard norm of the row. The plan totals cover the filtered contexts. The patient data of a context can be older than that of the plan, so it is not used.

routeMapping : RouteMapping array
formRoutes : FormRoute[]
totalsData : TotalsData array
plan : OrderPlan
Returns: OrderPlan

remainingVolumeOver routeMapping formRoutes totalsData norms patientData contexts

Full Usage: remainingVolumeOver routeMapping formRoutes totalsData norms patientData contexts

Parameters:
Returns: TotalNorm option

Returns the volume that is left within the volume norm of the patient while the orders of the contexts with exactly one scenario are below the minimum of the norm, as Totals.remainingVolume calculates it. A context without exactly one scenario adds nothing.

routeMapping : RouteMapping array
formRoutes : FormRoute[]
totalsData : TotalsData array
norms : TotalNorm array
patientData : PatientData
contexts : PlanContext array
Returns: TotalNorm option

removeOrderContext id plan

Full Usage: removeOrderContext id plan

Parameters:
Returns: OrderPlan

Removes the context with this id and every context linked to it from the plan and from the filter.

id : string
plan : OrderPlan
Returns: OrderPlan

removeOrderContexts ids plan

Full Usage: removeOrderContexts ids plan

Parameters:
Returns: OrderPlan

Removes the contexts with these ids, each with the contexts linked to it.

ids : string[]
plan : OrderPlan
Returns: OrderPlan

totalsOver routeMapping formRoutes totalsData norms patientData contexts

Full Usage: totalsOver routeMapping formRoutes totalsData norms patientData contexts

Parameters:
Returns: Totals

Calculates the totals of the orders of the contexts with exactly one scenario, for the patient data. Each total is checked against the norm in norms with the name of its Totals row, or else against the standard norm of the row. A context without exactly one scenario adds nothing.

routeMapping : RouteMapping array
formRoutes : FormRoute[]
totalsData : TotalsData array
norms : TotalNorm array
patientData : PatientData
contexts : PlanContext array
Returns: Totals

updateContext ruleSets id evaluated plan

Full Usage: updateContext ruleSets id evaluated plan

Parameters:
Returns: Result<OrderPlan, OrderPlanError>

Replaces the plan context with this id by the evaluated context, with the id and the category of the plan context. A nutrition context gets its pick lists narrowed to the rule set of its category. Returns NoSuchContext for an unknown id, and NotNarrowed when the evaluated context does not have exactly one scenario, because a context in the plan always has an order.

ruleSets : RuleSet[]
id : string
evaluated : PlanContext
plan : OrderPlan
Returns: Result<OrderPlan, OrderPlanError>

volumeCorrection routeMapping formRoutes totalsData norms others pc

Full Usage: volumeCorrection routeMapping formRoutes totalsData norms others pc

Parameters:
Returns: (ValueUnit * NearestSide) option

Returns the dose quantity of the order of the context that brings the volume of that order and of the orders of the other contexts within the volume norm of the patient of the context, with the side on which the nearest value is taken, as Totals.correctedDose calculates it. Each context adds an order when it has exactly one scenario. Returns None for a context without exactly one scenario, and when the dose needs no correction or cannot be corrected.

routeMapping : RouteMapping array
formRoutes : FormRoute[]
totalsData : TotalsData array
norms : TotalNorm array
others : PlanContext array
pc : PlanContext
Returns: (ValueUnit * NearestSide) option

Type something to start searching.