FHIR Extensions Pack
5.1.0 - 5.1.0 (April 2024) International flag

This page is part of the FHIR Core Extensions Registry (v5.1.0: Release 5.1) based on FHIR (HL7® FHIR® Standard) v5.0.0. This is the current published version. For a full list of available versions, see the Directory of published versions

StructureMap: FML Conversion for Encounter: R5 to R4B

Official URL: http://hl7.org/fhir/StructureMap/Encounter5to4B Version: 5.1.0
Standards status: Trial-use Maturity Level: 1 Computable Name: Encounter5to4B

FMLConversionforEncounterR5toR4B

/// url = 'http://hl7.org/fhir/StructureMap/Encounter5to4B'
/// name = 'Encounter5to4B'
/// title = 'FML Conversion for Encounter: R5 to R4B'
/// status = 'active'

conceptmap "EncounterLocationStatus" {
  prefix s = "http://hl7.org/fhir/encounter-location-status"
  prefix t = "http://hl7.org/fhir/4.3/encounter-location-status"

  s:planned - t:planned
  s:active - t:active
  s:reserved - t:reserved
  s:completed - t:completed
}

conceptmap "EncounterStatus" {
  prefix s = "http://hl7.org/fhir/encounter-status"
  prefix t = "http://hl7.org/fhir/4.3/encounter-status"

  s:planned - t:planned
  s:"in-progress" - t:triaged
  s:"on-hold" - t:onleave
  s:discharged - t:finished
  s:completed - t:finished
  s:cancelled - t:cancelled
  s:discontinued - t:cancelled
  s:"entered-in-error" - t:"entered-in-error"
  s:unknown - t:unknown
}

uses "http://hl7.org/fhir/StructureDefinition/Encounter" alias EncounterR5 as source
uses "http://hl7.org/fhir/4.3/StructureDefinition/Encounter" alias EncounterR4B as target

imports "http://hl7.org/fhir/StructureMap/*5to4B"

group Encounter(source src : EncounterR5, target tgt : EncounterR4B) extends DomainResource <<type+>> {
  src.identifier -> tgt.identifier;
  src.status as v -> tgt.status = translate(v, '#EncounterStatus', 'code');
  src.class as s -> tgt then {
    s.coding as sc -> tgt.class as t then Coding(sc, t);
  }; // src.class as s -> tgt.class = create('Coding') as tc, tc.system = (s.system), tc.code = (s.code), tc.display = s.display;
  src.priority -> tgt.priority;
  src.type -> tgt.type;
  src.serviceType -> tgt.serviceType;
  src.subject -> tgt.subject;
  src.episodeOfCare -> tgt.episodeOfCare; // src.subjectStatus -> tgt.subjectStatus;
  src.basedOn -> tgt.basedOn;
  src.partOf -> tgt.partOf; // src.careTeam -> tgt.careTeam;
  src.serviceProvider -> tgt.serviceProvider;
  src.participant as s -> tgt.participant as t then EncounterParticipant(s, t);
  src.appointment -> tgt.appointment;
  src.actualPeriod -> tgt.period; // src.virtualService -> tgt.virtualService;
  src.length -> tgt.length; // src.plannedStartDate -> tgt.plannedStartDate;
  src.diagnosis as s -> tgt.diagnosis as t then EncounterDiagnosis(s, t); // src.reason as s -> tgt.reason as t then EncounterReason(s,t);
  src.account -> tgt.account;
  src.admission as s -> tgt.hospitalization as t then EncounterAdmission(s, t); // src.dietPreference -> tgt.dietPreference;
  src.location as s -> tgt.location as t then EncounterLocation(s, t);
}

group EncounterParticipant(source src, target tgt) extends BackboneElement {
  src.type -> tgt.type;
  src.period -> tgt.period;
  src.actor -> tgt.individual;
}

// group EncounterReason(source src, target tgt) extends BackboneElement {
// src.use -> tgt.use;
// src.value -> tgt.value;
// }
group EncounterDiagnosis(source src, target tgt) extends BackboneElement {
  src.condition -> tgt.condition;
  src.use -> tgt.use;
}

group EncounterAdmission(source src, target tgt) extends BackboneElement {
  src.preAdmissionIdentifier -> tgt.preAdmissionIdentifier;
  src.origin -> tgt.origin;
  src.admitSource -> tgt.admitSource;
  src.reAdmission -> tgt.reAdmission;
  src.destination -> tgt.destination;
  src.dischargeDisposition -> tgt.dischargeDisposition;
}

group EncounterLocation(source src, target tgt) extends BackboneElement {
  src.location -> tgt.location;
  src.status as v -> tgt.status = translate(v, '#EncounterLocationStatus', 'code');
  src.form -> tgt.physicalType;
  src.period -> tgt.period;
}