FHIR Release 3 (STU) 5 Preview #3
This page is part of the FHIR Specification (v3.0.2: STU 3). The current version which supercedes this version is 4.0.1 . For a full list of available versions, see the Directory of published versions
Public Health and Emergency Response Work Group Maturity Level : N/A Ballot Standards Status : Informative Security Category : Patient Compartments : Patient , Practitioner

R2 : R3 Converson : R4 Conversion maps for Immunization.

Functional status for this map: 2 3 tests that all execute ok. 2 fail All tests pass round-trip testing and 2 3 r3 resources are invalid (2 (0 errors). ( see documentation)

map "http://hl7.org/fhir/StructureMap/Immunization2to3" = "R2 to R3 Conversions for Immunization"
map "http://hl7.org/fhir/StructureMap/Immunization3to4" = "R3 to R4 Conversions for Immunization"
uses "http://hl7.org/fhir/DSTU2/StructureDefinition/Immunization" alias ImmunizationR2 as source

uses "http://hl7.org/fhir/3.0/StructureDefinition/Immunization" alias ImmunizationR3 as source

uses "http://hl7.org/fhir/StructureDefinition/Immunization" alias Immunization as target
imports "http://hl7.org/fhir/StructureMap/*2to3"

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

group for type+types  Immunization extends DomainResource
  input src : ImmunizationR2 as source
  input tgt : Immunization as target

group Immunization(source src : ImmunizationR3, target tgt : Immunization) extends DomainResource <<type+>> {
  src.identifier -> tgt.identifier;
  src.status -> tgt.status;
  src.notGiven where value = true -> tgt.status = 'not-done';
  src.notGiven as v ->  tgt.extension as vt,  vt.url = 'http://hl7.org/fhir/3.0/StructureDefinition/extension-Immunization.notGiven',  vt.value = v;
  src.vaccineCode -> tgt.vaccineCode;
  src.patient -> tgt.patient;
  src.encounter -> tgt.encounter;
  src.date as vs -> tgt.occurrence = create('dateTime') as vt then dateTime(vs, vt);
  src.primarySource -> tgt.primarySource;
  src.reportOrigin -> tgt.reportOrigin;
  src.location -> tgt.location;
  src.manufacturer -> tgt.manufacturer;
  src.lotNumber -> tgt.lotNumber;
  src.expirationDate -> tgt.expirationDate;
  src.site -> tgt.site;
  src.route -> tgt.route;
  src.doseQuantity -> tgt.doseQuantity;
  src.practitioner as vs -> tgt.performer as vt then practitioner(vs, vt);
  src.note -> tgt.note;
  src.explanation as s then {
    s.reason -> tgt.reasonCode;
    s.reasonNotGiven -> tgt.reasonCode;
  };
  src.reaction as vs -> tgt.reaction as vt then reaction(vs, vt);
  src.vaccinationProtocol as vs -> tgt.protocolApplied as vt then protocol(vs, vt);
}

  "Immunization-identifier" : for src.identifier make tgt.identifier
  "Immunization-status" : for src.status where $this = 'completed' or $this = 'entered-in-error' make tgt.status
  "Immunization-date" : for src.date make tgt.date
  "Immunization-vaccineCode" : for src.vaccineCode make tgt.vaccineCode
  "Immunization-patient" : for src.patient make tgt.patient
  "Immunization-wasNotGiven" : for src.wasNotGiven make tgt.notGiven
  "Immunization-performer" : for src.performer as v make tgt.practitioner as p, p.role = cc("http://hl7.org/fhir/v2/0443", "AP"), p.actor = v
  "Immunization-requester" : for src.requester as v make tgt.practitioner as p, p.role = cc("http://hl7.org/fhir/v2/0443", "OP"), p.actor = v
  "Immunization-encounter" : for src.encounter make tgt.encounter
  "Immunization-manufacturer" : for src.manufacturer make tgt.manufacturer
  "Immunization-location" : for src.location make tgt.location
  "Immunization-lotNumber" : for src.lotNumber make tgt.lotNumber
  "Immunization-expirationDate" : for src.expirationDate make tgt.expirationDate
  "Immunization-site" : for src.site make tgt.site
  "Immunization-route" : for src.route make tgt.route
  "Immunization-doseQuantity" : for src.doseQuantity make tgt.doseQuantity
  "Immunization-note" : for src.note make tgt.note
  "Immunization-explanation" : for src.explanation as vs0 make tgt.explanation as vt0 then immExplanation(vs0, vt0)
  "Immunization-reaction" : for src.reaction as vs0 make tgt.reaction as vt0 then immReaction(vs0, vt0)
  "Immunization-vaccinationProtocol" : for src.vaccinationProtocol as vs0 make tgt.vaccinationProtocol as vt0 then immProtocol(vs0, vt0)
endgroup

group practitioner(source src, target tgt) extends BackboneElement {
  src.role -> tgt.function;
  src.actor -> tgt.actor;
}

group immExplanation extends BackboneElement
  input src as source
  input tgt as target
  
  "Immunization.explanation-reason" : for src.reason make tgt.reason
  "Immunization.explanation-reasonNotGiven" : for src.reasonNotGiven make tgt.reasonNotGiven
endgroup

group reaction(source src, target tgt) extends BackboneElement {
  src.date -> tgt.date;
  src.detail -> tgt.detail;
  src.reported -> tgt.reported;
}

group immReaction extends BackboneElement
  input src as source
  input tgt as target
  
  "Immunization.reaction-date" : for src.date make tgt.date
  "Immunization.reaction-detail" : for src.detail make tgt.detail
  "Immunization.reaction-reported" : for src.reported make tgt.reported
endgroup

group protocol(source src, target tgt) extends BackboneElement {
  src.doseSequence as vs -> tgt.doseNumber = create('positiveInt') as vt then positiveInt(vs, vt);
  src.description as v ->  tgt.extension as vt,  vt.url = 'http://hl7.org/fhir/3.0/StructureDefinition/extension-Immunization.vaccinationProtocol.description',  vt.value = v;
  src.authority -> tgt.authority;
  src.series -> tgt.series;
  src.seriesDoses as vs -> tgt.seriesDoses = create('positiveInt') as vt then positiveInt(vs, vt);
  src.targetDisease -> tgt.targetDisease;
  src.doseStatus as v ->  tgt.extension as vt,  vt.url = 'http://hl7.org/fhir/3.0/StructureDefinition/extension-Immunization.vaccinationProtocol.doseStatus',  vt.value = v;
  src.doseStatusReason as v ->  tgt.extension as vt,  vt.url = 'http://hl7.org/fhir/3.0/StructureDefinition/extension-Immunization.vaccinationProtocol.doseStatusReason',  vt.value = v;
}

group immProtocol extends BackboneElement
  input src as source
  input tgt as target
  
  "Immunization.vaccinationProtocol-doseSequence" : for src.doseSequence make tgt.doseSequence
  "Immunization.vaccinationProtocol-description" : for src.description make tgt.description
  "Immunization.vaccinationProtocol-authority" : for src.authority make tgt.authority
  "Immunization.vaccinationProtocol-series" : for src.series make tgt.series
  "Immunization.vaccinationProtocol-seriesDoses" : for src.seriesDoses make tgt.seriesDoses
  "Immunization.vaccinationProtocol-targetDisease" : for src.targetDisease make tgt.targetDisease
  "Immunization.vaccinationProtocol-doseStatus" : for src.doseStatus make tgt.doseStatus
  "Immunization.vaccinationProtocol-doseStatusReason" : for src.doseStatusReason make tgt.doseStatusReason
endgroup
  

map "http://hl7.org/fhir/StructureMap/Immunization3to2" = "R3 to R2 Conversion for Immunization"
map "http://hl7.org/fhir/StructureMap/Immunization4to3" = "R4 to R3 Conversion for Immunization"
uses "http://hl7.org/fhir/StructureDefinition/Immunization" alias Immunization as source
uses "http://hl7.org/fhir/DSTU2/StructureDefinition/Immunization" alias ImmunizationR2 as target

uses "http://hl7.org/fhir/3.0/StructureDefinition/Immunization" alias ImmunizationR3 as target

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

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

group for type+types  Immunization extends DomainResource
  input src : Immunization as source
  input tgt : ImmunizationR2 as target

group Immunization(source src : Immunization, target tgt : ImmunizationR3) extends DomainResource <<type+>> {
  src.identifier -> tgt.identifier;
  src.status where value != 'not-done' -> tgt.status;
  src.status where value = 'not-done' ->  tgt.status = 'completed',  tgt.notGiven = true;
  src.extension as e where url = 'http://hl7.org/fhir/3.0/StructureDefinition/extension-Immunization.notGiven' then {
    e.value -> tgt.notGiven;
  };
  src.vaccineCode -> tgt.vaccineCode;
  src.patient -> tgt.patient;
  src.encounter -> tgt.encounter;
  src.occurrence : dateTime as vs -> tgt.date as vt then dateTime(vs, vt);
  src.primarySource -> tgt.primarySource;
  src.reportOrigin -> tgt.reportOrigin;
  src.location -> tgt.location;
  src.manufacturer -> tgt.manufacturer;
  src.lotNumber -> tgt.lotNumber;
  src.expirationDate -> tgt.expirationDate;
  src.site -> tgt.site;
  src.route -> tgt.route;
  src.doseQuantity -> tgt.doseQuantity;
  src.performer as vs -> tgt.practitioner as vt then practitioner(vs, vt);
  src.note -> tgt.note;
  src.reasonCode as vs where src.status != 'not-done' ->  tgt.explanation as t,  t.reason = vs;
  src.reasonCode as vs where src.status = 'not-done' ->  tgt.explanation as t,  t.reasonNotGiven = vs;
  src.reaction as vs -> tgt.reaction as vt then reaction(vs, vt);
  src.protocolApplied as vs -> tgt.vaccinationProtocol as vt then protocol(vs, vt);
}

  "Immunization-identifier" : for src.identifier make tgt.identifier
  "Immunization-status" : for src.status make tgt.status
  "Immunization-date" : for src.date make tgt.date
  "Immunization-vaccineCode" : for src.vaccineCode make tgt.vaccineCode
  "Immunization-patient" : for src.patient make tgt.patient
  "Immunization-wasNotGiven" : for src.notGiven make tgt.wasNotGiven
  // can't translate reported
  "Immunization-performer" : for src.practitioner as v where v.role.coding.code.contains("AP") then {
    "Immunization-performer-inner" : for v.actor make tgt.performer 
  }
  "Immunization-requester" : for src.practitioner as v where v.role.coding.code.contains("OP") then {
    "Immunization-requester-inner" : for v.actor make tgt.requester 
  }
  "Immunization-encounter" : for src.encounter make tgt.encounter
  "Immunization-manufacturer" : for src.manufacturer make tgt.manufacturer
  "Immunization-location" : for src.location make tgt.location
  "Immunization-lotNumber" : for src.lotNumber make tgt.lotNumber
  "Immunization-expirationDate" : for src.expirationDate make tgt.expirationDate
  "Immunization-site" : for src.site make tgt.site
  "Immunization-route" : for src.route make tgt.route
  "Immunization-doseQuantity" : for src.doseQuantity make tgt.doseQuantity
  "Immunization-note" : for src.note make tgt.note
  "Immunization-explanation" : for src.explanation as vs0 make tgt.explanation as vt0 then immExplanation(vs0, vt0)
  "Immunization-reaction" : for src.reaction as vs0 make tgt.reaction as vt0 then immReaction(vs0, vt0)
  "Immunization-vaccinationProtocol" : for src.vaccinationProtocol as vs0 make tgt.vaccinationProtocol as vt0 then immProtocol(vs0, vt0)
endgroup

group practitioner(source src, target tgt) extends BackboneElement {
  src.function -> tgt.role;
  src.actor -> tgt.actor;
}

group immExplanation extends BackboneElement
  input src as source
  input tgt as target
  
  "Immunization.explanation-reason" : for src.reason make tgt.reason
  "Immunization.explanation-reasonNotGiven" : for src.reasonNotGiven make tgt.reasonNotGiven
endgroup

group reaction(source src, target tgt) extends BackboneElement {
  src.date -> tgt.date;
  src.detail -> tgt.detail;
  src.reported -> tgt.reported;
}

group immReaction extends BackboneElement
  input src as source
  input tgt as target
  
  "Immunization.reaction-date" : for src.date make tgt.date
  "Immunization.reaction-detail" : for src.detail make tgt.detail
  "Immunization.reaction-reported" : for src.reported make tgt.reported
endgroup

group protocol(source src, target tgt) extends BackboneElement {
  src.doseNumber : positiveInt as vs -> tgt.doseSequence as vt then positiveInt(vs, vt);
  src.extension as e where url = 'http://hl7.org/fhir/3.0/StructureDefinition/extension-Immunization.vaccinationProtocol.description' then {
    e.value -> tgt.description;
  };
  src.authority -> tgt.authority;
  src.series -> tgt.series;
  src.seriesDoses : positiveInt as vs -> tgt.seriesDoses as vt then positiveInt(vs, vt);
  src.targetDisease -> tgt.targetDisease;
  src.extension as e where url = 'http://hl7.org/fhir/3.0/StructureDefinition/extension-Immunization.vaccinationProtocol.doseStatus' then {
    e.value -> tgt.doseStatus;
  };
  src.extension as e where url = 'http://hl7.org/fhir/3.0/StructureDefinition/extension-Immunization.vaccinationProtocol.doseStatusReason' then {
    e.value -> tgt.doseStatusReason;
  };
}

group immProtocol extends BackboneElement
  input src as source
  input tgt as target
  
  "Immunization.vaccinationProtocol-doseSequence" : for src.doseSequence make tgt.doseSequence
  "Immunization.vaccinationProtocol-description" : for src.description make tgt.description
  "Immunization.vaccinationProtocol-authority" : for src.authority make tgt.authority
  "Immunization.vaccinationProtocol-series" : for src.series make tgt.series
  "Immunization.vaccinationProtocol-seriesDoses" : for src.seriesDoses make tgt.seriesDoses
  "Immunization.vaccinationProtocol-targetDisease" : for src.targetDisease make tgt.targetDisease
  "Immunization.vaccinationProtocol-doseStatus" : for src.doseStatus make tgt.doseStatus
  "Immunization.vaccinationProtocol-doseStatusReason" : for src.doseStatusReason make tgt.doseStatusReason
endgroup
  

example ERROR @ Immunization: Profile http://hl7.org/fhir/StructureDefinition/Immunization, Element 'Immunization.primarySource': minimum required = 1, but only found 0 (src = InstanceValidator) notGiven ERROR @ Immunization: Profile http://hl7.org/fhir/StructureDefinition/Immunization, Element 'Immunization.primarySource': minimum required = 1, but only found 0 (src = InstanceValidator) <p>No validation errors - all conversions are clean</p>