Logo GenPRES

OrderContext Module

Holds the empty order context and the changes a user makes to an order context: filter choices, diluent, components, scenario and order variable values.

Types and nested modules

Type/Module Description

Argumentation

Trims the argumentation a user writes for a deviation from the rules to at most 1000 characters and writes the argumentation to an order context.

Target (Module)

Reads and changes the order variable in an order that a target addresses.

FilterField

A field of the order context filter.

Options

What a user picks from: a filter field, the diluents, the components, the scenarios, or the values of an order variable.

Target (Type)

The order variable a command addresses: a level, its property, and the names that locate a component or an item.

Functions and values

Function or value Description

anyChosen f

Full Usage: anyChosen f

Parameters:
Returns: bool

Returns true when any filter field has a choice.

f : Filter
Returns: bool

applyChange field clearOwn write ctx

Full Usage: applyChange field clearOwn write ctx

Parameters:
Returns: OrderContext

Writes a change to one filter field and clears the scenarios, the picked products and the dose rule components, because these depend on the whole filter. A picked value keeps the other choices: the server narrows every option list by all choices, so the value agrees with them. When clearOwn is true, the field is emptied: its own options and the choices in the later steps of chain are cleared too. The options of those later fields stay until the server sends new ones, so the fields remain usable meanwhile. When no choice is left, all options are cleared, because they were narrowed by choices that are gone.

field : FilterField
clearOwn : bool
write : Filter -> Filter
ctx : OrderContext
Returns: OrderContext

chain ctx

Full Usage: chain ctx

Parameters:
Returns: FilterField list list

Returns the filter fields as steps in the order they are chosen. Emptying a field clears the choices in the later steps, not the choices in its own step. For a medication, the indication and the generic share the first step, because either can be chosen first and each narrows the options of the other; the route, form and dose type depend on the medication. For nutrition, the composition (the generic) comes first and the indication follows from it. A field that is not in the steps clears no other choices.

ctx : OrderContext
Returns: FilterField list list

changeDiluent n ctx

Full Usage: changeDiluent n ctx

Parameters:
Returns: Result<OrderContext, string>

Sets the diluent to its nth option, or empties it with None. Returns an error when n is out of range.

n : int option
ctx : OrderContext
Returns: Result<OrderContext, string>

changeFilter field n ctx

Full Usage: changeFilter field n ctx

Parameters:
Returns: Result<OrderContext, string>

Sets a filter field to its nth option, or empties it with None. Returns an error when n is out of range.

field : FilterField
n : int option
ctx : OrderContext
Returns: Result<OrderContext, string>

clearAll ctx

Full Usage: clearAll ctx

Parameters:
Returns: OrderContext

Returns an empty context with the patient data of ctx.

ctx : OrderContext
Returns: OrderContext

clearChoice field f

Full Usage: clearChoice field f

Parameters:
Returns: Filter

Clears the choice of a field and keeps its options.

field : FilterField
f : Filter
Returns: Filter

clearField field f

Full Usage: clearField field f

Parameters:
Returns: Filter

Clears the choice and the options of a field.

field : FilterField
f : Filter
Returns: Filter

componentsChange cs ctx

Full Usage: componentsChange cs ctx

Parameters:
Returns: OrderContext

Selects the named components; an empty array selects no optional component.

cs : string[]
ctx : OrderContext
Returns: OrderContext

contribution ctx

Full Usage: contribution ctx

Parameters:
Returns: OrderScenario option

Returns the scenario a context contributes to the plan when it has exactly one scenario; None otherwise. It copies PlanContext.contribution in GenORDER; an agreement test in the server tests keeps both equal.

ctx : OrderContext
Returns: OrderScenario option

count options ctx

Full Usage: count options ctx

Parameters:
Returns: int

Returns the number of options. For a variable it is 0 when the variable has no values or the context does not have exactly one scenario.

options : Options
ctx : OrderContext
Returns: int

diluentChange s ctx

Full Usage: diluentChange s ctx

Parameters:
Returns: OrderContext
s : string option
ctx : OrderContext
Returns: OrderContext

doseTypeChange dt ctx

Full Usage: doseTypeChange dt ctx

Parameters:
Returns: OrderContext
dt : DoseType option
ctx : OrderContext
Returns: OrderContext

empty

Full Usage: empty

Returns: OrderContext
Returns: OrderContext

filter

Full Usage: filter

Returns: Filter
Returns: Filter

filterFields

Full Usage: filterFields

Returns: FilterField list

All filter fields, used to clear the whole filter.

Returns: FilterField list

formChange s ctx

Full Usage: formChange s ctx

Parameters:
Returns: OrderContext
s : string option
ctx : OrderContext
Returns: OrderContext

indicationChange s ctx

Full Usage: indicationChange s ctx

Parameters:
Returns: OrderContext
s : string option
ctx : OrderContext
Returns: OrderContext

medicationChange s ctx

Full Usage: medicationChange s ctx

Parameters:
Returns: OrderContext
s : string option
ctx : OrderContext
Returns: OrderContext

nth what n xs

Full Usage: nth what n xs

Parameters:
    what : string
    n : int
    xs : 'a[]

Returns: Result<'a, string>
Type parameters: 'a

Returns the option at index n, counted from 0, or an error when n is out of range.

what : string
n : int
xs : 'a[]
Returns: Result<'a, string>

nutritionCategory ctx

Full Usage: nutritionCategory ctx

Parameters:
Returns: NutritionCategory option

Returns the nutrition category of a context, None for a medication. It copies PlanContext.nutritionCategory in GenORDER; an agreement test in the server tests keeps both equal.

ctx : OrderContext
Returns: NutritionCategory option

routeChange s ctx

Full Usage: routeChange s ctx

Parameters:
Returns: OrderContext
s : string option
ctx : OrderContext
Returns: OrderContext

scenario ctx

Full Usage: scenario ctx

Parameters:
Returns: Result<OrderScenario, string>

Returns the single scenario of the context, or an error with the number of scenarios.

ctx : OrderContext
Returns: Result<OrderScenario, string>

seedFilter source ind gen rte frm dt ctx

Full Usage: seedFilter source ind gen rte frm dt ctx

Parameters:
Returns: OrderContext

Sets the indication, generic, route, form and dose type from a source outside the filter fields. Formulary and Parenteralia keep the diluent only when the generic, route and form are the same (for Formulary also the indication), and clear the scenarios. Url writes over the current filter and keeps the diluent, and Reload changes nothing. The selected components and picked products stay only when all five choices are the same. OrderContext.seedFilter in GenORDER applies the same rules; an agreement test in the server tests keeps both equal.

source : SeedSource
ind : string option
gen : string option
rte : string option
frm : string option
dt : DoseType option
ctx : OrderContext
Returns: OrderContext

selectNthScenario n ctx

Full Usage: selectNthScenario n ctx

Parameters:
Returns: Result<OrderContext, string>

Narrows the context to its nth scenario and sets the filter form to the form of that scenario. Returns an error when n is out of range.

n : int
ctx : OrderContext
Returns: Result<OrderContext, string>

setNth target n ctx

Full Usage: setNth target n ctx

Parameters:
Returns: Result<OrderContext option, string>

Sets the variable to its nth value, as the dose dialog does. Returns None when the variable has no values, and an error without a single scenario, without the variable or for an index out of range.

target : Target
n : int
ctx : OrderContext
Returns: Result<OrderContext option, string>

setNthComponents ns ctx

Full Usage: setNthComponents ns ctx

Parameters:
Returns: Result<OrderContext, string>

Selects the components at these positions of the component options. Returns the first index error.

ns : int[]
ctx : OrderContext
Returns: Result<OrderContext, string>

setPatientData pat ctx

Full Usage: setPatientData pat ctx

Parameters:
Returns: OrderContext
pat : PatientData
ctx : OrderContext
Returns: OrderContext

values ovar

Full Usage: values ovar

Parameters:
Returns: string array

Returns the keys of the values of a variable; empty when it has no values.

ovar : OrderVariable
Returns: string array

withOrder ord ctx

Full Usage: withOrder ord ctx

Parameters:
Returns: OrderContext

Replaces the order in the scenario with the same order id.

ord : Order
ctx : OrderContext
Returns: OrderContext

withoutComponents f

Full Usage: withoutComponents f

Parameters:
Returns: Filter

Clears the components of a dose rule: the additive options, the dose rule components and the component selection.

f : Filter
Returns: Filter

Type something to start searching.