Encapsulated Package

Overview

The data_types.encapsulated package contains classes representing data values whose internal structure is defined outside the EHR model, such as multimedia and parsable data. It is illustrated below.

RM data types.encapsulated
Figure 1. rm.data_types.encapsulated package

Requirements

There is a need to be able to include content in the EHR whose interior structure is not modelled in the EHR reference model, but instead documented by sufficient meta-data attributes for specific tools to process the data. Types of content in this category are as follows.

  • Images, including images which are themselves a compressed version of one image from a high-resolution image set stored elsewhere. Such images may be in any of the well-known compressed or uncompressed formats, and may have their own thumbnail image attached, to facilitate web-viewing.

  • Bio-signal data series, such as a set of values representing a diagnostic part of an ECG trace. This might be represented as DICOM content.

  • Content which is textual (or nearly so) which is essentially a parsable language file of some kind. This includes all XML instance, HTML, and any other EHR content which happens to be represented in syntax form - such as the unit strings used in quantities. The name of the formalism should be stored as meta-data.

  • Binary content which is processed by a work processor or other dedicated tool.

  • Digital signatures.

Sufficient meta-data must be included with all of these types to enable a way for the content to be processed, typically by indicating either its type (e.g. "jpeg", "word document") or the name of a tool which can be used to process it. Important meta-data include:

  • size of the content;

  • natural language, if any.

Any encapsulated data item may be a summary, "thumbnail" or otherwise reduced form of an original content item found outside the EHR, in some other system or file-system. Checksums must be expressible for those items for which a checksum is available, or for which the system generates checksums to improve the quality of its internal data transmissions.

Design

The design approach used here is based on the following analysis.

  1. Any encapsulated data item may be in some particular language, even if it is an image or other graphic form such as a biosignal with axis markings in a particular language;

  2. The general structure of encapsulated content data items includes a block of bytes or characters representing the content, and various meta-data as appropriate, including:

    • size

    • character encoding

    • compression type/algorithm

    • name of formalism for parsable content

  3. For encapsulated items that have a counterpart in another system, the standard means of portable address is the W3C URI;

  4. For items may that have an associated integrity checksum, the checksum is itself a series of bytes, and the type of checksum must also be specified, e.g. "md5".

These observations lead naturally to an abstract DV_ENCAPSULATED class, with two subtypes, DV_PARSABLE, for all content which is syntactic in nature, and DV_MULTIMEDIA for everything else. Note that it is possible to imagine parsable content items which are large, stored in compressed form, and are themselves a summary of another item elsewhere on the web; such items can for practical purposes be represented as instances of DV_MULTIMEDIA, rather than DV_PARSABLE. The vast majority of parsable encapsulated data are expected to be short and stored in native textual form, e.g. fragments of XML or HTML.

The formal model of the classes DV_ENCAPSULATED and DV_MULTIMEDIA are closely based on the ED type from the HL7v3 data types specification.

Examples

The following examples show how to use the classes to represent some common encapsulated data types.

Data format Class Attributes

inline JSON

DV_PARSABLE

value = JSON string
formalism = "json"

inline JSON, minified
(white space removed)

DV_PARSABLE

value = minified JSON string
formalism = "json"

JSON document

DV_MULTIMEDIA

uri = URI at which document is located
media_type = "IANA::application/json"
size = Integer indicating number of bytes of target.

inline JPG

DV_MULTIMEDIA

data = byte array carrying JPG
media_type = "IANA::image/jpeg"
size = Integer indicating number of bytes of data.

inline JPG, Base64
encoded

DV_MULTIMEDIA

data = byte array carrying Base64 string of JPG
media_type = "IANA::image/jpeg;base64"
size = Integer indicating number of bytes of data.

inline JPG with
SHA-2 hash

DV_MULTIMEDIA

data = byte array carrying JPG
media_type = "IANA::image/jpeg"
integrity_check = byte array containing SHA-2 hash
integrity_check_algorithm = "openehr::SHA-2"
size = Integer indicating number of bytes of data.

Class Descriptions

DV_ENCAPSULATED Class

  • Definition

  • Effective

  • BMM

  • UML

Class

DV_ENCAPSULATED (abstract)

Description

Abstract class defining the common meta-data of all types of encapsulated data.

Inherit

DATA_VALUE

Attributes

Signature

Meaning

0..1

charset: CODE_PHRASE

Name of character encoding scheme in which this value is encoded. Coded from openEHR Code Set character sets . Unicode is the default assumption in openEHR, with UTF-8 being the assumed encoding. This attribute allows for variations from these assumptions.

0..1

language: CODE_PHRASE

Optional indicator of the localised language in which the data is written, if relevant. Coded from openEHR Code Set languages.

Invariants

Size_valid: size >= 0

Language_valid: language /= Void implies code_set (Code_set_id_languages).has_code (language)

Charset_valid: charset /= Void implies code_set (Code_set_id_character_sets).has_code (charset)

DV_ENCAPSULATED (abstract)

Abstract class defining the common meta-data of all types of encapsulated data.

Inherits: BASIC_DEFINITIONS, OPENEHR_DEFINITIONS, DATA_VALUE

Constants

BASIC_DEFINITIONS.CR: Character = '\015' [1..1]

Carriage return character.

BASIC_DEFINITIONS.LF: Character = '\012' [1..1]

Line feed character.

BASIC_DEFINITIONS.Any_type_name: String = "Any" [1..1]

BASIC_DEFINITIONS.Regex_any_pattern: String = ".*" [1..1]

BASIC_DEFINITIONS.Default_encoding: String = "UTF-8" [1..1]

BASIC_DEFINITIONS.None_type_name: String = "None" [1..1]

OPENEHR_DEFINITIONS.Local_terminology_id: String = "local" [1..1]

Predefined terminology identifier to indicate it is local to the knowledge resource in which it occurs, e.g. an archetype

Attributes

charset: CODE_PHRASE [0..1]

Name of character encoding scheme in which this value is encoded. Coded from openEHR Code Set character sets . Unicode is the default assumption in openEHR, with UTF-8 being the assumed encoding. This attribute allows for variations from these assumptions.

language: CODE_PHRASE [0..1]

Optional indicator of the localised language in which the data is written, if relevant. Coded from openEHR Code Set languages.

Invariants

Size_valid: size >= 0

Language_valid: language /= Void implies code_set (Code_set_id_languages).has_code (language)

Charset_valid: charset /= Void implies code_set (Code_set_id_character_sets).has_code (charset)

{
    "name": "DV_ENCAPSULATED",
    "documentation": "Abstract class defining the common meta-data of all types of encapsulated data.",
    "is_abstract": true,
    "ancestors": [
        "DATA_VALUE"
    ],
    "properties": {
        "charset": {
            "_type": "P_BMM_SINGLE_PROPERTY",
            "name": "charset",
            "documentation": "Name of character encoding scheme in which this value is encoded. Coded from openEHR Code Set  character sets . Unicode is the default assumption in openEHR, with UTF-8 being the assumed encoding. This attribute allows for variations from these assumptions. ",
            "type": "CODE_PHRASE"
        },
        "language": {
            "_type": "P_BMM_SINGLE_PROPERTY",
            "name": "language",
            "documentation": "Optional indicator of the localised language in which the data is written, if relevant. Coded from openEHR Code Set `languages`.",
            "type": "CODE_PHRASE"
        }
    },
    "invariants": {
        "Size_valid": "size >= 0",
        "Language_valid": "language /= Void implies code_set (Code_set_id_languages).has_code (language)",
        "Charset_valid": "charset /= Void implies code_set (Code_set_id_character_sets).has_code (charset)"
    }
}
DV_ENCAPSULATED

DV_MULTIMEDIA Class

  • Definition

  • Effective

  • BMM

  • UML

Class

DV_MULTIMEDIA

Description

A specialisation of DV_ENCAPSULATED for audiovisual and bio-signal types. Includes further metadata relating to multimedia types which are not applicable to other subtypes of DV_ENCAPSULATED.

Inherit

DV_ENCAPSULATED

Attributes

Signature

Meaning

0..1

alternate_text: String

Text to display in lieu of multimedia display/replay.

0..1

uri: DV_URI

URI reference to electronic information stored outside the record as a file, database entry etc, if supplied as a reference.

0..1

data: Array<Octet>

The actual data found at uri, if supplied inline.

1..1

media_type: CODE_PHRASE

Data media type coded from openEHR code set media types (interface for the IANA MIME types code set).

0..1

compression_algorithm: CODE_PHRASE

Compression type, a coded value from the openEHR Integrity check code set. Void means no compression.

0..1

integrity_check: Array<Octet>

Binary cryptographic integrity checksum.

0..1

integrity_check_algorithm: CODE_PHRASE

Type of integrity check, a coded value from the openEHR Integrity check code set.

0..1

thumbnail: DV_MULTIMEDIA

The thumbnail for this item, if one exists; mainly for graphics formats.

1..1

size: Integer

Original size in bytes of unencoded encapsulated data. I.e. encodings such as base64, hexadecimal etc do not change the value of this attribute.

Functions

Signature

Meaning

1..1

is_external (): Boolean

Computed from the value of the uri attribute: True if the data is stored externally to the record, as indicated by uri. A copy may also be stored internally, in which case is_expanded is also true.

1..1

is_inline (): Boolean

Computed from the value of the data attribute. True if the data is stored in expanded form, ie within the EHR itself.

1..1

is_compressed (): Boolean

Computed from the value of the compression_algorithm attribute: True if the data is stored in compressed form.

1..1

has_integrity_check (): Boolean

Computed from the value of the integrity_check_algorithm attribute: True if an integrity check has been computed.

Invariants

Not_empty: is_inline or is_external

Media_type_valid: media_type /= Void and then code_set (Code_set_id_media_types).has_code (media_type)

Compression_algorithm_validity: compression_algorithm /= Void implies code_set (Code_set_id_compression_algorithms).has_code (compression_algorithm)

Integrity_check_validity: integrity_check /= Void implies integrity_check_algorithm /= Void

Integrity_check_algorithm_validity: integrity_check_algorithm /= Void implies code_set (Code_set_id_integrity_check_algorithms).has_code (integrity_check_algorithm)

Size_valid: size >= 0

DV_MULTIMEDIA

A specialisation of DV_ENCAPSULATED for audiovisual and bio-signal types. Includes further metadata relating to multimedia types which are not applicable to other subtypes of DV_ENCAPSULATED.

Inherits: BASIC_DEFINITIONS, OPENEHR_DEFINITIONS, DATA_VALUE, DV_ENCAPSULATED

Constants

BASIC_DEFINITIONS.CR: Character = '\015' [1..1]

Carriage return character.

BASIC_DEFINITIONS.LF: Character = '\012' [1..1]

Line feed character.

BASIC_DEFINITIONS.Any_type_name: String = "Any" [1..1]

BASIC_DEFINITIONS.Regex_any_pattern: String = ".*" [1..1]

BASIC_DEFINITIONS.Default_encoding: String = "UTF-8" [1..1]

BASIC_DEFINITIONS.None_type_name: String = "None" [1..1]

OPENEHR_DEFINITIONS.Local_terminology_id: String = "local" [1..1]

Predefined terminology identifier to indicate it is local to the knowledge resource in which it occurs, e.g. an archetype

Attributes

DV_ENCAPSULATED.charset: CODE_PHRASE [0..1]

Name of character encoding scheme in which this value is encoded. Coded from openEHR Code Set character sets . Unicode is the default assumption in openEHR, with UTF-8 being the assumed encoding. This attribute allows for variations from these assumptions.

DV_ENCAPSULATED.language: CODE_PHRASE [0..1]

Optional indicator of the localised language in which the data is written, if relevant. Coded from openEHR Code Set languages.

alternate_text: String [0..1]

Text to display in lieu of multimedia display/replay.

uri: DV_URI [0..1]

URI reference to electronic information stored outside the record as a file, database entry etc, if supplied as a reference.

data: Array<Octet> [0..1]

The actual data found at uri, if supplied inline.

media_type: CODE_PHRASE [1..1]

Data media type coded from openEHR code set media types (interface for the IANA MIME types code set).

compression_algorithm: CODE_PHRASE [0..1]

Compression type, a coded value from the openEHR Integrity check code set. Void means no compression.

integrity_check: Array<Octet> [0..1]

Binary cryptographic integrity checksum.

integrity_check_algorithm: CODE_PHRASE [0..1]

Type of integrity check, a coded value from the openEHR Integrity check code set.

thumbnail: DV_MULTIMEDIA [0..1]

The thumbnail for this item, if one exists; mainly for graphics formats.

size: Integer [1..1]

Original size in bytes of unencoded encapsulated data. I.e. encodings such as base64, hexadecimal etc do not change the value of this attribute.

Functions

is_external (): Boolean [1..1]

Computed from the value of the uri attribute: True if the data is stored externally to the record, as indicated by uri. A copy may also be stored internally, in which case is_expanded is also true.

is_inline (): Boolean [1..1]

Computed from the value of the data attribute. True if the data is stored in expanded form, ie within the EHR itself.

is_compressed (): Boolean [1..1]

Computed from the value of the compression_algorithm attribute: True if the data is stored in compressed form.

has_integrity_check (): Boolean [1..1]

Computed from the value of the integrity_check_algorithm attribute: True if an integrity check has been computed.

Invariants

Size_valid: size >= 0

DV_ENCAPSULATED.Language_valid: language /= Void implies code_set (Code_set_id_languages).has_code (language)

DV_ENCAPSULATED.Charset_valid: charset /= Void implies code_set (Code_set_id_character_sets).has_code (charset)

Not_empty: is_inline or is_external

Media_type_valid: media_type /= Void and then code_set (Code_set_id_media_types).has_code (media_type)

Compression_algorithm_validity: compression_algorithm /= Void implies code_set (Code_set_id_compression_algorithms).has_code (compression_algorithm)

Integrity_check_validity: integrity_check /= Void implies integrity_check_algorithm /= Void

Integrity_check_algorithm_validity: integrity_check_algorithm /= Void implies code_set (Code_set_id_integrity_check_algorithms).has_code (integrity_check_algorithm)

{
    "name": "DV_MULTIMEDIA",
    "documentation": "A specialisation of `DV_ENCAPSULATED` for audiovisual and bio-signal types. Includes further metadata relating to multimedia types which are not applicable to other subtypes of `DV_ENCAPSULATED`.",
    "ancestors": [
        "DV_ENCAPSULATED"
    ],
    "properties": {
        "alternate_text": {
            "_type": "P_BMM_SINGLE_PROPERTY",
            "name": "alternate_text",
            "documentation": "Text to display in lieu of multimedia display/replay.",
            "type": "String"
        },
        "uri": {
            "_type": "P_BMM_SINGLE_PROPERTY",
            "name": "uri",
            "documentation": "URI reference to electronic information stored outside the record as a file, database entry etc, if supplied as a reference. \n",
            "type": "DV_URI"
        },
        "data": {
            "_type": "P_BMM_CONTAINER_PROPERTY",
            "name": "data",
            "documentation": "The actual data found at `_uri_`, if supplied inline.",
            "type_def": {
                "container_type": "Array",
                "type": "Octet"
            },
            "cardinality": {
                "lower": 0,
                "upper_unbounded": true
            }
        },
        "media_type": {
            "_type": "P_BMM_SINGLE_PROPERTY",
            "name": "media_type",
            "documentation": "Data media type coded from openEHR code set  media types  (interface for the IANA MIME types code set). \n",
            "is_mandatory": true,
            "type": "CODE_PHRASE"
        },
        "compression_algorithm": {
            "_type": "P_BMM_SINGLE_PROPERTY",
            "name": "compression_algorithm",
            "documentation": "Compression type, a coded value from the openEHR Integrity check code set. Void means no compression. ",
            "type": "CODE_PHRASE"
        },
        "integrity_check": {
            "_type": "P_BMM_CONTAINER_PROPERTY",
            "name": "integrity_check",
            "documentation": "Binary cryptographic integrity checksum.",
            "type_def": {
                "container_type": "Array",
                "type": "Octet"
            },
            "cardinality": {
                "lower": 0,
                "upper_unbounded": true
            }
        },
        "integrity_check_algorithm": {
            "_type": "P_BMM_SINGLE_PROPERTY",
            "name": "integrity_check_algorithm",
            "documentation": "Type of integrity check, a coded value from the openEHR `Integrity check` code set. ",
            "type": "CODE_PHRASE"
        },
        "thumbnail": {
            "_type": "P_BMM_SINGLE_PROPERTY",
            "name": "thumbnail",
            "documentation": "The thumbnail for this item, if one exists; mainly for graphics formats.",
            "type": "DV_MULTIMEDIA"
        },
        "size": {
            "_type": "P_BMM_SINGLE_PROPERTY",
            "name": "size",
            "documentation": "Original size in bytes of unencoded encapsulated data. I.e. encodings such as base64, hexadecimal etc do not change the value of this attribute.",
            "is_mandatory": true,
            "type": "Integer"
        }
    },
    "functions": {
        "is_external": {
            "name": "is_external",
            "documentation": "Computed from the value of the `_uri_` attribute: True if  the data is stored externally to the record, as indicated by `_uri_`. A copy may also be stored internally, in which case `_is_expanded_` is also true.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "is_inline": {
            "name": "is_inline",
            "documentation": "Computed from the value of the data attribute. True if  the  data is stored  in  expanded  form, ie within the EHR itself. ",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "is_compressed": {
            "name": "is_compressed",
            "documentation": "Computed from the value of the `_compression_algorithm_` attribute: True if  the  data is stored in compressed form. ",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        },
        "has_integrity_check": {
            "name": "has_integrity_check",
            "documentation": "Computed from the value of the `_integrity_check_algorithm_` attribute: True if an integrity check has been computed. ",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Boolean"
            }
        }
    },
    "invariants": {
        "Not_empty": "is_inline or is_external",
        "Media_type_valid": "media_type /= Void and then code_set (Code_set_id_media_types).has_code (media_type)",
        "Compression_algorithm_validity": "compression_algorithm /= Void implies code_set (Code_set_id_compression_algorithms).has_code (compression_algorithm)",
        "Integrity_check_validity": "integrity_check /= Void implies integrity_check_algorithm /= Void",
        "Integrity_check_algorithm_validity": "integrity_check_algorithm /= Void implies code_set (Code_set_id_integrity_check_algorithms).has_code (integrity_check_algorithm)",
        "Size_valid": "size >= 0"
    }
}
DV_MULTIMEDIA

DV_PARSABLE Class

  • Definition

  • Effective

  • BMM

  • UML

Class

DV_PARSABLE

Description

Encapsulated data expressed as a parsable String. The internal model of the data item is not described in the openEHR model in common with other encapsulated types, but in this case, the form of the data is assumed to be plaintext, rather than compressed or other types of large binary data.

Inherit

DV_ENCAPSULATED

Attributes

Signature

Meaning

1..1

value: String

The string, which may validly be empty in some syntaxes.

1..1

formalism: String

Name of the formalism, e.g. GLIF 1.0 , Proforma etc.

Functions

Signature

Meaning

1..1

size (): Integer

Size in bytes of value.

Invariants

Formalism_valid: not formalism.is_empty

Size_valid: size >= 0

DV_PARSABLE

Encapsulated data expressed as a parsable String. The internal model of the data item is not described in the openEHR model in common with other encapsulated types, but in this case, the form of the data is assumed to be plaintext, rather than compressed or other types of large binary data.

Inherits: BASIC_DEFINITIONS, OPENEHR_DEFINITIONS, DATA_VALUE, DV_ENCAPSULATED

Constants

BASIC_DEFINITIONS.CR: Character = '\015' [1..1]

Carriage return character.

BASIC_DEFINITIONS.LF: Character = '\012' [1..1]

Line feed character.

BASIC_DEFINITIONS.Any_type_name: String = "Any" [1..1]

BASIC_DEFINITIONS.Regex_any_pattern: String = ".*" [1..1]

BASIC_DEFINITIONS.Default_encoding: String = "UTF-8" [1..1]

BASIC_DEFINITIONS.None_type_name: String = "None" [1..1]

OPENEHR_DEFINITIONS.Local_terminology_id: String = "local" [1..1]

Predefined terminology identifier to indicate it is local to the knowledge resource in which it occurs, e.g. an archetype

Attributes

DV_ENCAPSULATED.charset: CODE_PHRASE [0..1]

Name of character encoding scheme in which this value is encoded. Coded from openEHR Code Set character sets . Unicode is the default assumption in openEHR, with UTF-8 being the assumed encoding. This attribute allows for variations from these assumptions.

DV_ENCAPSULATED.language: CODE_PHRASE [0..1]

Optional indicator of the localised language in which the data is written, if relevant. Coded from openEHR Code Set languages.

value: String [1..1]

The string, which may validly be empty in some syntaxes.

formalism: String [1..1]

Name of the formalism, e.g. GLIF 1.0 , Proforma etc.

Functions

size (): Integer [1..1]

Size in bytes of value.

Invariants

Size_valid: size >= 0

DV_ENCAPSULATED.Language_valid: language /= Void implies code_set (Code_set_id_languages).has_code (language)

DV_ENCAPSULATED.Charset_valid: charset /= Void implies code_set (Code_set_id_character_sets).has_code (charset)

Formalism_valid: not formalism.is_empty

{
    "name": "DV_PARSABLE",
    "documentation": "Encapsulated data expressed as a parsable String. The internal model of the data item is not described in the openEHR model in common with other encapsulated types, but in this case, the form of the data is assumed to be plaintext, rather than compressed or other types of large binary data. ",
    "ancestors": [
        "DV_ENCAPSULATED"
    ],
    "properties": {
        "value": {
            "_type": "P_BMM_SINGLE_PROPERTY",
            "name": "value",
            "documentation": "The string, which may validly be empty in some syntaxes.",
            "is_mandatory": true,
            "type": "String"
        },
        "formalism": {
            "_type": "P_BMM_SINGLE_PROPERTY",
            "name": "formalism",
            "documentation": "Name of the formalism, e.g.  GLIF 1.0 ,  Proforma  etc.",
            "is_mandatory": true,
            "type": "String"
        }
    },
    "functions": {
        "size": {
            "name": "size",
            "documentation": "Size in bytes of value.",
            "result": {
                "_type": "P_BMM_SIMPLE_TYPE",
                "type": "Integer"
            }
        }
    },
    "invariants": {
        "Formalism_valid": "not formalism.is_empty",
        "Size_valid": "size >= 0"
    }
}
DV_PARSABLE