Structure Types

Overview

The types described in this section are basic data structures assumed to be standard available in implementation technologies. The following types constitute 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 1. base.foundation_types.structures package

Class Definitions

Container Class

  • Definition

  • Effective

  • BMM

  • UML

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.

Container<T> (abstract)

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

Inherits: Any

Functions

(abstract) Any.is_equal (
other: Any[1]
): Boolean [1..1]

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

Parameters
other

Other object for comparison.

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

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

Parameters
other

Other object for comparison.

Any.instance_of (
a_type: String[1]
): Any [1..1]

Create new instance of a type.

Any.type_of (
an_object: Any[1]
): String [1..1]

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

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

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

(abstract) has (
v: T[1]
): Boolean [1..1]

Test for membership of a value.

(abstract) count (): Integer [1..1]

Number of items in container.

(abstract) is_empty (): Boolean [1..1]

True if container is empty.

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

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

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

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

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

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

select (
test: Operation[1]
): T [0..1]

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

{
    "name": "Container",
    "documentation": "Abstract ancestor of container types whose items are addressable in some way.",
    "is_abstract": true,
    "ancestors": [
        "Any"
    ],
    "generic_parameter_defs": {
        "T": {
            "name": "T",
            "conforms_to_type": "Any"
        }
    },
    "functions": {
        "has": {
            "name": "has",
            "documentation": "Test for membership of a value.",
            "is_abstract": true,
            "parameters": {
                "v": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER_OPEN",
                    "name": "v",
                    "type": "T"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "count": {
            "name": "count",
            "documentation": "Number of items in container.",
            "is_abstract": true,
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        },
        "is_empty": {
            "name": "is_empty",
            "documentation": "True if container is empty.",
            "is_abstract": true,
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "there_exists": {
            "name": "there_exists",
            "aliases": [
                "there exists",
                "∃"
            ],
            "documentation": "Existential quantifier applied to container, taking one agent argument `_test_` whose signature is `(v:T): Boolean`.",
            "parameters": {
                "test": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "test",
                    "type": "Operation"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "for_all": {
            "name": "for_all",
            "aliases": [
                "for all",
                "∀"
            ],
            "documentation": "Universal quantifier applied to container, taking one agent argument `_test_` whose signature is `(v:T): Boolean`.",
            "parameters": {
                "test": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "test",
                    "type": "Operation"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "matching": {
            "name": "matching",
            "documentation": "Return a List all items matching the predicate function `_test_` which has signature `(v:T): Boolean`. If no matches, an empty List is returned.",
            "parameters": {
                "test": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "test",
                    "type": "Operation"
                }
            },
            "result": {
                "_type": "P_BMM_CONTAINER_TYPE",
                "container_type": "List",
                "type": "T"
            },
            "is_nullable": true
        },
        "select": {
            "name": "select",
            "documentation": "Return first item matching the predicate function `_test_` which has signature `(v:T): Boolean`, or Void if no match.",
            "parameters": {
                "test": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "test",
                    "type": "Operation"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "T"
            },
            "is_nullable": true
        }
    }
}
Container

List Class

  • Definition

  • Effective

  • BMM

  • UML

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

List<T>

Ordered container that may contain duplicates.

Inherits: Any, Container

Functions

(abstract) Any.is_equal (
other: Any[1]
): Boolean [1..1]

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

Parameters
other

Other object for comparison.

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

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

Parameters
other

Other object for comparison.

Any.instance_of (
a_type: String[1]
): Any [1..1]

Create new instance of a type.

Any.type_of (
an_object: Any[1]
): String [1..1]

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

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

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

(abstract) Container.has (
v: T[1]
): Boolean [1..1]

Test for membership of a value.

(abstract) Container.count (): Integer [1..1]

Number of items in container.

(abstract) Container.is_empty (): Boolean [1..1]

True if container is empty.

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

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

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

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

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

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

Container.select (
test: Operation[1]
): T [0..1]

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

first (): T [1..1]

Return first element.

last (): T [1..1]

Return last element.

Invariants

First_validity: not is_empty implies first /= Void

Last_validity: not is_empty implies last /= Void

{
    "name": "List",
    "documentation": "Ordered container that may contain duplicates.",
    "ancestors": [
        "Container"
    ],
    "generic_parameter_defs": {
        "T": {
            "name": "T",
            "conforms_to_type": "Any"
        }
    },
    "functions": {
        "first": {
            "name": "first",
            "documentation": "Return first element.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "T"
            }
        },
        "last": {
            "name": "last",
            "documentation": "Return last element.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "T"
            }
        }
    },
    "invariants": {
        "First_validity": "not is_empty implies first /= Void",
        "Last_validity": "not is_empty implies last /= Void"
    }
}
List

Set Class

  • Definition

  • Effective

  • BMM

  • UML

Class

Set<T>

Description

Unordered container that may not contain duplicates.

Inherit

Container

Set<T>

Unordered container that may not contain duplicates.

Inherits: Any, Container

Functions

(abstract) Any.is_equal (
other: Any[1]
): Boolean [1..1]

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

Parameters
other

Other object for comparison.

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

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

Parameters
other

Other object for comparison.

Any.instance_of (
a_type: String[1]
): Any [1..1]

Create new instance of a type.

Any.type_of (
an_object: Any[1]
): String [1..1]

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

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

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

(abstract) Container.has (
v: T[1]
): Boolean [1..1]

Test for membership of a value.

(abstract) Container.count (): Integer [1..1]

Number of items in container.

(abstract) Container.is_empty (): Boolean [1..1]

True if container is empty.

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

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

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

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

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

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

Container.select (
test: Operation[1]
): T [0..1]

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

{
    "name": "Set",
    "documentation": "Unordered container that may not contain duplicates.",
    "ancestors": [
        "Container"
    ],
    "generic_parameter_defs": {
        "T": {
            "name": "T",
            "conforms_to_type": "Any"
        }
    }
}
Set

Array Class

  • Definition

  • Effective

  • BMM

  • UML

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.

Array<T>

Container whose storage is assumed to be contiguous.

Inherits: Any, Container

Functions

(abstract) Any.is_equal (
other: Any[1]
): Boolean [1..1]

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

Parameters
other

Other object for comparison.

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

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

Parameters
other

Other object for comparison.

Any.instance_of (
a_type: String[1]
): Any [1..1]

Create new instance of a type.

Any.type_of (
an_object: Any[1]
): String [1..1]

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

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

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

(abstract) Container.has (
v: T[1]
): Boolean [1..1]

Test for membership of a value.

(abstract) Container.count (): Integer [1..1]

Number of items in container.

(abstract) Container.is_empty (): Boolean [1..1]

True if container is empty.

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

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

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

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

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

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

Container.select (
test: Operation[1]
): T [0..1]

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

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

Return item for key a_key.

{
    "name": "Array",
    "documentation": "Container whose storage is assumed to be contiguous.",
    "ancestors": [
        "Container"
    ],
    "generic_parameter_defs": {
        "T": {
            "name": "T",
            "conforms_to_type": "Any"
        }
    },
    "functions": {
        "item": {
            "name": "item",
            "aliases": [
                "[]"
            ],
            "documentation": "Return item for key  `_a_key_`.",
            "parameters": {
                "a_key": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER",
                    "name": "a_key",
                    "type": "Integer"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "T"
            }
        }
    }
}
Array

Hash Class

  • Definition

  • Effective

  • BMM

  • UML

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.

Hash<K,V>

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

Inherits: Any, Container

Functions

(abstract) Any.is_equal (
other: Any[1]
): Boolean [1..1]

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

Parameters
other

Other object for comparison.

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

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

Parameters
other

Other object for comparison.

Any.instance_of (
a_type: String[1]
): Any [1..1]

Create new instance of a type.

Any.type_of (
an_object: Any[1]
): String [1..1]

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

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

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

(abstract) Container.has (
v: T[1]
): Boolean [1..1]

Test for membership of a value.

(abstract) Container.count (): Integer [1..1]

Number of items in container.

(abstract) Container.is_empty (): Boolean [1..1]

True if container is empty.

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

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

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

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

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

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

Container.select (
test: Operation[1]
): T [0..1]

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

has_key (
a_key: K[1]
): Boolean [1..1]

Test for presence of a_key.

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

Return item for key a_key.

{
    "name": "Hash",
    "documentation": "Type representing a keyed table of values. V is the value type, and K the type of the keys. ",
    "ancestors": [
        "Container"
    ],
    "generic_parameter_defs": {
        "K": {
            "name": "K",
            "conforms_to_type": "Ordered"
        },
        "V": {
            "name": "V"
        }
    },
    "functions": {
        "has_key": {
            "name": "has_key",
            "documentation": "Test for presence of `_a_key_`.",
            "parameters": {
                "a_key": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER_OPEN",
                    "name": "a_key",
                    "type": "K"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "item": {
            "name": "item",
            "aliases": [
                "[]"
            ],
            "documentation": "Return item for key `_a_key_`.",
            "parameters": {
                "a_key": {
                    "_type": "P_BMM_SINGLE_FUNCTION_PARAMETER_OPEN",
                    "name": "a_key",
                    "type": "K"
                }
            },
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "V"
            }
        }
    }
}
Hash