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 |
|
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
|
Full Usage:
addOrderContext newId context plan
Parameters:
unit -> string
context : PlanContext
plan : OrderPlan
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.
|
Full Usage:
addOrderContexts newId routeMapping rules main linked plan
Parameters:
unit -> string
routeMapping : RouteMapping array
rules : LinkRule[]
main : PlanContext
linked : PlanContext array
plan : OrderPlan
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.
|
Full Usage:
create patientData contexts
Parameters:
PatientData
contexts : PlanContext[]
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.
|
|
Returns the contexts whose id is in the plan filter, or all contexts when the filter is empty.
|
Full Usage:
followPatientData logger provider plan
Parameters:
Logger
provider : IResourceProvider
plan : OrderPlan
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.
|
Full Usage:
linkError plan pc
Parameters:
OrderPlan
pc : PlanContext
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.
|
Full Usage:
linkRuleError routeMapping rules plan pc
Parameters:
RouteMapping array
rules : LinkRule[]
plan : OrderPlan
pc : PlanContext
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.
|
Full Usage:
linkedOffers routeMapping rules sets evaluate main
Parameters:
RouteMapping array
rules : LinkRule[]
sets : RuleSet[]
evaluate : RuleSet option -> PlanContext -> Result<Outcome<PlanContext>, 'a>
main : PlanContext
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.
|
|
Returns the order scenario of every context with exactly one scenario, in context order.
|
Full Usage:
recalculate routeMapping formRoutes totalsData plan
Parameters:
RouteMapping array
formRoutes : FormRoute[]
totalsData : TotalsData array
plan : OrderPlan
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.
|
Full Usage:
remainingVolumeOver routeMapping formRoutes totalsData norms patientData contexts
Parameters:
RouteMapping array
formRoutes : FormRoute[]
totalsData : TotalsData array
norms : TotalNorm array
patientData : PatientData
contexts : PlanContext array
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.
|
|
|
|
|
Full Usage:
totalsOver routeMapping formRoutes totalsData norms patientData contexts
Parameters:
RouteMapping array
formRoutes : FormRoute[]
totalsData : TotalsData array
norms : TotalNorm array
patientData : PatientData
contexts : PlanContext array
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.
|
Full Usage:
updateContext ruleSets id evaluated plan
Parameters:
RuleSet[]
id : string
evaluated : PlanContext
plan : OrderPlan
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.
|
Full Usage:
volumeCorrection routeMapping formRoutes totalsData norms others pc
Parameters:
RouteMapping array
formRoutes : FormRoute[]
totalsData : TotalsData array
norms : TotalNorm array
others : PlanContext array
pc : PlanContext
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.
|
GenPRES