GDL2 Object Model

Package Structure

The Guideline Object Model, the object model of GDL2 consists of three packages, the guideline package, expression package and the terminology package, each described in detail through the following sections.

CDS cds packages
Figure 1. cds Package

Guideline Package

Overview

The following UML diagram shows the guideline and terminology packages.

CDS cds.guideline
Figure 2. cds.guideline Package

Class Definitions

GUIDELINE Class

  • Definition

Class

GUIDELINE

Description

Representation of a discrete guideline, which defines archetype bindings, rules and descriptive meta-data.

Inherit

AUTHORED_RESOURCE

Attributes

Signature

Meaning

1..1

id: String

Identification of this guideline. Syntax is a string of format:

  • concept_name '.v' [N[.M.P]]

For example: calculate_bmi.v1.

0..1

gdl_version: String

The version of the GDL the guide is written in, in a string of format:

  • N.M[.P]

i.e. a 2- or 3-number form of version, e.g. "1.0", "2.0", etc.

1..1

concept: String

The normative meaning of the guideline as whole. Expressed as a gt-code.

1..1

definition: GUIDELINE_DEFINITION

The main definition part of the guide. It consists of archetype bindings and rule definitions.

1..1

terminology: TERMINOLOGY

Terminology definitions of the guideline containing definitions and translations (if applicable) for every gt-code.

GUIDELINE_DEFINITION Class

  • Definition

Class

GUIDELINE_DEFINITION

Description

The definition of the guideline includes:

  • pre_conditions: conditions defining the applicability of this guideline to a subject;

  • data bindings: bindings to to archetypes and other sources;

  • rules: define the logic of the guideline;

  • template: defines the output reporting structure.

Attributes

Signature

Meaning

0..1

data_bindings: Hash<String,DATA_BINDING>

List of archetype/template bindings, which define specific elements to be used by rules in this guideline.

0..1

pre_conditions: List<ASSERTION>

Pre-conditions to be met before the guideline can be selected for execution. Pre-conditions constitute the definition of the guideline 'entry point', i.e. the match to a patient type to which the guideline may apply.

0..1

rules: Hash<String,RULE>

Map of rules indexed by local gt codes.

0..1

default_actions: List<ASSIGNMENT>

Actions that will always be performed, whenever the when conditions are evaluated, regardless of the result.

0..1

templates: Hash<String,OUTPUT_TEMPLATE>

One or more output termplates that define how to represent output reporting structure.

0..1

internal_variables: List<VARIABLE>

Variables used internally to a GDL guideline, i.e. not bound to external data entities. These are generated during parsing of expressions and used to track interim state.

RULE Class

  • Definition

Class

RULE

Description

A single rule defined in a guideline, of the logical form

when conditions then actions.

Conditions are assertions based on input and/or environment variables (e.g.time, date etc). Actions take the form of assignments to output variables.

Attributes

Signature

Meaning

1..1

id: String

The gt-code of this rule.

0..1

when: List<ASSERTION>

List of assertions that when evaluated to True cause the rule to be fired. The when assertions may only mention 'input' type variables.

0..1

then: List<ASSIGNMENT>

List of actions if the rule is fired. Each action is in the form of an assignment to an 'output' type variable.

1..1

priority: Integer

Indicates the evaluation order of Rules within a Guideline. Rules with a higher priority value are executed first.

DATA_BINDING Class

  • Definition

Class

DATA_BINDING

Description

A list of bindings of nodes for a data-set' - i.e. from the archetype (and optionally template) specified by archetype_id and template_id respectively, to guideline variables, each specified by an element binding.

Attributes

Signature

Meaning

1..1

model_id: String

The identifier of the data-set model (i.e. archetype or other) from which the list of elements is selected.

0..1

template_id: String

The ID of an optional template to be used for selecting elements.

0..1

bindings: Hash<String,ELEMENT>

Map of variable binding indexed by identifying gt-code of the variable.

0..1

predicates: List<ASSERTION>

Predicates (constraints) that need to be satisfied before rule execution can occur. Generally speaking, predicates are constraints on variable values, and can only mention gt-codes of variables.

1..1

type: String

Marker to indicate whether variable is an input or output variable in the data-set. The value can either be:

  • "INPUT": input data to the guideline, e.g. values retrieved from the EHR;

  • "OUTPUT": output value generated by Guideline Rule execution.

ELEMENT Class

  • Definition

Class

ELEMENT

Description

The binding between a specific node in an archetype and a variable in the guide.

Attributes

Signature

Meaning

1..1

id: String

The gt-code of this element.

1..1

path: String

The path within archetype to reach this element.

OUTPUT_TEMPLATE Class

  • Definition

Class

OUTPUT_TEMPLATE

Description

Definition of structure for reporting guideline execution results.

Attributes

Signature

Meaning

1..1

id: String

The gt-code of this output template.

1..1

name: String

Name of this template.

1..1

model_id: String

Identifier of a model that defines the structure of the object.

0..1

template_id: String

The identifier of a template based on the model identified by model_id defining the attached object.

1..1

object: String

Detailed output report structure as an object that may be defined by a published model.

Expressions Package

Overview

The expression package is illustrated below.

CDS cds.expression
Figure 3. cds.expression Package

Class Definitions

EXPRESSION_ITEM Class

  • Definition

Class

EXPRESSION_ITEM (abstract)

Description

Abstract parent of all valued elements that may be used as a term in an expression. Concrete descendant types are generated by a GDL2 parser when processing a GDL2 text.

The function type() returns a value for the type of any concrete element, which may have been inferred and stored during parsing (Constants and Variables), or may be looked up (library of function calls).

Functions

Signature

Meaning

1..1

type (): String

Type name of the item. Comparisons should be done case-insensitive.

OPERATOR Class

  • Definition

Class

OPERATOR (abstract)

Description

Abstract model of an operator-based expression.

Inherit

EXPRESSION_ITEM

Attributes

Signature

Meaning

1..1

operator: OPERATOR_KIND

The operator type of this expression.

UNARY_OPERATOR Class

  • Definition

Class

UNARY_OPERATOR

Description

Concrete model of a unary operator in the rule.

Inherit

OPERATOR

Attributes

Signature

Meaning

1..1

operand: EXPRESSION_ITEM

The operand.

BINARY_OPERATOR Class

  • Definition

Class

BINARY_OPERATOR

Description

Concrete model of a binary operator in the rule.

Inherit

OPERATOR

Attributes

Signature

Meaning

1..1

left: EXPRESSION_ITEM

Left operand.

1..1

right: EXPRESSION_ITEM

Right operand.

OPERATOR_KIND Enumeration

  • Definition

Enumeration

OPERATOR_KIND

Description

Enumeration of operator types.

Attributes

Signature

Meaning

ADDITION

Addition ('+') operation.

SUBTRACTION

Subtraction ('-') operation.

MULTIPLICATION

Multiplication ('*') operation.

DIVISION

Division ('/') operation.

EXPONENT

Exponent ('^') operation.

AND

Logical and ('&&') operation.

OR

Logical or ('||') operation.

NOT

Logical negation ('!') operation.

EQUALITY

Relational equality ('==') operation.

INEQUALITY

Relational inequality ('!=') operation.

LESS_THAN

Relational less-than ('<') operation.

GREATER_THAN

Relational greater-than ('>') operation.

LESS_THAN_OR_EQUAL

Relational less-than-or-equal ('<=') operation.

GREATER_THAN_OR_EQUAL

Relational greater-than-or-equal ('>=') operation.

IS_A

Subsumption operator ('is_a').

IS_NOT_A

Negated subsumption operator ('!is_a').

FOR_ALL

Universal quantifier operator ('∀').

FUNCTION_CALL Class

  • Definition

Class

FUNCTION_CALL

Description

Concrete expression in the form of a function.

Inherit

EXPRESSION_ITEM

Attributes

Signature

Meaning

0..1

items: List<EXPRESSION_ITEM>

Function arguments.

1..1

function: FUNCTION_KIND

The specific function.

FUNCTION_KIND Enumeration

  • Definition

Enumeration

FUNCTION_KIND

Description

Enumeration of function types.

Attributes

Signature

Meaning

abs

Returns the absolute value of a double value.

ceil

Returns the smallest double value that is greater than or equal to the argument and is equal to a mathematical integer.

exp

Returns Euler’s number e raised to the power of a double value.

floor

Returns the largest double value that is less than or equal to the argument and is equal to a mathematical integer.

log

Returns the natural logarithm (base e) of a double value.

log10

Returns the base 10 logarithm of a double value.

log1p

Returns the natural logarithm of the sum of the argument and 1.

round

Returns the closest long to the argument, with ties rounding to positive infinity.

sqrt

Returns the correctly rounded positive square root of a double value.

sin

Returns the trigonometric sine of an angle.

cos

Returns the trigonometric cosine of an angle.

max

Maximum value of N elements.

min

Minimum value of N elements.

count

Count of instances of an element.

sum

Total sum of N element values.

CONSTANT Class

  • Definition

Class

CONSTANT (abstract)

Description

Terminal expression element representing a constant; subtypes define constants of specific types.

Inherit

EXPRESSION_ITEM

Attributes

Signature

Meaning

1..1

name: String

Symbolic name of constant.

1..1

value: Any

Value of constant, redefined to specific types in descendants.

STRING_CONSTANT Class

  • Definition

Class

STRING_CONSTANT

Description

Constant of type String.

Inherit

CONSTANT

Attributes

Signature

Meaning

1..1
(redefined)

value: String

Value of constant, redefined to specific types in descendants.

INTEGER_CONSTANT Class

  • Definition

Class

INTEGER_CONSTANT

Description

Constant of type Integer.

Inherit

CONSTANT

Attributes

Signature

Meaning

1..1
(redefined)

value: Integer

Value of constant, redefined to specific types in descendants.

BOOLEAN_CONSTANT Class

  • Definition

Class

BOOLEAN_CONSTANT

Description

Inherit

CONSTANT

Attributes

Signature

Meaning

1..1
(redefined)

value: Boolean

Value of constant, redefined to specific types in descendants.

DATE_TIME_CONSTANT Class

  • Definition

Class

DATE_TIME_CONSTANT

Description

Constant of type Date/time.

Inherit

CONSTANT

Attributes

Signature

Meaning

1..1
(redefined)

value: Iso8601_date_time

Value of constant, redefined to specific types in descendants.

CODE_PHRASE_CONSTANT Class

  • Definition

Class

CODE_PHRASE_CONSTANT

Description

Constant of type Code phrase.

Inherit

CONSTANT

Attributes

Signature

Meaning

1..1
(redefined)

value: CODE_PHRASE

Value of constant, redefined to specific types in descendants.

CODED_TEXT_CONSTANT Class

  • Definition

Class

CODED_TEXT_CONSTANT

Description

Constant of type Coded text.

Inherit

CONSTANT

Attributes

Signature

Meaning

1..1
(redefined)

value: DV_CODED_TEXT

Value of constant, redefined to specific types in descendants.

ORDINAL_CONSTANT Class

  • Definition

Class

ORDINAL_CONSTANT

Description

Constant of type Ordinal.

Inherit

CONSTANT

Attributes

Signature

Meaning

1..1
(redefined)

value: DV_ORDINAL

Value of constant, redefined to specific types in descendants.

QUANTITY_CONSTANT Class

  • Definition

Class

QUANTITY_CONSTANT

Description

Constant of type Quantity.

Inherit

CONSTANT

Attributes

Signature

Meaning

1..1
(redefined)

value: DV_QUANTITY

Value of constant, redefined to specific types in descendants.

VARIABLE Class

  • Definition

Class

VARIABLE

Description

Terminal expression element representing a named variable with a definition provided by the code attribute, containing a gt-code.

Inherit

EXPRESSION_ITEM

Attributes

Signature

Meaning

1..1

name: String

Variable symbolic name.

1..1

code: String

Internal gt-code defining the meaning of this variable.

STATEMENT Class

  • Definition

Class

STATEMENT (abstract)

Description

Abstract concept of a statement, which is a self-standing procedural element.

ASSIGNMENT Class

  • Definition

Class

ASSIGNMENT

Description

A statement assigning an expression result to a variable.

Inherit

STATEMENT

Attributes

Signature

Meaning

1..1

variable: VARIABLE

Variable that is the target of the assignment.

1..1

expression: EXPRESSION_ITEM

Expression that is the source of the assignment.

ASSERTION Class

  • Definition

Class

ASSERTION

Description

A statement of the logical form assert(cond) that asserts the truth of a Boolean expression, which if not true, generates an exception at runtime.

Inherit

STATEMENT

Attributes

Signature

Meaning

1..1

expression: EXPRESSION_ITEM

Expression that is the subject of the assertion.

Invariants

Inv_expression_type: expression.type().is_case_insensitive_equal('Boolean')

Terminology Package

Overview

The terminology package is illustrated earlier. The TERMINOLOGY and TERM classes are slightly simplified versions of the ARCHETYPE_TERMINOLOGY and ARCHETYPE_TERM classes from the openEHR AOM2 specification.

Class Definitions

TERMINOLOGY Class

  • Definition

Class

TERMINOLOGY

Description

Local terminology of an archetype. This class defines the semantics of the terminology of an archetype.

Attributes

Signature

Meaning

1..1

is_differential: Boolean

Indicates whether this terminology is differential with respect to a specialisation parent, or complete.

1..1

original_language: String

Original language of the terminology, as set at creation or parsing time; must be a code in the ISO 639-1 2 character language code-set.

1..1

concept_code: String

Term code defining the meaning of the artefact as a whole, and always used as the at-code on the root node of the archetype. Must be defined in the term_definitions property.

1..1

term_definitions: Hash<String, Hash<String, TERM>>

Directory of term definitions as a two-level table. The outer hash keys are language codes, e.g. "en", "de", while the inner hash keys are term codes, e.g. "gt17".

0..1

term_bindings: Hash <String, TERM_BINDING>

Directory of bindings to external terminology codes and value sets, as a two-level table. The outer hash keys are terminology ids, e.g. "SNOMED_CT", and the inner hash keys are constraint codes, e.g. "at4", "ac13" or paths. The indexed DV_URI objects represent references to externally defined resources, either terms, ontology concepts, or terminology subsets / ref-sets.

Functions

Signature

Meaning

1..1

specialisation_depth (): Integer

Specialisation depth of this artefact. Unspecialised artefacts have depth 0, with each additional level of specialisation adding 1 to the specialisation_depth.

1..1

has_language (
a_lang: String[1]
): Boolean

True if language a_lang is present in archetype terminology.

1..1

has_terminology (
a_terminology_id: String[1]
): boolean

True if there are bindings to terminology a_terminology_id present. True if terminology `a_terminology' is present in archetype ontology.

1..1

has_term_code (
a_code: String[1]
): boolean

True if code a_code defined in this terminology.

1..1

term_definition (
a_lang: String[1],
a_code: String[1]
): TERM

Pre: has_term-definition (a_lang, a_code)

Term definition for a code, in a specified language.

1..1

term_binding (
a_terminology: String[1],
a_code: String[1]
): Uri

Pre: has_term_binding (a_terminology_id, a_code)

Binding of constraint corresponding to a_code in target external terminology a_terminology_id, as a string, which is usually a formal query expression.

1..1

terminologies_available (): List<String>

List of terminologies to which term or constraint bindings exist in this terminology, computed from bindings.

1..1

languages_available (): List<String>

List of languages in which terms in this terminology are available.

Invariants

Original_language_validity: code_set (Code_set_id_languages).has_concept_id (original_language)

concept_code_validity: id_codes.has (concept_code)

Term_bindings_validity: bindings /= void implies not bindings.is_empty

Parent_archetype_valid: parent_archetype.terminology = Current

TERM Class

  • Definition

Class

TERM

Description

Representation of any coded entity (term or constraint) in the artefact terminology.

Attributes

Signature

Meaning

1..1

code: String

Code of this term.

1..1

text: String

Short term text, typically for display.

1..1

description: String

Full description text.

0..1

other_items: Hash<String, String>

Hash of keys and corresponding values for other items in a term, e.g. provenance. Hash of keys ("text", "description" etc) and corresponding values.

TERM_BINDING Class

  • Definition

Class

TERM_BINDING

Description

One binding between a local gt-code and one or more external bindings

Attributes

Signature

Meaning

0..1

bindings: List<TERM>

List of external codes, typically parsed in either URI form or openEHR standard form namespace '::' code.

1..1

code: String

Local gt-code to which external terms are bound.