Structure Types

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 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.

Container<T> (abstract)

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

Inherits: Any

Functions

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

Value equality.
Inherited from Any

infix = (
other: Any[1]
): Boolean [1..1]

Reference equality.
Inherited from Any

Parameters
other

Reference equality.

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

Create new instance of a type.
Inherited from 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>".
Inherited from Any

(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.

{
    "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"
            }
        }
    }
}
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) is_equal (
other: Any[1]
): Boolean [1..1]

Value equality.
Inherited from Any

infix = (
other: Any[1]
): Boolean [1..1]

Reference equality.
Inherited from Any

Parameters
other

Reference equality.

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

Create new instance of a type.
Inherited from 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>".
Inherited from Any

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

Test for membership of a value.
Inherited from Container

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

Number of items in container.
Inherited from Container

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

True if container is empty.
Inherited from Container

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) is_equal (
other: Any[1]
): Boolean [1..1]

Value equality.
Inherited from Any

infix = (
other: Any[1]
): Boolean [1..1]

Reference equality.
Inherited from Any

Parameters
other

Reference equality.

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

Create new instance of a type.
Inherited from 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>".
Inherited from Any

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

Test for membership of a value.
Inherited from Container

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

Number of items in container.
Inherited from Container

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

True if container is empty.
Inherited from Container

{
    "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

Array<T>

Container whose storage is assumed to be contiguous.

Inherits: Any, Container

Functions

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

Value equality.
Inherited from Any

infix = (
other: Any[1]
): Boolean [1..1]

Reference equality.
Inherited from Any

Parameters
other

Reference equality.

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

Create new instance of a type.
Inherited from 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>".
Inherited from Any

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

Test for membership of a value.
Inherited from Container

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

Number of items in container.
Inherited from Container

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

True if container is empty.
Inherited from Container

{
    "name": "Array",
    "documentation": "Container whose storage is assumed to be contiguous.",
    "ancestors": [
        "Container"
    ],
    "generic_parameter_defs": {
        "T": {
            "name": "T",
            "conforms_to_type": "Any"
        }
    }
}
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 membership of a key.

1..1

item (
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) is_equal (
other: Any[1]
): Boolean [1..1]

Value equality.
Inherited from Any

infix = (
other: Any[1]
): Boolean [1..1]

Reference equality.
Inherited from Any

Parameters
other

Reference equality.

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

Create new instance of a type.
Inherited from 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>".
Inherited from Any

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

Test for membership of a value.
Inherited from Container

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

Number of items in container.
Inherited from Container

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

True if container is empty.
Inherited from Container

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

Test for membership of a key.

item (
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 membership 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",
            "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