openEHR to FHIR Data Type Mapping, published by HL7 International / FHIR Infrastructure. This guide is not an authorized publication; it is the continuous build for version 0.1.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/openehr-fhir/data-type-mapping-ig/ and changes regularly. See the Directory of published versions
| Page standards status: Informative |
openEHR's Foundation Types specification defines primitive value classes —
Integer, Integer64, Real, Double — that carry a raw value plus a set of
associated functions. These are generally not used directly in archetypes.
Numbers are normally carried inside DV_ wrappers (DV_COUNT, DV_QUANTITY,
DV_PROPORTION, DV_ORDINAL, DV_SCALE), and the Foundation primitives appear
as the declared types of attributes of those classes.
FHIR takes the opposite shape. It defines stand-alone numeric primitives —
integer, integer64, decimal, positiveInt, unsignedInt — that are used
directly, both inside complex types and as resource elements. unsignedInt and
positiveInt are integer restricted to 0.. and 1.. respectively, so a value
below that range has no form in an element of either type.
The consequence is that this category is mostly consulted through another
one: a mapping for DV_QUANTITY.magnitude is a Real → decimal mapping, and
the rules below are what make it well defined.
Four facts govern every row here.
decimal preserves lexical precision; openEHR Real and Double do
not. FHIR treats trailing zeros in the lexical form as significant. Where
precision must survive a round trip, either write the value with explicit
trailing zeros or carry it in the quantity-precision extension. A
decimal may also carry up to 18 digits, more than a 32-bit Real holds.integer is 32-bit. FHIR defines integer64 for values that may
exceed 2³¹ − 1, and serialises it as a JSON String rather than a JSON
number, "due to issues with precision in floating point libraries". A guide
that publishes a bare number for an integer64 publishes a wire format R5
does not have.integer64 is uncommon as an element type. Few named R5 elements are
typed integer64 — Attachment.size and two SubscriptionStatus counters —
though every open value[x] admits it, and most FHIR elements holding
integer data are typed integer. For a 64-bit openEHR attribute mapped to an
integer element, map in-range values into it and carry anything that
exceeds it in an extension, whose valueInteger64 takes the full range.Real → decimal needs care. Binary floating-point values do not always
have an exact decimal lexical form, and a naive conversion can widen or narrow
the apparent precision of a clinical value. FHIR allows no INF, -INF, or
NaN in a decimal, so a non-finite value has no decimal form at all.See Quantities for the wrappers these primitives are carried in, and Conventions for how to read the tables.
| openEHR type | FHIR type | → FHIR | → openEHR | Maturity | Scope |
|---|---|---|---|---|---|
Integer | integer | lossy | lossy | settled | datatype |
Integer64 | integer64 | lossy | lossy | open | datatype |
Real / Double | decimal | lossy | lossy | settled | datatype |
Sources: openEHR BASE — Integer · openEHR BASE — type cross-reference (primitive widths) · FHIR R5 — integer · FHIR R5 — unsignedInt · FHIR R5 — positiveInt
| openEHR field | FHIR target | → FHIR | → openEHR | Maturity | Notes |
|---|---|---|---|---|---|
Integer 1..1 | when the target element is typed integer: integerwhen the target element is typed unsignedInt and the value is not negative: unsignedIntwhen the target element is typed positiveInt and the value is positive: positiveInt | lossless | lossless | settled | Both are 32-bit signed integers, so the ranges coincide; openEHR states the width in its Foundation Types cross-reference. unsignedInt (0..2,147,483,647) and positiveInt (1..2,147,483,647) are integer restricted to a sub-range, so a value inside it maps unchanged and one outside it is a sub-case below. openEHR Foundation primitives are generally not used directly in archetypes: numbers are carried inside DV_ wrappers, and this row states what the wrapper’s attribute mapping means. |
Integer[negative] 1..1 | — no counterpart (inventory) | unmapped | unmapped | settled | → FHIR: A negative value cannot be carried in an element typed unsignedInt: the archetype and the FHIR element disagree about the range, and no conversion of the value repairs that. → openEHR: An unsignedInt is never negative, so nothing arrives. archetype scope: the sub-case arises only where the target element is typed unsignedInt, which the element decides, not the data type. |
Integer[non-positive] 1..1 | — no counterpart (inventory) | unmapped | unmapped | settled | → FHIR: A zero or negative value cannot be carried in an element typed positiveInt: the archetype and the FHIR element disagree about the range, and no conversion of the value repairs that. → openEHR: A positiveInt is never zero or negative, so nothing arrives. archetype scope: the sub-case arises only where the target element is typed positiveInt, which the element decides, not the data type. |
Sources: openEHR BASE — Integer64 · openEHR BASE — type cross-reference (primitive widths) · FHIR R5 — integer64 · FHIR R5 — integer
| openEHR field | FHIR target | → FHIR | → openEHR | Maturity | Notes |
|---|---|---|---|---|---|
Integer64 1..1 | when the target element is typed integer64: integer64when the target element is typed integer and the value is within the 32-bit range: integer | lossless | lossless | settled | FHIR serialises integer64 as a JSON String, not as a JSON number, "due to issues with precision in floating point libraries" — a guide that publishes a bare number for one publishes a wire format R5 does not have; an integer stays a JSON number. Few named R5 elements are typed integer64 — Attachment.size and two SubscriptionStatus counters — though every open value[x] admits it, and most elements holding integer data are typed integer. For a 64-bit openEHR attribute mapped to an integer element, map in-range values into it and carry anything that exceeds it in an extension; that sub-case is the row below. The reference converter targets integer64, and carries the full 64-bit range. |
Integer64[overflow] 1..1 | — no counterpart (inventory) | unmapped | unmapped | open | → FHIR: A value exceeding 2³¹ − 1 cannot be carried in an element typed integer. An extension is required, and its value can be a valueInteger64, which takes the full range; which extension depends on the element, so no general answer is given here. (owner: working-group) → openEHR: Nothing arrives, because nothing was emitted. (owner: working-group) archetype scope: the sub-case arises only where the target element is typed integer, which the element decides, not the data type. FHIR’s own definition of integer says "for larger values, use decimal" — advice about the type an element is given, which an instance cannot change. |
Sources: openEHR BASE — Real · openEHR BASE — Double · openEHR BASE — type cross-reference (primitive widths) · FHIR R5 — decimal
| openEHR field | FHIR target | → FHIR | → openEHR | Maturity | Notes |
|---|---|---|---|---|---|
Real 1..1 | decimal | lossless | lossy | settled | → openEHR: drops decimal — FHIR treats trailing zeros in the lexical form of a decimal as significant; openEHR Real and Double do not carry lexical precision at all, so the significance is lost unless a receiving DV_QUANTITY.precision is available to take it. A decimal may also carry up to 18 digits, while a 32-bit Real holds about 7 significant digits and a 64-bit Double about 15 to 17, so digits beyond those are rounded Where precision must survive a round trip, either write the value with explicit trailing zeros or carry it in the quantity-precision extension, whose contexts include decimal; see Quantities. Double maps to decimal on the same terms as Real. Care is needed converting binary floating-point values, whose exact decimal lexical form can widen or narrow the apparent precision of a clinical value. |
Real[non-finite] 1..1 | — no counterpart (inventory) | unmapped | unmapped | settled | → FHIR: Nothing is produced for the value. FHIR states why an element has no value with the data-absent-reason extension on the element, whose code system has not-a-number, negative-infinity, and positive-infinity for exactly these cases. → openEHR: A decimal is always finite, so nothing arrives. archetype scope: the replacement is an extension on the element whose value is absent, which the element decides, not the data type. openEHR’s widths admit any interoperable representation, including IEEE floating point, which has these values; openEHR canonical JSON cannot carry them, so the case arises only from other representations. The reference converter refuses one, reporting Real[non-finite]. How a data-absent-reason reads back is the null-flavour mapping. |