Rules and the Library resources that contain their logic are provided in the eHealth Infrastructure through the Library Service. Once created as Library resources, they can be made part of the PlanDefinition/ActivityDefinition complex (defined as templates). The PlanDefinition/ActivityDefinition and Library complex becomes interesting when applied to particular Patient resources in the form of CarePlan/ProcedureRequest ServiceRequest resources. Library resources, whether of calculation or automated processing type, come into use immediately prior before or after the submission of measurement. Before delving into details on the life cycle of rules and Library resources, the described ways in which Library resources are involved have an impact on some ground rules described in the following.
...
- A Library resource (and the rule contained in it) is immutable. The only element allowed to change is the
Library.status
which can change fromactive
toretired
. Change to retired status does not affect how it is used and is solely to signify that the Library should no longer be used in future CarePlan/ProcedureRequestServiceRequest. - Multiple versions and revisions of a rule can co-exist, each in a Library resource of their own.
Creating and updating of Library resources is controlled through privileges and authorization based on ownership and co-author specified in Library.ehealth-modifier-role
.
Preparing a New Rule/Library
A rule expresses desired clinical desired outcome(s) given input and a set of decisions.
Identify the organizational scope and individuals participating in the rule definition
...
Define input, decisions and desired
...
outcomes expressed in the participants'
...
wording
If the answer(s) to a questionnaire is involved (as QuestionnaireResponse), provide the questionnaire definition.
Hint: Provide a description that covers as many ‘what-ifs’ as possible (software developers/testers tend to uncover edge cases/additional what-ifs)
State a point
...
of
...
contact that can elaborate and provide further decisions
Identify the organization(s) to be set as owner of the rule
Writing a Rule and Creating a Library
...
The variable to hold output is defined as a global (see DRL Globals), for instance, to return a Coding:
global org.hl7.fhir.dstu3.model.CodeableConcept ruleResult
The type specified must correspond to that defined as the output type in Library.parameter
.
function (optional)
A number of Several functions supporting the rule logic can be added. See examples in https://ehealth-dk.atlassian.net/wiki/spaces/EDTW/pages/562692264/Example+Library+Resources#Automated-Processing-Type-Library-Resource-Examples .
...
global com.systematic.ehealth.automatedprocessing.AutomatedProcessingDTO ruleResult
function (optional)
A number of Several functions supporting the rule logic can be added. See examples in https://ehealth-dk.atlassian.net/wiki/spaces/EDTW/pages/562692264/Example+Library+Resources#Automated-Processing-Type-Library-Resource-Examples .
...
The rule logic can be tested in the “library” codebase repository. In the current test harness, the rule can be subjected to different input inputs and assertions can be made against instructions (for automated processing type rule) and/or GuidanceResponse returned upon invoking the evaluate
operation.
...
Once adequately tested, a Library can be deployed to the eHealth Infrastructure. Currently, this is performed by including the rule and creating the Library in the “kol-rules” codebase repository.
...
The Library can be slated for retirement by setting the Library.status
to retired
. As mentioned this signifies that future use should be prevented and does not affect current use of the Library neither in the PlanDefinition/ActivityDefinition complex nor in CarePlan/ProcedureRequestServiceRequest. To immediately stop the use of a Library, all ProcedureRequest ServiceRequest defined by ActivityDefinition referencing the Library must be de-activated and possibly replaced by a new, active ProcedureRequestServiceRequest.