Logo GenPRES

Resources Module

Declares the resources of the formulary, loads each resource once in dependency order, and provides the loaded resources with an optional cache.

Types and nested modules

Type/Module Description

Departments

Collects the distinct departments named by the dose rules, the solution rules and the reconstitutions, and tests whether a department is known.

Keys

Holds the typed key of every resource.

Locations

Collects the distinct locations named by the dose rules, the solution rules and the reconstitutions.

ResourceKey

Creates the typed key of a resource from the name of the resource.

CachedResourceProvider

A resource provider that loads the resources on first use and caches them. With a TTL in minutes it loads them again after the TTL; without one the cache never expires. A failed load is cached as empty resources.

CoreCalculationWeightsAndHeights

CoreEGFRBandOption

CoreEGFRBandSheetWarning

CoreNormalValueError

CoreNormalValueSheetError

CoreNormalValueSheetWarning

CoreNormalValueTables

Data

IResourceProvider

Gives the loaded resources, built and in memory.

IResourceResolver

Resolves the other resources a loader depends on while the loader runs.

LoadEngine

Resolves a resource on its first request, after the resources it depends on, and caches the value. Collects the warnings of every loader. Raises ResourceLoadError for a loader error, a cyclic dependency or a resource that is not registered.

LoadedResources

The loaded resources as a typed ResourceState, and as a map of every resolved resource by name for IResourceProvider.Get and the resources that are functions.

PrescriptionRuleCache

A cache of the prescription rules per patient for the dose rules and the stand-alone dose rules of a load, with the other rules of the load it is built from.

ResourceInfo

ResourceKey<'T>

The name of a resource, typed with the value type 'T of the resource.

ResourceLoadError

ResourceLoader

Takes the resolver for the dependencies and returns the boxed value with the non-fatal warnings, or the fatal errors. The value is boxed so one registry holds every resource type; the typed keys unbox it at the right type.

ResourceProvider

A plain provider over an already-loaded resource set.

ResourceRegistry

The loader of every resource by name. A new resource needs only a new entry.

ResourceState

The loaded resources: the data read from the sources in Data, and the products and rules built from it at the top level.

Functions and values

Function or value Description

calculationWeightsAndHeightsOf rows

Full Usage: calculationWeightsAndHeightsOf rows

Parameters:
    rows : Map<string, string[][]>

Returns: Result<(CalculationWeightsAndHeights * Message list), Message list>

Parses the calculation weights and heights from the rows with GenCORE. Returns them with a warning for each correction, or an error for each problem.

rows : Map<string, string[][]>
Returns: Result<(CalculationWeightsAndHeights * Message list), Message list>

defaultRegistry logger dataUrlId

Full Usage: defaultRegistry logger dataUrlId

Parameters:
    logger : Logger
    dataUrlId : string

Returns: ResourceRegistry

The default registry, which reads the sheets of dataUrlId. A loader names its dependencies with r.Get, and the engine loads each resource once. The parenteral, enteral and other products all read the formularyProducts resource, so the Formulary sheet is read once.

logger : Logger
dataUrlId : string
Returns: ResourceRegistry

departmentsOf loaded

Full Usage: departmentsOf loaded

Parameters:
Returns: string[]

The departments of a resolved resource set; none when the rules did not load.

loaded : LoadedResources
Returns: string[]

derive f r

Full Usage: derive f r

Parameters:
Returns: Result<(obj * Message list), Message list>
Type parameters: 'T

Makes a loader that builds a value from other resources, without warnings.

f : IResourceResolver -> 'T
r : IResourceResolver
Returns: Result<(obj * Message list), Message list>

deriveWith f r

Full Usage: deriveWith f r

Parameters:
Returns: Result<(obj * Message list), Message list>
Type parameters: 'T

Makes a loader that builds a value from other resources, with warnings.

f : IResourceResolver -> 'T * Message list
r : IResourceResolver
Returns: Result<(obj * Message list), Message list>

distinctNames named

Full Usage: distinctNames named

Parameters:
    named : string option seq

Returns: string array

Returns the names the rules give, such as the departments or the locations: trimmed, blanks ignored, distinct and sorted.

named : string option seq
Returns: string array

egfrBandOptionsOf rows

Full Usage: egfrBandOptionsOf rows

Parameters:
    rows : string[][]

Returns: EGFRBandOption list * Message list

Parses the eGFR band options from the rows with GenCORE, with a warning for every problem. Empty rows give no options and no warning, because the failed sheet read has already warned.

rows : string[][]
Returns: EGFRBandOption list * Message list

egfrBandSheetWarningText warning

Full Usage: egfrBandSheetWarningText warning

Parameters:
Returns: string

Returns the message text for a problem in the eGFR band sheet.

warning : EGFRBandSheetWarning
Returns: string

loadAllResources logger dataUrlId

Full Usage: loadAllResources logger dataUrlId

Parameters:
    logger : Logger
    dataUrlId : string

Returns: Result<LoadedResources, Message list>

Loads every resource of the default registry.

logger : Logger
dataUrlId : string
Returns: Result<LoadedResources, Message list>

loadAllResourcesWithRegistry registry

Full Usage: loadAllResourcesWithRegistry registry

Parameters:
Returns: Result<LoadedResources, Message list>

Loads every resource of the registry. Returns the errors of the first resource that fails.

registry : ResourceRegistry
Returns: Result<LoadedResources, Message list>

locationsOf loaded

Full Usage: locationsOf loaded

Parameters:
Returns: string[]

The locations of a resolved resource set; none when the rules did not load.

loaded : LoadedResources
Returns: string[]

maxCachedPatients

Full Usage: maxCachedPatients

Returns: int

The number of distinct patients the prescription rules are cached for.

Returns: int

normalValueErrorText err

Full Usage: normalValueErrorText err

Parameters:
Returns: string

Returns the message text for an error in the normal-value rows.

err : NormalValueError
Returns: string

normalValueSheetErrorText err

Full Usage: normalValueSheetErrorText err

Parameters:
Returns: string

Returns the message text for an error in the rows of the sheet of the calculation weights or heights.

err : NormalValueSheetError
Returns: string

normalValueSheetWarningText warning

Full Usage: normalValueSheetWarningText warning

Parameters:
Returns: string

Returns the message text for a problem in the sheet of the calculation weights or heights that the parse corrects.

warning : NormalValueSheetWarning
Returns: string

normalValueTablesOf rows

Full Usage: normalValueTablesOf rows

Parameters:
    rows : Map<string, string[][]>

Returns: NormalValueTables option * Message list

Parses the normal-value tables from the rows with GenCORE. Returns None with a warning per error when the rows do not parse. Empty rows return None without a warning, because the failed sheet read has already warned.

rows : Map<string, string[][]>
Returns: NormalValueTables option * Message list

ofResult f arg2

Full Usage: ofResult f arg2

Parameters:
Returns: Result<(obj * Message list), Message list>
Type parameters: 'T

Makes a loader without dependencies from a read that returns a Result. An error fails the whole load.

f : unit -> Result<'T, Message list>
arg1 : IResourceResolver
Returns: Result<(obj * Message list), Message list>

ofResultOrDefault note fallback f arg4

Full Usage: ofResultOrDefault note fallback f arg4

Parameters:
    note : string - Says what was not loaded and what that means.
    fallback : 'T - The value returned on an error.
    f : unit -> Result<'T, Message list> - The read.
    arg3 : IResourceResolver

Returns: Result<(obj * Message list), Message list>
Type parameters: 'T

Makes a loader without dependencies whose failure does not fail the whole load.

On an error the loader returns fallback and turns each error into a warning that starts with note. The warning shows in ResourceInfo.Messages, and a reload of the resources retries the read.

note : string

Says what was not loaded and what that means.

fallback : 'T

The value returned on an error.

f : unit -> Result<'T, Message list>

The read.

arg3 : IResourceResolver
Returns: Result<(obj * Message list), Message list>

ofResultWith f arg2

Full Usage: ofResultWith f arg2

Parameters:
Returns: Result<(obj * Message list), Message list>
Type parameters: 'T

Makes a loader without dependencies that passes the warnings of its result on.

f : unit -> Result<('T * Message list), Message list>
arg1 : IResourceResolver
Returns: Result<(obj * Message list), Message list>

prescriptionRuleCacheLoader

Full Usage: prescriptionRuleCacheLoader

Returns: ResourceLoader

Builds the prescription rule cache over the solution and renal rules, the route mappings, the additive lookup and the predilution rules of one load. The dose rules and the stand-alone dose rules of the load each get a memo of at most maxCachedPatients patients. A reload builds a new, empty cache.

Returns: ResourceLoader

renalRuleDataLoader fetch

Full Usage: renalRuleDataLoader fetch

Parameters:
Returns: IResourceResolver -> Result<(obj * Message list), Message list>
Type parameters: 'a

The loader of the renal rule data. A renal sheet that fails to load fails the whole load, because empty renal rules would give every patient with a reduced kidney function the full dose.

fetch : unit -> Result<'a, Message list>
Returns: IResourceResolver -> Result<(obj * Message list), Message list>

Type something to start searching.