PlanContext Module
Creates a plan context, an order context with an id, a category, totals and a link, and evaluates a command on the plan context.
Nested modules
| Modules | Description |
|
Holds the serializable shape of a plan context, with the category as a string, and converts a plan context to and from the Dto. |
Functions and values
| Function or value |
Description
|
|
Returns the order scenario that the context contributes to the plan, when it has exactly one scenario.
|
Full Usage:
create id category ctx
Parameters:
string
category : OrderCategory
ctx : OrderContext
Returns: PlanContext
|
Creates a plan context from an id, a category and an order context, with empty totals and no link.
|
Full Usage:
evaluateOutcome start logger provider totalsData norms cmd pc
Parameters:
DateTime
logger : Logger
provider : IResourceProvider
totalsData : unit -> TotalsData[]
norms : TotalNorm array
cmd : OrderContext -> Command
pc : PlanContext
Returns: Result<Outcome<PlanContext>, Message list>
|
Evaluates the plan context against the rules and returns the outcome. A filter or scenario pick is first applied to the context as sent. 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.
|
Full Usage:
evaluateSent start logger provider totalsData norms restore cmd pc
Parameters:
DateTime
logger : Logger
provider : IResourceProvider
totalsData : unit -> TotalsData[]
norms : TotalNorm array
restore : OrderContext -> OrderContext
cmd : OrderContext -> Command
pc : PlanContext
Returns: Result<Outcome<PlanContext>, Message list>
|
Evaluates the plan context against the rules and returns the outcome. An update of the order context looks the rules up again, and a reload does so after reloading the resources. A pick that the rules no longer offer for the patient gives a refusal with the context as sent, so the pick is not lost without notice. A refusal of the lookup, except one for a missing diluent, has each pick list narrowed by the other picks. After a successful lookup, restore sets the component quantities of the sent context again. Any other command runs on the reconciled context. The totals are calculated after the evaluation, except for the refusal of a pick that the rules no longer offer. 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. The id, the category and the link do not change. Returns an error when the evaluation fails.
|
Full Usage:
evaluateSettled start logger provider norms set cmd pc
Parameters:
DateTime
logger : Logger
provider : IResourceProvider
norms : TotalNorm array
set : RuleSet option
cmd : OrderContext -> Command
pc : PlanContext
Returns: Result<Outcome<PlanContext>, Message list>
|
Evaluates the plan context with the command and returns the outcome. An evaluated nutrition context is narrowed to the rule set and evaluated again, with every single-option list taken as its choice, until no single-option list is left without a choice; a refusal along the way is returned as the refused context. A refused nutrition context is also narrowed to the rule set, so it offers no medication of another category. A medication context, which has no rule set, is evaluated once. 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.
|
Full Usage:
findRuleSet category sets
Parameters:
NutritionCategory
sets : RuleSet[]
Returns: Result<RuleSet, OrderPlanError>
|
Returns the rule set of a nutrition category, or the error NoRuleSet when there is none or when it has no rules.
|
|
Returns the generic of the order of the context, else the generic picked in the filter, else an empty string.
|
|
Returns the nutrition category of a plan context, or None for a medication.
|
Full Usage:
resolveChange cmd pc
Parameters:
OrderContext -> Command
pc : PlanContext
Returns: Result<((OrderContext -> Command) * PlanContext), Message list>
|
Applies a filter pick, a scenario pick or a seed to the context as sent, before the context is reconciled with the rules, because a pick reads an index in the lists as sent. Returns the existing command to evaluate with the changed plan context, or an error when the index is out of range. Any other command is returned unchanged.
|
Full Usage:
ruleSetOf provider pat category
Parameters:
IResourceProvider
pat : PatientData
category : NutritionCategory option
Returns: Result<(RuleSet array * RuleSet option), OrderPlanError>
|
Returns the rule sets for the patient and the rule set of a nutrition category, or the error NoRuleSet when there is no rule set for the category. For a medication, returns no rule sets and no rule set.
|
Full Usage:
withPatientData patientData pc
Parameters:
PatientData
pc : PlanContext
Returns: PlanContext
|
Sets the patient data of the order context of a plan context.
|
GenPRES