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: Provenance Transforms: R4 to R3

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

ProvenanceTransformsR4toR3

/// url = 'http://hl7.org/fhir/StructureMap/Provenance4to3'
/// name = 'Provenance4to3'
/// title = 'Provenance Transforms: R4 to R3'
/// status = 'active'

uses "http://hl7.org/fhir/4.0/Provenance" alias Provenance as source
uses "http://hl7.org/fhir/3.0/Provenance" alias ProvenanceR3 as target

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

group Provenance(source src : Provenance, target tgt : ProvenanceR3) extends DomainResource <<type+>> {
  src.target -> tgt.target;
  src.occurred : Period as vs0 -> tgt.period as vt0 then Period(vs0, vt0) "period";
  src.occurred : dateTime as vs0 ->  tgt.period as vt0,  vt0.start = vs0,  vt0.end = vs0 "period";
  src.recorded -> tgt.recorded;
  src.policy -> tgt.policy;
  src.location -> tgt.location;
  src.reason -> tgt.reason;
  src.activity -> tgt.activity;
  src.agent as vs0 -> tgt.agent as vt0 then agent(vs0, vt0);
  src.entity as vs0 -> tgt.entity as vt0 then entity(vs0, vt0);
  src.signature -> tgt.signature;
}

group agent(source src : ProvenanceR3, target tgt : Provenance) extends BackboneElement {
  src.role -> tgt.role;
  src.who as vs0 where extension('http://hl7.org/fhir/3.0/StructureDefinition/BaseType').empty() -> tgt.who = create('Reference') as vt0 then Reference(vs0, vt0);
  src.who as vs0 where extension('http://hl7.org/fhir/3.0/StructureDefinition/BaseType').exists() -> tgt.who = create('uri') as vt0 then {
    vs0.reference as vs1 then uri(vs1, vt0);
  };
  src.onBehalfOf as vs0 where extension('http://hl7.org/fhir/3.0/StructureDefinition/BaseType').empty() -> tgt.onBehalfOf = create('Reference') as vt0 then Reference(vs0, vt0);
  src.onBehalfOf as vs0 where extension('http://hl7.org/fhir/3.0/StructureDefinition/BaseType').exists() -> tgt.onBehalfOf = create('uri') as vt0 then {
    vs0.reference as vs1 then uri(vs1, vt0);
  };
  src.type -> tgt.relatedAgentType;
}

group entity(source src : ProvenanceR3, target tgt : Provenance) extends BackboneElement {
  src.role -> tgt.role;
  src.what as vs0 where extension('http://hl7.org/fhir/3.0/StructureDefinition/BaseType').empty() and identifier.empty() -> tgt.what = create('Reference') as vt0 then Reference(vs0, vt0);
  src.what as vs0 where extension('http://hl7.org/fhir/3.0/StructureDefinition/BaseType').exists() -> tgt.what = create('uri') as vt0 then {
    vs0.reference as vs1 then uri(vs1, vt0);
  };
  src.what as vs0 where identifier.exists() -> tgt.what = create('Identifier') as vt0 then Reference2Identifier(vs0, vt0);
  src.agent as vs0 -> tgt.agent as vt0 then agent(vs0, vt0);
}