Logo GenPRES

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

Dto

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

contribution pc

Full Usage: contribution pc

Parameters:
Returns: OrderScenario option

Returns the order scenario that the context contributes to the plan, when it has exactly one scenario.

pc : PlanContext
Returns: OrderScenario option

create id category ctx

Full Usage: create id category ctx

Parameters:
Returns: PlanContext

Creates a plan context from an id, a category and an order context, with empty totals and no link.

id : string
category : OrderCategory
ctx : OrderContext
Returns: PlanContext

evaluateOutcome start logger provider totalsData norms cmd pc

Full Usage: evaluateOutcome start logger provider totalsData norms cmd pc

Parameters:
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.

start : DateTime
logger : Logger
provider : IResourceProvider
totalsData : unit -> TotalsData[]
norms : TotalNorm array
cmd : OrderContext -> Command
pc : PlanContext
Returns: Result<Outcome<PlanContext>, Message list>

evaluateSent start logger provider totalsData norms restore cmd pc

Full Usage: evaluateSent start logger provider totalsData norms restore cmd pc

Parameters:
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.

start : 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>

evaluateSettled start logger provider norms set cmd pc

Full Usage: evaluateSettled start logger provider norms set cmd pc

Parameters:
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.

start : DateTime
logger : Logger
provider : IResourceProvider
norms : TotalNorm array
set : RuleSet option
cmd : OrderContext -> Command
pc : PlanContext
Returns: Result<Outcome<PlanContext>, Message list>

findRuleSet category sets

Full Usage: findRuleSet category sets

Parameters:
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.

category : NutritionCategory
sets : RuleSet[]
Returns: Result<RuleSet, OrderPlanError>

generic pc

Full Usage: generic pc

Parameters:
Returns: string

Returns the generic of the order of the context, else the generic picked in the filter, else an empty string.

pc : PlanContext
Returns: string

nutritionCategory pc

Full Usage: nutritionCategory pc

Parameters:
Returns: NutritionCategory option

Returns the nutrition category of a plan context, or None for a medication.

pc : PlanContext
Returns: NutritionCategory option

resolveChange cmd pc

Full Usage: resolveChange cmd pc

Parameters:
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.

cmd : OrderContext -> Command
pc : PlanContext
Returns: Result<((OrderContext -> Command) * PlanContext), Message list>

ruleSetOf provider pat category

Full Usage: ruleSetOf provider pat category

Parameters:
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.

provider : IResourceProvider
pat : PatientData
category : NutritionCategory option
Returns: Result<(RuleSet array * RuleSet option), OrderPlanError>

withPatientData patientData pc

Full Usage: withPatientData patientData pc

Parameters:
Returns: PlanContext

Sets the patient data of the order context of a plan context.

patientData : PatientData
pc : PlanContext
Returns: PlanContext

Type something to start searching.