Current Build
Structured Documents Work GroupMaturity Level: N/AStandards Status: InformativeSecurity Category: Not Classified Compartments: Device, Encounter, Patient, Practitioner, RelatedPerson

R3 : R4 Conversion maps for DocumentReference.

Functional status for this map: 1 test of which 1 fail to execute. (see documentation)

map "http://hl7.org/fhir/StructureMap/DocumentReference3to4" = "R3 to R4 Conversions for DocumentReference"

uses "http://hl7.org/fhir/3.0/StructureDefinition/DocumentReference" alias DocumentReferenceR3 as source
uses "http://hl7.org/fhir/StructureDefinition/DocumentReference" alias DocumentReference as target

imports "http://hl7.org/fhir/StructureMap/*3to4"

group DocumentReference(source src : DocumentReferenceR3, target tgt : DocumentReference) extends DomainResource <<type+>> {
  src.masterIdentifier -> tgt.masterIdentifier;
  src.identifier -> tgt.identifier;
  src.status -> tgt.status;
  src.docStatus -> tgt.docStatus;
  src.type -> tgt.type;
  src.class -> tgt.category;
  src.subject -> tgt.subject;
  src.indexed -> tgt.date;
  src.created as vs ->  tgt.extension as ext,  ext.url = "http://hl7.org/fhir/StructureDefinition/X34-dr-created",  ext.value = vs;
  src.author as s -> tgt.agent as t then agent(s, t);
  src.authenticator -> tgt.authenticator;
  src.custodian -> tgt.custodian;
  src.relatesTo as vs0 -> tgt.relatesTo as vt0 then relatesTo(vs0, vt0);
  src.description -> tgt.description;
  src.securityLabel -> tgt.securityLabel;
  src.content as vs0 -> tgt.content as vt0 then content(vs0, vt0);
  src.context as vs0 -> tgt.context as vt0 then context(vs0, vt0);
}

group agent(source src, target tgt) extends BackboneElement {
  src -> tgt.type as cc, cc.coding as c, c.system = 'http://terminology.hl7.org/CodeSystem/v3-ParticipationType', c.code = 'AUT';
  src -> tgt.who as vt0 then Reference(src, vt0);
}

group relatesTo(source src, target tgt) extends BackboneElement {
  src.code -> tgt.code;
  src.target -> tgt.target;
}

group content(source src, target tgt) extends BackboneElement {
  src.attachment -> tgt.attachment;
  src.format -> tgt.format;
}

group context(source src, target tgt) extends BackboneElement {
  src.encounter -> tgt.encounter;
  src.event -> tgt.event;
  src.period -> tgt.period;
  src.facilityType -> tgt.facilityType;
  src.practiceSetting -> tgt.practiceSetting;
  src.sourcePatientInfo -> tgt.sourcePatientInfo;
  src.related as vs0 -> tgt.related as vt0 then related(vs0, vt0);
}

group related(source src, target tgt) {
  src.identifier as vs0 then Identifier2Reference(vs0, tgt);
  src.ref as vs0 then Reference(vs0, tgt);
}


map "http://hl7.org/fhir/StructureMap/DocumentReference4to3" = "R4 to R3 Conversion for DocumentReference"

uses "http://hl7.org/fhir/StructureDefinition/DocumentReference" alias DocumentReference as source
uses "http://hl7.org/fhir/3.0/StructureDefinition/DocumentReference" alias DocumentReferenceR3 as target

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

group DocumentReference(source src : DocumentReference, target tgt : DocumentReferenceR3) extends DomainResource <<type+>> {
  src.masterIdentifier -> tgt.masterIdentifier;
  src.identifier -> tgt.identifier;
  src.status -> tgt.status;
  src.docStatus -> tgt.docStatus;
  src.type -> tgt.type;
  src.category -> tgt.class;
  src.subject -> tgt.subject;
  src.date -> tgt.indexed;
  src.extension as ext where url = 'http://hl7.org/fhir/StructureDefinition/X34-dr-created' then {
    ext.value as vs0 -> tgt.created = vs0 "created2";
  } "created";
  src.agent as s where type.coding.where(system = 'http://terminology.hl7.org/CodeSystem/v3-ParticipationType' and code = 'AUT').exists() -> tgt.author as t then agent(s, t);
  src.authenticator -> tgt.authenticator;
  src.custodian -> tgt.custodian;
  src.relatesTo as vs0 -> tgt.relatesTo as vt0 then relatesTo(vs0, vt0);
  src.description -> tgt.description;
  src.securityLabel -> tgt.securityLabel;
  src.content as vs0 -> tgt.content as vt0 then content(vs0, vt0);
  src.context as vs0 -> tgt.context as vt0 then context(vs0, vt0);
}

group agent(source src, target tgt) extends Element {
  src.who as vs0 then Reference(vs0, tgt);
}

group relatesTo(source src, target tgt) extends BackboneElement {
  src.code -> tgt.code;
  src.target -> tgt.target;
}

group content(source src, target tgt) extends BackboneElement {
  src.attachment -> tgt.attachment;
  src.format -> tgt.format;
}

group context(source src, target tgt) extends BackboneElement {
  src.encounter -> tgt.encounter;
  src.event -> tgt.event;
  src.period -> tgt.period;
  src.facilityType -> tgt.facilityType;
  src.practiceSetting -> tgt.practiceSetting;
  src.sourcePatientInfo -> tgt.sourcePatientInfo;
  src.related as vs0 -> tgt.related as vt0 then related(vs0, vt0);
}

group related(source src, target tgt) {
  src where reference.exists() -> tgt.ref as vt0 then ReferenceNoIdentifier(src, vt0);
  src where identifier.exists() -> tgt.identifier as vt0 then Reference2Identifier(src, vt0);
}


<p>No validation errors - all conversions are clean</p>