StructureMap
Introduction
Scope and Usage
The StructureMap resource defines a detailed set of rules that describe how one Structure is related to another and provides sufficient detail to allow for automated conversion of instances.
The intention of the structure map resource is to allow a specialist in formats and interoperability to specify the full relationships between two structures (e.g. a CDA document and a set of FHIR resources), and then many different systems - both testing and production clinical systems - can leverage that to automatically transform from one format to the other.
Maps are unidirectional: they map from the source structure to the target structure, and no reverse map is implied. Even if the mapping is simple, and loss-less, it cannot be assumed that there are no conditions that might additionally apply in the reverse direction.
The mapping language, along with a concrete syntax, is defined in detail in the FHIR Mapping Language. The StructureMap resource represents the abstract syntax, and the concrete syntax is the recommended narrative representation for a StructureMap. See also the Tutorial.
Boundaries and Relationships
Note that many mappings between models only establish conceptual equivalence between the structures. These models are useful because they quickly convey how the structures are related to humans, whereas more maps with sufficient detail to support instance transformation are necessarily full of fine detail that can obscure the conceptual relationships. The ConceptMap resource is suitable for representing high level relationships between models, while this StructureMap resource is intended to describe the full details that need to be known in order to transform an instance of data from one structure to another.
The StructureMap resource assumes that both the source and the target models are fully defined using StructureDefinition resources - either resources, or logical models, and is described accordingly. However, there is no direct relationship between the mapping language contained in the StructureMap resource, and the existence of the appropriate structure definitions, so that this mapping language could be used to define a map from an HL7 V2 message to a CDA document. Note, that various implementation contexts may introduce a direct relationship (e.g. see [op to defined]).
It's possible to apply the mapping language to structures that do not even have (or cannot have) formally defined types, although the type-related parts of the mapping language cannot be used in these cases.
The Mapping Language and the StructureMap resource are built on top of FHIRPath, and a FHIRPath implementation is required in order to execute a StructureMap.
Background and Context
Each structure map contains, in addition to the standard metadata that all conformance resources contain, the following information:
- A list of the structure definitions referenced by the map
- A list of other structure maps that the map uses
- One or more groups of rules that describe how content in the source is transformed to content in the target
Each group of rules defines a set of input and output variables that must be passed when the group is invoked in a particular context. When a group is invoked, all the rules in the group are checked to see whether they apply.
Each rule may have some or all of the following properties:
- A name - used as the identity in internal references, and traces
- Contexts in both source and target models that define where the rule applies
- A set of source elements that provide data to be mapped
- Conditions that specify if the rule is to apply
- A set of target elements that will be created
- Transform rules that describe how raw data is converted from the source format to the target format (e.g. string manipulation)
- Flags for how instances that can repeat are handled
- Additional rules that apply to the newly created elements (e.g. new contexts)
The mapping language is entirely declarative; there is no imperative or procedural aspects to the definitions.
StructureDefinition
Elements (Simplified)
- StructureMap [0..*]: - A Map of relationships between 2 structures that can be used to transform data
- StructureMap.url [1..1]: uri Canonical identifier for this structure map, represented as a URI (globally unique)
- StructureMap.identifier [0..*]: Identifier Additional identifier for the structure map
- StructureMap.version [0..1]: string Business version of the structure map
- StructureMap.versionAlgorithm[x] [0..1]: string, Coding extensible:version-algorithm How to compare versions
- StructureMap.name [1..1]: string Name for this structure map (computer friendly)
- StructureMap.title [0..1]: string Name for this structure map (human friendly)
- StructureMap.status [1..1]: code required:publication-status draft | active | retired | unknown
- StructureMap.experimental [0..1]: boolean For testing only - never for real usage
- StructureMap.date [0..1]: dateTime Date last changed
- StructureMap.publisher [0..1]: string Name of the publisher/steward (organization or individual)
- StructureMap.contact [0..*]: ContactDetail Contact details for the publisher
- StructureMap.description [0..1]: markdown Natural language description of the structure map
- StructureMap.useContext [0..*]: UsageContext The context that the content is intended to support
- StructureMap.jurisdiction [0..*]: CodeableConcept extensible:jurisdiction Jurisdiction of the authority that maintains the structure map (if applicable)
- StructureMap.purpose [0..1]: markdown Why this structure map is defined
- StructureMap.copyright [0..1]: markdown Notice about intellectual property ownership, can include restrictions on use
- StructureMap.copyrightLabel [0..1]: string Copyright holder and year(s)
- StructureMap.structure [0..*]: BackboneElement Structure Definition used by this map
- StructureMap.structure.url [1..1]: canonical Canonical reference to structure definition
- StructureMap.structure.mode [1..1]: code required:map-model-mode source | queried | target | produced
- StructureMap.structure.alias [0..1]: string Name for type in this map
- StructureMap.structure.documentation [0..1]: string Documentation on use of structure
- StructureMap.import [0..*]: canonical Other maps used by this map (canonical URLs)
- StructureMap.const [0..*]: BackboneElement Definition of the constant value used in the map rules
- StructureMap.const.name [0..1]: id Constant name
- StructureMap.const.value [0..1]: string FHIRPath exression - value of the constant
- StructureMap.group [1..*]: BackboneElement Named sections for reader convenience
- StructureMap.group.name [1..1]: id Human-readable label
- StructureMap.group.extends [0..1]: id Another group that this group adds rules to
- StructureMap.group.typeMode [0..1]: code required:map-group-type-mode types | type-and-types
- StructureMap.group.documentation [0..1]: string Additional description/explanation for group
- StructureMap.group.input [1..*]: BackboneElement Named instance provided when invoking the map
- StructureMap.group.input.name [1..1]: id Name for this instance of data
- StructureMap.group.input.type [0..1]: string Type for this instance of data
- StructureMap.group.input.mode [1..1]: code required:map-input-mode source | target
- StructureMap.group.input.documentation [0..1]: string Documentation for this instance of data
- StructureMap.group.rule [0..*]: BackboneElement Transform Rule from source to target
- StructureMap.group.rule.name [0..1]: id Name of the rule for internal references
- StructureMap.group.rule.source [1..*]: BackboneElement Source inputs to the mapping
- StructureMap.group.rule.source.context [1..1]: id Type or variable this rule applies to
- StructureMap.group.rule.source.min [0..1]: unsignedInt Specified minimum cardinality
- StructureMap.group.rule.source.max [0..1]: string Specified maximum cardinality (number or *)
- StructureMap.group.rule.source.type [0..1]: string Rule only applies if source has this type
- StructureMap.group.rule.source.defaultValue [0..1]: string Default value if no value exists
- StructureMap.group.rule.source.element [0..1]: string Optional field for this source
- StructureMap.group.rule.source.listMode [0..1]: code required:map-source-list-mode first | not_first | last | not_last | only_one
- StructureMap.group.rule.source.variable [0..1]: id Named context for field, if a field is specified
- StructureMap.group.rule.source.condition [0..1]: string FHIRPath expression - must be true or the rule does not apply
- StructureMap.group.rule.source.check [0..1]: string FHIRPath expression - must be true or the mapping engine throws an error instead of completing
- StructureMap.group.rule.source.logMessage [0..1]: string Message to put in log if source exists (FHIRPath)
- StructureMap.group.rule.target [0..*]: BackboneElement Content to create because of this mapping rule
- StructureMap.group.rule.target.context [0..1]: string Variable this rule applies to
- StructureMap.group.rule.target.element [0..1]: string Field to create in the context
- StructureMap.group.rule.target.variable [0..1]: id Named context for field, if desired, and a field is specified
- StructureMap.group.rule.target.listMode [0..*]: code required:map-target-list-mode first | share | last | single
- StructureMap.group.rule.target.listRuleId [0..1]: id Internal rule reference for shared list items
- StructureMap.group.rule.target.transform [0..1]: code required:map-transform create | copy +
- StructureMap.group.rule.target.parameter [0..*]: BackboneElement Parameters to the transform
- StructureMap.group.rule.target.parameter.value[x] [1..1]: id, string, boolean, integer, decimal, date, time, dateTime Parameter value - variable or literal
- StructureMap.group.rule.rule [0..*]: - Rules contained in this rule
- StructureMap.group.rule.dependent [0..*]: BackboneElement Which other rules to apply in the context of this rule
- StructureMap.group.rule.dependent.name [1..1]: id Name of a rule or group to apply
- StructureMap.group.rule.dependent.parameter [1..*]: - Parameter to pass to the rule or group
- StructureMap.group.rule.documentation [0..1]: string Documentation for this instance of data
Mappings
- StructureMap Mappings — 13 mapping entries
Operations
- transform — Model Instance Transformation — The transform operation takes input content, applies a structure map transform, and then returns the output.
Resource Packs
list-StructureMap-packs.xml
<?xml version="1.0" encoding="UTF-8"?>
<List xmlns="http://hl7.org/fhir">
<id value="StructureMap-packs"/>
<status value="current"/>
<mode value="working"/>
</List>
Search Parameters
- context — token — A use context assigned to the structure map —
(StructureMap.useContext.value.ofType(CodeableConcept)) - context-quantity — quantity — A quantity- or range-valued use context assigned to the structure map —
(StructureMap.useContext.value.ofType(Quantity)) | (StructureMap.useContext.value.ofType(Range)) - context-type — token — A type of use context assigned to the structure map —
StructureMap.useContext.code - context-type-quantity — composite — A use context type and quantity- or range-based value assigned to the structure map —
StructureMap.useContext - context-type-value — composite — A use context type and value assigned to the structure map —
StructureMap.useContext - date — date — The structure map publication date —
StructureMap.date - description — string — The description of the structure map —
StructureMap.description - identifier — token — External identifier for the structure map —
StructureMap.identifier - jurisdiction — token — Jurisdiction of the authority that maintains the the structure map —
StructureMap.jurisdiction - name — string — Computationally friendly name of the structure map —
StructureMap.name - publisher — string — Name of the publisher of the structure map —
StructureMap.publisher - status — token — The current status of the structure map —
StructureMap.status - title — string — The human-friendly name of the structure map —
StructureMap.title - url — uri — The uri that identifies the structure map —
StructureMap.url - version — token — The business version of the structure map —
StructureMap.version - source — uri — A source StructureDefinition for the map —
StructureMap.structure.where(mode = 'source').url - target — uri — A target StructureDefinition for the map —
StructureMap.structure.where(mode = 'target').url - queried — uri — A queried StructureDefinition for the map —
StructureMap.structure.where(mode = 'queried').url - produced — uri — A produced StructureDefinition for the map —
StructureMap.structure.where(mode = 'produced').url - experimental — token — Whether the StructureMap is experimental —
StructureMap.experimental
Examples
- example — structuremap-example — Example
- structuremap-example — structuremap-example
- structuremap-examples-header — structuremap-examples-header
Mapping Exceptions
structuremap-fivews-mapping-exceptions.xml
Unmapped Elements
- FiveWs.what — Not relevant for this resource
- FiveWs.author — Not relevant for this resource
- FiveWs.actor — Not relevant for this resource
- FiveWs.cause — Not relevant for this resource
- FiveWs.where — Not relevant for this resource
- FiveWs.context — Unknown
- FiveWs.init — Not relevant for this resource
- FiveWs.source — Not relevant for this resource
- FiveWs.who — Not relevant for this resource
- FiveWs.grade — Not relevant for this resource
- FiveWs.planned — Not relevant for this resource
- FiveWs.done — Not relevant for this resource
- FiveWs.subject — Not relevant for this resource