openEHR logo

Foundation Types

Issuer: openEHR Specification Program

Release: BASE Release-1.2.0

Status: STABLE

Revision: [latest_issue]

Date: [latest_issue_date]

Keywords: openehr, identifiers, types

openEHR components
© 2017 - 2021 The openEHR Foundation

The openEHR Foundation is an independent, non-profit foundation, facilitating the sharing of health records by consumers and clinicians via open specifications, clinical models and open platform implementations.

Licence

image Creative Commons Attribution-NoDerivs 3.0 Unported. https://creativecommons.org/licenses/by-nd/3.0/

Support

Issues: Problem Reports
Web: specifications.openEHR.org

Amendment Record

Issue Details Raiser Completed

BASE Release 1.2.0

1.2.0

SPECBASE-34: Allow +14:00 timezone.

S Iancu

22 Mar 2021

SPECBASE-25: Improve and correct function definitions in Foundation types. Add 'nominal' computation functions to Iso8601_date and Iso8601_date_time. Add negative() functions to numeric classes and Iso8601_duration.

openEHR SEC

30 Apr 2020

BASE Release 1.1.0

1.1.0

SPECRM-72: Add guidance on date/time formatting, recommending extended ISO 8601 format.

B Lah

22 Nov 2018

SPECBASE-15. Add foundation types specification to BASE component.
Rename Aggregate to Container to be more consistent with current languages and also openEHR BMM.

T Beale

19 Jul 2018

SPECPUB-6. Correct UML package nesting and paths in documents; insert base parent package.

T Beale

27 Nov 2017

0.7.6

Re-organise heading structure. Remove references to ISO 11404. Rename to 'Foundation types';
added type cross-reference table.

T Beale

17 Aug 2017

0.7.0

Initial Writing. Taken from openEHR RM Release 1.0.3 Support Model

T Beale

20 May 2016

The Amendment history relevant to the original content in this specification can be found here (a fully hyper-linked version may be found on the working baseline).

Acknowledgements

Authors

This specification is developed and maintained by the openEHR Specifications Editorial Committee

Contributors

This specification has benefited from formal and informal input from the openEHR and wider health informatics community.

Trademarks

  • 'openEHR' is a registered trademark of the openEHR Foundation

1. Preface

1.1. Purpose

This document describes the openEHR Foundation Types, a collection of built-in and library types whose semantics are assumed by all other openEHR specifications.

The intended audience includes:

  • Standards bodies producing health informatics standards;

  • Research groups using openEHR, ISO 13606, archetypes and related technologies;

  • The open source healthcare community;

  • Solution vendors.

Prerequisite documents for reading this document include:

1.3. Status

This specification is in the STABLE state. The development version of this document can be found at https://specifications.openehr.org/releases/BASE/Release-1.2.0/foundation_types.html.

Known omissions or questions are indicated in the text with a 'to be determined' paragraph, as follows:

TBD: (example To Be Determined paragraph)

1.4. Feedback

Feedback may be provided on the technical mailing list.

Issues may be raised on the specifications Problem Report tracker.

To see changes made due to previously reported issues, see the BASE component Change Request tracker.

1.5. Previous Versions

This specification is based on the types orginally defined in the openEHR Support Information Model from Release 1.0.3 of the Reference Model. Some changes have been made as follows.

1.5.1. Interval types

The additional types Point_interval and Proper_interval have been added, to support the common need for a point value and a proper interval to be specified as substitutable types. The types Multiplicity_interval and Cardinality have been added, from the AOM2 specification.

1.5.2. Functional meta-types

A collection of meta-types representing routines, procedures and functions has been added, to support specifications that need to use these concepts.

2. Overview

The openEHR Foundation Types (org.openehr.base.foundation_types package) consists of generic low level types assumed by and used throughout the openEHR components and specifications. The types described here are specified in order to establish the names and minimal semantics of typical standard classes, as used by all other openEHR specifications, and to provide a mapping point into implementation technologies.

The set of types chosen here is based on a common set derived from various published sources, including:

The package structure is illustrated below.

BASE foundation types packages
Figure 1. base.foundation_types Package

The primitive_types, structures and time packages describe types assumed by the openEHR specifcations to exist in any implementation technology, such as a programming language, schema language or database environment.

The functional package includes types enabling functional programming primitives to be expressed in the openEHR modelling environment, i.e. functions-as-objects and 'lambda' expressions.

The types are described in this specification are typically of two kinds: built-in types, which are those built in to a type system of the development language, and library types, which are assumed to be available in a (class) library defined in the formalism. Thus, the type Boolean is always assumed to exist in a formalism, while the type Array<T> is assumed to be available in a library. For practical purposes, these two categories do not matter greatly - whether String is really a library class (the usual case) or an inbuilt type doesn’t make much difference to the programmer. They are shown separately here mainly as an explanatory convenience. The built-in types are indicated in the UML with the «Value_type» stereotype.

The assumptions that openEHR makes about existing types are documented below in terms of interface definitions. Each of these definitions contains only the assumptions required for the given type to be used in the openEHR type system - it is not by any means a complete interface definition. The name and semantics of any function used here for an assumed type might not be identical to those found in some implementation technologies. Any mapping required should be stated in the relevant implementation technology specification (ITS). To give a concrete example, where the assumed Set<T> type defined below has an operation has (item: T): Boolean which is used throughout the openEHR specifications, Java has the method contains() on its Set<T> class. In a Java implementation, the contains() method should then be used throughout the openEHR classes as expressed in Java, in place of the has () method.

2.1. Operators

Some operations have symbolic or textual operator equivalents defined, in order to support parsing of textual form of expressions. Two categories of operator are supported via two stereotypes that add a list of Strings to an operation, enabling standard operators, and optionally, symbolic operators to be associated with a function. These are as follows.

  • «ops»: default operator(s) for an operation, assumed to be expressible in normal text, for exmaple '=' for equal();

  • «sym_ops»: additional symbolic operators typically defined for mathematical and logical operations, e.g. '∀' for Container.for_all().

The main utility of such operators is to enable function signature-matching from parsed expressions. For example, the expression a_date_time - P1Y (subtract a time period of 1 year from a date/time) has the signature <[Iso8601_duration], ?>, equivalent to a function of the form func (dur: Iso8601_duration): ? defined on the type Iso8601_date_time (i.e. the return type is unknown until the function definition can be inferred). The correct function can be found on the latter type by searching for a function with the operator '-' and taking a single Iso8601_duration argument. In this specification, this turns out to be the Iso8601_duration.subtract() operation.

The operators provided by this means are not intended to prevent other kinds of operators being associated with functions defined on types in the openEHR specifications, rather they provide a minimal set for common operations.

2.2. The Any Class

Within all object-oriented and most other modern programming and modelling environments exists an ultimate ancestor type to which all others conform. In this specification, we assume the type Any, which defines a bare minimum of operations, and stands for the real Any or Object type found in real technologies.

The primary operations specified are those for equality, i.e.:

  • equal(other: Any): Boolean: return True if this and other are equal in value for value types, and for reference types, if they refer to the same object;

  • is_equal(other: Any): Boolean: return True if this and other are equal in value; typically redefined in descendants.

In these specifications, the equal() operation is normally rendered using its operator, i.e. the '=' sign, while is_equal() is always specified as a function call.

2.3. openEHR Leaf Types

The sections below provide formal definitions of all the foundation types used in openEHR. A subset of these can be understood as terminal or leaf types, typically used as terminal value types in other information models. The following diagram provides an aide memoire for the leaf types.

BASE foundation types leaf types
Figure 2. Leaf Types

2.4. Class Definitions

2.4.1. Any Class

Class

Any (abstract)

Description

Abstract ancestor class for all other classes. Usually maps to a type like Any or Object in an object-oriented technology. Defined here to provide value and reference equality semantics.

Functions

Signature

Meaning

1..1
(abstract)

is_equal (
other: Any[1]
): Boolean

Value equality: return True if this and other are attached to objects considered to be equal in value.

Parameters
other

Other object for comparison.

1..1

equal alias "=", "==" (
other: Any[1]
): Boolean

Reference equality for reference types, value equality for value types.

Parameters
other

Other object for comparison.

1..1

instance_of (
a_type: String[1]
): Any

Create new instance of a type.

1..1

type_of (
an_object: Any[1]
): String

Type name of an object as a string. May include generic parameters, as in "Interval<Time>".

1..1

not_equal alias "!=", "≠" (
other: Ordered[1]
): Boolean

True if current object not equal to other. Returns not equal().

3. Primitive Types

3.1. Overview

This section describes primitive types assumed by all openEHR models. These are types supported directly by most programing languages, and usually visible via either a class interface and/or a built-in raw value type. The following table lists the primitive types assumed by openEHR.

Type name
in openEHR
Description

Octet

a type whose value is an 8-bit value.

Character

a type whose value is a member of an 8-bit character-set (ISO: "repertoire").

Boolean

logical True/False values; usually physically represented as an integer, but need not be.

Integer

32-bit integers.

Integer64

64-bit integers.

Real

32-bit real numbers in any interoperable representation, including single-width IEEE floating point.

Double

64-bit real numbers, in any interoperable representation including double-precision IEEE floating point.

String

represents unicode-enabled strings.

The figure below illustrates these types. Simple inheritance relationships are shown which facilitate the type descriptions below. Actual inheritance from or subsitutability for an Any class is not assumed, and is shown only for convenience (e.g. to indicate that the '=' operator is available on any type). The type Ordered_numeric is on the other hand is used to indicate assumed substitutability of numeric types, and is intended to be mapped to an equivalent type in a real type system (e.g. in Java, java.lang.Number). Data-oriented implementation type systems such as XML-schema do not have such operations.

BASE foundation types.primitive types
Figure 3. base.foundation_types.primitive_types Package

3.2. Unicode

It is assumed in the openEHR specifications that Unicode is supported by the type String. Unicode is needed for all Asian, Arabic and other script languages, for both data values (particularly plain text and coded text) and for many predefined string attributes of the classes in the openEHR Reference Model. It encompasses all existing character sets. In openEHR, UTF-8 encoding is assumed.

3.3. Class Definitions

3.3.1. Boolean Class

Class

Boolean

Description

Type representing minimal interface of built-in Boolean type.

Inherit

Any

Functions

Signature

Meaning

1..1

conjunction alias "and", "∧", "&" (
other: Boolean[1]
): Boolean

Post_de_Morgan: Result = not (not self or not other)
Post_commutative: Result = (other and self)

Logical conjunction of this with other.

1..1

semistrict_conjunction alias "and then", "&&" (
other: Boolean[1]
): Boolean

Post_de_Morgan: Result = not (not self or else not other)

Boolean semi-strict conjunction with other.

1..1

disjunction alias "or", "∨", "|" (
other: Boolean[1]
): Boolean

Post_de_Morgan: Result = not (not self and not other)
Post_commutative: Result = (other or Current)
Post_consistent_with_semi_strict: Result implies (self or else other)

Boolean disjunction with other.

1..1

semistrict_disjunction alias "or else", "||" (
other: Boolean[1]
): Boolean

Post_de_Morgan: Result = not (not self and then not other)

Boolean semi-strict disjunction with other.

1..1

exclusive_disjunction alias "xor", "⊻" (
other: Boolean[1]
): Boolean

Post_definition: Result = self or other) and not (self and other

Boolean exclusive or with other.

1..1

implication alias "implies", "⇒" (
other: Boolean[1]
): Boolean

Post_definition: Result = (not self or else other)

Boolean implication of other (semi-strict)

1..1

negation alias "not", "¬", "!" (): Boolean

Boolean negation of the current value.

Invariants

Involutive_negation: is_equal (not (not self))

Non_contradiction: not (self and (not self))

Completeness: self or else (not self)

3.3.2. Ordered Class

Class

Ordered (abstract)

Description

Abstract parent class of ordered types i.e. types on which the '<' operator is defined.

Inherit

Any

Functions

Signature

Meaning

1..1
(abstract)

less_than alias "<" (
other: Ordered[1]
): Boolean

Arithmetic value comparison. Returns True if current object is less than other. This operator is effected and/or redefined in descendants to provide the appropriate ordering semantics for concrete types.

In conjunction with =, enables the definition of the related functions greater_than() etc.

1..1

less_than_or_equal alias "<=", "≤" (
other: Ordered[1]
): Boolean

Post_result: not (other < self)

True if current object less than or equal to other.

1..1

greater_than alias ">" (
other: Ordered[1]
): Boolean

Post_result: Result = (other < self)

True if current object greater than other.

1..1

greater_than_or_equal alias ">=", "≥" (
other: Ordered[1]
): Boolean

Post_result: Result = (other <= self)

True if current object greater than or equal to other.

3.3.3. Character Class

Class

Character

Description

Type representing minimal interface of built-in Character type.

Inherit

Ordered

3.3.4. Octet Class

Class

Octet

Description

Type representing minimal interface of built-in Octet type.

Inherit

Ordered

3.3.5. String Class

Class

String

Description

Type representing minimal interface of built-in String type, as used to represent textual data in any natural or formal language.

Inherit

Ordered

Functions

Signature

Meaning

1..1

is_empty (): Boolean

True if string is empty, i.e. equal to "".

1..1

is_integer (): Boolean

True if string can be parsed as an integer.

1..1

as_integer (): Integer

Return the integer corresponding to the integer value represented in this string.

1..1

append alias "+" (
other: String[1]
): String

Concatenation operator - causes other to be appended to this string.

1..1
(effected)

less_than alias "<" (
other: String[1]
): Boolean

Lexical comparison of string content based on ordering in relevant character set.

1..1

contains (
other: String[1]
): Boolean

Return True if this String contains other (case-sensitive).

3.3.6. Uri Class

Class

Uri

Description

A kind of String constrained to obey the syntax of RFC 3986.

Inherit

String

3.3.7. Numeric Class

Class

Numeric (abstract)

Description

Abstract parent class of numeric types, which are types which have various arithmetic and comparison operators defined.

Inherit

Any

Functions

Signature

Meaning

1..1
(abstract)

add alias "+" (
other: Numeric[1]
): Numeric

Sum with other (commutative). Actual type of result depends on arithmetic balancing rules.

1..1
(abstract)

subtract alias "-" (
other: Numeric[1]
): Numeric

Result of subtracting other. Actual type of result depends on arithmetic balancing rules.

1..1
(abstract)

multiply alias "*" (
other: Numeric[1]
): Numeric

Product by other. Actual type of result depends on arithmetic balancing rules.

1..1
(abstract)

divide alias "/" (
other: Numeric[1]
): Numeric

Divide by`other`. Actual type of result depends on arithmetic balancing rules.

1..1
(abstract)

exponent alias "^" (
other: Numeric[1]
): Numeric

Expontiation of this by other.

1..1
(abstract)

negative alias "-" (): Numeric

Generate negative of current value.

3.3.8. Ordered_Numeric Class

Class

Ordered_Numeric (abstract)

Description

Abstract notional parent class of ordered, numeric types, which are types with both the less_than() and arithmetic functions defined.

Inherit

Ordered, Numeric

3.3.9. Integer Class

Class

Integer

Description

Type representing minimal interface of built-in Integer type.

Inherit

Ordered_Numeric

Functions

Signature

Meaning

1..1
(effected)

add alias "+" (
other: Integer[1]
): Integer

Integer addition.

1..1
(effected)

subtract alias "-" (
other: Integer[1]
): Integer

Integer subtraction.

1..1
(effected)

multiply alias "*" (
other: Integer[1]
): Integer

Integer multiplication.

1..1
(effected)

divide alias "/" (
other: Integer[1]
): Double

Integer division.

1..1
(effected)

exponent alias "^" (
other: Double[1]
): Double

Integer exponentiation.

1..1

modulo alias "mod", "\\" (
mod: Integer[1]
): Integer

Return self modulo other.

1..1
(effected)

less_than alias "<" (
other: Integer[1]
): Boolean

Returns True if current Integer is less than other.

1..1
(effected)

negative alias "-" (): Integer

Generate negative of current Integer value.

1..1
(effected)

is_equal (
other: Integer[1]
): Boolean

Value equality: return True if this and other are attached to objects considered to be equal in value.

Parameters
other

Other object for comparison.

1..1
(redefined)

equal alias "=", "==" (
other: Integer[1]
): Boolean

Reference equality for reference types, value equality for value types.

Parameters
other

Other object for comparison.

3.3.10. Integer64 Class

Class

Integer64

Description

Type representing minimal interface of built-in Integer64 type.

Inherit

Ordered_Numeric

Functions

Signature

Meaning

1..1
(effected)

add alias "+" (
other: Integer[1]
): Integer64

Large integer addition.

1..1
(effected)

subtract alias "-" (
other: Integer[1]
): Integer64

Large integer subtraction.

1..1
(effected)

multiply alias "*" (
other: Integer[1]
): Integer64

Large integer multiplication.

1..1
(effected)

divide alias "/" (
other: Integer[1]
): Double

Large integer division.

1..1
(effected)

exponent alias "^" (
other: Double[1]
): Double

Large integer exponentiation.

1..1

modulo alias "mod", "\\" (
mod: Integer[1]
): Integer64

Large integer modulus.

1..1
(effected)

less_than alias "<" (
other: Integer64[1]
): Boolean

Returns True if current Integer is less than other.

1..1
(effected)

negative alias "-" (): Integer64

Generate negative of current Integer value.

1..1
(effected)

is_equal (
other: Integer64[1]
): Boolean

Value equality: return True if this and other are attached to objects considered to be equal in value.

Parameters
other

Other object for comparison.

1..1
(redefined)

equal alias "=", "==" (
other: Integer64[1]
): Boolean

Reference equality for reference types, value equality for value types.

Parameters
other

Other object for comparison.

3.3.11. Real Class

Class

Real

Description

Type used to represent decimal numbers. Corresponds to a single-precision floating point value in most languages.

Inherit

Ordered_Numeric

Functions

Signature

Meaning

1..1

floor (): Integer

Return the greatest integer no greater than the value of this object.

1..1
(effected)

add alias "+" (
other: Real[1]
): Real

Real number addition.

1..1
(effected)

subtract alias "-" (
other: Real[1]
): Real

Real number subtraction.

1..1
(effected)

multiply alias "*" (
other: Real[1]
): Real

Real number multiplication.

1..1
(effected)

divide alias "/" (
other: Real[1]
): Double

Real number division.

1..1
(effected)

exponent alias "^" (
other: Double[1]
): Double

Real number exponentiation.

1..1
(effected)

less_than alias "<" (
other: Real[1]
): Boolean

Returns True if current Real is less than other.

1..1
(effected)

negative alias "-" (): Real

Generate negative of current Real value.

1..1
(effected)

is_equal (
other: Real[1]
): Boolean

Value equality: return True if this and other are attached to objects considered to be equal in value.

Parameters
other

Other object for comparison.

1..1
(redefined)

equal alias "=", "==" (
other: Real[1]
): Boolean

Reference equality for reference types, value equality for value types.

Parameters
other

Other object for comparison.

3.3.12. Double Class

Class

Double

Description

Type used to represent double-precision decimal numbers. Corresponds to a double-precision floating point value in most languages.

Inherit

Ordered_Numeric

Functions

Signature

Meaning

1..1

floor (): Integer

Return the greatest integer no greater than the value of this object.

1..1
(effected)

add alias "+" (
other: Double[1]
): Double

Double-precision real number addition.

1..1
(effected)

subtract alias "-" (
other: Double[1]
): Double

Double-precision real number subtraction.

1..1
(effected)

multiply alias "*" (
other: Double[1]
): Double

Double-precision real number multiplication.

1..1
(effected)

divide alias "/" (
other: Double[1]
): Double

Double-precision real number division.

1..1
(effected)

exponent alias "^" (
other: Double[1]
): Double

Double-precision real number exponentiation.

1..1
(effected)

less_than alias "<" (
other: Double[1]
): Boolean

Returns True if current Double is less than other.

1..1
(effected)

negative alias "-" (): Double

Generate negative of current Double value.

1..1
(effected)

is_equal (
other: Double[1]
): Boolean

Value equality: return True if this and other are attached to objects considered to be equal in value.

Parameters
other

Other object for comparison.

1..1
(redefined)

equal alias "=", "==" (
other: Double[1]
): Boolean

Reference equality for reference types, value equality for value types.

Parameters
other

Other object for comparison.

4. Structure Types

4.1. Overview

The types described in this section are basic data structures assumed to be standardly available in implementation technologies. The following types consititute the minimum set of structure types assumed by openEHR of an implementation environment.

Type name
in openEHR
Description

Array<T>

physical container of items indexed by number

List<T>

container of items, implied order, non-unique membership

Set<T>

container of items, no order, unique membership

Hash<K:Ordered, V>

a table of values of any type V, keyed by values of any Ordered descendant K, typically String or Integer, but may be more complex types, e.g. a coded term type.

The following UML diagram illustrates the base.foundation_types.structures package. As with the primitive types, inheritance and abstract classes are used for convenience of the definitions in openEHR models, but are not assumed to exist in exactly the same way within implementation technologies. Hence, in an implementation, various workarounds or equivalences may be needed to obtain the defined semantics.

BASE foundation types.structures
Figure 4. base.foundation_types.structures package

4.2. Class Definitions

4.2.1. Container Class

Class

Container<T> (abstract)

Description

Abstract ancestor of container types whose items are addressable in some way.

Inherit

Any

Functions

Signature

Meaning

1..1
(abstract)

has (
v: T[1]
): Boolean

Test for membership of a value.

1..1
(abstract)

count (): Integer

Number of items in container.

1..1
(abstract)

is_empty (): Boolean

True if container is empty.

1..1

there_exists alias "there exists", "∃" (
test: Operation[1]
): Boolean

Existential quantifier applied to container, taking one agent argument test whose signature is (v:T): Boolean.

1..1

for_all alias "for all", "∀" (
test: Operation[1]
): Boolean

Universal quantifier applied to container, taking one agent argument test whose signature is (v:T): Boolean.

0..1

matching (
test: Operation[1]
): List<T>

Return a List all items matching the predicate function test which has signature (v:T): Boolean. If no matches, an empty List is returned.

0..1

select (
test: Operation[1]
): T

Return first item matching the predicate function test which has signature (v:T): Boolean, or Void if no match.

4.2.2. List Class

Class

List<T>

Description

Ordered container that may contain duplicates.

Inherit

Container

Functions

Signature

Meaning

1..1

first (): T

Return first element.

1..1

last (): T

Return last element.

Invariants

First_validity: not is_empty implies first /= Void

Last_validity: not is_empty implies last /= Void

4.2.3. Set Class

Class

Set<T>

Description

Unordered container that may not contain duplicates.

Inherit

Container

4.2.4. Array Class

Class

Array<T>

Description

Container whose storage is assumed to be contiguous.

Inherit

Container

Functions

Signature

Meaning

1..1

item alias "[]" (
a_key: Integer[1]
): T

Return item for key a_key.

4.2.5. Hash Class

Class

Hash<K,V>

Description

Type representing a keyed table of values. V is the value type, and K the type of the keys.

Inherit

Container

Functions

Signature

Meaning

1..1

has_key (
a_key: K[1]
): Boolean

Test for presence of a_key.

1..1

item alias "[]" (
a_key: K[1]
): V

Return item for key a_key.

5. Interval

5.1. Overview

Another kind of structure commonly needed in rich data is the interval. The definition of the Interval<T> class here is an intensional one, i.e. it states its members by implication from its limits, rather than enumerating them. To support the common need for defining times in models that could be either a fixed point in time or a time interval, the classes Point_interval<T> and Proper_interval<T> are provided. If Interval<X> is defined as the type of a feature in a class in an openEHR model, where X is some descendant of Ordered, then at runtime, either a Point_interval or Proper_interval may be attached.

In addition to the generic interval types, the derived types Multiplicity_interval and Cardinality are provided, for use in models to represent multiplicity, optionality, and cardinality.

The following UML diagram illustrates the interval package.

BASE foundation types.interval
Figure 5. base.foundation_types.interval package

5.2. Class Definitions

5.2.1. Interval Class

Class

Interval<T> (abstract)

Description

Interval abstraction, featuring upper and lower limits that may be open or closed, included or not included. Interval of ordered items.

Inherit

Any

Attributes

Signature

Meaning

0..1

lower: T

Lower bound. lower bound.

0..1

upper: T

Upper bound. Upper bound.

1..1

lower_unbounded: Boolean

lower boundary open (i.e. = -infinity). lower boundary open (i.e. = -infinity)

1..1

upper_unbounded: Boolean

upper boundary open (i.e. = +infinity). upper boundary open (i.e. = +infinity)

1..1

lower_included: Boolean

lower boundary value included in range if not lower_unbounded. lower boundary value included in range if not lower_unbounded.

1..1

upper_included: Boolean

upper boundary value included in range if not upper_unbounded. upper boundary value included in range if not upper_unbounded.

Functions

Signature

Meaning

1..1
(abstract)

has (
e: T[1]
): Boolean

Post_result: Result = (lower_unbounded or lower_included and v >= lower) or v > lower and (upper_unbounded or upper_included and v <= upper or v < upper)

True if the value e is properly contained in this Interval. True if (lower_unbounded or lower_included and v >= lower) or v > lower and (upper_unbounded or upper_included and v <= upper or v < upper)

1..1
(abstract)

intersects (
other: Interval[1]
): Boolean

True if there is any overlap between intervals represented by Current and other. True if at least one limit of other is strictly inside the limits of this interval.

1..1
(abstract)

contains (
other: Interval[1]
): Boolean

True if current interval properly contains other? True if all points of other are inside the current interval.

1..1
(effected)

is_equal (
other: Any[1]
): Boolean

True if current object’s interval is semantically same as other.

Invariants

Lower_included_valid: lower_unbounded implies not lower_included

Upper_included_valid: upper_unbounded implies not upper_included

Limits_consistent: (not upper_unbounded and not lower_unbounded) implies lower <= upper

Limits_comparable: (not upper_unbounded and not lower_unbounded) implies lower.strictly_comparable_to (upper)

5.2.2. Point_interval Class

Class

Point_interval<T>

Description

Type representing an Interval that happens to be a point value. Provides an efficient representation that is substitutable for Interval<T> where needed.

Inherit

Interval

Attributes

Signature

Meaning

1..1
(redefined)

lower_unbounded: Boolean
{default = false}

Lower boundary open (i.e. = -infinity).

1..1
(redefined)

upper_unbounded: Boolean
{default = false}

Upper boundary open (i.e. = +infinity).

1..1
(redefined)

lower_included: Boolean
{default = true}

Lower boundary value included in range if not lower_unbounded.

1..1
(redefined)

upper_included: Boolean
{default = true}

Upper boundary value included in range if not upper_unbounded.

Invariants

Inv_point: lower = upper

5.2.3. Proper_interval Class

Class

Proper_interval<T>

Description

Type representing a 'proper' Interval, i.e. any two-sided or one-sided interval.

Inherit

Interval

Invariants

Inv_not_point: lower /= upper

5.2.4. Multiplicity_interval Class

Class

Multiplicity_interval

Description

An Interval of Integer, used to represent multiplicity, cardinality and optionality in models.

Inherit

Proper_interval

Constants

Signature

Meaning

1..1

Multiplicity_range_marker: String = ".."

Marker to use in string form of interval between limits.

1..1

Multiplicity_unbounded_marker: char = '*'

Symbol to use to indicate upper limit unbounded.

Functions

Signature

Meaning

1..1

is_open (): Boolean

True if this interval imposes no constraints, i.e. is set to 0..*.

1..1

is_optional (): Boolean

True if this interval expresses optionality, i.e. 0..1.

1..1

is_mandatory (): Boolean

True if this interval expresses mandation, i.e. 1..1.

1..1

is_prohibited (): Boolean

True if this interval is set to 0..0.

5.2.5. Cardinality Class

Class

Cardinality

Description

Express constraints on the cardinality of container objects which are the values of multiply-valued attributes, including uniqueness and ordering, providing the means to state that a container acts like a logical list, set or bag.

Attributes

Signature

Meaning

1..1

interval: Multiplicity_interval

The interval of this cardinality.

1..1

is_ordered: Boolean

True if the members of the container attribute to which this cardinality refers are ordered.

1..1

is_unique: Boolean

True if the members of the container attribute to which this cardinality refers are unique.

Functions

Signature

Meaning

1..1

is_bag (): Boolean

True if the semantics of this cardinality represent a bag, i.e. unordered, non-unique membership.

1..1

is_list (): Boolean

True if the semantics of this cardinality represent a list, i.e. ordered, non-unique membership.

1..1

is_set (): Boolean

True if the semantics of this cardinality represent a set, i.e. unordered, unique membership.

6. Time Types

6.1. Overview

The primitive Date/Time types used in openEHR are represented by classes defined in the package base.foundation_types.time. These are concrete types based on the ISO 8601 (2019) date/time standard semantics, which supports partial dates, times, and complex durations, all of which are needed in the biomedical and clinical domains. These classes have a String physical representation. and are assumed to exist in close to the form specified here, because they are specified in other openEHR specifications.

The time package is shown below.

BASE foundation types.time
Figure 6. base.foundation_types.time package

6.2. Primitive Time Types

The set of ISO 8601 based types define dates and times with a String representation (as per ISO 8601), and the ISO 8601 'partial' and 'extended' semantics. They are defined as descendents of the native types described above, and add the necessary elements required for ISO 8601.

Note
class names of the form Iso8601_xxx have been used here to clearly identify these classes where used elsewhere in the openEHR specifications. In real implementations, other class names may be used as convenient, just as for the other primitive types.
Note
For reasons of readability in data, it is strongly recommended that the 'extended' form of date and time strings be used when writing and displaying data, rather than the compact form. An extended date has the form yyyy-mm-dd rather than yyyymmdd, and an extended time has the form hh:mm:ss rather than hhmmss. Nevertheless, both forms should be supported so that openEHR-based systems that use 'straight-through' processing on legacy data that may be in the compact form remain conformant to the specifications.

ISO 8601 semantics not included in these types include:

  • 'expanded' dates, which have year numbers of greater than 4 digits, and may be negative; in openEHR, only 4-digit year numbers are assumed;

  • the YYYY-WW-DD method of expressing dates (since this is imprecise and difficult to compute with due to variable week starting dates, and not required in health);

  • partial date/times with fractional minutes or hours, e.g. hh,hhh or mm,mm; in openEHR, only fractional seconds are supported;

  • the interval syntax. Intervals of date/times are supported in openEHR, but their syntax form is defined by ADL, and is standardised across all comparable types, not just dates and times.

Deviations from the published standard include the following.

  • Durations are supposed to take the form of PnnW or PnnYnnMnnDTnnHnnMnnS, but in openEHR, the W (week) designator can be used in combination with the other designators, since it is very common to state durations of pregnancy as some combination of weeks and days.

  • Durations in openEHR may take a negative sign, indicating a duration prior to an origin. This supports healthcare needs such as 'adjusted age' (e.g. '-P3M', an age of 'minus 3 months') for very premature newborns.

  • Partial variants of Iso8601_date_time can include missing hours, days and months, whereas ISO 8601:2019 (section 4.3.3 c) only allows missing seconds and minutes. The reasons for this deviation are:

    • the same deviation is used in HL7v2 and HL7v3 TS (timestamp) type, i.e. there are data in existing clinical systems matching this specification;

    • in a typed object model, this deviation is more sensible anyway; the ISO 8601 rule is most likely a limitation of the purely syntactic means of expression. In real systems where a timestamp/date-time is specified in a screen form, it makes sense to allow it to be as partial as possible, rather than artifically restricted to only missing seconds and minutes.

  • The time 24:00:00 (or 240000) is not allowed anywhere, whereas in ISO 8601:2019 it appears to be legal at least for pure times. This deviation is also appears to be used in HL7v2 and HL7v3 (where midnight is defined as the time 00:00:00), and is preferable to the documented standard, since a date/time with time of 24:00:00 is really the next day, i.e. the date part is then incorrect.

Negation for ISO 8601 durations is also supported by W3C XML-schema and various programming languages. See Wikipedia and the official ISO 8601 standard for details. Note that in the date, time and date/time formats shown below, 'Z' and 'T' are literals. In the duration class shown below, 'P', 'Y', 'M', 'W', 'D', 'H', 'S' and 'T' are literals.

6.3. Derived Interval / Time Types

A number of useful types may be generated from the Date/time classes and the Interval classes. These are shown in blue on the following diagram.

BASE foundation types.time intervals
Figure 7. Useful time interval types

6.4. Computational Functions

A number of computational functions are defined in the interfaces of the concrete data/time types, of two kinds:

  • definite: computed according to the usual numeric rules for arithmetic, in which all values are treated as definite, i.e. exact and invariant;

  • nominal: computed using commonly accepted rules of 'everyday' calendrical time, in which 'year' and 'month' are understood to be variable periods.

Most of the functions defined on the date/time types are of the definite kind. The exception is functions involving Iso8601_duration values, which take both definite and nominal forms. The definite forms are named using the standard names add(), subtract() etc, while the nominal versions have names of the form xxx_nominal(), e.g. add_nominal() etc.

An example of an operation having both forms is addition for the type Iso8601_date. The definite operation is called add() and treats the Iso8601_duration argument as an exact amount, based on constant values for length of year and month, defined by Time_definitions.Average_days_in_month and Time_definitions.Average_days_in_year.

The nominal form of the operation is add_nominal(), and is computed according to 'everyday' rules, i.e. in which the phrase 'a year from now' means the same date next year (with occasional slight adjustment), and 'in a month' means the same date next month (or possibly a day or more earlier due to next month being shorter). In a similar way, the addition of a period of one day ('P1D'), although itself a regular quantity is computed differently to the definite form: in the definite form, addition of P1D results in the addition of exactly 24h of time to the date, which may result in a time that is different by one hour due to a change of summer time during the interval, while the nominal addition results in the same time on the next of previous day, even though occasionally this will represent 23 or 25 hours' difference.

The definite functions have standard operators such as '+', '-', etc associated with them, while the nominal functions have the operators '++', '--', etc.

6.5. Class Definitions

6.5.1. Time_Definitions Class

Class

Time_Definitions

Description

Definitions for date/time classes. Note that the timezone limits are set by where the international dateline is. Thus, time in New Zealand is quoted using +12:00, not -12:00.

Constants

Signature

Meaning

1..1

Seconds_in_minute: Integer = 60

Number of seconds in a minute.

1..1

Minutes_in_hour: Integer = 60

Number of minutes in an hour.

1..1

Hours_in_day: Integer = 24

Number of clock hours in a day, i.e. 24.

1..1

Average_days_in_month: Real = 30.42

Used for conversions of durations containing months to days and / or seconds.

1..1

Max_days_in_month: Integer = 31

Maximum number of days in any month.

1..1

Days_in_year: Integer = 365

Calendar days in a normal year, i.e. 365.

1..1

Average_days_in_year: Real = 365.24

Used for conversions of durations containing years to days and / or seconds.

1..1

Days_in_leap_year: Integer = 366

Calendar days in a standard leap year, i.e. 366.

1..1

Max_days_in_year: Integer

Maximum number of days in a year, i.e. accounting for leap years.

1..1

Days_in_week: Integer = 7

Number of days in a week.

1..1

Months_in_year: Integer = 12

Number of months in a year.

1..1

Min_timezone_hour: Integer = 12

Minimum hour value of a timezone according to ISO 8601 (note that the -ve sign is supplied in the ISO8601_TIMEZONE class).

1..1

Max_timezone_hour: Integer = 14

Maximum hour value of a timezone according to ISO 8601.

1..1

Nominal_days_in_month: Real = 30.42

Used for conversions of durations containing months to days and / or seconds.

1..1

Nominal_days_in_year: Real = 365.24

Used for conversions of durations containing years to days and / or seconds.

Functions

Signature

Meaning

1..1

valid_year (
y: Integer[1]
): Boolean

Post: Result = y >= 0

True if y >= 0.

1..1

valid_month (
m: Integer[1]
): Boolean

Post: Result = m >= 1 and m <= Months_in_year

True if m >= 1 and m <= months_in_year.

1..1

valid_day (
y: Integer[1],
m: Integer[1],
d: Integer[1]
): Boolean

Post: Result = d >= 1 and d <= days_in_month (m, y)

True if d >= 1 and d <= days_in_month (m, y).

1..1

valid_hour (
h: Integer[1],
m: Integer[1],
s: Integer[1]
): Boolean

Post: Result = (h >= 0 and h < Hours_in_day) or (h = Hours_in_day and m = 0 and s = 0)

True if (h >= 0 and h < Hours_in_day) or (h = Hours_in_day and m = 0 and s = 0) .

1..1

valid_minute (
m: Integer[1]
): Boolean

Post: Result = m >= 0 and m < Minutes_in_hour

True if m >= 0 and m < Minutes_in_hour.

1..1

valid_second (
s: Integer[1]
): Boolean

Post: Result = s >= 0 and s < Seconds_in_minute

True if s >= 0 and s < Seconds_in_minute .

1..1

valid_fractional_second (
fs: Double[1]
): Boolean

Post: Result = fs >= 0.0 and fs < 1.0

True if fs >= 0.0 and fs < 1.0 .

1..1

valid_iso8601_date (
s: String[1]
): Boolean

String is a valid ISO 8601 date, i.e. takes the complete form:

  • YYYY-MM-DD (extended, preferred) or one of the partial forms YYYY-MM or YYYY

  • YYYYMMDD (compact) or a partial variant YYYYMM.

Where:

  • YYYY is the string form of any positive number in the range 0000 - 9999 (zero-filled to four digits)

  • MM is 01 - 12 (zero-filled to two digits)

  • DD is 01 - 31 (zero-filled to two digits)

The combinations of YYYY, MM, DD numbers must be correct with respect to the Gregorian calendar.

1..1

valid_iso8601_time (
s: String[1]
): Boolean

String is a valid ISO 8601 date, i.e. takes the form:

  • hh:mm:ss[(,|.)s+][Z|±hh[:mm]] (extended)

  • hhmmss[(,|.)s+][Z|±hh[mm]] (compact)

  • or one of the partial forms:

    • hh:mm (extended)

    • hhmm or hh (compact)

with an additional optional timezone indicator of:

  • Z or ±hh[:mm] (extended) ±hh[mm] (compact)

Where:

  • hh is "00" - "23" (0-filled to two digits)

  • mm is "00" - "59" (0-filled to two digits)

  • ss is "00" - "60" (0-filled to two digits)

  • [(,|.)s+] is an optional string consisting of a comma or decimal point followed by numeric string of 1 or more digits, representing a fractional second

  • Z is a literal meaning UTC (modern replacement for GMT), i.e. timezone +0000

1..1

valid_iso8601_date_time (
s: String[1]
): Boolean

String is a valid ISO 8601 date-time, i.e. takes the form:

  • YYYY-MM-DDThh:mm:ss[(,|.)s+][Z|±hh[:mm]] (extended)

  • YYYYMMDDThhmmss[(,|.)s+][Z|±hh[mm]] (compact)

  • or one of the partial forms:

    • YYYY-MM-DDThh:mm or YYYY-MM-DDThh (extended)

    • YYYYMMDDThhmm or YYYYMMDDThh (compact)

1..1

valid_iso8601_duration (
s: String[1]
): Boolean

String is a valid ISO 8601 duration, i.e. takes the form:

  • P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]

Where each nn represents a number of years, months, etc. nnW represents a number of 7-day weeks.

Note: allowing the W designator in the same expression as other designators is an exception to the published standard, but necessary in clinical information (typically for representing pregnancy duration).

Parameters
s

String is a valid ISO 8601 duration, i.e. takes the form:

  • P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]

Where each nn represents a number of years, months, etc. nnW represents a number of 7- day weeks.

Note
allowing the W designator in the same expression as other designators is an exception to the published standard, but necessary in clinical information (typically for representing pregnancy duration).

6.5.2. Temporal Class

Class

Temporal (abstract)

Description

Abstract ancestor of time-related classes.

Inherit

Ordered

6.5.3. Iso8601_type Class

Class

Iso8601_type (abstract)

Description

Abstract ancestor type of ISO 8601 types, defining interface for 'extended' and 'partial' concepts from ISO 8601.

Inherit

Temporal, Time_Definitions

Attributes

Signature

Meaning

1..1

value: String

Representation of all descendants is a single String.

Functions

Signature

Meaning

1..1
(abstract)

is_partial (): Boolean

True if this date time is partial, i.e. if trailing end (right hand) value(s) is/are missing.

1..1
(abstract)

is_extended (): Boolean

True if this ISO8601 string is in the 'extended' form, i.e. uses '-' and / or ':' separators. This is the preferred format.

6.5.4. Iso8601_date Class

Class

Iso8601_date

Description

Represents an ISO 8601 date, including partial and extended forms. Value may be:

  • YYYY-MM-DD (extended, preferred)

  • YYYYMMDD (compact)

  • a partial invariant.

See Time_definitions.valid_iso8601_date() for validity.

Inherit

Iso8601_type

Functions

Signature

Meaning

1..1

year (): Integer

Extract the year part of the date as an Integer.

1..1

month (): Integer

Pre: not month_unknown

Extract the month part of the date as an Integer, or return 0 if not present.

1..1

day (): Integer

Pre: not day_unknown

Extract the day part of the date as an Integer, or return 0 if not present.

1..1

timezone (): Iso8601_timezone

Timezone; may be Void.

1..1

month_unknown (): Boolean

Indicates whether month in year is unknown. If so, the date is of the form "YYYY".

1..1

day_unknown (): Boolean

Indicates whether day in month is unknown. If so, and month is known, the date is of the form "YYYY-MM" or "YYYYMM".

1..1
(effected)

is_partial (): Boolean

True if this date is partial, i.e. if days or more is missing.

1..1
(effected)

is_extended (): Boolean

True if this date uses '-' separators.

1..1

as_string (): String

Return string value in extended format.

1..1

add alias "+" (
a_diff: Iso8601_duration[1]
): Iso8601_date

Arithmetic addition of a duration to a date.

1..1

subtract alias "-" (
a_diff: Iso8601_duration[1]
): Iso8601_date

Arithmetic subtraction of a duration from a date.

1..1

diff alias "-" (
a_date: Iso8601_date[1]
): Iso8601_duration

Difference of two dates.

1..1

add_nominal alias "++" (
a_diff: Iso8601_duration[1]
): Iso8601_date

Addition of nominal duration represented by a_diff. For example, a duration of 'P1Y' means advance to the same date next year, with the exception of the date 29 February in a leap year, to which the addition of a nominal year will result in 28 February of the following year. Similarly, 'P1M' is understood here as a nominal month, the addition of which will result in one of:

  • the same day in the following month, if it exists, or;

  • one or two days less where the following month is shorter, or;

  • in the case of adding a month to the date 31 Jan, the result will be 28 Feb in a non-leap year (i.e. three less) and 29 Feb in a leap year (i.e. two less).

1..1

subtract_nominal alias "--" (
a_diff: Iso8601_duration[1]
): Iso8601_date

Subtraction of nominal duration represented by a_diff. See add_nominal() for semantics.

Invariants

Year_valid: valid_year (year)

Month_valid: not month_unknown implies valid_month (month)

Day_valid: not day_unknown implies valid_day (year, month, day)

Partial_validity: month_unknown implies day_unknown

6.5.5. Iso8601_time Class

Class

Iso8601_time

Description

Represents an ISO 8601 time, including partial and extended forms. Value may be:

  • hh:mm:ss[(,|.)sss][Z|±hh[:mm]] (extended, preferred) or

  • hhmmss[(,|.)sss][Z|±hh[mm]] (compact)

  • or a partial invariant.

See valid_iso8601_time() for validity.

Note
A small deviation to the ISO 8601:2004 standard in this class is that the time 24:00:00 is not allowed, for consistency with Iso8601_date_time.

Inherit

Iso8601_type

Functions

Signature

Meaning

1..1

hour (): Integer

Extract the hour part of the date/time as an Integer.

1..1

minute (): Integer

Extract the minute part of the time as an Integer, or return 0 if not present.

1..1

second (): Integer

Extract the integral seconds part of the time (i.e. prior to any decimal sign) as an Integer, or return 0 if not present.

1..1

fractional_second (): Real

Pre: not second_unknown

Extract the fractional seconds part of the time (i.e. following to any decimal sign) as a Real, or return 0.0 if not present.

1..1

timezone (): Iso8601_timezone

Timezone; may be Void.

1..1

minute_unknown (): Boolean

Indicates whether minute is unknown. If so, the time is of the form “hh”.

1..1

second_unknown (): Boolean

Indicates whether second is unknown. If so and month is known, the time is of the form "hh:mm" or "hhmm".

1..1

is_decimal_sign_comma (): Boolean

True if this time has a decimal part indicated by ',' (comma) rather than '.' (period).

1..1
(effected)

is_partial (): Boolean

True if this time is partial, i.e. if seconds or more is missing.

1..1
(effected)

is_extended (): Boolean

True if this time uses '-', ':' separators.

1..1

has_fractional_second (): Boolean

True if the fractional_second part is significant (i.e. even if = 0.0).

1..1

as_string (): String

Return string value in extended format.

1..1

add alias "+" (
a_diff: Iso8601_duration[1]
): Iso8601_time

Arithmetic addition of a duration to a time.

1..1

subtract alias "-" (
a_diff: Iso8601_duration[1]
): Iso8601_time

Arithmetic subtraction of a duration from a time.

1..1

diff alias "-" (
a_time: Iso8601_time[1]
): Iso8601_duration

Difference of two times.

Invariants

Hour_valid: valid_hour(hour, minute, second)

Minute_valid: not minute_unknown implies valid_minute (minute)

Second_valid: not second_unknown implies valid_second (second)

Fractional_second_valid: has_fractional_second implies (not second_unknown and valid_fractional_second (fractional_second))

Partial_validity: minute_unknown implies second_unknown

6.5.6. Iso8601_date_time Class

Class

Iso8601_date_time

Description

Represents an ISO 8601 date/time, including partial and extended forms. Value may be:

  • YYYY-MM-DDThh:mm:ss[(,|.)sss][Z | ±hh[:mm]] (extended, preferred) or

  • YYYYMMDDThhmmss[(,|.)sss][Z | ±hh[mm]] (compact)

  • or a partial variant.

See valid_iso8601_date_time() for validity.

Note that this class includes 2 deviations from ISO 8601:2004:

  • for partial date/times, any part of the date/time up to the month may be missing, not just seconds and minutes as in the standard;

  • the time 24:00:00 is not allowed, since it would mean the date was really on the next day.

Inherit

Iso8601_type

Functions

Signature

Meaning

1..1

year (): Integer

Extract the year part of the date as an Integer.

1..1

month (): Integer

Pre: not month_unknown

Extract the month part of the date/time as an Integer, or return 0 if not present.

1..1

day (): Integer

Pre: not day_unknown

Extract the day part of the date/time as an Integer, or return 0 if not present.

1..1

hour (): Integer

Pre: not hour_unknown

Extract the hour part of the date/time as an Integer, or return 0 if not present.

1..1

minute (): Integer

Pre: not minute_unknown

Extract the minute part of the date/time as an Integer, or return 0 if not present.

1..1

second (): Integer

Pre: not second_unknown

Extract the integral seconds part of the date/time (i.e. prior to any decimal sign) as an Integer, or return 0 if not present.

1..1

fractional_second (): Real

Extract the fractional seconds part of the date/time (i.e. following to any decimal sign) as a Real, or return 0.0 if not present.

1..1

timezone (): Iso8601_timezone

Timezone; may be Void.

1..1

month_unknown (): Boolean

Indicates whether month in year is unknown.

1..1

day_unknown (): Boolean

Indicates whether day in month is unknown.

1..1

minute_unknown (): Boolean

Indicates whether minute in hour is known.

1..1

second_unknown (): Boolean

Indicates whether minute in hour is known.

1..1

is_decimal_sign_comma (): Boolean

True if this time has a decimal part indicated by ',' (comma) rather than '.' (period).

1..1
(effected)

is_partial (): Boolean

True if this date time is partial, i.e. if seconds or more is missing.

1..1
(effected)

is_extended (): Boolean

True if this date/time uses '-', ':' separators.

1..1

has_fractional_second (): Boolean

True if the fractional_second part is significant (i.e. even if = 0.0).

1..1

as_string (): String

Return the string value in extended format.

1..1

add alias "+" (
a_diff: Iso8601_duration[1]
): Iso8601_date_time

Arithmetic addition of a duration to a date/time.

1..1

subtract alias "-" (
a_diff: Iso8601_duration[1]
): Iso8601_date_time

Arithmetic subtraction of a duration from a date/time.

1..1

diff alias "-" (
a_date_time: Iso8601_date_time[1]
): Iso8601_duration

Difference of two date/times.

1..1

add_nominal alias "++" (
a_diff: Iso8601_duration[1]
): Iso8601_date

Addition of nominal duration represented by a_diff. See Iso8601_date.add_nominal() for semantics.

1..1

subtract_nominal alias "--" (
a_diff: Iso8601_duration[1]
): Iso8601_date

Subtraction of nominal duration represented by a_diff. See add_nominal() for semantics.

Invariants

Year_valid: valid_year (year)

Month_valid: valid_month (month)

Day_valid: valid_day(year, month, day)

Hour_valid: valid_hour (hour, minute, second)

Minute_valid: not minute_unknown implies valid_minute(minute)

Second_valid: not second_unknown implies valid_second (second)

Fractional_second_valid: has_fractional_second implies (not second_unknown and valid_fractional_second (fractional_second))

Partial_validity_year: not month_unknown

Partial_validity_month: not month_unknown

Partial_validity_day: not day_unknown

Partial_validity_hour: not hour_unknown

Partial_validity_minute: minute_unknown implies second_unknown

6.5.7. Iso8601_duration Class

Class

Iso8601_duration

Description

Represents an ISO 8601 duration, which may have multiple parts from years down to seconds. The value attribute is a String in the format:

  • P[nnY][nnM][nnW][nnD][T[nnH][nnM][nnS]]

Note
two deviations from ISO 8601 are supported, the first, to allow a negative sign, and the second allowing the 'W' designator to be mixed with other designators.

Inherit

Iso8601_type

Functions

Signature

Meaning

1..1
(effected)

is_extended (): Boolean

Returns True.

1..1
(effected)

is_partial (): Boolean

Returns False.

1..1

years (): Integer

Number of years in the value, i.e. the number preceding the 'Y' in the 'YMD' part, if one exists.

1..1

months (): Integer

Number of months in the value, i.e. the value preceding the 'M' in the 'YMD' part, if one exists.

1..1

days (): Integer

Number of days in the value, i.e. the number preceding the 'D' in the 'YMD' part, if one exists.

1..1

hours (): Integer

Number of hours in the value, i.e. the number preceding the 'H' in the 'HMS' part, if one exists.

1..1

minutes (): Integer

Number of minutes in the value, i.e. the number preceding the 'M' in the 'HMS' part, if one exists.

1..1

seconds (): Integer

Number of seconds in the value, i.e. the integer number preceding the 'S' in the 'HMS' part, if one exists.

1..1

fractional_seconds (): Real

Fractional seconds in the value, i.e. the decimal part of the number preceding the 'S' in the 'HMS' part, if one exists.

1..1

weeks (): Integer

Number of weeks in the value, i.e. the value preceding the W, if one exists.

1..1

is_decimal_sign_comma (): Boolean

True if this time has a decimal part indicated by ',' (comma) rather than '.' (period).

1..1

to_seconds (): Real

Total number of seconds equivalent (including fractional) of entire duration. Where non-definite elements such as year and month (i.e. 'Y' and 'M') are included, the corresponding 'average' durations from Time_definitions are used to compute the result.

1..1

as_string (): String

Return the duration string value.

1..1

add alias "+" (
a_val: Iso8601_duration[1]
): Iso8601_duration

Arithmetic addition of a duration to a duration, via conversion to seconds, using Time_definitions.Average_days_in_year and Time_definitions.Average_days_in_month

1..1

subtract alias "-" (
a_val: Iso8601_duration[1]
): Iso8601_duration

Arithmetic subtraction of a duration from a duration, via conversion to seconds, using Time_definitions.Average_days_in_year and Time_definitions.Average_days_in_month

1..1

multiply alias "*" (
a_val: Real[1]
): Iso8601_duration

Arithmetic multiplication a duration by a number.

1..1

divide alias "/" (
a_val: Real[1]
): Iso8601_duration

Arithmetic division of a duration by a number.

1..1

negative alias "-" (): Iso8601_duration

Generate negative of current duration value.

Invariants

Years_valid: years >= 0

Months_valid: months >= 0

Weeks_valid: weeks >= 0

Days_valid: days >= 0

Hours_valid: hours >= 0

Minutes_valid: minutes >= 0

Seconds_valid: seconds >= 0

Fractional_second_valid: fractional_second >= 0.0 and fractional_second < 1.0

6.5.8. Iso8601_timezone Class

Class

Iso8601_timezone

Description

ISO8601 timezone string, in format:

  • Z | ±hh[mm]

where:

  • hh is "00" - "23" (0-filled to two digits)

  • mm is "00" - "59" (0-filled to two digits)

  • Z is a literal meaning UTC (modern replacement for GMT), i.e. timezone +0000

Inherit

Iso8601_type

Functions

Signature

Meaning

1..1

hour (): Integer

Extract the hour part of timezone, as an Integer in the range 00 - 14.

1..1

minute (): Integer

Extract the hour part of timezone, as an Integer, usually either 0 or 30.

1..1

sign (): Integer

Direction of timezone expresssed as +1 or -1.

1..1

minute_unknown (): Boolean

Indicates whether minute part known.

1..1
(effected)

is_partial (): Boolean

True if this time zone is partial, i.e. if minutes is missing.

1..1
(effected)

is_extended (): Boolean

True if this time-zone uses ‘:’ separators.

1..1

is_gmt (): Boolean

True if timezone is UTC, i.e. +0000.

1..1

as_string (): String

Return timezone string in extended format.

Invariants

Min_hour_valid: sign = -1 implies hour > 0 and hour <= Min_timezone_hour

Max_hour_valid: sign = 1 implies hour > 0 and hour <= Max_timezone_hour

Minute_valid: not minute_unknown implies valid_minute (minute)

Sign_valid: sign = 1 or sign = -1

7. Terminology Package

7.1. Overview

The base.foundation_types.terminology package provides leaf types used to represent a terminology code, i.e. a code within a terminology, and a term, which is the combination of a code and one rubric (natural language) string associated with it. Terminology codes are sometimes called concept codes among terminology experts, and when used as references, concept references.

An instance of Terminology_code is a reference to any referenceable entity within a terminology or ontology, which may be:

  • a single term, for which a rubric(s) and potentially relationships (at least the IS-A relationship) are defined;

  • a value set i.e. a set of single terms, possibly in a tree or other structure corresponding to relationships between the member terms;

  • any other terminological entity referencable with a code.

An instance of Terminology_term provides a way to record a terminology code and the rubric used in some operational context, allowing the receiver or reader of the data to avoid having to perform a terminology lookup to obtain the rubric, e.g. for display purposes.

BASE foundation types.terminology
Figure 8. base.foundation_types.terminology package

7.2. Class Definitions

7.2.1. Terminology_term Class

Class

Terminology_term

Description

Leaf type representing a standalone term from a terminology, which consists of the term text and the code, i.e. a concept reference.

Inherit

Any

Attributes

Signature

Meaning

1..1

concept: Terminology_code

Reference to the terminology concept formally representing this term.

1..1

text: String

Text of term.

7.2.2. Terminology_code Class

Class

Terminology_code

Description

Primitive type representing a standalone reference to a terminology concept, in the form of a terminology identifier, optional version, and a code or code string from the terminology.

Inherit

Any

Attributes

Signature

Meaning

1..1

terminology_id: String

The archetype environment namespace identifier used to identify a terminology. Typically a value like "snomed_ct" that is mapped elsewhere to the full URI identifying the terminology.

0..1

terminology_version: String

Optional string value representing terminology version, typically a date or dotted numeric.

1..1

code_string: String

A terminology code or post-coordinated code expression, if supported by the terminology. The code may refer to a single term, a value set consisting of multiple terms, or some other entity representable within the terminology.

0..1

uri: Uri

The URI reference that may be used as a concrete key into a notional terminology service for queries that can obtain the term text, definition, and other associated elements.

8. Functional Meta-types

8.1. Overview

A small number of meta-types are defined that correspond to functional programming primitives, otherwise known as 'closures', 'lambda expressions' and so on. These concepts are supported in most modern programming languages now, and the types defined here are intended to provide a minimal formal basis to enable other openEHR specification to defined function-related elements. Since UML does not contain native functional elements, the semantics here are approximated using normal class facilities.

The following illustrates the functional package.

BASE foundation types.functional
Figure 9. base.foundation_types.functional Package

Two key abstractions are required, namely 'function as a type', and 'tuple', which enables arguments to be formalised. To provide a 'function' type, a 'routine' type is also required. For completeness, a 'procedure' type is also defined. The 'tuple' type is defined as a generic meta-type whose descendants may additionally define any number of generic parameter types, corresponding to a type list.

8.1.1. Class Definitions

8.1.2. ROUTINE Class

Class

ROUTINE<ARGS>

Description

Type representing a function with a return type and 0 or more arguments represented as a TUPLE.

8.1.3. FUNCTION Class

Class

FUNCTION<ARGS,RESULT>

Description

Type representing a function with a return type and 0 or more arguments represented as a TUPLE.

Inherit

ROUTINE

8.1.4. PROCEDURE Class

Class

PROCEDURE<ARGS>

Description

Type representing a procedure with 0 or more arguments represented as a TUPLE.

Inherit

ROUTINE

8.1.5. TUPLE Class

Class

TUPLE

Description

Parent type of all TUPLE types.

8.1.6. TUPLE1 Class

Class

TUPLE1<A>

Description

A Tuple type used, among other things, for representing a single typed argument within a Routine signature.

Inherit

TUPLE

8.1.7. TUPLE2 Class

Class

TUPLE2<A,B>

Description

A Tuple type used, among other things, for representing two typed arguments within a Routine signature.

Inherit

TUPLE

9. Type Cross-Reference

The following table provides a cross-reference from openEHR foundation types to their equivalents in common implementation formalisms. Where there is no equivalent listed, a specific library may still exist, or an implementation may be required of the openEHR specification.

Type name
in openEHR
Description XML Java C#

Octet

8-bit value.

-

Byte

Byte

Character

a member of an 8-bit character-set.

string

Character

Char

Boolean

logical True/False values.

boolean

Boolean

Boolean

Integer

32-bit integers.

decimal

Integer

Int32

Integer64

64-bit integers.

decimal

Long

Int64

Real

32-bit real numbers

float,
decimal

Float

Single

Double

64-bit real numbers

double

Double

Double

String

Unicode-enabled strings.

string

String

String

Array<T>

Contiguous Array.

sequence

Array<T>

Array<T>

List<T>

Ordered List.

sequence

List<T>

List<T>

Set<T>

Unordered, unique membership container.

all

Set<T>

HashSet<T>

Hash<K:Ordered, V>

Unique-keyed map.

(various)

Map<T>

HashTable<T>

Interval<T:Ordered>

Interval of ordered types.

-

-

Date

Native date type.

date

java.util.Date

DateTime

Time

Native time type.

time

java.util.Date

DateTime

Date_time

Native date/time type.

dateTime

java.util.Date

DateTime

Duration

Native duration type.

duration

java.time.Duration

TimeSpan

Iso8601_Date

ISO 8601-encoded date type.

date

use java.text.SimpleDateFormat
or org.joda.time.format.ISODateTimeFormat

(use formatted string)

Iso8601_Time

ISO 8601-encoded time type.

time

use j`ava.text.SimpleDateFormat`
or org.joda.time.format.ISODateTimeFormat

(use formatted string)

Iso8601_Date_time

ISO 8601-encoded date/time type.

dateTime

use java.text.SimpleDateFormat
or org.joda.time.format.ISODateTimeFormat

(use formatted string)

Iso8601_Duration

ISO 8601-encoded duration type.

duration

use java.text.SimpleDateFormat
or org.joda.time.format.ISODateTimeFormat

(use formatted string)

Interval<Integer>

Interval of Integer.

-

(various)

-

Interval<Date>

Interval of Date.

-

(various)

-

Interval<Time>

Interval of Time.

-

(various)

-

Interval<DateTime>

Interval of DateTime.

-

(various)

-