FHIR Cross-Version Mapping Pack
0.1.0 - Ballot for Release 5.1.0 International flag

FHIR Cross-Version Mapping Pack, 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/HL7/fhir-cross-version/ and changes regularly. See the Directory of published versions

StructureMap: StructureDefinition Transforms: R2 to R3

Official URL: http://hl7.org/fhir/StructureMap/StructureDefinition2to3 Version: 0.1.0
Standards status: Draft Maturity Level: 1 Computable Name: StructureDefinition2to3

StructureDefinitionTransformsR2toR3

/// url = 'http://hl7.org/fhir/StructureMap/StructureDefinition2to3'
/// name = 'StructureDefinition2to3'
/// title = 'StructureDefinition Transforms: R2 to R3'
/// status = 'active'

uses "http://hl7.org/fhir/1.0/StructureDefinition" alias StructureDefinitionR2 as source
uses "http://hl7.org/fhir/3.0/StructureDefinition" alias StructureDefinition as target

imports "http://hl7.org/fhir/StructureMap/*2to3"

group StructureDefinition(source src : StructureDefinitionR2, target tgt : StructureDefinition) extends DomainResource <<type+>> {
  src.url -> tgt.url "StructureDefinition-url";
  src.identifier -> tgt.identifier "StructureDefinition-identifier";
  src.version -> tgt.version "StructureDefinition-version";
  src.name -> tgt.name "StructureDefinition-name";
  src.display -> tgt.title "StructureDefinition-title";
  src.status -> tgt.status "StructureDefinition-status";
  src.experimental -> tgt.experimental "StructureDefinition-experimental";
  src.publisher -> tgt.publisher "StructureDefinition-publisher";
  src.contact as vs0 -> tgt.contact as vt0 then {
    vs0.name -> vt0.name "ContactDetail-name";
    vs0.telecom -> vt0.telecom "ContactDetail-telecom";
  } "StructureDefinition-contact";
  src.date -> tgt.date "StructureDefinition-date";
  src.description -> tgt.description "StructureDefinition-description";
  src.requirements -> tgt.purpose "StructureDefinition-purpose";
  src.copyright -> tgt.copyright "StructureDefinition-copyright";
  src.useContext where coding.system = 'urn:iso:std:iso:3166' -> tgt.jurisdiction "StructureDefinition-jurisdiction";
  src.useContext as vs where (coding.system = 'urn:iso:std:iso:3166').not() ->  tgt.useContext as uc,  uc.code as ucc,  ucc.system = 'http://hl7.org/fhir/usage-context-type',  ucc.code = 'task',  uc.value as vt then CodeableConcept(vs, vt) "StructureDefinition-useContext";
  src.code -> tgt.keyword "StructureDefinition-keyword";
  src.fhirVersion -> tgt.fhirVersion "StructureDefinition-fhirVersion";
  src.mapping as vs0 -> tgt.mapping as vt0 then {
    vs0.identity -> vt0.identity "mapping-identity";
    vs0.uri -> vt0.uri "mapping-uri";
    vs0.name -> vt0.name "mapping-name";
    vs0.comments -> vt0.comment "mapping-comments";
  } "StructureDefinition-mapping";
  src where constrainedType.empty() -> tgt.derivation = 'specialization' "StructureDefinition-derivation-1";
  src.id as vs where src.constrainedType.empty() -> tgt.type = vs "StructureDefinition-type-1";
  src where constrainedType.exists() -> tgt.derivation = 'constraint' "StructureDefinition-derivation-2";
  src.constrainedType as vs -> tgt.type = vs "StructureDefinition-type-2";
  src.kind where $this = 'logical' -> tgt.kind "StructureDefinition-kind-1";
  src.kind where $this = 'resource' -> tgt.kind "StructureDefinition-kind-2";
  src.kind as vt where ($this = 'datatype') and (src.id in ('boolean' | 'integer' | 'string' | 'decimal' | 'uri' | 'base64Binary' | 'instant' | 'date' | 'dateTime' | 'time' | 'code' | 'oid' | 'id' | 'markdown' | 'unsignedInt' | 'positiveInt')) -> tgt.kind = 'primitive-type' as vt "StructureDefinition-kind-3";
  src.kind as vt where ($this = 'datatype') and (src.id in ('boolean' | 'integer' | 'string' | 'decimal' | 'uri' | 'base64Binary' | 'instant' | 'date' | 'dateTime' | 'time' | 'code' | 'oid' | 'id' | 'markdown' | 'unsignedInt' | 'positiveInt')).not() -> tgt.kind = 'complex-type' as vt "StructureDefinition-kind-4";
  src.abstract -> tgt.abstract "StructureDefinition-abstract";
  src.contextType -> tgt.contextType "StructureDefinition-contextType";
  src.context -> tgt.context "StructureDefinition-context";
  src.constrainedType -> tgt.type "StructureDefinition-type";
  src.base -> tgt.baseDefinition "StructureDefinition-baseDefinition";
  src.snapshot as vs0 -> tgt.snapshot as vt0 then {
    vs0.element first as vs ->  vt0.element as vt,  create('boolean') as first,  first.value = 'true' then ElementDefinition(vs, vt, first) "snapshot-element-1";
    vs0.element not_first as vs ->  vt0.element as vt,  create('boolean') as first,  first.value = 'false' then ElementDefinition(vs, vt, first) "snapshot-element-2";
  } "StructureDefinition-snapshot";
  src.differential first as vs0 -> tgt.differential as vt0 then {
    vs0.element first as vs ->  vt0.element as vt,  create('boolean') as first,  first.value = 'true' then ElementDefinition(vs, vt, first) "differential-element-1";
    vs0.element not_first as vs ->  vt0.element as vt,  create('boolean') as first,  first.value = 'false' then ElementDefinition(vs, vt, first) "differential-element-2";
  } "StructureDefinition-differential";
}