openEHR to FHIR Data Type Mapping
0.1.0 - ci-build International flag

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

Textual Data

Page standards status: Informative

Textual data

openEHR carries text in DV_TEXT, an attribute-rich class with value, formatting, encoding, language, mappings, and the deprecated hyperlink. FHIR uses three plain-text primitives — string (UTF-8, capped at 1 MiB), markdown (CommonMark), and xhtml (constrained XHTML) — plus extensions that let a string element carry a richer rendered form alongside its plain value.

This asymmetry is the single most important thing to understand about the category: a FHIR string is a value, and an openEHR DV_TEXT is a class. Everything a DV_TEXT carries beyond value needs somewhere else to go.

Five cross-cutting facts govern the rows.

  • Character encoding. FHIR mandates UTF-8 throughout. openEHR permits several character sets through its character_sets code system. Non-UTF-8 content must be converted before mapping, and the original encoding is not preserved on the FHIR side.
  • Empty and whitespace-only strings. FHIR strips leading and trailing whitespace and does not permit an empty string. An empty optional openEHR text value is dropped; an empty mandatory one is an upstream data error, not a mapping problem.
  • Length. FHIR string is capped at 1 MiB. openEHR sets no formal cap. In practice this is unlikely to be reached, and an oversize value is handled as an exception rather than truncated silently.
  • Language. FHIR represents language at the resource level (Resource.language) and, at element level, through extensions. openEHR carries DV_TEXT.language directly on the value, so the two are at different levels of the model. The element-level language extension is a code required-bound to all-languages, so it carries the tag alone: the CODE_PHRASE.terminology_id that stated which scheme the tag belongs to is a named drop on the way out, and is derived from the extension's own binding on the way back.
  • Term mappings. DV_TEXT.mappings is not covered here. It belongs to Coded Data, under TERM_MAPPING.

DV_PARSABLE — an encapsulated string plus a formalism — and the deprecated DV_PARAGRAPH are also in this category. DV_PARAGRAPH has not been examined by the working group, and this guide records that rather than inventing a mapping for it. A route through its markdown DV_TEXT replacement is proposed on Open Items.

See Conventions for how to read the tables.

Summary

openEHR typeFHIR type→ FHIR→ openEHRMaturityScope
DV_TEXTstring | markdownlossylossyopendatatype
DV_PARAGRAPHmarkdown | stringunmappedunmappednot-discusseddatatype

DV_TEXT and string / markdown

Sources: openEHR RM — DV_TEXT · FHIR R5 — string · FHIR R5 — markdown · openEHR TERM — languages code set (External_id: ISO_639-1)

openEHR fieldFHIR target→ FHIR→ openEHRMaturityNotes
DV_TEXT.value 1..1when the target element is typed string: string.value
when the target element is typed markdown and formatting says markdown: markdown.value
losslesslosslesssettledA direct mapping; the target type is decided by the FHIR element definition, not by the data. FHIR strips leading and trailing whitespace and does not permit an empty string: an empty optional openEHR value is dropped, and an empty mandatory one is an upstream data error. FHIR caps string at 1 MiB; openEHR sets no cap, and an oversize value is an exception rather than something to truncate silently. The FHIR side is modelled here as the primitive together with its _-sibling — the value plus extension pair — because that is what carries the extensions the rows below use. The openEHR attribute is mandatory and the FHIR element is optional, so an incoming instance that omits it cannot be converted: the reference implementation produces nothing rather than inventing a value. See the mandatory-attribute rule.
DV_TEXT.formatting 0..1string.extension[rendering-markdown]† (extension)lossylosslessopen→ FHIR: drops DV_TEXT.formatting — markdown is carried, by the rendering-markdown extension or by choosing a markdown target. What is dropped is the distinction between plain and plain_no_newlines — FHIR has no element recording it — and the legacy deprecated CSS string, which has no FHIR representation either Where formatting is markdown, the FHIR target SHOULD be a markdown element, or a string carrying the rendering-markdown extension, and a FHIR string carrying that extension on the way back sets formatting to markdown. There is no html formatting value. RM § 5.1.7 enumerates formatting exhaustively — Void, "markdown", "plain", "plain_no_newlines", and a legacy deprecated CSS string — and rejects HTML as a formatting approach explicitly, so this guide recommends no XHTML target and emits none. XHTML support on the openEHR side is pending a Reference Model change request; until it lands the guide publishes it as a gap, on the row below and in the FHIR features with no openEHR counterpart inventory.
—
no counterpart (inventory)
string.extension[rendering-xhtml]† (extension)unmappedlossyopen→ FHIR: Nothing produces one. No DV_TEXT.formatting value states XHTML rendering, so this guide emits no rendering-xhtml and recommends none. (owner: openehr-modelling) → openEHR: drops string.extension[rendering-xhtml] — a received string may state XHTML rendering and DV_TEXT.formatting has no value to record it, so the rendering instruction is not carried. DV_TEXT.value converts faithfully, so the text is kept and the instruction alone is the drop — refusing the whole conversion would discard content that maps perfectly well This is the sub-case that the formatting row above deliberately does not fold in: it has no openEHR endpoint at all, so it carries its own verdicts and its own citations rather than borrowing the parent row’s. It closes when the Reference Model change request adding XHTML support lands, at which point this becomes an ordinary formatting value.
DV_TEXT.language 0..1string.extension[language]† (extension)lossylossyopen→ FHIR: drops DV_TEXT.language.terminology_id — the language extension declares value[x]: code 1..1 with a required binding to all-languages, so it carries the tag alone; the CODE_PHRASE.terminology_id that stated which scheme the tag belongs to has no home on a bare code → openEHR: drops string.extension[language][region-subtag] — FHIR’s all-languages binding is BCP 47 and openEHR binds language to its own published ISO_639-1 code set. BCP 47 strictly contains ISO 639-1, so en-US and zh-Hant are BCP 47 tags that ISO 639-1 has no code for. The primary language subtag is carried and the region or script subtag is not; string.extension[language][outside-code-set] — a tag that is not an ISO 639-1 alpha-2 code — a three-letter ISO 639-2 code, a private-use tag — is outside the code set Language_valid requires, so no language is written at all rather than a terminology_id being invented for a code the code set does not hold. language is 0..1, and the text itself converts faithfully The two standards carry language at different levels of the model. openEHR puts it on the value; FHIR puts the primary language on Resource.language and uses element-level extensions — language, translation, additional-language, and narrativeLanguageControl — for anything finer. Which of those applies is a resource-level decision, so only the element-level language extension is stated here. A cluster archetype for narrative, accounting for narrative language control, is owned by the openEHR modelling team. Coming back, the two standards do not bind language to the same set: FHIR’s all-languages binding is BCP 47 and openEHR publishes exactly one language code set, Id: languages, External_id: ISO_639-1, which DV_TEXT.Language_valid requires the value to belong to. BCP 47 strictly contains ISO 639-1, so the inbound conversion is a narrowing and says so, rather than deriving an openEHR identifier from a FHIR binding.
DV_TEXT.encoding 0..1—
no counterpart (inventory)
unmappedunmappedsettled→ FHIR: The character set is not carried. openEHR permits several through its character_sets code system; the sender is responsible for converting to UTF-8 before mapping, and the original encoding is not preserved. → openEHR: Nothing arrives. A receiving system MAY set encoding to UTF-8, which is an inference from the FHIR rule rather than a carried value.
DV_TEXT.mappings 0..*—
no counterpart (inventory)
unmappedunmappedsettled→ FHIR: Not carried by this mapping. A DV_TEXT with term mappings SHOULD be mapped as a CodeableConcept instead — see Coded Data — where each mapping becomes an additional coding. → openEHR: A plain string carries no codings, so nothing arrives.

Worked example - a plain note

{
  "_type": "DV_TEXT",
  "value": "Patient reports intermittent headache."
}
{
  "value": "Patient reports intermittent headache."
}

Worked example - markdown with a language

{
  "_type": "DV_TEXT",
  "value": "**Allergy:** penicillin",
  "formatting": "markdown",
  "language": {
    "_type": "CODE_PHRASE",
    "terminology_id": {
      "value": "ISO_639-1"
    },
    "code_string": "en"
  }
}
{
  "value": "**Allergy:** penicillin",
  "extension": [
    {
      "url": "http://hl7.org/fhir/StructureDefinition/rendering-markdown",
      "valueMarkdown": "**Allergy:** penicillin"
    },
    {
      "url": "http://hl7.org/fhir/StructureDefinition/language",
      "valueCode": "en"
    }
  ]
}

DV_PARAGRAPH and markdown / string

Sources: openEHR RM — DV_PARAGRAPH · openEHR RM — Text package · FHIR R5 — markdown · FHIR R5 — string

openEHR fieldFHIR target→ FHIR→ openEHRMaturityNotes
DV_PARAGRAPH.items 1..*—
no counterpart (inventory)
unmappedunmappednot-discussed→ FHIR: DV_PARAGRAPH has not been discussed. It is deprecated in the Reference Model but may appear in older data and archetypes, so it is listed rather than omitted. No mapping is asserted, because none has been agreed. (owner: working-group) → openEHR: Nothing is mapped into a deprecated type that has not been discussed. (owner: working-group) The Reference Model says "DEPRECATED: use markdown formatted DV_TEXT instead", and that for legacy reasons the type "remains legal, and should be supported in at least a basic way". FHIR markdown is GFM CommonMark, which is what DV_TEXT ↔ string / markdown carries for markdown-formatted text, so mapping a paragraph through its prescribed replacement is the route proposed on Open Items.