View Revision MarksHide Revision Marks

Data Types - Abstract Specification

Not Balloting this Cycle
HL7 V3 DT R2
HL7 Version 3 Standard: Data Types - Abstract Specification, Release 2
Last Ballot: Normative Ballot 4 - September 2009spacer
Primary Contributer & Co-Chair of Modelling & Methodology Grahame Grieve
grahame@kestral.com.au
Kestral Computing Pty. Ltd.
Primary Contributer Gunther Schadow
gschadow@regenstrief.org
Indiana School of Medicine
Primary Contributer (R1) Paul Biron
paul@sparrow-hawk.org
Sparrow Hawk Photography
Primary Contributer & Co-Chair of Modelling & Methodology Lloyd McKenzie
lloyd@lmckenzie.com
Lloyd Mackenzie and Associates
Co-Chair of Modelling & Methodology George (Woody) Beeler
woody@beelers.com
Beeler Consulting LLC
Co-Chair of Modelling & Methodology Dale Nelson
dale@zed-logic.com
II4SM
Co-Chair of Modelling & Methodology Craig Parker
craigparkermd@gmail.com
Arizona State University
Co-Chair of Modelling & Methodology Ioana Singureanu
ioana.singureanu@gmail.com
Eversolve, LLC

Table of Contents

2.4.1  Declaration
2.4.4  Literal Form
2.4.6  Flavors
3.3.8  Literal Form
3.5.8  Literal Form
3.6.12  Literal Form
3.10.2  Literal Form
4.3.12  Literal Form
4.5.14  CD Examples
4.7.8  Literal Form
4.9.1  Literal Form
4.10.6  Literal Form
4.12.8  Literal Form
4.13.3  Literal Form
4.16.6  AD Examples
4.18.8  EN Examples
5.3.13  Literal Form
5.4.11  Literal Form
5.5.3  Literal Form
5.6.18  Literal Form
5.8.9  Literal Form
5.11.11  Literal Form
6.10.10  Literal Form
6.12.1  Literal Form
6.13.8  Literal Form
6.14.3  Literal Form
6.15.1  Literal Form

Appendices

A.1.3  Literal Form

 i Preface
 i - a Notes to Readers

This is the fourth membership ballot for Release 2 of the Data Type - Abstract Specification.

One substantiative change has been to this ballot, the removal of the CD.isCompositional property. This change is the only part of the document that is open for comment in this ballot. Other comments may be made, but will most likely be deferred to data types R3.

The primary issue already deferred to R3 is the question of an improved conformance framework that properly handles translations and property level conformance. In particular, this should provide a more elegant solution to the recognised problem of requiring an attribute to have either text or a code. In addition, the subject of nested ADXP's will be considered for R3.

 i - b Acknowledgements

This work is the result of much work and many MBs of text in skype, wiki, and email by the Data Types R2 Taskforce, as well as phone calls and face to face meetings. The Data Types R2 Taskforce has an informal membership. The core members are

  • Grahame Grieve

  • Gunther Schadow

  • Lloyd Mckenzie

  • Lee Coller

  • Charlie McCay

  • Dale Nelson

Many other individuals have helped out during the data types R2 proposal. The R2 taskforce would particularly like to thank

  • Doug Pratt

  • Mark Tucker

  • Kevin Coonan

  • David Markwell

  • Jay Lyle

Release 2 was made possible by Connecting For Health.

Data Types Release 2 is a continuation of the first release of the data types, which was the result of many years of intense work through e-mail, telephone conferences and meeting discussions. And ballot reconciliation. Thanks go to many individuals who participated at various times in design, discussions and ballot review. Gunther Schadow chaired the task force, and was the main author of this document. Paul Biron, Doug Pratt, Lloyd Mckenzie, and Grahame Grieve served as editors at various times. Major contributions of thoughts and support come from Mark Tucker, George Beeler, Stan Huff, as well as Mike Henderson, Anthony Julian, Joann Larson, Mark Shafarman, Wes Rishel, and Robin Zimmerman. Acknowledgements for their critical review and infusion of ideas go to Bob Dolin, Clem McDonald, Kai Heitmann, Rob Seliger, and Harold Solbrig. Vital support came from the members of the task force, Laticia Fitzpatrick, Matt Huges, Randy Marbach, Larry Reis, Carlos Sanroman, and Greg Thomas. Thanks also to James Case, Norman Daoust, Irma Jongeneel, Michio Kimura, John Molina, Richard Ohlmann, David Rowed, and Klaus Veil, for sharing their expertise in critical questions.

Release 1 was made possible by the Regenstrief Institute for Health Care.


 1 Overview
 1.1 Introduction and Scope

This document provides the semantic definitions for the data types used in the creation of HL7 V3 specifications. These "abstract" semantic definitions are also able to be used as constraints in the creation of implementation guides, and implementation technology specifications that enable actual exchange of data are based on these semantic definitions.

The audience for this document is anyone who uses HL7 V3 data types - both implementers and designers of HL7 specifications. For implementers, this document should be treated as secondary supplemental information to the ITS data types, which provide an basis for actual implementation of the data types.

The data types defined in this specification are not intended to be implemented solely based on the details presented herein. For example, this specification does not differentiate between the information that should be represented explicitly in any technical representation such as XML and the information that should be derived from the explicit representation. This document corresponds broadly to the RM-ODP informational view ("concerned with the kinds of information handled by the system and constraints on the use and interpretation of that information"). The ISO data types specification is an ITS for these data types that corresponds to the RM-ODP computational view ("concerned with the functional decomposition of the system into a set of objects"). See [http://www.rm-odp.net/] for further information.

Readers should be familiar with the use of data types in a programming context, and will find reading easier if they are familiar with standard notations such as regular expressions, Bakus-Naur form, and UML class diagrams.

 1.2 What is a Data Type?

The RIM is composed of classes with attributes which are data elements. A data element is a unit of data for which the definition, identification, representation, and permissible values are specified by means of a set of attributes. Every data element has a data type. The data type defines the set of valid values that can be assigned to a data element and their meaning (semantics). Meaningful exchange of data requires that we know the definition of values so exchanged. This is true for complex "values" such as timing specifications as well as for simpler values such as character strings or integer numbers. An instance of a data type is a data value.

According to ISO 11404, a data type is "a set of distinct values, characterized by properties of those values and by operations on those values." A data type can be defined by intension or by extension, or by a combination of these approaches. Intensional definition specifies the properties that the set of valid values must have: e.g. a definition that stipulates that a "string" is "an ordered collection of legible characters from a defined character set." Extensional definition enumerates the values deemed valid: e.g. the assertion that the boolean type consists of the values "true" and "false". While extensional definitions are useful for coded attributes, almost all abstract data types are defined intensionally.

A property of a data type is referred to by a name and can be evaluated for any value of a data type. The value of a data value's property must itself be a value defined by a data type - no data value exists that cannot be defined by a data type.

Data types are thus the basic building blocks used to construct any higher order meaning: messages, computerized patient records, or business objects and their transactions. For the purposes of this document, business objects are defined as any class built using data types that is used to store or convey information in helathcare systems (this definition is more general than the term business objects may convey in other contexts). What, then, is the difference between a data type and a message, document, or business object? Data type values stand for themselves: the value is all that counts. Neither identity nor state is defined for a data value. In business objects, we track state and identity; the properties of an identical object might change between now and later. Not so with data values: a data value and its properties are constant. For example, number 5 is always number 5: there is no difference between this number 5 and that number 5 (no identity distinguished from value), number 5 never changes to number 6 (no change of state). One can think of data values as immutable objects where identity does not matter (identity and equality are the same).

 1.3 Representation of Data Values

Data values can be represented through various symbols but the data value's meaning is not bound to any particular representation.

For example, integers are defined intensionally as a data type where each value has a successor value. Based on this definition we can define addition, multiplication, and other mathematical operations. Whatever representation reflects the rules we stated in the intensional definition of the integer data type is a valid representation of integer numbers. Examples for valid integer representations are decimal digit strings, roman numerals, or scratches on a wall, given appropriate syntaxes for negative numbers. The number five is represented by the word "five", by the Arabic number "5" or by the Roman number "V". The representation does not matter as long as it conforms to the semantic definition of the data type.

Another example, the Boolean data type is defined by its extension, the two distinct values true and false and the rules of negation and combining these values in conjunction and disjunction. The representation of Boolean values can be the words "true" and "false," "yes" and "no," the numbers 0 and 1, or any other two signs that are distinct from each other. The representation of data types does not matter as long as it conforms to the semantic definition of the data type.

This specification defines the semantics, the meaning of the HL7 data types. This specification is about semantics only, independent from representational and operational concerns or specific implementation technologies. Additional standards for representing the data values defined here using various technological approaches may be defined by HL7 or other standards bodies. These standards are called "Implementable Technology Specification" (ITS). These ITS define how values are represented so that they conform to the semantic definitions of this specification, this may include syntaxes for character or binary representations, and computer procedures to act on the representation of data values. The meaning of these ITS representations communicated, generated, and processed in computer programs, is defined based on this standard, the semantic data type specification.

 1.4 Properties of Data Values

Data types specify the properties of data values. The fields of composite data types — e.g., the units property of a measurement — are an obvious example of such properties. Generally, however, one should think of a data value's properties as logical predicates or as mathematical functions. In simpler but still correct terms, properties are the answers to questions one can ask about a data value.

A property is referred to by its name. For example, the data type integer may have a property named "sign." A property has a domain, which is the set of possible "answer" values. The set of possible "answer" values is defined by the property's data type. The domain of a property may be a subset of the property's data type's value set, since other constraints may be applied to the data type in the context of the property.

A property may also have arguments, additional information one must supply with a question to get an answer. For example, an important property of an integer number is that one integer plus another integer results in another integer, so the plus property of one integer requires an argument: the other integer.

Whether properties have arguments is not a fundamentally relevant distinction. Properties that do not take arguments are not necessarily more fundamental than others, and such a property is not necessarily to be represented as a field of a composite data type. For example, for integer values, we can define the property is-zero that has the Boolean value true when the number is zero and false when the number is not zero. This does not mean that is-zero must be an explicit component of any integer representation.

Similarly, a property with arguments need not imply specific operational notions such as "procedure calls" or "arguments." These are concepts of computer system implementations of data types, but these operational notions are irrelevant for the semantics of data types. The fact that a data type has a property does not mean that implementations must explicitly model the property; only that the property must be derivable. The "sign" property in the previous example could be modeled as a discrete element separate from the integer's magnitude, or it could be implicit in the field, discretely identifiable only through an operation such as comparing the value to its absolute value.

Many properties are never explicitly represented in an implementation, and may be only implicitly derivable from the implementation design rather than the data value. For instance, every type defined here inherits the "type" property, but actual data values are not commonly stored with explicit representations of their types: that information is implicit in the database, schema, or other data storage technology or specification.

This specification is about semantics of data types only. It is not about value representation syntax (not even an abstract syntax), nor is it about an operational interface to the data values.

 1.5 Need for Abstraction

Why does this specification make such a big issue about its being abstract from representation syntax as well as operational implementation?

HL7 needs this kind of abstract semantic data type specification for a very practical purpose. One important design feature of HL7 version 3 is its neutrality towards representation and implementation technologies. All HL7 version 3 specifications are required to be technology and representationally neutral. HL7 acknowledges that, while at times some representation and implementation technologies may be more popular than others, technology is going to change - and with changing technology, representations of data values will change. HL7 standards are primarily targeted to healthcare domain information, independent from the technology supporting this information. HL7 expects that specifications defined independent from today's technology will continue to be useful, even after the next technological "paradigm shift."

The issue of data types is closer to implementation technology than most other HL7 information standards - and therein lays a certain danger that we define data types too dependent on current implementation technologies.

The majority of HL7 standards are about complex business objects. Complex business objects with many informational attributes can be specified as abstract syntax, where components are eventually defined in terms of data types. Conversely, defining data types in terms of some abstract representational syntax is of little use because the components of such abstract syntax constructs would still need to be defined.

Why is this specification so circular? Why is the data type "ANY" defined in terms of specializations of itself?

This specification needs to be independent of any particular implementation, so its definitions are necessarily self-dependent. The properties of ANY all have a type that is some specialisation of ANY; this allows the self-dependent definitions of basic concepts to be re-used where appropriate. The circularity is not a problem, as it does not introduce any uncertainty about what this specification says. This specification is also abstract, and not intended to be directly implemented, and therefore does not address the challenges this poses for implementations; this is left to the various implementation technology specifications to best resolve.

Why doesn't this specification define a set of primitive data types based on which composite data types could be defined simply as abstract syntax?

Any concrete implementation of the HL7 standards must ultimately use the built-in data types of its implementation technology. Therefore, we need a flexible mapping between HL7 abstract data types and those data types built into any specific implementation technology. An Implementable Technology Specification (ITS) conforms to an abstract specification by asserting a mapping the constructs of its technology and the properties defined in the HL7 version 3 abstract data types. Whether a data type is primitive or composite is irrelevant from a semantic perspective, and the answer may be different for different implementation technologies.

For example, this standard specifies a character string as a data type with many properties (e.g., charset, language, etc.). However, in many Implementation Technologies, character strings are primitive first class data types. We encourage that these native data types be used rather than a structure that slavishly represents all the semantic properties as "components." This specification only requires that the properties defined for data values can somehow be inferred from whatever representation is chosen: it does not matter how these values are represented. Whether "primitive" or "composite," with few or many "components," as "fields" or "methods" - this is all irrelevant.

For another example, a decimal representation, a floating-point register and a scaled integer are all possible native representations of real numbers for different implementation technologies. Some of these representations have properties that others do not have. Scaled integers, for instance, have a fixed precision and a relatively small range. Floating-point values have variable precision and a large range, but floating-point values lose any information about precision. Decimal representations are of variable precision and maintain the precision information (yet are slow to process). The data type semantics must be independent from all these accidental properties of the various representations, and must define the essential properties that any technology should be able to represent.

 1.6 Need for an HL7 Data Type Standard

Why does HL7 need its own data type standard? Why can't HL7 simply adopt a standard defined by some other body?

As noted in the previous section, all HL7 implementation technologies have some data type system, but there are differences among the data type systems between implementation technologies. In addition, many implementation technologies' data type systems are not powerful enough to express the concepts that matter for the HL7 application layer.

Few implementation technologies provide the concepts of physical quantities, precision, ranges, missing information, and uncertainty that are so relevant in scientific and health care computing.

On the other hand, implementation technologies do make distinctions that are not relevant from the abstract semantics viewpoint, e.g., fixed point vs. floating-point real numbers; 8, 16, 32, or 64-bit integers; date vs. timestamp.

A number of data type systems have been used as input to this specification. These include the type systems of many major programming languages, including BASIC, Pascal, MODULA-2, C, C++, JAVA, ADA, LISP and SCHEME. This also includes type systems of language-independent implementation technologies, such as Abstract Syntax Notation One (ASN.1), Object Management Group's (OMG) Interface Definition Language (IDL) and Object Constraint Language (OCL), SQL 92 and SQL 99, the ISO 11404 language independent data types, and XML Schema Part 2 data types. Health care standards related data types have been considered as well, among these HL7 version 2.x, types used by CEN TC 251 messages and Electronic Health Record Architecture (EHCRA) and DICOM.

 1.7 Overview of Data Types

The following table lists all of the data types in this specification, each with the text description taken from its definition.

  Table 1: Overview of HL7 version 3 data types
  Name Symbol Description
Foundation Core structural datatypes that are needed in order to build the types that are in the healthcare domain
  DataValue ANY An abstract type that defines the basic properties common to all data values defined in this specification. Data Value is an abstract type, meaning that no proper value can be just a data value without belonging to any concrete type. Every concrete type is a specialization of this general abstract DataValue type.
  Boolean BL A binary value for use in boolean logic. A BL value can be either true or false, or, as any other value, MAY be NULL.
  Collection COLL A collection of values which can be enumerated using an iterator.
  Bag BAG An unordered collection of values, where any value can occur more than once.
  Sequence LIST An ordered collection of discrete (but not necessarily distinct) values.
  Set SET A value that contains distinct values in no particular order.
  EqualComparator CEQ A comparator based on the equality relationship defined for all types.
  DiscreteSet DSET An unordered collection of values that contains discrete distinct values.
  HistoryItem HXIT A generic data type extension that adds a time range and/or link to the ControlAct associated with the creation of the data on any data value whatever its data type.
  History HIST A list of data values that have a valid-time property.
Basic Basic building blocks that are used in health care information models - text, coded concepts, identifiers, names and addresses
  EncapsulatedData ED Data that is primarily intended for human interpretation or for further machine processing outside the scope of HL7.
  CharacterString ST Text data, primarily intended for machine processing (e.g., sorting, querying, indexing, presentation, etc.).
  CharacterStringWithCode SC A character string that optionally may have a code attached.
  ConceptDescriptor CD A reference to a concept defined in a code system
  CodedOrdinal CO Coded data, where the coding system from which the code comes defines a partial or complete order on some or all of the codes in the system.
  CodedSimpleValue CS Coded data in its simplest form, where only the code is not predetermined. The code system and code system version are fixed by the context in which CS value occurs. CS is used for coded attributes that have a single HL7-defined value set.
  ObjectIdentifier OID A globally unique string representing an ISO Object Identifier (OID) in a form that consists only of numbers and dots (e.g., "2.16.840.1.113883.3.1"). According to ISO, OIDs are paths in a tree structure, with the left-most number representing the root and the right-most number representing a leaf.
  UniversalUniqueIdentifier UUID A globally unique string representing a DCE Universal Unique Identifier (UUID) in the common UUID format that consists of 5 hyphen-separated groups of hexadecimal digits having 8, 4, 4, 4, and 12 places respectively.
  HL7ReservedIdentifierScheme RUID A globally unique string defined exclusively by HL7. Identifiers in this scheme SHALL only be defined by balloted HL7 specifications. Local communities or systems SHALL never use such reserved identifiers based on bilateral negotiations.
  InstanceIdentifier II An identifier that uniquely identifies a thing or object. Examples are object identifier for HL7 RIM objects, medical record number, order id, service catalog item id, Vehicle Identification Number (VIN), etc.
  TelecommunicationAddress TEL A locatable resource that is identified by a URI. The address is specified as a Universal Resource Identifier (URL) qualified by time specification and use codes that help in deciding which address to use for a given time and purpose. TEL may be used to designate a retrievable resource such as a web page, a telephone number (voice, fax or some other resource mediated by telecommunication equipment), an e-mail address, or any other locatable resource that can be specified by a URL.
  PostalAddress AD Mailing and home or office addresses. A sequence of address parts, such as street or post office box, city, postal code, country, etc.
  EntityName EN A name for a person, organization, place or thing. A sequence of name parts, such as given name or family name, prefix, suffix, etc. Examples for entity name values are "Jim Bob Walton, Jr.", "Health Level Seven, Inc.", "Lake Tahoe", etc. An entity name may be as simple as a character string or may consist of several entity name parts, such as, "Jim", "Bob", "Walton", and "Jr.", "Health Level Seven" and "Inc.", "Lake" and "Tahoe".
Quantities Simple numerical types such as numbers, and also more complex notions such as physical quantities and ratios
  IntegerNumber INT Integer numbers (-1,0,1,2, 100, 3398129, etc.) are precise numbers that are results of counting and enumerating. Integer numbers are discrete, the set of integers is infinite but countable. No arbitrary limit is imposed on the range of integer numbers. Two NULL flavors are defined for the positive and negative infinity.
  RealNumber REAL A scalar magnitude. Typically used whenever quantities are measured, estimated, or computed from other real numbers. The typical representation is decimal, where the number of significant decimal digits is known as the precision.
  Ratio RTO A quantity constructed as the quotient of a numerator quantity divided by a denominator quantity. Common factors in the numerator and denominator are not automatically cancelled out. The RTO data type supports titers (e.g., "1:128") and other quantities produced by laboratories that truly represent ratios. Ratios are not simply "structured numerics": for instance, blood pressure measurements (e.g. "120/60") are not ratios.
  PhysicalQuantity PQ A dimensioned quantity expressing the result of measuring.
  MonetaryAmount MO A quantity expressing an amount of money in some currency. While the monetary amount is a single kind of quantity (money) the exchange rates between the different units are variable. This is the principle difference between PQ and MO, and the reason why currency units are not physical units.
  PointInTime TS A quantity specifying a point on the axis of natural time. A point in time is most often represented as a calendar expression.
  Expression EXPR A generic data type extension used to specify an expression that can be used to derive the actual value of T given information taken from the context of use.
Quantity Collections Complex expressional types which can be used to build sophisticated concepts such as timing specifications
  ContinuousSet QSET An unordered set of distinct values which are quantities.
  ContinuousSetUnion QSU A Term in a QSET expression that builds a QSET from a union of other QSETs.
  ContinuousSetIntersection QSI A Term in a QSET expression that builds a QSET from an intersection of other QSETs.
  ContinuousSetDifference QSD A Term in a QSET expression that builds a QSET from the difference between 2 QSETs.
  ContinuousSetPeriodicHull QSP A Term in a QSET expression that builds a QSET from the difference between 2 QSETs.
  CodedContinuousSet QSC A Term in a QSET expression that builds a QSET from a coded value.
  Interval IVL A set of consecutive values of an ordered base data type.
  PeriodicInterval PIVL An interval of time that recurs periodically. PIVL has two properties, phase and period/frequency. phase specifies the "interval prototype" that is repeated every period or frequency.
  EventRelatedPeriodicInterval EIVL Specifies a periodic interval of time where the recurrence is based on activities of daily living or other important events that are time-related but not fully determined by time.
  GeneralTimingSpecification GTS An alias for QSET<TS>.
Uncertainties Extend the previously defined types to cater for the various quantitative uncertainties encountered in healthcare information models
  UncertainValueProbabilistic UVP A generic data type extension used to specify a quantified probability expressing the information producer's belief that the given value is correct.
  UncertainRange URG Indicates that the value comes from a range of possible values of an ordered base data type.

 

The following table lists all of the flavors in this specification, each with the text description taken from its definition. Flavors (§ 2.4.6 ) are not fully qualified types, but only restrictions on previously defined types and flavors.

  Table 2: Overview of HL7 version 3 data type flavors
  Name Symbol Description
  BooleanNonNull BN BN constrains the BL so that it is not null. This is defined for use within the data types specification where it is not appropriate for a null value to be used.
  TextWithReference ED.TEXT ED.TEXT constrains ED so that it only contains plain text.
  DigitalSignature ED.SIGNATURE ED.SIGNATURE constrains ED so that the contents are an XML digital Signature according the W3C Signature specifications.
  Image ED.IMAGE ED.IMAGE constrains ED so that the contents are an image.
  StructuredText ED.STRUCTURED_TEXT ED.STRUCTURED_TEXT constrains ED so that the contents are structured text.
  StructuredTitle ED.STRUCTURED_TITLE ED.STRUCTURED_TITLE constrains ED so that the contents are a structured title.
  StringNoTranslations ST.NT ST.NT constrains ST so that it there are no translations.
  StringSimple ST.SIMPLE ST.SIMPLE constrains ST.NT so that it does not specify a language.
  CodedStringNoTranslations SC.NT SC.NT constrains SC so that it has no translations.
  CodedValue CV CV constrains CD so that there is no translations, and only a single concept is allowed.
  LocatableResource TEL.URL TEL.URL constrains TEL so that it points to a locatable resource that returns binary content.
  TelephoneAddress TEL.PHONE TEL.PHONE constrains TEL.PERSON so it refers to some telephone based communication system with a person or organisation.
  EmailAddress TEL.EMAIL TEL.EMAIL constrains the TEL.PERSON type so that it is an SMTP email address.
  PersonName PN PN constrains EN for use when the named Entity is a Person.
  OrganizationName ON ON constrains EN for use when the named Entity is an Organization.
  TrivialName TN TN constrains EN so that it is effectively a simple string, suitable for use as a simple name for things and places.
  IntegerNonNegative INT.NONNEG INT.NONNEG constrains INT so that it has a value of 0 or greater.
  IntegerPositive INT.POS INT.POS constrains INT.NONNEG so that it has a value greater than 0.
  LengthOfTime PQ.TIME PQ.TIME constraints PQ so that it has units that describe a period of time.
  Date TS.DATE TS.DATE constrains TS so that it only contains a date value.
  FullDate TS.DATE.FULL TS.DATE.FULL constrains TS.DATE so that it contains a reference to a particular day.
  DateTime TS.DATETIME TS.DATETIME constrains a TS so that it is not more precise than seconds.
  FullDateTime TS.DATETIME.FULL TS.DATETIME.FULL constrains TS.DATETIME so that it contains a reference to a particular second with a timezone.
  InstantInTime TS.INSTANT TS.INSTANT constrains TS.DATETIME so that it contains a reference to a particular millisecond with a timezone.
  IntervalLow IVL.LOW IVL.LOW constrains IVL so that low is provided and lowClosed is true. All other properties are prohibited.
  IntervalHigh IVL.HIGH IVL.HIGH constrains IVL so that high is provided and highClosed is true. All other properties are prohibited.
  IntervalWidth IVL.WIDTH IVL.WIDTH constrains IVL so that width is mandatory and low, lowClosed, high and highClosed are prohibited.
  UncertainRangeLow URG.LOW URG.LOW constrains URG so that low and lowClosed are required. high and highClosed are prohibited.
  UncertainRangeHigh URG.HIGH URG.HIGH constrains URG so that high and highClosed are required. low and lowClosed are prohibited.
  BoundedPeriodicInterval GTS.BOUNDEDPIVL GTS.BOUNDEDPIVL constrains QSI<TS> (GTS) so that it only allows an intersection of IVL<TS> and PIVL<TS>.

 

 1.8 Conformance

All instantiations of these data types SHALL be valid with respect to the invariant statements contained in this specification. If an application receives or parses an instance that is not valid with regard to this specification, the receiver MAY reject the instance in whatever fashion it deems appropriate, but it is not required to.

Note that many of the invariants contained in this specification only apply when the data types do not have an exceptional value (some kind of nullFlavor). These invariants specifically exclude exceptional values using some statement such as

invariant(T x) where x.nonNull {
  etc...
};

Other invariants must be true whether or not the value is an exceptional value.

 1.8.1 Constraining Model

Generally these data types are used as the type of a RIM attribute in the presence of other models that may express further constraints on the domain values of these types. In such cases, there MAY be one single model which is regarded as the primary Constraining Model.

If the constraining model labels the attribute as Mandatory, the instance SHALL contain a valid data value that conforms to all the constraints stated in this specification and any additional constraints on the value domain stated in the model. In cases where the attribute is not mandatory, if the instance does not meet the constraints specified in the Constraining Model, the instance SHALL have some form of nullFlavor, though other information may still be provided.

The constraining model may apply a cardinality to an attribute. A cardinality consists of a minimum value, specified as a whole number, and a maximum value, specified as a whole number or "*". The cardinality is usually presented as [minimum value]..[maximum value], e.g. 0..1 or [1..*]. The meaning of the cardinality differs between collection based attributes and other attributes.

For attributes with a collection type (COLL and its specializations), the cardinality specifies how many items may be in the collection. A cardinality maximum value of * means that there is no limit to the number of items in the collection. (Note that this does not imply that applications are required to handle infinitely large collections of data, but the specification itself places no limit on the size of the collection). The minimum value specifies how many items must be in the collection. Note that in the case of a mandatory collection, the collection SHALL NOT contain any null items.

For other attributes, the only cardinalities that may be applied are 0..0, 0..1, and 1..1. Cardinality of 0 means that the attribute is not to be represented in the instance, and has an implicit nullFlavor of NI. Cardinality of 1 means that the attribute has a value, though the value may be a nullFlavor unless the attribute is also mandatory.

A mandatory attribute SHALL have a minimum cardinality of 1 or more.

If an application receives or parses an instance that does not conform to these rules, the receiver MAY reject the instance in whatever fashion it deems appropriate but it is not required to by this specification. Note that other specifications that describe how Constraining Models are constructed and applied MAY make additional rules concerning application behaviour.

Any specification that describes a model other than a primary constraining model (such as templates) MUST also describe how it affects the conformance behavior of downstream models. For further information, see in the "Core Principles of V3 Models" specification under "CIM" ([../coreprinciples/v3modelcoreprinciples.htm#coreP_Types_of_HL7_V3_Models-Static-CIM])

 2 Data Type Definitions

This specification groups data types into the following sections: foundation (necessary to construct the other types), basic, quantities, collections of quantities, and uncertainties. Each section of this document uses a UML class diagram to illustrate the relationships among the types within the section. In addition to the UML diagram that introduces each section, each data type specified here is defined with the following sections:

  • A natural language name, unique within this specification; an abbreviation of that name; and the specializations, or parent data types from which the type being specified inherits properties

  • A prose definition

  • A table of "primary" properties (described below)

  • A formal Data Type Definition Language (DTDL) definition (described below)

  • A full description for each property of the data type

  • A table of domain definitions for coded types or properties (described below)

  • A prose explanation of key points of the definition, or clarification or extension of the DTDL definition (optional)

  • Notes identifying common misunderstandings, usage expectations, open questions, and other important points that don’t fit neatly into the above categories (optional)

 2.1 Unified Modeling Language (UML) Diagrams

This specification uses Unified Modeling Language (UML) class diagrams to graphically represent how data types relate to each other. Data types are shown as UML classes using the shortname for the type. Properties of types are shown as UML operations. Generic types are shown as UML parameterized classes.

Much of the detail of the data type declarations cannot be represented in the UML representation. Therefore the formal definition of the data types in the Data Type Definition Language (DTDL) should be used for detailed specification of the data types.


UML Overview of Data Types and Flavors
UML Overview of Data Types and Flavors

A number of stereotypes, enclosed in guillemots («»), are used in the diagram, some defined explicitly in order to represent the concepts embodied in this specification.

interface: All the types defined in this specification are interfaces, so the standard UML interface stereotype has been used throughout. These data types are not intended for implementation, but describe a set of conceptual interfaces that may be implemented in multiple different ways.

bind: When a generic type is specialized, and the specialization includes binding the generic to a particular type, a "realize" association links the two classes, using a "bind" stereotype to indicate that the specialization binds the class to a particular type for the parameter. The type is indicated as a parameter on the bind stereotype.

mixin: The mixin stereotype applies to a generic type: it denotes that the type is an interface, and that it specializes the parameter type and expresses all the properties of the type T in addition to its own properties - known as a Generic Type Extension.

flavor: Rather than being a type, a flavor that expresses a set of constraints on a data type. Note: “null flavors” is a concept domain, not a flavor in this sense.

constrain: Indicates the relationship between a flavor and the type or other flavor that it constrains. The exact nature of the relationship is described in the Flavors (§ 2.4.6 ) section.

iteratable: Indicates that it makes sense to enumerate the items of the collection that this interface represents using a classic iterator interface.

The UML diagrams use colors in the diagram. The colors act as an informal categorization of the data types. No particular significance is associated with the categorization. The colors have absolutely no relationship to the color coding of the RIM or of classes in static model diagrams.

Colour Category
White Infrastructure
Salmon Text & Multimedia
Green Coded Concepts
Orange Names and Addresses
Purple Identifiers & Contacts
Grey Quantities
Yellow Generics
Blue Generic Extensions
Mauve Comparators
 2.2 Tables of Properties

For a quick overview at the beginning of many data types this specification contains tables listing "primary" properties. "Primary" properties are a somewhat fuzzy notion of those properties that are semantically most salient, and more likely to be thought of as "fields" when the data type where implemented as a record, or that are expected to be used more often. These tables are provided to facilitate an overview of the content and purpose of data types. There is no requirement that the properties listed in these tables be represented as fields, and these tables are not abstract syntax definitions.

Each row of the property tables describes one property with the following columns:

  1. Name - the name of the property as stated in the formal definition.
  2. Type - the data type of that property.
  3. Definition - a short text describing the meaning of the property.
 2.3 Concept Domain Definitions and Bindings

A number of properties in this specification have associated concept domains that define the value domain for the property. These properties are all of type CD or some constraint thereof.

A concept domain is a named category of like concepts. Concept domains are bound to value sets in the context of a realm. A value set represents a uniquely identifiable set of valid concept representations, which may be taken from one or more code systems. The binding process is discussed in detail in the Core Principles of V3 Models [../coreprinciples/v3modelcoreprinciples.htm] document.

Unless otherwise specified, these concept domains are universally bound to value sets that comprise a single code system. The code systems may be defined by HL7 or some other external body, such as the W3C. The owner of the code system is clearly identified. The OID (Object Identifier) for the code system is also clearly specified. Note that OIDs are subject to ongoing revision; the OID published in this specification is correct at the time that this specification is published. The Core Principles of V3 Models [../coreprinciples/v3modelcoreprinciples.htm] document discusses OID management in depth. Unless otherwise specified, the name of the code system is the same as the name of the domain.

Where possible, a set of illustrative codes from the code system will be provided. For externally defined code systems, the actual contents of the domain are defined on an on-going basis by the external body. In the case of HL7 defined domains, the contents of the code systems are subject to on-going changes by harmonisation. This document lists the code system definitions as they were when the document was published, but more recent versions of the contents published by HL7 may be used with the data types defined herein, unless otherwise indicated.

The list of illustrative codes is shown in tables containing columns representing code, name, definition, and either status or level. Note that Status and level are not incompatible, but no circumstance where a combination of the two is useful has arisen. The table has a caption which names the concept domain, specifies the OID of the associated code system, and names the owner of the code system.

The code systems presented in this specification are all hierarchical in nature. The hierarchy represents subsumption, except in the case of AddressPartType where the hierarchy is compositional in nature. In a compositional hierachy, codes represented as child codes of another code represent parts of the concept represented by the parent code; whereas in a subsumption heirarchy, the child codes represent a more specialised meaning than the parent code.

code: The code column contains the symbol that goes in the CD.code property, and that is actually exchanged in the instance in order to represent the concept. Subsumption or composition within the code system hierarchy is shown by indenting the code.

name: The name column contains a descriptive name for the concept, and is a suitable value for use in the CD.displayName property.

definition: The definition specifies the meaning of the concept, along with clarifying information and usage notes.

status: For some domains, HL7 stipulates whether implementation of specific concepts is prohibited, permitted, or required.

level: The level column (labelled "lvl") is a value that represents the depth of the subsumption or composition of the current concept. This is only provided to help readers navigate the tables; it has no other meaning.

Some concepts are abstract, and are only defined to allow the relationships of other concepts to be defined. These concepts have a code of "--" shown. Since multiple abstract concepts may exist that subsume or compose the same concrete concept, a concept may be listed more than once in the definition of the domain.

 2.4 Formal Data Type Definition Language (DTDL)

We define a formal data type definition language in order to specify the semantics of the proposed types as unambiguously as possible. A specific abstract syntax is required because other syntaxes are either specific to a technology or dependent on their own type libraries and conventions. Formal languages make essential statements crisply and are therefore accessible to formal argument of proof or rebuttal. However, the terseness of such formal statements may also be difficult to understand. Therefore, all the important inferences from the formal statements are also included as plain English statements.

NOTE: This is not an API specification. While this formal language might resemble a programming language or interface definition language, it is not intended to define the details of programs and other means of implementation. The formal definitions are a normative part of this specification, but this particular language need not be implemented or used in conformant systems; nor need all the semantic properties be implemented or used by conformant systems. The internal working of systems, their way of implementing data types, and their functionality and services is entirely out of scope of this specification. The formal definition defines the meaning of the data values through statements defining semantic relationships and behavior. Property definitions resemble programmatic function or method definitions, but the resemblance does not imply any procedural machinery. The DTDL borrows from a variety of existing tools and specifications, including Interface Definition Language (IDL), the Object Constraint Language (OCL), JAVA, C++, and the parser generation tools LEX and YACC, to meet the key objectives of semantic descriptiveness, internal consistency, syntactical agnosticism, freedom from built-in or primitive types, and concision.

This formal data type definition language specifies:

  • type name and short name
  • named values of a fully enumerated extension
  • semantic properties, unary, binary, and higher order properties
  • invariants, i.e. constraints over the properties
  • allowable type conversions
  • syntax of character string value literals (if any)
  • additional constraints on the types as flavors

Definition of a data type occurs in two steps. First, the data type is declared. The declaration claims a name for a new data type with a list of names, types, and signatures of the new type's properties. This declares the type, but not does not define it. The definition occurs in logic statements about what is always true about this type's values and their properties (invariant statements).

 2.4.1 Declaration

Every data type is declared in a form that begins with the keyword type. For example, the following is the header of a declaration for the data type Boolean which has the short name BL and specializes the data type ANY.

type Boolean alias BL specializes ANY
   values(true, false)
{
     BL  not;
     BL  and(BL x);
     BL  or(BL x);
     BL  xor(BL x);
     BL  implies(BL x);
};

The Boolean data type declaration also contains a values clause that declares the Boolean's complete set of values (its extension) as named entities. These named values are also valid character string literals. None of the other data types defined in this specification has a finite value set, which is why the values clause is unique to the Boolean.

The block in curly braces following the header contains declarations of the semantic properties that hold for every value of the data type. A semicolon terminates each property declaration; and another semicolon after the closing curly brace terminates the data type declaration.

A property declaration specifies from left to right (1) the data type of the property's value domain, (2) the property name, and (3) an optional argument list. The argument list of a property is enclosed in parentheses containing a sequence of argument declarations. Each argument is declared by the data type name and argument name. Semantic properties without arguments do not use an empty argument list.

The specializes clause implies (a) inheritance of properties from the genus to the species, and (b) substitutability of values of the species type for variables of the genus type. Specialization can include the definition of additional properties and the specification of constraints on inherited properties for the specialized type.

An example for inheritance: CD has the constraint that every nonNull CD must have a code. Because CS specializes CD, every CS must also have a code if it is nonNull, even though this constraint is not made explicit in the definition of CS itself. Note that a type can be declared to specialize a flavor rather than a type. This means that the type inherits from the base type that the flavor constrains, and in addition is subject to the constraints defined for the flavor.

An example for substitutability: A property is declared as of data type ED. Because ST specializes ED, then a value of such property MAY be of type ST. In other words, substitutability is the same as subsumption of all values of type ST being also values of type ED.

It is generally agreed that inheritance should not retract properties defined for the genus. However, because a child type may constrain the properties of a parent type, it is possible for a child to constrain a property to the null value without retracting the property.

The type declaration may be qualified by the keyword abstract, protected,, or private. An abstract type is a type where no non-exceptional value can be of this type: a proper value MUST belong to a concrete specialization of the abstract type. A protected type is a type that is used inside this specification but no property outside this specification should be declared of a protected type. A private type is an internal "helper" abstraction, defined only for the purpose of defining some aspect of the semantics of data types but that is not used even as the type of another protected or public type's property.1

 2.4.2 Invariant Statements

The declaration of semantic properties, their names, data types, and arguments provide only clues as to what the new data type might be about. The true definition lies in the invariant statements. Invariant statements are logical statements that are true at all times.

Throughout this specification, invariant statements are provided in a formal syntax but are also written in plain English. The advantage of the formal syntax is that it can be interpreted unambiguously, and that it is strongly typed. The advantage of plain English statements is that they are more understandable, especially to those untrained in reading formal languages.

The formal syntax sharpens the decisiveness of this specification. In some cases, however, the full semantics of a type are beyond what can be fully expressed in such invariant statements. The combination of both plain and formal language makes this specification more clear.

Invariant statements are formed using the invariant keyword that declares one or more variables in the form of an argument list of a property. The invariant statement can contain a where clause that constrains the arguments for the invariant body. The invariant body is enclosed in curly braces. It contains a list of assertions that must all be true.

invariant(BL x)
      where x.nonNull {
   x.and(true).equal(x);
};

The semantics of the invariant statement is a logic predicate with a universal quantifier ("for all").

The above invariant statement can be read in English as "For all Boolean values x, where x is non-NULL it holds that x AND true equals x." All properties should be named such that one can read the assertions like English sentences by substituting appropriate english words for the syntactical elements such as dot notation for property access. Note that some familiarity with reverse polish notation is useful in this regard.

The argument list of an invariant statement need not be specified if no such argument is needed.

invariant {
   true.not.equal(false);
   false.not.equal(true);
};
 2.4.2.1 Assertion Expressions

Assertions in invariant statements are expressions built with the semantic properties of the data types defined in this specification. Assertion expressions MUST have a Boolean value (true or false). No primitive data types, or operations, pre-exist the definition of any data type. The only preexisting features of the assertion expression language are the following:2

  • character strings representing utterances in the data type definition language;
  • the notion of an assertion being successful (true) or failing (false);
  • the invariant statement: invariant(...) where ... {...};
  • the universal quantifier expression form forall (...) where ... {...}; synonymous to the invariant statement;
  • the existence quantifier expression form exists (...) where ... {...};
  • the implicit conjunction (logical AND) between the semicolon-separated assertions: assertion1; assertion2; ... ; assertionn;
  • variables and declarations in the invariant argument list;
  • the property reference using the period: x.property;
  • implicit and explicit type conversion: (T)x;
  • parentheses to override the priorities of the conversion and property resolution operators: (T)x.property versus((T)x).property.

It is because the entities upon which this syntax operates are themselves data types that the specification is fundamentally recursive.

 2.4.2.2 Nested Quantifier Expressions

A quantifier expression indicates the scope of an assertion: it is true for all scenarios (universal quantifier), no scenarios (prohibition), or for at least one (existential). The invariant statement is a universal quantifier. Quantifiers can be nested within assertion expressions to articulate complex requirements. In the following example, the outer statement regarding the set x contains an inner statement about the elements T of x.

invariant(SET<T> x, y)
      where x.nonNull {
   x.subset(y).equal(
      forall(T element) where x.contains(element) {
         y.contains(element);
         });
};

The existence quantifier has the same meaning as in common propositional logic. For example, the following invariant means: "SET values x and y intersect if and only if there exists an element e that is contained in both sets x and y."

invariant(SET x, y)
      where x.nonNull {
   x.intersects(y).equal(
      exists(T e) {
         x.contains(e);
         y.contains(e);
         });
};

The existence quantifier may have a where-clause; however, there is no difference whether an assertion is made as a where-clause or in the body of the existence quantifier. Conversely, for universal quantifiers, the where-clause weakens the assertion since the body now only applies for values that meet the criterion in the where-clause.

 2.4.3 Type Conversion

This specification defines certain allowable conversions between data types. For example, there are a pair of conversions between the Character String (ST) and Encode Data (ED). This means that if a one expects an ED value but actually encounters an ST value instead, one can convert the ST value into an ED.

Three kinds of type conversions are defined: promotion, demotion, and character string literals. Type conversions can be implicit or explicit. Implicit type conversion occurs when a certain type is expected (e.g. as an argument to a statement) but a different type is actually provided. If the type provided has a conversion to the type expected the conversion should be performed implicitly.

NOTE: Implementation Technology Specifications must specify how implicit type conversions are supported. Some technologies support it directly, while others do not; in any case, processing rules can be defined that specify how these conversions are realized.

An explicit conversion can be specified in an assertion expression using the converted-to type name in parenthesis before the converted value. For example the following is an explicit type conversion from ED to ST in the where clause of an invariant statement.

invariant(ED x)
   where ((ST)x).nonNull { ... };

The type conversion has lower order of precedence than the property resolution period. Thus "(T)a.b " converts the value of the property b of variable a to data type T while "((T)a).b " converts the value of variable a to T and then references property b of that converted value.

Implicit type conversions in the assertion expressions are performed where possible. If a property's formal argument is declared of data type T, but the expression used as an actual argument is of type U, and if U does not extend T, and if U defines a conversion to T, that conversion from T to U takes effect.

 2.4.3.1 Demotion

A demotion is a conversion with a net loss of information. Generally, this means that a more complex type is converted into a simple type.

An example for a demotion is the conversion from Interval (IVL) to a simple Quantity (QTY), e.g. the center of the interval. In the data type definition language, a demotion is declared using the keyword demotion and the data type name to which to demote:

type Interval alias IVL {
   ...
   demotion  QTY;
   ...
};

The specification of demotions SHALL indicate what information is lost and what the major consequences of losing this information are.

 2.4.3.2 Promotion

A promotion is a conversion where new information is generated. Generally, this means that a simpler type is converted into a more complex type.

For example, we allow any Quantity (QTY) to be converted to an Interval (IVL). However, IVL has more semantic properties than QTY, including low and high boundaries. Thus, the conversion of QTY to IVL is a promotion. The additional properties of QTY not present in IVL must assume new values, default values, or computed values. The specification of the promotion must indicate what these values are or how they can be generated.

A promoting conversion from type QTY to type IVL is defined as a semantic property of data type QTY using the keyword promotion and the data type name to which to promote:

type Quantity alias QTY {
   ...
   promotion  IVL;
   ...
};

Typically, a promotion is defined from a simple type to a more complex type. Also, typically, the simple type is declared earlier in this document than a more complex type. Declaring all promotions to complex types in the simple type would thus involve forward references in the document, and may be confusing to the reader. Therefore, an alternative syntax allows promotions to be defined in the more complex type. This is indicated by naming the type from which to promote in an argument list behind the type to which to promote.

type Interval alias IVL {
   ...
   promotion  IVL (QTY x);
   ...
};
 2.4.4 Literal Form

A literal is a character string representation of a data value. Literals are defined for many types. A literal is a type conversion from and to a Character String (ST) with a specially defined syntax.

Not every conversion from and to an ST is a literal conversion, however. A literal for a data type should be able to represent the entire value set of a data type whereas any other conversion to and from ST may only map a smaller subset of the converted data type.

The purpose of having literals is so that one can write down values in a short, human-readable form. For example, literals for the types integer number (INT) and real number (REAL) are strings of sign, digits, possibly a decimal point, etc. The more important interval types (IVL<REAL>, IVL<PQ>, IVL<TS>) have literal representations that allow one to use, e.g., "<5" to mean "less than 5", which is much more readable than a fully structured form of the interval. For some of the more advanced data types such as intervals, general timing specification, and parametric probability distribution, we expect that the literal form may be the only form seen for representing these values until users have become used to the underlying conceptualizations.

Each literal conversion has its own syntax (grammar), often aligned with what people find intuitive. This syntax may therefore not be the most obvious from a computing perspective.

NOTE: Character string based Implementable Technology Specifications (ITS) of these abstract data types may or may not choose the literals defined here as their representations for these data types. We expect that the XML ITS will use some but not all of the literals defined here. The different grammars of literals are not meant to be combined into one overall HL7 value expression grammar. Although attempts have been made to resolve potential ambiguities between the literals of different types where they would be harmful, some of these ambiguities still remain. For example "1.2" can be a valid literal for both Object Identifier (OID) and a Real Number.
 2.4.4.1 Declaration

In the data type definition language we declare a literal form as a property of a data type using the keyword "literal" followed by the data type name ST, since the literal is a conversion to and from the ST data type.

type IntegerNumber alias INT {
   ...
   literal  ST;
   ...
};
 2.4.4.2 Definition

The actual definition of the literal form occurs outside the data type declaration body using an attribute grammar. An attribute grammar is a grammar that specifies both syntax and semantics of language structures. The syntax is defined in essentially the Backus-Naur-Form (BNF).3

For example, consider the following simple definition of a data type for cardinal numbers (positive integers). This type definition depends only the Boolean data type (BL) and has a character string literal declared:

type CardinalNumber alias CARD {
   BL       isZero;
   BL       equal(ANY x);
   CARD     successor;
   CARD     plus(CARD x);
   CARD     timesTen;
   literal  ST;
};

The literal syntax and semantics is first exposed completely and then described in all detail. The following example shows a literal consisting of two syntactic rules, each including several semantic definitions.

CARD.literal ST {
   CARD : CARD digit  { $.equal($1.timesTen.plus($2); }
        | digit       { $.equal($1); };

   CARD digit : "0"   { $.isZero; }
              | "1"   { $.equal(0.successor); }
              | "2"   { $.equal(1.successor); }
   ...
              | "8"   { $.equal(7.successor); }
              | "9"   { $.equal(8.successor); }
};

Every syntactic rule consists of the name of a symbol, a colon and the definition (so called production) of the symbol. A production is a sequence of symbols. These other symbols are also defined in the grammar, or they are terminal symbols. Terminal symbols are character strings written in double quotes or string patterns (called regular expressions). Thus the form:

CARD : CARD digit
     | digit;

means, that any cardinal number symbol is a cardinal number symbol followed by a digit or just a digit. The vertical bar stands for a disjunction (logical OR). A syntactic rule ends with a semicolon.

Every symbol has exactly one value of a defined data type. The data type of the symbol's value is declared where the symbol is defined:

CARD digit : "0"
           | "1"
           | "2"
           | ...
           | "8"
           | "9";

means that the symbol digit has a value of type CARD. The start-symbol is the data type itself and does not need a separate name.

The semantics of the literal expression is specified in semantic rules enclosed in curly braces for each of the defined productions of a symbol:

symbol : production1 { rule1 } | production2 { rule2 } | ... | productionn { rulen };

A semantic rule is simply a semicolon-separated list of Boolean assertion expressions of the same kind as those used in invariant statements. However, there are special variables defined in the semantic rule that all begin with a dollar character (e.g., $, $1, $2, $3, ...) The simple $ stands for the value of the currently defined symbol; while $1, $2, $3, etc. stand for the values of the respective parts of the semantic rule's associated production. For example, in

CARD : CARD digit  { $.equal($1.timesTen.plus($2); }
     | digit       { $.equal($1); };

the first production "CARD digit" has a semantic rule that says: the value $ of the defined symbol equals the value $1 of the first symbol CARD times ten plus the value $2 of the second symbol digit.4

A terminal symbol can be specified as a string pattern, so-called regular expression. The regular expression syntax used here is the classic syntax invented by Aho and used in AWK, LEX, GREP, and Perl. Regular expressions appear between two slashes /.../. In a regular expression pattern every character except [ ] ^ $ . / : ( ) \ | ? * + { } matches itself. The other characters that are actually used in this specification are defined in Table 3.

  Table 3: Special Characters for Regular Expressions
Pattern Definition
[ ... ] Specifies a character class. For example, /[A-Za-z]/ matches the characters of the upper and lower case English alphabet.
[^ ...] Specifies a character class negatively. For example, /[^BCD]/ matches any character except B, C, and D.
...? The preceding pattern is optional. For example, /ab?c/ matches "ac" and "abc".
...* The preceding pattern may occur zero or many times. For example, /ab*c/ matches "ac", "abc", "abbc", "abbbc", etc.
...+ The preceding pattern may occur one or more times. For example, /ab+c/ matches "abc", "abbc", "abbbc", but not "ac".
... {n,m} The preceding pattern may occur n to m times where n and m are cardinal numbers 0 ( n ( m. For example, /ab{2,4}c/ matches "abbc", "abbbc", and "abbbbc".
... | ... The pattern on either side of the bar may match. For example, /ab|cd/ matches "abd" and "acd" but not "abcd".
( ... ) The pattern in parentheses is used as one pattern for the above operators. For example, /a(bc)*/ matches "a", "abc", "abcbc", "abcbcbc", etc.
... : ... The left pattern matches if followed by the right pattern, but the right pattern is not consumed by a match. For example, /ab:c/ matches "abc" but not "ab", however, the value of a symbol thus matched is "ab" and the "c" is left over for the next symbol. The colon is a slight deviation from the conventional slash / but the slash is also conventionally used to enclose the entire pattern and may occur as a character to match - three meanings is one too many.
... \ ... Matches the following character literally, i.e. escapes from any special meaning of that character. For example, /a\+b/ matches "a+b".
... \/ ... Matches the slash as a character. For example, /a\/bc/ matches "a/bc".
 2.4.5 Generic Data Types

Generic data types are incomplete type definitions. This incompleteness is signified by one or more parameters to the type definition, which stand for other types, using the keyword template. Using parameters, a generic type might declare semantic properties that are not fully specified. For example, the generic data type Interval is declared with a parameter T that can stand for any Quantity data type (QTY). The properties low and high are declared as being of type T.

template<QTY T>
type Interval<T> alias IVL<T> {
   T  low;
   T  high;
};

Instantiating a generic type means completing its definition. For example, to instantiate an Interval, one SHALL specify of what base data type the interval should be. This is done by binding the parameter T to a specific data type. To instantiate an Interval of Integer numbers, one would bind the parameter T to the type Integer. Thus, the incomplete data type Interval is completed to the data type Interval of Integer.

For example, the following type definition for MyType declares a property named "multiplicity" that is an interval of the integer number data type used in the above examples.

type MyType alias MT {
   IVL<INT>  multiplicity;
};

A type parameter MAY have a default type associated with it. This default type is implied if no other parameter is bound when the type is associated. In the following example, a default parameter type has been used to specify exactly the same outcome as the previous example.

template<QTY T = INT>
type Interval<T> alias IVL<T> {
   T  low;
   T  high;
};

type MyType alias MT {
   IVL       multiplicity;
};

Default types for parameters requires care on the part of the users, and this technique is used sparingly in this specification.

Generics SHALL have types specified for each parameter prior to being instantiated. The types MAY be supplied in this specification, in any dependent specification, or even at run-time: that is, an ITS may allow the use of a generic type that leaves the parameter type unspecified until it is used.

 2.4.5.1 Generic Collections

Generic data types for collections are used throughout this specification. The most important of them are:

Set (SET<T>) A set contains elements in no particular order and without duplicate elements. There are two specializations of SET: DSET, for sets composed from discrete elements that may be iterated, and QSET, for sets composed of items from continuous domains, such as REAL.

Sequence (LIST<T>) A sequence is a collection of values in a specified order. A sequence has a head and a tail, where the head is the first element and the tail is the sequence without its head.

Interval (IVL)<T> An interval is a continuous subset of an ordered type.

These generic data types and their properties are used in this specification and readers should understand these types to understand this specification completely.

 2.4.5.2 Generic Type Extensions

Generic data type extensions are generic types with one parameter type that the generic type specializes. In the formal data type definition language, generic type specializations follow the pattern:

NOTE: Values of such extended types MAY be substituted for their base type. However, an ITS MAY limit what extensions are supported.

At this time generic type extensions SHALL NOT be used except where the type of an attribute is assigned to ANY, or the use is explicitly enabled (in this or another HL7 specification) for use cases where this advanced functionality is important. In these cases, instances of these generic type extensions SHALL be specifically and explicitly reflected in the RIM, static models or other specifications as applicable, as a result of formally approved content.5

Generic extensions keep their properties when specialized or subtended by generic collections. If a generic extension that extends QTY is applied to a QSET type parameter or specialization, the generic extension can be used throughout the QSET on any value contained within the expression tree.

template<ANY T>
type GenericTypeExtensionName specializes T {
   ...
};

These generic type extensions inherit the properties of their base type and add some specific feature to it. The generic type extension is a specialization of the base type, thus a value of the extension data type can be used instead of its base data type.6

While a Generic Type Extension extends its base—or parameter type—in effect annotating it with additional properties, it does not modify the interface of the of the base parameter type. However the Generic Type Extension, while not changing the definition of a property MAY alter the semantics of the implementation. For instance, while INT of 1 is equal of INT of 1, INT of 1 is not equal to a PPD<INT> of 1 +/- 0.5. Similarly, while INT.plus(INT) has a return type of INT, both PPD<INT>.plus(INT) and INT.plus(PPD<INT>) have a return type of PPD<INT>. Note that in all cases the invariants on the parameter type must always be true.7

invariant (INT x, INT y, PPD<INT> z) 
    where x.isOne.and(y.isOne).and(((INT) z).isOne).and(z.standardDeviation.nonNull) {
  x.equal(y);
  x.equal(z).isNull; 
};
 2.4.6 Flavors

Data type flavors are named constraints on the existing data types. The flavors do not introduce any new semantics to the data type, but constrain an existing data type for a particular purpose. Flavors MAY NOT add new properties, or set default values for properties; the value of properties can be fixed, but not defaulted.

Flavors MAY be used as types in other models, for instance in the RIM, and in RIM-derived models, when attributes are assigned a type that is a flavor. However flavors are not true types; when used in this fashion, they designate that the type of the attribute is the type from which the flavor is derived, with the constraints indicated in the flavor definition applied. For an instance of the data value assigned to the attribute, the type property is always that of the underlying type.

Flavors MAY constrain other flavors. When a flavor constrains another flavor, the flavor adds new constraints to those already specified in the other flavor.

Flavors are limited in this fashion so that a single implementation based on this specification will always be able to process all instances, but local implementations may describe a number of different constraint patterns on the data types defined in this specification.8

In the formal data type definition language, flavors follow this pattern:

flavor LongDescriptiveName alias ShortName constrains BaseTypeOrFlavor;

The definition of a flavor cannot introduce any new semantics, only define a long and short name, and the type or flavor that this flavor constrains. By convention, the short name has the form Type.shortName, such as TS.Time, but some flavors have other names due to backwards compatibility constraints. Once the flavor is defined it is usually followed by one or more invariants that specify the constraints associated with the flavor.

In rare cases, the constraints cannot be even partially expressed using the data type definition language, but it is still useful to define the flavor. In such cases, the flavor will not have any associated invariant statements. An example of this case would be further constraints on the narrative text described in the CDA specification ([http://www.hl7.org/v3ballot/html/infrastructure/cda/cda.htm]).

Representational Properties (§ B ) documents the property flavorId. When this representational property is used in association with one of the flavors documented here, it contains the value of the flavor name.

Additional flavors may be defined beyond those defined in this specification. The rules concerning definition, naming, and registration may be found in the Refinement, Constraint and Localization Specification ([http://www.hl7.org/v3ballot/html/infrastructure/conformance/conformance.htm]).

 2.4.7 Concept References

Some invariants make reference to concepts defined in a concept domain. The syntax for this reference is [CodeSystemName].[code] where [CodeSystemName] is the name of one of the code systems presented in this specification and [code] is the code of one of the concepts defined in that domain.

invariant(ANY x) {
   x.isNull.equal(x.nullFlavor.implies(NullFlavor.NI));
};

This invariant specifies that when a data type is null, its nullFlavor property implies the NullFlavor concept NI, which is identified by the Concept Reference NullFlavor.NI.

 3 Foundation Types

Foundation types
Foundation types
 3.1 DataValue (ANY)

Definition:      An abstract type that defines the basic properties common to all data values defined in this specification. Data Value is an abstract type, meaning that no proper value can be just a data value without belonging to any concrete type. Every concrete type is a specialization of this general abstract DataValue type.

  Table 4: Property Summary of DataValue
Name Type Description
dataType TYPE The data type of the value.
nullFlavor CS An indicator of a data value's exceptional status, sometimes also denoting the manner and rationale for that status.
nonNull BN A predicate indicating that that a property has a value, i.e. is a non-null ("non-exceptional") value of the data type.
isNull BN A predicate indicating that that a value is an exceptional value, or a null-value. A null value means that the information does not exist, is not available, or cannot be expressed in the data type's normal value set.
notApplicable BL A predicate indicating that this exceptional value is of nullFlavor not-applicable (NA), i.e., that a proper value is not meaningful in the given context.
unknown BL A predicate indicating that this exceptional value is of nullFlavor unknown (UNK).
other BL A predicate indicating that this exceptional value is of nullFlavor other (OTH), i.e., that the required value domain does not contain the appropriate value.
abstract type DataValue alias ANY {
   TYPE  dataType;
   CS    nullFlavor;
   BN    nonNull;
   BN    isNull;
   BL    notApplicable;
   BL    unknown;
   BL    other;
   BL    equal(ANY x);
   protected  BN    identical(ANY x);
};
 3.1.1 Data Type (dataType) : TYPE

Definition:      The data type of the value.

Every proper data value implicitly carries information about its own data type.

invariant(ANY x) where x.nonNull {
   x.dataType.nonNull;
};

Note that the type of a flavor is always the underlying type. For instance, the type of a ED.IMAGE is always ED. The kind of flavor will be identified in the flavorId property. See Representational Properties (§ B ) for further information.

An exceptional value may not have a type specified by its context of use, either in the applicable models or the instance itself. In these cases, the datatype will default to ANY. Data values with a nullFlavor that implies INV SHALL have a known type that is not ANY.

invariant(ANY x) 
  where x.nullFlavor.implies("INV") {
   x.dataType.nonNull;
};
 3.1.2 Exceptional Value Detail (nullFlavor) : CS

Definition:      An indicator of a data value's exceptional status, sometimes also denoting the manner and rationale for that status.

A data type MAY have an exceptional value (NULL-value, or just "null") rather than a proper value as described by this specification, either because the information does not exist, is not known or available, or cannot be expressed in the allowed value domain. In this case, the nullFlavor expresses in what way and why proper information is missing.

Null values are improper values that do not conform to the proper or expected value domain as described by this specification. This specification makes many rules concerning the relationship between the nullFlavor property and other properties, and these rules SHALL always be true. Both nonNull and null values SHALL always be valid according to the rules expressed in this specification.

Null values are also known as exceptional values. This is to denote that the information contained in the value is an exception to the expected value domain that applies to the type. The information may either be missing or partially present, or even completely present but not valid with respect to the constraints imposed by the Constraining Model (see Constraining Model (§ 1.8.1 )).

NOTE: This property is named nullFlavor because of the similarities between the concept of null value and the concept and behaviour of null in implementation technologies, particularly SQL and OCL. As in SQL and OCL, the result of a comparison operation between a null value and some other value is always null. In this sense, null values propagate through operations. However there are some notable differences between these concepts. Most notably, in most implementation technologies, a null instance has no further information associated with it (some variation of the concept of a null pointer). This is not true of the HL7 concept of null, where any of the properties of a null value might not be null. In OCL, null is an instance of OclVoid which is a super type of all types. This is not true for null values in this specification where a null value is still a valid instance of a particular type. If a true null is encountered in an implementation environment, it is semantically equivalent to a null-value of NI, and all other properties not related to nullFlavor will also have nullFlavor NI.

The null concept provides a general framework for handling incomplete data which is often encountered in healthcare information collection, use and analysis. The nullFlavor property plays a special role in the conformance framework. See "Conformance" in Core Principles of V3 Models [../coreprinciples/v3modelcoreprinciples.htm#coreP_V3_Conformance] for further information.

  Table 5: Concept Domain NullFlavor. ValueSet OID: 2.16.840.1.113883.11.10609. CodeSystem "NullFlavor", OID: 2.16.840.1.113883.5.1008, Owner: HL7
lvl code name definition
1 NI no information

The value is exceptional (missing, omitted, incomplete, improper). No information as to the reason for being an exceptional value is provided. This is the most general exceptional value. It is also the default exceptional value.

2  INV invalid

The value as represented in the instance is not a member of the set of permitted data values in the constrained value domain of a variable.

3   OTH other

The actual value is not a member of the set of permitted data values in the constrained value domain of a variable. (e.g., concept not provided by required code system).

4    NINF negative infinity

Negative infinity of numbers.

4    PINF positive infinity

Positive infinity of numbers.

3   UNC unencoded

No attempt has been made to encode the information correctly but the raw source information is represented (usually in originalText).

3   DER derived

An actual value may exist, but it must be derived from the provided information (usually an expression is provided directly).

2  UNK unknown

A proper value is applicable, but not known.

3   ASKU asked but unknown

Information was sought but not found (e.g., patient was asked but didn't know)

4    NAV temporarily unavailable

Information is not available at this time but it is expected that it will be available later.

3   QS sufficient quantity

The specific quantity is not known, but is known to be non-zero and is not specified because it makes up the bulk of the material.

e.g. 'Add 10mg of ingredient X, 50mg of ingredient Y, and sufficient quantity of water to 100mL.' The null flavor would be used to express the quantity of water.

3   NASK not asked

This information has not been sought (e.g., patient was not asked)

3   TRC trace

The content is greater than zero, but too small to be quantified.

2  MSK masked

There is information on this item available but it has not been provided by the sender due to security, privacy or other reasons. There may be an alternate mechanism for gaining access to this information.

Note: using this null flavor does provide information that may be a breach of confidentiality, even though no detail data is provided. Its primary purpose is for those circumstances where it is necessary to inform the receiver that the information does exist without providing any detail.

2  NA not applicable

No proper value is applicable in this context (e.g., last menstrual period for a male).

The null flavors are a general domain extension of all normal data type domains ("domain" in this sense means the set of all possible values for the data type, not "domain" in the more restricted sense used for coded data types). So this is true not only for coded data types with specified vocabulary domains, but for non-coded value domains as well, e.g. integers, temporal intervals, infectious disease cases, etc.

Note that while all these nullFlavors are considered to be exceptional values - a proper value is not known, under some circumstances the nullFlavor itself may be semantically useful. For instance, while the value PINF may represent an actual unknown value, it can be used as the upper limit of an interval. Similarly, the value QS represents an unknown amount but may be converted to a real amount during the actual dispensing of a formulation.

As a general domain extension of all normal data types, the null flavors also extend the literal form of those data types that have a literal form. In any literal form, the literal NullFlavor.X signals that the data type has the assigned nullFlavor, where X is the code, such as NA.

Note that the nullFlavor property isNull is reverse to that of the data type itself. If the data type is not null, then the nullFlavor property itself will be null. If the data type is null, then the nullFlavor is not null - it will specify an actual nullFlavor that provides more detail as to in what way or why no proper value is supplied.

invariant(ANY x) {
   x.nullFlavor.isNull.equal(x.nonNull);
};

The general implication of this is that in a CD or descendant (usually CS), when the code for a nullFlavor is carried in the code/codeSystem (code = "NI" and codeSystem = "2.16.840.1.113883.5.1008"), the CD itself is not null. The CD is only null when its nullFlavor carries this code.

When performing operations upon null values, the semantic meaning of the nullFlavor SHALL be considered. This is particularly important for equality. The only case where non-proper (NULL) values may be equal is where both values have a nullFlavor of NA. In most other cases, the outcome of comparing NULL values is also null. However, there are exceptions based on the semantic meaning of nullFlavor. For instance, although direct comparison of two values with nullFlavor PINF is always null (NI), two intervals with the equal low bounds and high bounds of PINF will return true, since they specify the same set. Similarly, comparison of NINF and PINF is always False.

The "actual value" refers to the value of the information itself, rather than the information as represented in the type itself. These two may diverge when the information provided is incomplete, such as when an expression is provided. The null flavor "other" is used whenever the actual value is not in the required value domain: this may occur, for example, when the value exceeds some constraints that are defined in too restrictive a manner

For example, if the value for age is 100 yrs, but the constraining model specifies that the age must be less than 100 years, the age may still be specified, provided that the model does not make the attribute mandatory.

Example 1.
<value nullFlavor="OTH" value="120" unit="yr"/>

Some of the null flavors are not generally applicable to all data types. The nullFlavors NINF and PINF SHALL only be associated with QTY types other than MO and RTO. The nullFlavors QS, and TRC SHALL only be used with PQ. The nullFlavor UNC SHALL only be used with any type that has an originalText, and when UNC is used the originalText property SHALL be populated. The nullFlavor DER SHALL only be used with the EXPR type, and an expression SHALL be provided.

invariant(ANY x) {
  x.nullFlavor.implies(NullFlavor.PINF).implies(x.dataType.implies(QTY));
  x.nullFlavor.implies(NullFlavor.NINF).implies(x.dataType.implies(QTY));
  x.nullFlavor.implies(NullFlavor.QS).implies(x.dataType.implies(QTY));
  x.nullFlavor.implies(NullFlavor.TRC).implies(x.dataType.implies(QTY));

  /* if whatever type x is doesn't have an originalText property, 
     the invariant will be null (not true) */
  x.nullFlavor.equals(UNC).implies(((x.dataType)x).originalText.nonNull);

  x.nullFlavor.equals(DER).implies(x.dataType.implies(EXPR<QTY>)
    .and((EXPR<QTY>) x).expression.nonNull);
};

Note: the two nullFlavors INV and OTH draw a distinction between the actual value and the vlalue as represented in the instance. Some of the datatypes may be used to provide a representation of the value which requires subsequent transformation to generate the real value. For instance, an expression may be provided which will generate an actual value that is in the required value domain of the instance.

NOTE: NULL-flavors are applicable to any property of a data value or a higher-level object attribute. Where the null flavor is determited to be not significant by the core HL7 infrastrcture committees, ITS are not required to represent them. If nothing else is noted in this specification, ITS need not represent general NULL-flavors for data-value properties. In addition, there is a difference between semantic properties and representational "components" of data values. An ITS SHOULD only represent those components that are needed to infer the semantic properties. The null-flavor predicates nonNull, isNull, notApplicable, unknown, and other can all be inferred from the nullFlavor property.

Some of these null flavors are associated with named properties that can be used as simple predicates for all data values. This does not change the semantics of the property; it is done to simplify the formulation of invariants in the remainder of this specification.

 3.1.3 Proper Value (nonNull) : BN

Definition:      A predicate indicating that that a property has a value, i.e. is a non-null ("non-exceptional") value of the data type.

invariant(ANY x) {
   x.nonNull.equal(x.isNull.not);
};

When a property (i.e. RIM attribute, or message field) is labeled mandatory, and the container is not null itself, then any value assigned to the property SHALL be nonNull.

 3.1.4 Exceptional Value (isNull) : BN

Definition:      A predicate indicating that that a value is an exceptional value, or a null-value. A null value means that the information does not exist, is not available, or cannot be expressed in the data type's normal value set.

Every data element has either a proper value or it is considered NULL. If (and only if) it is NULL, the nullFlavor provides more detail as to in what way or why no proper value is supplied.

invariant(ANY x) {
   x.isNull.equal(x.nullFlavor.implies(NullFlavor.NI));
};
 3.1.5 Inapplicable Proper Value (notApplicable) : BL

Definition:      A predicate indicating that this exceptional value is of nullFlavor not-applicable (NA), i.e., that a proper value is not meaningful in the given context.

invariant(ANY x) {
   x.notApplicable.equal(x.nullFlavor.implies(NullFlavor.NA));
};
 3.1.6 unknown (unknown) : BL

Definition:      A predicate indicating that this exceptional value is of nullFlavor unknown (UNK).

invariant(ANY x) {
   x.unknown.equal(x.nullFlavor.implies(NullFlavor.UNK));
};
 3.1.7 Value Domain Exception (other) : BL

Definition:      A predicate indicating that this exceptional value is of nullFlavor other (OTH), i.e., that the required value domain does not contain the appropriate value.

invariant(ANY x) {
   x.other.equal(x.nullFlavor.implies(NullFlavor.OTH));
};
 3.1.8 Equality (equal) : BL

Definition:      A reflexive, symmetric, and transitive relation between any two data values indicating that the two values are the same.

invariant(ANY x, y, z)
      where x.nonNull.and(y.nonNull).and(z.nonNull) {
   x.equal(x);                                         /* reflexivity */
   x.equal(y).equal(y.equal(x));                       /* symmetry */
   x.equal(y).and(y.equal(z)).implies(x.equal(z));      /* transitivity */
};

How equality is determined must be defined for each data type, and care must be taken when implementing equals in a polymorphic environment. There is a tension between what is logical and desired, and the requirement for symmetry and transitivity. 9 These data types and the definitions of equals have been carefully constructed so that their definitions of equals are both symmetric and transitive.

Some of the definitions of equality exclude some of the properties of a data type from the equality test, where those properties are not essential to the meaning of the value. In addition, some interpretation of the semantics of the values may be required to determine the equality of two values. For example physical quantity () has the two semantic properties (1) a real number and (2) a coded unit of measure. The equality test, however, must account for the fact that, e.g., 1 meter equals 100 centimeters; independent equality of the two semantic properties is too strong a criterion for the equality test. Therefore, physical quantity must override the equality definition.

The requirement for understanding the meaning of the data applies to nullFlavors as well. Under certain circumstances the test for equality between two different values with different flavors of null may not be null. Consult nullFlavor for more information.

 3.1.9 Identity Comparison (identical) : BN

Definition:      Identity comparison is a reflexive, symmetric, and transitive relation between any two data values. Any values can be identical, whether or not they are null or contain property with null values. The identity comparison always returns true or false. The result is never null.

The identity relationship is defined to assist in the definition of uniqueness constraints on DSETs. The identity relationship SHOULD NOT otherwise be used as it has no other use, and is therefore given a protected status to indicate that it should not be used outside this specification.

invariant(ANY x, y, z) {
   x.identical(x);                                              /* reflexivity */
   x.identical(y).equal(y.identical(x));                        /* symmetry */
   x.identical(y).and(y.identical(z)).implies(x.identical(z));  /* transitivity */
};

How identity is determined is the same for every data type except BL. If all the properties of two values are identical, the values are identical. For BL, the two values are identical if they have the same nullFlavor or if they are both true or both false.10

 3.2 DataType (TYPE) specializes ANY

Definition:      The data type of a data element or property.

This property is a meta-type declared in order to allow the formal definitions to make invariants about the data type of a value. Any data type defined in this specification is a value of the type DataType.

  Table 6: Property Summary of DataType
Name Type Description
shortName ST The alias of the data type.
longName ST The full name of the data type.
private type DataType alias TYPE specializes ANY {
   ST  shortName;
   ST  longName;
   BL  implies(TYPE that);
   BL  isComparableTo(TYPE that);
};

Note that the type of a flavor is always the underlying type. For instance, the type of a ED.IMAGE is always ED. The kind of flavor will be identified in the flavorId property. See Representational Properties (§ B ) for further information.

 3.2.1 Short Name (shortName) : ST

Definition:      The alias of the data type.

invariant(DataType x)
      where x.nonNull {
   x.shortName.nonNull;
};
 3.2.2 Long Name (longName) : ST

Definition:      The full name of the data type.

 3.2.3 Equality (equal) : BL, inherited from ANY

Two nonNull data types are equal if they are the same type.

invariant(DataType x, y)
      where x.nonNull.and(y.nonNull) {
   x.equal(y).equal(x.shortName.equal(y.shortName));
};
 3.2.4 Implies (implies) : BL

Definition:      A relation that indicates that a data type has the same type or is a specialization of the argument type.

 3.2.5 Comparable To (isComparableTo) : BL

Definition:      A relation that indicates whether two types have the same equality criteria

A data type is comparable to another data type if they both have the same equality criteria. For instance, has the same equality criteria as , so is comparable to . Note that the fact that two data types can be compared does not mean that all instances of the data types may be compared - for instance, it is not possible to compare the PQ values 3yr and 5m.

 3.3 Boolean (BL) specializes ANY

Definition:      A binary value for use in boolean logic. A BL value can be either true or false, or, as any other value, MAY be NULL.

truefalse
type Boolean alias BL specializes ANY
   values(true, false) {
            BL  not;
            BL  and(BL x);
            BL  or(BL x);
            BL  xor(BL x);
            BL  implies(BL x);
   literal  ST.SIMPLE;
};

With any data value potentially being NULL, the two-valued logic is effectively extended to a three-valued logic as shown in the following truth tables:

 3.3.1 Truth tables for Boolean logic with NULL values
  Table 7: Truth Table: NOT
NOT  
true false
false true
NULL NULL
  Table 8: Truth Table: AND
AND true false NULL
true true false NULL
false false false false
NULL NULL false NULL
  Table 9: Truth Table: OR
OR true false NULL
true true true true
false true false NULL
NULL true NULL NULL

Where a boolean operation is performed upon 2 data types with different nullFlavors, the nullFlavor of the result SHALL be any common ancestor of the 2 different nullFlavors. The result SHOULD be the first common ancestor.

 3.3.2 Negation (not) : BL

Definition:      The opposite value. Negation of a BL turns true into false and false into true and is NULL for NULL values.

invariant(BL x) {
   true.not.equal(false);
   false.not.equal(true);
   x.isNull.equal(x.not.isNull);
};
 3.3.3 Conjunction (and) : BL

Definition:      Conjunction between a value and another value indicates that both values are true. Conjunction is associative and commutative, with true as a neutral element. False AND any Boolean value is false. These rules hold even if one or both of the operands are NULL. If both operands for AND are NULL, the result is NULL.

invariant(BL x, y) {
   x.and(true).equal(x);
   x.and(false).equal(false);
   x.isNull.implies(x.and(y).isNull);
};
 3.3.4 Disjunction (or) : BL

Definition:      A parametric property indicating that the value or the argument is true, or both are true. The disjunction x OR y is false if and only if x is false and y is false.

invariant(BL x, y) {
   x.or(y).equal(x.not.and(y.not).not);
};
 3.3.5 Exclusive Disjunction (xor) : BL

Definition:      A parametric property indicating that either the value or the argument is true, but not both.

invariant(BL x, y) {
   x.xor(y).equal(x.or(y).and(x.and(y).not));
};
 3.3.6 Equality (equal) : BL, inherited from ANY

Two non null BL are equal if the have the same value.

invariant(BL x, y)
      where x.nonNull.and(y.nonNull) {
   x.equal(y).equal(x.equal(true).and(y.equal(true).or(x.equal(false).and(y.equal(false)))));
};
 3.3.7 Implication (implies) : BL

Definition:      A parametric property indicating that the argument is true when the value is true, supporting rules of the form IF condition THEN conclusion

Logically, the implication is defined as the disjunction of the negated condition and the conclusion, meaning that when the condition is true the conclusion must be true to make the overall statement true. The logical implication is important to make invariant statements.

invariant(BL condition, conclusion) {
   condition.implies(conclusion).equal(
      condition.not.or(conclusion));
};

The implication is not reversible and does not specify whether the condition is true when the condition is false (ex falso quodlibet lat. “from false follows anything”).

 3.3.8 Literal Form

The literal form of the Boolean is determined by the named values specified in the values clause, i.e., true and false.

 3.4 Collection (COLL) specializes ANY

Definition:      A collection of values which can be enumerated using an iterator.

template<ANY T>
abstract type Collection<T> alias COLL<T> specializes ANY {
  BL      isEmpty;
  BL      notEmpty;
  INT     count;
  BL      contains(T item);
};

COLL is introduced to represent the concept of an enumerable collection. Collections that are enumerable are inherently countable, though some collections may have an infinite number of items in the collection.

RIM attributes with a collection type MAY be assigned a cardinality by the constraining model. In these cases, the cardinality is understood to refer to the number of items in the collection. To require that a collection have at least one item, the minimum multiplicity of the attribute must be constrained to 1 or more.

 3.4.1 The Empty Collection (isEmpty) : BL

Definition:      An indicator that the COLL has no elements. The return value may be null (when the collection itself is null, whether the collection is empty is not known).

 3.4.2 Not-Empty (notEmpty) : BL

Definition:      An indicator that the COLL contains at least one item. The return value may be null (when the collection itself is null, whether the collection is empty is not known).

 3.4.3 Count (count) : INT

Definition:      The number of elements in the COLL. The return value may be null (when the collection itself is null, the number of items in the collection is not known).

 3.4.4 Contains Item (contains) : BL

Definition:      An indicator that the COLL contains an item with the given item value using the equals property. If item is null, the return value will be null.

 3.5 Bag (BAG) specializes COLL

Definition:      An unordered collection of values, where any value can occur more than once.

template<ANY T>
type Bag<T> alias BAG<T> specializes COLL<T> {
              INT     count(T item);
              BAG<T>  plus(BAG<T> x);
              BAG<T>  minus(BAG<T> x);
   literal    ST.SIMPLE;
   promotion  BAG<T>  (T x);
   promotion  BAG<T>  (DSET<T> x);
};

A bag MAY contain NULL values as items.

NOTE: A BAG can be represented in two ways: either as a simple enumeration of elements, including repeated elements, or as a "compressed bag" whereby the content of the BAG is listed in pairs of element value and count. A histogram showing absolute frequencies is a BAG represented in compressed form. BAG is therefore useful to communicate raw statistical data samples.
 3.5.1 Count (count) : INT, inherited from COLL

Definition:      The number of elements in the bag. NULL elements are counted as bag elements.

invariant(BAG<T> bag, INT zero)
      where bag.nonNull.and(zero.isZero) {
   bag.isEmpty.equal(bag.count.isZero);
   bag.notEmpty.equal(bag.count.greaterThan(zero));
};
 3.5.2 Count Item (count) : INT

Definition:      The number of items in this bag with the given item value.

This is the primitive property of a BAG, on which all other properties are defined.

invariant(BAG<T> bag, T item)
      where bag.nonNull {
   bag.count(item).nonNegative;
   bag.isEmpty.implies(bag.count(item).isZero);
};
 3.5.3 Contains Item (contains) : BL, inherited from COLL

Definition:      True if the bag contains an item with the given item value.

invariant(BAG<T> bag, T item)
      where bag.nonNull {
   bag.contains(item).equal(bag.count(item).isNegative.not);
};
 3.5.4 The Empty Collection (isEmpty) : BL, inherited from COLL

Definition:      A predicate indicating that this BAG has no elements (negation of the notEmpty predicate. The empty BAG is a proper value, not an exceptional (NULL) value.

invariant(BAG<T> bag)
      where bag.nonNull {
   bag.isEmpty.equal(notEmpty.not);
};
 3.5.5 Not-Empty (notEmpty) : BL, inherited from COLL

Definition:      A predicate indicating that this BAG contains at least one item. The item MAY be null.

invariant(BAG<T> bag)
      where bag.nonNull {
   bag.notEmpty.equal(exists(T item) {
      bag.contains(item);
      });
};
 3.5.6 Addition (plus) : BAG<T>

Definition:      A BAG that contains all items of the operand BAGs.

invariant(BAG<T> x, y, z)
      where x.nonNull.and(y.nonNull) {
   x.plus(y).equal(z).equal(
      forall(T e)
            where e.nonNull {
         z.contains(e).equal(x.contains(e)
                      .or(y.contains(e)));
         });
};
 3.5.7 Subtraction (minus) : BAG<T>

Definition:      A BAG that contains all items of this BAG (minuend) diminished by the items in the other BAG (subtrahend). BAGs cannot carry deficits: When the subtrahend contains more items of one value than the minuend, the difference contains zero items of that value.

invariant(BAG<T> x, y, z)
      where x.nonNull.and(y.nonNull) {
   x.minus(y).equal(z).equal(
      forall(T e)
            where e.nonNull {
               exists(INT n)
                  where n.equal(x.count(e).minus(y.count(e))) {
         n.nonNegative.equal(z.count(e));
         n.isNegative.equal(z.count(e).isZero);
         };
      });
};
 3.5.8 Literal Form

When the element type T has a literal form, the bag of T elements has a literal form, wherein the elements of the set are enumerated within curly braces and separated by semicolon characters.

BAG<T>.literal ST.SIMPLE {
   BAG<T>          : "{" elements "}"   { $.equal($2); };
   BAG<T> elements : elements ";" T     { $.except($2).equal($1); }
                  | T                   { $.contains($1);
                                          $.except($1).isEmpty; };
};
NOTE: This literal form for bags is only practical for relatively small bags; this does not mean, however, that all bag are relatively small enumerations of elements.
  Table 10: Example
literal meaning
{1; 3; 3; 5; 7; 19} a bag of integer numbers or real numbers
{3; 1; 5; 19; 3, 7} the same bag of integer numbers or real numbers
{1.2 m; 2.67 m; 17.8 m} a bag of discrete physical quantities
{"apple"; "orange"; "banana"; "strawberry"; "apple"} a bag of character strings (for strings, use quoted form to prevent problems with ";")
NOTE: A character-based ITS SHOULD choose a different literal form for bags if the Implementation Technology has a more native literal form for such collections.
 3.5.9 Promotion of Item Values to Bags (promotion) : BAG<T>

A data value of type T can be promoted into a trivial BAG of type T with that data value as its only item.

invariant(T x) {
   ((BAG<T>)x).count.equal(1);
}

invariant(T x) where x.isNull {
   ((BAG<T>)x).count(x).isNull;
}

invariant(T x) where x.nonNull {
   ((BAG<T>)x).count(x).equal(1);
   
   forall(T y) where y.nonNull {
      ((BAG<T>)x).count(y).isZero.not
                 .implies(x.equal(y)) };
}

invariant(T x) where x.isNull {
   ((BAG<T>)x).count(x).unknown;
};
 3.5.10 Promotion of Sets to Bags (promotion) : BAG<T>

A discrete set of items can be promoted into a BAG that contains the same items. No items are lost during the promotion.

invariant(DSET<T> x) where x.nonNull {
   ((BAG<T>)x).count.equal(x.count);
};

invariant(DSET<T> x, T y) where x.nonNull.and(y.nonNull) {
   ((BAG<T>)x).contains(y).equal(x.contains(y));
};
 3.5.11 Equality (equal) : BL, inherited from ANY

Two bags are equal if and only if they are both empty, or if they both contain the same items.

It is not necessary that the two BAGs have the same type for parameter T; as long as the two bags have parameter types that are comparable (for instance, CD and CV), the bags can be equal.

invariant(BAG<T> x, BAG<U> y)
      where x.nonNull.and(y.nonNull).and(T.datatype.compares(U.datatype)) {
   x.equal(y).equal((forall(T e) {
      x.count(e).equal(y.count(e));
    }).and(forall(U e) {
      x.count(e).equal(y.count(e));
    }));
};
 3.6 Sequence (LIST) specializes COLL

Definition:      An ordered collection of discrete (but not necessarily distinct) values.

template<ANY T>
type Sequence<T> alias LIST<T> specializes COLL<T> {
             T        head;
             LIST<T>  tail;
             T        item(INT index);
             INT      length;
             LIST<T>  subList(INT start, INT end);
             LIST<T>  subList(INT start);
  literal    ST.SIMPLE;
  promotion  LIST<T>  (T x);
  demotion   BAG<T>;
};

A sequence MAY contain NULL values as items.

The sequence is an ordered collection of values, but no particular order is associated with the sequence in the definition of LIST. The meaning of the order of the items SHALL be defined where a LIST is used. Note that in some cases, the order is fixed ( e.g. HIST), but in other cases, the order is not fixed: only the meaning associated with the order in the instance is defined (e.g. EN, AD).

 3.6.1 Head Item (head) : T

Definition:      The first item in this sequence.

 3.6.2 Tail Sequence (tail) : LIST<T>

Definition:      The sequence following the first item in this sequence.

 3.6.3 The Empty Collection (isEmpty) : BL, inherited from COLL

Definition:      A predicate that is true if this sequence contains no items.

An empty sequence is a proper sequence, not an exceptional (null) value.

invariant(LIST<T> x)
      where x.isEmpty {
   x.length.isZero;
   x.head.isNull;
   x.tail.isEmpty;
};

In an empty sequence, the length is zero, the tail is empty, and the head is null. Note that both head and tail being NULL does not mean that the sequence is empty; while this is a necessary condition of an empty sequence, it is not sufficient for determining an empty list, since a sequence may contain NULL-values as items. Therefore this condition can mean that the sequence has only a head item that happens to be NULL.

 3.6.4 Not-Empty (notEmpty) : BL, inherited from COLL

Definition:      A predicate that is true if this sequence contains at least one element. Negation of isEmpty.

invariant(LIST<T> x)
      where x.nonNull {
   x.notEmpty.equal(x.isEmpty.not);
};
 3.6.5 Item by Index (item) : T

Definition:      The item at the given sequential position (index) in the sequence. The index zero refers to the first element (head) of the sequence.

invariant(LIST<T> list; INT index)
      where list.nonNull.and(index.nonNegative) {
   list.isEmpty.implies(list.item(index).isNull);
   list.notEmpty.and(index.isZero)
       .implies(list.item(index).equal(list.head));
   list.notEmpty.and(index.nonZero)
       .implies(list.item(index).equal(
          list.tail.item(index.predecessor)));
};
 3.6.6 Contains Item (contains) : BL, inherited from COLL

Definition:      A predicate that is true if this sequence contains the given item value.

invariant(LIST<T> list; T item)
      where list.nonNull {
   list.isEmpty.implies(list.contains(item).not);
   
   list.nonEmpty.and(item.nonNull).implies(list.contains(item).equal(
        list.head.equal(item).or(list.tail.contains(item))));
		
   list.notEmpty.and(item.isNull).implies(list.contains(item).equal(
        list.head.isNull.or(list.tail.contains(item))));
};
 3.6.7 Length (length) : INT

Definition:      The number of elements in the sequence. NULL elements are counted as sequence elements.

invariant(LIST<T> list)
      where list.nonNull {
   list.isEmpty.equal(list.length.isZero);
   list.notEmpty.equal(list.length.equal(list.tail.length.successor));
};
 3.6.8 Count (count) : INT, inherited from COLL

Definition:      The number of elements in the list.

This property is defined for consistency of definitions of collection types. The count of the number of elements in a discrete set always matches the length of the list.

invariant(LIST<T> list) where list.nonNull {
   list.count.equal(list.length);
};
 3.6.9 SubList (subList) : LIST<T>

Definition:      A contiguous subset of the list containing the items found in the list from index start to end, inclusively.

invariant(LIST<T> x, INT start, end)
   where 
     x.nonNull.and(
	 start.greaterOrEqual(0)).and(
	 start.lessThan(x.length)).and(
	 end.greaterOrEqual(0)).and(
	 end.lessThan(x.length)).and(
	 start.lessOrEqual(end)) {
   x.subList(start, end).length.equal(end.minus(start).sucessor);
   forall(INT i) where i.greaterOrEqual(0).and(i.lessThen(end.minus(start))) {
     x.subList(start, end).item(i).equal(x.item(start.plus(i)));
   }
};

The list starts at item 0. If the bounds are less than 0 or greater than or equal to the length of the list, or if end is less than start, then the result of the operation is undefined (i.e. null).

 3.6.10 SubList (subList) : LIST<T>

Definition:      A contiguous subset of the list containing the items found in the list from index start to the end of the list, inclusively.

invariant(LIST<T> x, INT start)
   where 
     x.nonNull.and(
	 start.greaterOrEqual(0)).and(
	 start.lessThan(x.length)).and(
	 end.greaterOrEqual(0)) {
   x.subList(start).length.equal(x.length.minus(start));
   forall(INT i) where i.greaterOrEqual(0) {
     x.subList(start).item(i).equal(x.item(start.plus(i)));
   }
};

The list starts at item 0. If the bounds are less than 0 or greater than or equal to the length of the list, then the result of the operation is undefined.

 3.6.11 Equality (equal) : BL, inherited from ANY

Two lists are equal if and only if they are both empty, or if both their head and their tail are equal.

It is not necessary that the two LISTs have the same type for parameter T; as long as the two lists have parameter types that are comparable (for instance, CD and CV), the lists can be equal.

invariant(LIST<T> x, LIST<U> y)
      where x.nonNull.and(y.nonNull).and(T.datatype.compares(U.datatype)) {
   x.isEmpty.and(y.isEmpty).implies(x.equal(y));
   
   (x.notEmpty.and(y.isEmpty)).or(x.isEmpty.and(y.notEmpty)).implies(x.equal(y).not);
   
   x.notEmpty.and(y.notEmpty).and(x.head.nonNull).implies(
      x.equal(y).equal(x.head.equal(y.head).and(x.tail.equal(y.tail))));
	  
   x.notEmpty.and(y.notEmpty).and(x.head.isNull).implies(
      x.equal(y).equal(y.head.isNull.and(x.tail.equal(y.tail))));
};

Note that when lists contain null items, it is usually not possible to determine whether the lists are equal, though it may be possible to determine that they are different. For example, a list containing an unknown value is not equal to a list containing another unknown value, nor are two lists holding values of PINF. However a list containing a value of NINF is not equal to a list holding a value of PINF.

 3.6.12 Literal Form

When the element type T has a literal form, the sequence LIST has a literal form. List elements are enumerated, separated by semicolon, and enclosed in parentheses.

LIST<T>.literal ST.SIMPLE {
   LIST<T> : "(" elements ")"        { $.equal($2); }
           | "(" ")"                 { $.isEmpty; };
   LIST<T> elements
           : T ";" elements          { $.head.equal($1);
                                       $.tail.equal($3); }
           | T                       { $.head.equal($1);
                                       $.tail.isEmpty; };
};
  Table 11: Examples
literal meaning
(1; 3; 5; 7; 19) a sequence of integer numbers or real numbers
(3; 1; 5; 19; 7) a different sequence of integer numbers or real numbers
(1.2 m; 17.8 m; 2.67 m) a sequence of discrete physical quantities
(apple; orange; banana) a sequence of character strings
NOTE: a character-based ITS SHOULD choose a different literal form for sequences if the Implementation Technology has a more native literal form for such collections.
 3.6.13 Promotion of Item Values to Sequences (promotion) : LIST<T>

A data value of type T can be promoted into a trivial sequence of T with that data value as its only item.

invariant(T x) {
   ((LIST<T>)x).head.equal(x);
   ((LIST<T>)x).tail.isEmpty;
};
 3.6.14 Demotion of Sequences to Bags (demotion) : BAG<T>

A sequence (an ordered collection of items) can be demoted to a bag of items (no order). All items are preserved in the demotion.

invariant(LIST<T> x) where x.nonNull {
   ((BAG<T>)x).count.equal(x.count);
};

invariant(LIST<T> x, T y) where x.nonNull.and(y.nonNull) {
   ((BAG<T>)x).contains(y).equal(x.contains(y));
};
 3.7 Set (SET) specializes ANY

Definition:      A value that contains distinct values in no particular order.

template<ANY T, COMP C = CEQ>
abstract type Set<T, C<T>> alias SET<T, C<T>> specializes ANY {
   C<T>    comparator;
   BL      contains(T element);
   BL      contains(SET<T> subset);
   BL      isEmpty;
   BL      notEmpty;
   INT     cardinality;
   SET<T>  union(SET<T> otherset);
   SET<T>  union(T element);
   SET<T>  except(SET<T> otherset);
   SET<T>  except(T element);
   SET<T>  intersection(SET<T> otherset);
};

A set SHALL NOT contain items that the comparator does not differentiate. When the default equals based comparator applies, a set SHALL NOT contain NULL values as items.

SET is an abstract type. There are two specializations of SET that are actually used in models and instances, DSET (Discrete Sets) and QSET (Quantity Sets). DSET is for collection based sets that are composed of a series of discrete elements, and corresponds to general computationally friendly list found in most implementation environments. QSET is for quantity based sets where it makes sense to build complex sets using expressions and ranges of values. QSETs correspond to the mathematical notion of a set. Both types of sets support the common operations defined in SET that relate to the notion of set membership and related operations. DSET extends this notion to include some collection specific operations. QSET extends the notion to support a number of different methods for specifying set ranges and building complex sets based on set operations which are not possible for non-quantity based sets.

There are some complex relationships between DSET and QSET. For example, IVL<INT> is a type that conforms to the semantics expressed in both a DSET and a QSET, though for purposes of definition, this specification defines an IVL as a specialization of QSET and not DSET, since all types of IVLs are also QSETs. The situation for TS is a little more complicated. IVL<TS> is not a DSET<TS>, but a DSET<TS> may make sense in some circumstances, and if a DSET<TS> is defined, it also conforms to the semantics expressed in QSET<TS>. A DSET<PQ> may also be a QSET<PQ> but only if all the values are comparable (this relationship is true for all DSET<QTY>).

Generally, if T is a specialization of QTY, then a QSET would be the appropriate type of SET to specify in a model or use in an instance.

 3.7.1 Comparator (comparator) : C<T>

Definition:      The comparator used to define uniqueness and membership in the set.

The uniqueness in the set is a function of the comparator.

invariant(SET<T> x)
      where x.nonNull {
 forall(T a) where a.nonNull {
   forall(T b) where b.nonNull {
     /* if the comparator cannot compare a or b,
	    both cannot be in the Set */ 
	 x.contains(a).and(x.contains(b)).implies.
	    x.comparator.compare(a, b).nonNull;  
	   
     /* if both a and b are in the set, they must be different 
       (unless they are the are the same instance)*/ 
	 x.contains(a).and(x.contains(b)).implies(
	   a.identical(b).or(x.comparator.compare(a, b).not));
	 }
   }
};

Because of these constraints, considerable care must be taken in defining the comparator. In particular, the equals-based comparator SHALL always be used for types that are specializations of QTY. Note also that where a comparator could be defined that specifies nonNull outcomes for null values of T, sets MAY contain null values.

Implementable Static Models SHALL always fix the comparator - it must not be left to be decided at run-time.

 3.7.2 Contains Element (contains) : BL

Definition:      A relation of the set with a value, true if the given value is an element of the set.

This is the primitive semantic property of a set, based on which all other properties are defined. Contains is ascertained using the comparator for the SET, which MAY specify some different comparison than the equals property.

A set SHALL only contain distinct elements. Values for which the comparator is unable to differentiate cannot be elements of a set. For normal sets, based on CEQ, exceptional values (NULL-values) cannot be elements of a set.

invariant(SET<T> s, T m, n)
      where s.nonNull {
   s.contains(m).and(s.contains(n)).implies(s.comparator.compare(m,n).nonNull);
};

invariant(SET<T> s, T n)
      where s.nonNull.and(s.comparator.implies(CEQ)).and(n.isNull) {
   s.contains(n).not;
};
 3.7.3 Contains Subset (contains) : BL

Definition:      The relation between a set and its subsets, where each element in the subset is also an element of the superset.

invariant(SET<T> superset, subset) 
      where superset.nonNull.and(subset.nonNull) {
         superset.contains(subset).equal(
      forall(T element) where subset.contains(element) {
         superset.contains(element);      
	     });
};

This implies that the empty set is a subset of every set including itself.

 3.7.4 The Empty Set (isEmpty) : BL

Definition:      A predicate indicating that this set has no elements; the negation of notEmpty. The empty set is a proper set value, not an exceptional (NULL) value.

invariant(SET<T> set)
      where set.nonNull {
   set.isEmpty.equal(notEmpty.not);
};
 3.7.5 Not-Empty (notEmpty) : BL

Definition:      A predicate indicating that this set contains elements.

invariant(SET<T> set)
      where set.nonNull {
   set.notEmpty.equal(exists(T element) {
      set.contains(element);
      });
};
 3.7.6 Cardinality (cardinality) : INT

Definition:      The number of distinct elements in the set.

invariant(SET<T> set)
      where set.nonNull {
   exists(T element) where set.contains(element) {
      set.cardinality.equal(set.except(element)
                     .cardinality.successor);
         };
};

The cardinality definition works for finite sets in this specification, but is not sufficient since it doesn't converge for uncountably infinite sets (REAL, PQ, etc.) and it doesn't terminate for infinite sets. The cardinality value is an example where it would be necessary to distinguish the cardinality ℵ0 (aleph0) of countably infinite sets (e.g., INT) from ℵ1 (aleph1), the cardinality of uncountable sets (e.g., REAL, PQ).

 3.7.7 Union (union) : SET<T>

Definition:      A set for which each element is an element of at least one component set.

invariant(SET<T> x, y, z)
      where x.nonNull.and(y.nonNull).and(z.nonNull) {
   x.union(y).equal(z).equal(forall(T e) {
      z.contains(e).equal(x.contains(e).or(y.contains(e)));
      });
};
 3.7.8 Include Element (union) : SET<T>

Definition:      A union of a set and an element.

invariant(SET<T> set, singletonset; T element)
      where set.nonNull.and(element.nonNull)
               .and(singletonset.cardinality.isOne)
               .and(singletonset.contains(element)) {
   set.union(element).equal(set.union(singleton));
};
 3.7.9 Set Difference (except) : SET<T>

Definition:      The set containing all elements of the subtracted set that are not elements of the subtracting set.

invariant(SET<T> x, y, z)
      where x.nonNull.and(y.nonNull).and(z.nonNull) {
   x.except(y).equal(z).equal(forall(T e) {
      z.contains(e).equal(x.contains(e).and(y.contains(e).not));
      });
};
 3.7.10 Exclude Element (except) : SET<T>

Definition:      The set that contains all elements of this set except for the subtracting element value.

invariant(SET<T> x, z; T d)
      where x.nonNull.and(z.nonNull).and(d.nonNull) {
   x.except(d).equal(z).equal(forall(T e) {
      z.contains(e).equal(x.contains(e).and(d.equal(e).not));
      });
};
 3.7.11 Intersection (intersection) : SET<T>

Definition:      The set containing all and only those elements that are contained in both of the operand sets.

invariant(SET<T> x, y, z)
      where x.nonNull.and(y.nonNull).and(z.nonNull) {
   x.intersection(y).equal(z).equal(forall(T e) {
      z.contains(e).equal(x.contains(e).and(y.contains(e)));
      });
};
 3.7.12 Equality (equal) : BL, inherited from ANY

Two nonNull SETs are equal if they have the same elements. It is not necessary that the two SETs have the same type for parameter T; as long as the two sets have parameter types that are comparable (for instance, CD and CV), the sets can be equal.

invariant(SET<T> x, SET<U> y)
      where x.nonNull.and(y.nonNull).and(T.datatype.compares(U.datatype)) {
   x.equal(y).equal((forall(T e) {
      x.contains(e).equal(y.contains(e));
    }).and(forall(U e) {
      x.contains(e).equal(y.contains(e));
    }));
};
 3.8 Comparator (COMP)

Definition:      An abstract type that defines a comparison between two values of the same type.

template<ANY T>
abstract protected type Comparator<T> alias COMP<T> {
   TYPE  dataType;
    BL      compare(T element1, T element2);
};

Although every type has a clear definition of the meaning of semantic equality, this definition does not always fit a particular use: in these cases, a specialization of COMP that expresses the criteria for the comparison relationship may be used. The comparator type is defined to allow custom definitions of the meaning of equality between types. This is most useful in defining the criteria for uniqueness in a SET but may find other applications in implementation environments.

COMP is an abstract type, and no actual comparator is defined.

NOTE: COMP and its descendants never appear in an instance, and an ITS should not create a representation for them.

Because COMP never appears in the instance, new specializations of COMP MAY be defined outside of this specification. All new specializations SHALL be approved at harmonisation prior to being included in a normative specification.

An example of a custom comparator might be to specify that a particular SET of TEL is allowed to contain the same telecommunication address more than once if it has different useablePeriod properties. In this case, compare should return false if only one of the two TELs has a useablePeriod, or if they both do and they are different. Here is how to define such a comparator:

type MyTelephoneComparator alias MYTELCOMP specializes COMP<TEL>{
    BL      compare(T element1, T element2);
};

invariant(MYTELCOMP c, TEL x, y)
      where x.equal(y).nonNull {
   c.compare(x, y).equal(
     x.equal(y)
      .and(x.useablePeriod.isNull.xor(y.useablePeriod.isNull)).not
	  .or(x.useablePeriod.nonNull.implies(
	     x.useablePeriod.equals(y.useablePeriod))));
};

A set that used this comparator would be defined as DSET<TEL, MYTELCOMP>.

 3.8.1 Data Type (dataType) : TYPE

Definition:      The data type of the comparator.

Every comparator implicitly carries information about its own data type.

invariant(COMP x) {
   x.dataType.nonNull;
};
 3.8.2 Comparison (compare) : BL

Definition:      The result of comparing the two elements.

Like the equality relationship, comparison is a reflexive, symmetric, and transitive relationship between any two data values.

invariant(COMP<T> c, T x, y, z)
      where x.nonNull.and(y.nonNull).and(z.nonNull) {
   c.compare(x, x);                                                 /* reflexivity */
   c.compare(x, y).equal(c.compare(y, x));                          /* symmetry */
   c.compare(x, y).and(c.compare(y, z)).implies(c.compare(x, z));   /* transitivity */
};
 3.9 EqualComparator (CEQ) specializes COMP

Definition:      A comparator based on the equality relationship defined for all types.

template<ANY T>
type EqualComparator<T> alias CEQ<T> specializes COMP<T> {
    BL      compare(T element1, T element2);
};

This is the default concrete comparator that compares the two values based on the equality relationship defined for all types.

 3.9.1 Comparison (compare) : BL

Definition:      The value of the equality relationship between the two values.

invariant(CEQ<T> c, T x, y)
      where x.equal(y).nonNull {
   c.compare(x, y).equal(x.equal(y));
};
 3.10 DiscreteSet (DSET) specializes SET and COLL

Definition:      An unordered collection of values that contains discrete distinct values.

A DSET differs from the general SET because it is constrained to contain only discrete items. The practical consequence of this is that a DSET can be iterated, like bag, but unlike QSET.

template<ANY T, COMP C = CEQ>
type DiscreteSet<T, C<T>> alias DSET<T, C<T>> specializes SET<T, C<T>>, COLL<T> {
   literal    ST.SIMPLE;
   promotion  DSET<T>  (T x);
};
 3.10.1 Count (count) : INT, inherited from COLL

Definition:      The number of elements in the set.

This property is defined for consistency of definitions of collection types. The count of the number of elements in a discrete set always matches the cardinality of the set.

invariant(DSET<T> set) where set.nonNull {
   set.count.equal(set.cardinality);
};
 3.10.2 Literal Form

When the element type T has a literal form, the discrete set of T elements has a literal form, wherein the elements of the set are enumerated within curly braces and separated by semicolon characters.

DSET<T>.literal ST.SIMPLE {
   DSET<T>          : "{" elements "}"   { $.equal($2); };
   DSET<T> elements : elements ";" T     { $.except($2).equal($1); }
                  | T                   { $.contains($1);
                                          $.except($1).isEmpty; };
};
NOTE: This literal form for sets is only practical for relatively small discrete sets; this does not mean, however, that all sets are relatively small enumerations of elements.
  Table 12: Example
literal meaning
{1; 3; 5; 7; 19} a set of integer numbers or real numbers
{3; 1; 5; 19; 7} the same set of integer numbers or real numbers
{1.2 m; 2.67 m; 17.8 m} a set of discrete physical quantities
{apple; orange; banana} a set of character strings
NOTE: A character-based ITS SHOULD choose a different literal form for discrete sets if the Implementation Technology has a more native literal form for such collections.
 3.10.3 Promotion of Element Values to Sets (promotion) : DSET<T>

A data value of type T can be promoted into a trivial discrete set of T with that data value as its only element.

invariant(T x) where x.nonNull {
   ((DSET<T>)x).contains(x);
   ((DSET<T>)x).except(x).isEmpty;
};

invariant(T x) where x.isNull {
   ((DSET<T>)x).isNull;
};
 3.10.4 Equality (equal) : BL, inherited from ANY

The evaluation of equality for DSET is taken from the SET data type: Two nonNull SETs are equal if they have the same elements.

This means that values of the type DSET and any other kind of SET MAY be equal.

 3.11 HistoryItem (HXIT) specializes T

Definition:      A generic data type extension that adds a time range and/or link to the ControlAct associated with the creation of the data on any data value whatever its data type.

HXIT adds the controlActIdRef property to the the base type T. In addition, if the base type T does not possess a validTime property, the HXIT adds that property to the base type. If, however, the base type T does have a valid time property (currently only EN), that property is mapped to the valid time property of the HXIT and the HXIT constraints on validTime apply.11

The time range is the time in which the information represented by the value is (or was) valid. The ControlAct id reference indicates the event responsible for the value of the data type. The time range is not the time during which any particular system considered this information valid (as in, an audit trail), though the link to the control act may provide some information of relevance in this regard.

template<ANY T>
type HistoryItem<T> alias HXIT<T> specializes T {
   IVL<TS> validTime;
   BL comesBefore(HXIT<T>);
   II controlActIdRef;  
};
 3.11.1 Valid Time (validTime) : IVL<TS>

Definition:      The time interval during which the given information was, is, or is expected to be valid. The interval can be closed-- i.e. finite and defined—or open—i.e. infinite or undefined —on either side. The interval cannot be just a width, nor can the width be zero

invariant(HXIT<T> x) where x.nonNull {
  x.validTime.nonNull.implies(x.validTime.low.nonNull.or(x.validTime.high.nonNull));
  x.validTime.nonNull.implies(x.validTime.width.isZero.not);
};
 3.11.2 Comes Before (comesBefore) : BL

Definition:      A predicate expressing a chronological order relation that is asymmetric and transitive, between this HXIT and another HXIT.

A HXIT comes before another in a sequence of history items (HIST) if the high boundary of the validTime is less or equal to the low boundary of the other interval.

invariant(HXIT<T> x, y) where x.validTime.nonNull.and(y.validTime.nonNull) {
  x.comesBefore(y).implies(x.validTime.high.nonNull);
  x.comesBefore(y).implies(y.validTime.low.nonNull);
  x.comesBefore(y).implies(x.validTime.high.lessOrEqual(y.validTime.low));
};
 3.11.3 ControlAct Id Reference (controlActIdRef) : II

Definition:      The identifier of the ControlAct associated with setting the data type to its specified value.

By referencing a particular ControlAct, the property links to all of the information surrounding that ControlAct, such as who made the change, when it was made, why it was made, what system originated the change, etc.

 3.12 History (HIST) specializes LIST<HXIT<T>>

Definition:      A list of data values that have a valid-time property.

The intent of HIST is to capture the true historical (and future) values of an item, rather than the audit trail of values any given system has held for the item. The history information is not limited to the past; expected future values MAY also appear.

template<ANY T>
type History<T> alias HIST<T> specializes LIST<HXIT<T>> {
            HXIT<T>  current;
            HXIT<T>  earliest;
            HIST<T>  exceptEarliest;
            HXIT<T>  latest;
            HIST<T>  exceptLatest;
  demotion  HXIT<T>;
};

All items in the list SHALL have a non-null validTime property. The validTime periods on the list SHALL NOT overlap. The contents of HIST SHALL be ordered in ascending chronological order.

invariant(HIST x; HXIT<T> e)
      where x.nonNull {
  x.contains(e).implies(e.validTime.nonNull);

  forall(INT.POSITIVE i) where i.lessThan(x.length) {
      x.item(i.predecessor).comesBefore(x.item(i));
  };
};

If a list of historical items should allow multiple items and/or overlapping ranges, then the type of the attribute should be BAG<HXIT<T>>. The type HIST<SET<T>> actually denotes a history of the set values themselves. The semantics of SET<HXIT<T>> become very complicated; given that validTime is usually excluded from the equality test, this type should not be used.

 3.12.1 Current Item (current) : HXIT<T>

Definition:      The item in the list whose validTime interval includes the current time.

Note that the current time is not necessarily the same time as the instant at which an instance is being processed. The relevant current time will be dictated by the context of operation.

There may be no current value, in which case the value of this operation is NULL.

 3.12.2 Earliest Item (earliest) : HXIT<T>

Definition:      The item in the list whose IVL.LOW boundary (validity start time) is less than (i.e. before) or equal to that of any other history item in the list.

invariant(HIST x; HXIT<T> e)
      where x.contains(e) {
   x.earliest.validTime.low.lessOrEqual(e.validTime.low);
};
 3.12.3 Except Earliest Item (exceptEarliest) : HIST<T>

Definition:      The derived history that has the earliest item excluded.

invariant(HIST x)
      where x.nonNull {
   x.exceptEarliest.equal(x.except(x.earliest));
};
 3.12.4 Latest Item (latest) : HXIT<T>

Definition:      The item in the list whose IVL.HIGH boundary (validity end time) is greater than (i.e. after) or equal to that of any other history item in the list.

invariant(HIST x; HXIT<T> e)
      where x.contains(e) {
   x.latest.validTime.high.greaterOrEqual(e.validTime.high);
};
 3.12.5 Except Latest Item (exceptLatest) : HIST<T>

Definition:      The derived history that has the latest item excluded.

invariant(HIST x)
      where x.nonNull {
   x.exceptLatest.equal(x.except(x.latest));
};
 3.12.6 Demotion of a History to a Single History Item (demotion) : HXIT<T>
invariant(HIST x)
      where x.nonNull {
   x.notEmpty;
   ((T)x).equal(x.current);
};

A type conversion between an entire history HIST and a single history item HXIT. This conversion takes the current data from the history, if a current value exists.

The purpose of this conversion is to allow an information producer to produce a history of any value instead of sending just one value.12 An information-consumer, who does not expect a history but a simple value, will convert the history to the current value. Note that the source system may only send a history of a value if the constraining models permits this.

 3.12.7 Equality (equal) : BL, inherited from ANY

The evaluation of equality for HIST is the same as the LIST data type. This means that values of the type HIST and LIST may be equal.

 4 Basic Types

Overview of Text and Multimedia Data Types
Overview of Text and Multimedia Data Types
 4.1 BinaryData (BIN) specializes LIST<BN>

Definition:      A raw block of bits.

BIN is a protected type that SHALL NOT be assigned to any property outside the data type specification.

A bit is semantically identical with a non-null BL value. Thus, all binary data is — semantically — a sequence of non-null BL values.

protected type BinaryData alias BIN specializes LIST<BN>;
NOTE: The representation of arbitrary binary data is the responsibility of an ITS. How the ITS accomplishes this depends on the underlying Implementation Technology (whether it is character-based or binary) and on the represented data. Character data MAY be represented as binary data; however, a character-based ITS SHOULD NOT convert character data into arbitrary binary data and then represent binary data in a character encoding. E.g., the letter "J" might be encoded as ASCII "74" (or hexadecimal "4A"): these character representations of numerical data should not be represented in lieu of the original "J."

An empty sequence is not considered binary data but counts as a NULL-value. In other words, non-NULL binary data contains at least one bit. All bits in a non-NULL binary data value SHALL NOT be NULL.

invariant(BIN x)
      where x.nonNull {
   x.notEmpty;
   x.length.greaterThan(0);
};
 4.1.1 Equality (equal) : BL, inherited from ANY

The evaluation of equality for BIN is the same as the LIST data type.

This means that values of the type BIN and LIST<BL> may be equal.

 4.2 EncapsulatedData (ED) specializes ANY

Definition:      Data that is primarily intended for human interpretation or for further machine processing outside the scope of HL7.

This includes unformatted or formatted written language, multimedia data, or structured information as defined by a different standard (e.g., XML-signatures). Instead of the data, an ED may contain only a reference (see TEL). Note that ST is a specialization of ED where the mediaType is fixed to text/plain and several other properties are constrained to null.

  Table 13: Property Summary of EncapsulatedData
Name Type Description
data BIN The binary content of the ED
mediaType CS The type of the encapsulated data.
charset CS An Internet Assigned Numbers Authority (IANA) Charset Registered character set and character encoding for character-based media types.
language CS The human language of the content.
compression CS The compression algorithm, if any, used on the raw byte data.
reference TEL.URL A URL the target of which is taken as the binary content of the ED.
integrityCheck BIN A checksum calculated over the binary data.
integrityCheckAlgorithm CS The algorithm used to compute the integrityCheck value.
description ST An alternative description of the media where the context is not suitable for rendering the media.
thumbnail ED An abbreviated rendition of the full data.
translation DSET<ED> Alternate renditions of the same content translated into a different language or a different mediaType. The translation property is a set of ED that each translate the first rendition into a different language or use a different mediaType. Each element of the translation set SHALL be a translation of the ED value. Translations SHALL NOT contain translations.
length INT The length of the content in the ED.
type EncapsulatedData alias ED specializes ANY {
   BIN     data;
   CS      mediaType;
   CS      charset;
   CS      language;
   CS      compression;
   TEL.URL reference;
   BIN     integrityCheck;
   CS      integrityCheckAlgorithm;
   ST      description;
   ED      thumbnail;
   DSET<ED> translation;

   INT     length;
   ED      subPart(INT start, INT end);
};

Encapsulated data can be present in two forms, inline or by reference. Inline data is communicated or moved as part of the encapsulated data value, whereas by-reference data may reside at a different (remote) location. The data is the same whether it is located inline or remote.

 4.2.1 Binary Data (data) : BIN

Definition:      The binary content of the ED

ED acts as a wrapper of binary content. Operations performed against the ED directly are mediated by the mediatype and, if so indicated by the mediatype, the character set. For example, two BIN values are equal if they have the same sequence of bits in their content. However the ED are only equal if they have the same sequence of logical items. For instance, if the media type is a kind of text, then the sequence of characters indicated by the character set and the binary content must be equal. Similarly, the length of an ED is the number of component parts as indicated by the mediatype. For application and image media types, the length of ED is the same as the length of the data. Note that operations may also be performed directly upon the binary content by using data.

invariant(ED x)
      where x.nonNull {
   x.data.nonNull;			
};

Although data SHALL be nonNull if the ED is not null, it need not be contained in-line in the instance; instead, the binary content, along with some other properties, MAY be defined by the reference property.

 4.2.2 Media Type (mediaType) : CS

Definition:      The type of the encapsulated data.

The default mediaType is text/plain. The type of the encapsulated data may help identify a method to interpret or render the data.

mediaType is a mandatory property, i.e., every non-NULL instance of ED SHALL have a non-NULL mediaType property.

invariant(ED x)
      where x.nonNull {
   x.mediaType.nonNull;
};

The IANA defined domain of media types is established by the Internet standard RFC 2045 [http://www.ietf.org/rfc/rfc2045.txt] and 2046 [http://www.ietf.org/rfc/rfc2046.txt]. RFC 2046 defines the media type to consist of two parts:

  1. top level media type, and
  2. media subtype

However, this specification treats the entire media type as one atomic code symbol in the form defined by IANA, i.e., top level type followed by a slash "/" followed by media subtype. Currently defined media types are registered in a database [http://www.iana.org/assignments/media-types/index.html] maintained by IANA. Currently several hundred different MIME media types are defined, with the list growing rapidly. In general, all those types defined by the IANA MAY be used.

To promote interoperability, this specification prefers certain media types to others. This is to define a greatest common denominator on which interoperability is not only possible, but that is powerful enough to support even advanced multimedia communication needs.

Table below assigns a status to certain MIME media types, where the status means one of the following:

  • required: Every HL7 application SHALL support at least the required media types if it supports a given kind of media. One required media-type for each kind of media exists. Some media types are required for a specific purpose, which is then indicated as "required for ..."
  • recommended: Other media types are recommended for a particular purpose. For any given purpose there should be only very few additionally recommended media types and the rationale, conditions and assumptions of such recommendations must be made very clear.
  • indifferent: This status means, HL7 neither forbids nor endorses the use of this media type. All media types not mentioned in Table have status indifferent by default. Since there are one required and several recommended media types for most practically relevant use cases, media types of this status should be used very conservatively.
  • deprecated: Deprecated media types SHOULD NOT be used, because these media types are flawed, because there are better alternatives, or because of certain risks. Such risks could be security risks, for example, the risk that such a media type could spread computer viruses. Not every flawed media type is marked as deprecated, though. A media type that is not mentioned in Table 6, and thus has status indifferent, may well be flawed.
  Table 14: Concept Domain MediaType. ValueSet OID: 2.16.840.1.113883.11.14824. CodeSystem "MediaType", OID: 2.16.840.1.113883.5.79, Owner: IANA
code name status definition
text/plain  Plain Text  required  For any plain text. This is the default and is used for a character string (ST) data type. 
text/x-hl7-ft  HL7 Text  recommended  For compatibility, this represents the HL7 v2.x FT data type. Its use is recommended only for backward compatibility with HL7 v2.x systems. 
text/html  HTML Text  recommended  For marked-up text according to the Hypertext Mark-up Language. HTML markup is sufficient for typographically marking-up most written-text documents. HTML is platform independent and widely deployed. 
application/pdf  PDF  recommended  The Portable Document Format is recommended for written text that is completely laid out and read-only. PDF is a platform independent, widely deployed, and open specification with freely available creation and rendering tools. 
text/xml  XML Text  indifferent  For structured character based data. There is a risk that general SGML/XML is too powerful to allow a sharing of general SGML/XML documents between different applications. 
text/x-hl7-text+xml  HL7 Sturctured Narrative  recommended  The content described by the CDA Narrative Block (not just used by CDA). 
multipart/x-hl7-cda-level1  CDA Level 1 Multipart  recommended  The HL7 clinical document Architecture, Level 1 MIME package. 
text/rtf  RTF Text  indifferent  The Rich Text Format is widely used to share word-processor documents. However, RTF does have compatibility problems, as it is quite dependent on the word processor. May be useful if word processor edit-able text should be shared. 
application/msword  MSWORD  deprecated  This format is very prone to compatibility problems. If sharing of edit-able text is required, text/plain, text/html or text/rtf should be used instead. 
audio/basic  Basic Audio  required  This is a format for single channel audio, encoded using 8bit ISDN mu-law [PCM] at a sample rate of 8000 Hz. This format is standardized by: CCITT, Fascicle III.4 -Recommendation G.711. Pulse Code Modulation (PCM) of Voice Frequencies. Geneva, 1972. 
audio/mpeg  MPEG audio layer 3  required  MPEG-1 Audio layer-3 is an audio compression algorithm and file format defined in ISO 11172-3 and ISO 13818-3. MP3 has an adjustable sampling frequency for highly compressed telephone to CD quality audio. 
audio/k32adpcm  K32ADPCM Audio  indifferent  ADPCM allows compressing audio data. It is defined in the Internet specification RFC 2421 [ftp://ftp.isi.edu/in-notes/rfc2421.txt]. Its implementation base is unclear. 
image/png  PNG Image  required  Portable Network Graphics (PNG) [http://www.cdrom.com/pub/png] is a widely supported lossless image compression standard with open source code available. 
image/gif  GIF Image  indifferent  GIF is a popular format that is universally well supported. However GIF is patent encumbered and should therefore be used with caution. 
image/jpeg  JPEG Image  required  This format is required for high compression of high color photographs. It is a "lossy" compression, but the difference to lossless compression is almost unnoticeable to the human vision. 
application/dicom  DICOM  recommended  Digital Imaging and Communications in Medicine (DICOM) MIME type defined in RFC3240 [http://ietf.org/rfc/rfc3240.txt]. 
image/g3fax  G3Fax Image  recommended  This is recommended only for fax applications. 
image/tiff  TIFF Image  indifferent  Although TIFF (Tag Image File Format) is an international standard it has many interoperability problems in practice. Too many different versions that are not handled by all software alike. 
video/mpeg  MPEG Video  required  MPEG is an international standard, widely deployed, highly efficient for high color video; open source code exists; highly interoperable. 
video/x-avi  X-AVI Video  deprecated  The AVI file format is just a wrapper for many different codecs; it is a source of many interoperability problems. 
model/vrml  VRML Model  recommended  This is an openly standardized format for 3D models that can be useful for virtual reality applications such as anatomy or biochemical research (visualization of the steric structure of macromolecules) 

The set of required media types is very small so that no undue requirements are forced on HL7 applications, especially legacy systems. In general, no HL7 application is forced to support any given kind of media other than written text. For example, many systems just do not want to receive audio data, because those systems can only show written text to their users. It is a matter of application conformance statements to say: "I will not handle audio". Only if a system claims to handle audio media, then it must support the required media type for audio.

 4.2.3 Charset (charset) : CS

Definition:      An Internet Assigned Numbers Authority (IANA) Charset Registered character set and character encoding for character-based media types.

The charset SHALL be identified by an Internet Assigned Numbers Authority (IANA) Charset Registration [http://www.iana.org/assignments/character-sets] in accordance with RFC 2978 [http://www.ietf.org/rfc/rfc2978.txt]. The IANA source specifies names and multiple aliases for most character sets. For HL7's purposes, use of multiple alias names is not allowed. The standard name for HL7 is the one marked by IANA as "preferred for MIME." If IANA has not marked one of the aliases as "preferred for MIME" the main name SHALL be the one used for HL7.

Table 15 lists a few of the IANA defined character sets that are of interest to current HL7 members.

  Table 15: Concept Domain Charset. ValueSet OID: 2.16.840.1.113883.11.14853. CodeSystem "CharSet", OID: 2.16.840.1.113883.5.21, Owner: IANA
lvl code name definition
1 EBCDIC EBCDIC

HL7 is indifferent to the use of this Charset.

1 ISO-10646-UCS-2 ISO-10646-UCS-2

Deprecated for HL7 use.

1 ISO-10646-UCS-4 ISO-10646-UCS-4

Deprecated for HL7 use.

1 ISO-8859-1 ISO-8859-1

HL7 is indifferent to the use of this Charset.

1 ISO-8859-2 ISO-8859-2

HL7 is indifferent to the use of this Charset.

1 ISO-8859-5 ISO-8859-5

HL7 is indifferent to the use of this Charset.

1 JIS-2022-JP JIS-2022-JP

HL7 is indifferent to the use of this Charset.

1 US-ASCII US-ASCII

Required for HL7 use.

1 UTF-7 UTF-7

HL7 is indifferent to the use of this Charset.

1 UTF-8 UTF-8

Required for Unicode support.

NOTE: The above list is not complete let alone exclusive. In particular, international HL7 affiliates may make special recommendations about charsets to be used in their realm. These recommendations MAY add additional charsets and MAY reassign the recommendations status of a listed charset.

The charset property needs to be known where the data of ED is character type data in any form. If the data is provided in-line, then the charset SHALL be clearly conveyed. If the data is provided as a reference, and the access method does not provide the charset for the data, typically as a mime header, then the charset SHALL be conveyed as part of the ED.

Interested readers may also want to consult the "Character Model for the World Wide Web" [http://www.w3.org/TR/charmod] for a more complete discussion of character set and related issues.

 4.2.4 Language (language) : CS

Definition:      The human language of the content.

The need for a language code for text data values is documented in RFC 2277, IETF Policy on Character Sets and Languages [http://www.ietf.org/rfc/rfc2277.txt]. Further background information can be found in Using International Characters in Internet Mail [http://www.imc.org/mail-i18n.html], a memo by the Internet Mail Consortium.

The principles of the code domain of this attribute are specified by the Internet standard RFC 3066 [http://www.ietf.org/rfc/rfc3066.txt]. The RFC 3066 coding scheme is principally constructed from a primary subtag component encoded using the language codes of ISO 639, with an optional second subtag component encoded using the two letter country codes of ISO 3166. Where this scheme does not provide a suitable code, RFC 3066 allows for other codes, mostly as defined by ISO or the Internet Assigned Names Authority [http://www.iana.org/assignments/language-tags].13 This code domain is assigned the OID 2.16.840.1.113883.6.121.

While Language tags usually alter the meaning of the text, the language does not alter the meaning of the characters in the text.14

NOTE: Representation of language tags to text is highly dependent on the ITS. An ITS MAY use the native way of language tagging provided by its target implementation technology. Some may have language information in a separate component, e.g., XML has the xml:lang tag for strings. Others may rely on language tags as part of the binary character string representation, e.g., ISO 10646 (Unicode) and its "plane-14" language tags.

The language tag SHOULD NOT be mandatory if it is not mandatory in the implementation technology. Semantically, language tagging of strings follows a default-logic. In circumstances where a realm may support multiple langauges, it is up to the realm to define rules to handle language where none is specified when no language is specified. If no other rule is specified, the local language of the reader is assumed. If a language is set for an entire message or document, that language is the default. If any information element or value that is superior in the syntax hierarchy specifies a language, that language is the default for all subordinate text values.

If language tags are present in the beginning of the encoded binary text (e.g., through Unicode's plane-14 tags) this is the source of the language property of the encapsulated data value.

 4.2.5 Compression (compression) : CS

Definition:      The compression algorithm, if any, used on the raw byte data.

  Table 16: Concept Domain CompressionAlgorithm. ValueSet OID: 2.16.840.1.113883.11.10620. CodeSystem "CompressionAlgorithm", OID: 2.16.840.1.113883.5.1009, Owner: HL7
code name status definition
DF    required   
GZ    indifferent   
ZL    indifferent   
  deprecated   
BZ    indifferent   
Z7    indifferent   
  • required: Every HL7 application SHALL support at least the required compression types.
  • indifferent: This status means, HL7 neither forbids nor endorses the use of this compression algorithm.
  • deprecated: Deprecated compression algorithms SHOULD NOT be used, because they are flawed, because there are better alternatives, or because of certain risks.

The compression applies to the data applied in line, not to data provided by reference, even if there is no data provided in line. Note that some compression formats allow multiple archive files to be embedded within a single compressed volume. Applications SHALL ensure that the decompressed form of the data conforms to the stated media type. The stated media type applies to the uncompressed data.

 4.2.6 Reference (reference) : TEL.URL

Definition:      A URL the target of which is taken as the binary content of the ED.

A telecommunication address (TEL) is a URL (i.e. for HTTP or FTP) which will resolve to precisely the same binary data that could as well have been provided as inline data. The semantic value of an encapsulated data value is the same, regardless whether the data is present inline data or just by-reference. However, an encapsulated data value without inline data behaves differently, since any attempt to examine the data requires the data to be downloaded from the reference. An encapsulated data value MAY have both inline data and a reference.

If both reference and inline data are provided, the reference SHALL point to data identical to that provided inline. It is an error if the data resolved through the reference does not match either the integrity check or the in-line data.

The reference may contain a usablePeriod to indicate that the data may only be available for a limited period of time. Whether the reference is limited by a usablePeriod or not, the content of the reference SHALL be fixed for all time. Any application using the reference SHALL always receive the same data, or an error. The reference cannot be reused to send a different version of the same data, or different data.

By-reference encapsulated data may not be allowed depending on the attribute or component that is declared encapsulated data. Values of type ST SHALL always be inline.

 4.2.7 Integrity Check (integrityCheck) : BIN

Definition:      A checksum calculated over the binary data.

The integrity check is a short binary value representing a cryptographically strong checksum that is calculated over the binary data. The purpose of this property, when communicated with a reference is for anyone to validate later whether the reference still resolved to the same data that the reference resolved to when the encapsulated data value with reference was created. It is an error if the data resolved through the reference does not match the integrity check.

The integrity check is calculated according to the integrityCheckAlgorithm. By default, the Secure Hash Algorithm-1 (SHA-1) shall be used. The integrity check is binary encoded according to the rules of the integrity check algorithm.

The integrity check is calculated over the raw binary data that is contained in the data component, or that is accessible through the reference. No transformations are made before the integrity check is calculated. If the data is compressed, the Integrity Check is calculated over the compressed data.

 4.2.8 Integrity Check Algorithm (integrityCheckAlgorithm) : CS

Definition:      The algorithm used to compute the integrityCheck value.

The default value is SHA-1.15

  Table 17: Concept Domain IntegrityCheckAlgorithm. ValueSet OID: 2.16.840.1.113883.11.17385. CodeSystem "IntegrityCheckAlgorithm", OID: 2.16.840.1.113883.5.1010, Owner: HL7
lvl code name definition
1 SHA-1 secure hash algorithm - 1

This algorithm is defined in FIPS PUB 180-1: Secure Hash Standard. As of April 17, 1995.

1 SHA-256 secure hash algorithm - 256

This algorithm is defined in FIPS PUB 180-2: Secure Hash Standard.

 4.2.9 Description (description) : ST

Definition:      An alternative description of the media where the context is not suitable for rendering the media.

E.g. Short text description of an image or sound clip, etc. This attribute is not intended to be a complete substitute for the original. For complete substitutes, use the "translation" property. The intent of this property is allow compliance with disability requirements such as those expressed in American's with Disability Act (also known as "Section 508"), where there is a requirement to provide a short text description of included media in some form that can be read by a screen reader. This is similar to a very short thumbnail with mediaType = text/plain.

 4.2.10 Thumbnail (thumbnail) : ED

Definition:      An abbreviated rendition of the full data.

A thumbnail requires significantly fewer resources than the full data, while still maintaining some distinctive similarity with the full data. A thumbnail is typically used with by-reference encapsulated data. It allows a user to select data more efficiently before actually downloading through the reference. Originally, the term thumbnail refers to an image in a lower resolution (or smaller size) than another image. However, the thumbnail concept can be metaphorically used for media types other than images. For example, a movie may be represented by a shorter clip; an audio-clip may be represented by another audio-clip that is shorter, has a lower sampling rate, or a lossy compression; or an abstract provided for a long document.

Thumbnails may not be allowed depending on the attribute or component that is declared encapsulated data. Values of type ST SHALL NOT have thumbnails, and a thumbnail itself SHALL NOT contain a thumbnail.

invariant(ED x)
      where x.thumbnail.nonNull {
   x.thumbnail.thumbnail.isNull;
};
NOTE: ITS's SHOULD consider the case where the thumbnail and the original both have the same properties of type, charset and compression. In this case, these properties need not be represented explicitly for the thumbnail but might be "inherited" from the main encapsulated data value to its thumbnail.
 4.2.11 Translation (translation) : DSET<ED>

Definition:      Alternate renditions of the same content translated into a different language or a different mediaType. The translation property is a set of ED that each translate the first rendition into a different language or use a different mediaType. Each element of the translation set SHALL be a translation of the ED value. Translations SHALL NOT contain translations.

The translations SHALL convey the same information, but in a different language or mediaType. The translations do not take part in the test for equality, so SHALL NOT introduce any new semantics to the value.

invariant(ED x)
      where x.nonNull {
   forall(ED t) where x.translation.contains(t) {
     t.description.isNull;
	 t.language.equals(x.language).not.or(t.mediaType.equals(x.mediaType).not);
	 t.translation.isEmpty;
   }
};
 4.2.12 Length (length) : INT

Definition:      The length of the content in the ED.

The length of the ED may not be the same as the length of the binary content of the ED in the data property. The length is the number of items in the content where the kind of item is determined by the mediaType. For instance, if the mediatype is a type of text, then the length of the ED is the number of characters found in the binary content, as specified by the charset. For application, video, audio and image mediatypes, the length is the same as the length of the binary content.

invariant(ED x, INT y)
      where x.nonNull.and(y.isZero) {
   x.length.greaterThan(y);
};

nonNull ED SHALL always have some content, and length is greater than 0.

 4.2.13 SubPart (subPart) : ED

Definition:      A contiguous sublist of the ED containing the content found from index start to end, inclusively.

As with length, the subPart of an ED may be different to a subList of the data. The offsets are determined based on the logical contents as determined by the mediaType. For application, video, audio and image mediatypes, the offsets are the same as the offsets in the binary content. The content must then the re-rendered into some binary representation.

The mediaType and the charset of the return value are usually of the same type as the ED, but this may not always be the case.