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: Encounter Transforms: R3 to R2

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

EncounterTransformsR3toR2

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

uses "http://hl7.org/fhir/3.0/Encounter" alias Encounter as source
uses "http://hl7.org/fhir/1.0/Encounter" alias EncounterR2 as target

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

group Encounter(source src : Encounter, target tgt : EncounterR2) extends DomainResource <<type+>> {
  src.identifier -> tgt.identifier "Encounter-identifier";
  src.status check status != 'entered-in-error' -> tgt.status "Encounter-status";
  src.statusHistory as vs0 -> tgt.statusHistory as vt0 then encStatusHistory(vs0, vt0) "Encounter-statusHistory";
  src.class as v -> tgt.class = translate(v, 'http://hl7.org/fhir/ConceptMap/Encounter.class-R3toR2', 'code') "Encounter-class";
  src.type -> tgt.type "Encounter-type";
  src.priority -> tgt.priority "Encounter-priority";
  src.subject -> tgt.patient "Encounter-patient";
  src.episodeOfCare -> tgt.episodeOfCare "Encounter-episodeOfCare";
  src.incomingReferral -> tgt.incomingReferral "Encounter-incomingReferral";
  src.participant as vs0 -> tgt.participant as vt0 then encParticipant(vs0, vt0) "Encounter-participant";
  src.appointment -> tgt.appointment "Encounter-appointment";
  src.period -> tgt.period "Encounter-period";
  src.length as vs -> tgt.length as vt then DurationToQuantity(vs, vt) "Encounter-length";
  src.reason -> tgt.reason "Encounter-reason";
  src.diagnosis as d then encDiagnosis(d, tgt) "Encounter-indication";
  src.hospitalization as vs0 -> tgt.hospitalization as vt0 then encHospitaization(vs0, vt0) "Encounter-hospitalization";
  src.location as vs0 -> tgt.location as vt0 then encLocation(vs0, vt0) "Encounter-location";
  src.serviceProvider -> tgt.serviceProvider "Encounter-serviceProvider";
  src.partOf -> tgt.partOf "Encounter-partOf";
}

group encDiagnosis(source src, target tgt) extends BackboneElement {
  src.condition as v where src.role.coding.code.contains('AD').not() and role.coding.code.contains('DD').not() -> tgt.indication = v "indication-condition1";
  src.condition as v where src.role.coding.code.contains('AD') ->  tgt.hospitalization as h,  h.admittingDiagnosis = v "indication-condition2";
  src.condition as v where src.role.coding.code.contains('DD') ->  tgt.hospitalization as h,  h.dischargeDiagnosis = v "indication-condition3";
}

group encStatusHistory(source src, target tgt) extends BackboneElement {
  src.status -> tgt.status "statusHistory-status";
  src.period -> tgt.period "statusHistory-period";
}

group encParticipant(source src, target tgt) extends BackboneElement {
  src.type -> tgt.type "participant-type";
  src.period -> tgt.period "participant-period";
  src.individual -> tgt.individual "participant-individual";
}

group encHospitaization(source src, target tgt) extends BackboneElement {
  src.preAdmissionIdentifier -> tgt.preAdmissionIdentifier "hospitalization-preAdmissionIdentifier";
  src.origin -> tgt.origin "hospitalization-origin";
  src.admitSource -> tgt.admitSource "hospitalization-admitSource";
  src.reAdmission -> tgt.reAdmission "hospitalization-reAdmission";
  src.dietPreference -> tgt.dietPreference "hospitalization-dietPreference";
  src.specialCourtesy -> tgt.specialCourtesy "hospitalization-specialCourtesy";
  src.specialArrangement -> tgt.specialArrangement "hospitalization-specialArrangement";
  src.destination -> tgt.destination "hospitalization-destination";
  src.dischargeDisposition -> tgt.dischargeDisposition "hospitalization-dischargeDisposition";
}

group encLocation(source src, target tgt) extends BackboneElement {
  src.location -> tgt.location "location-location";
  src.status -> tgt.status "location-status";
  src.period -> tgt.period "location-period";
}