R4 Draft for Comment

This page is part of the FHIR Specification (v3.2.0: R4 Ballot 1). The current version which supercedes this version is 5.0.0. For a full list of available versions, see the Directory of published versions . Page versions: R5 R4B R4 R3

Patient Administration Work GroupMaturity Level: N/ABallot Status: Informative Compartments: Encounter, Patient, Practitioner, RelatedPerson

R2 : R3 Conversion maps for Encounter.

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

map "http://hl7.org/fhir/StructureMap/Encounter2to3" = "R2 to R3 Conversions for Encounter"

conceptmap "ActEncounterCode" {
  prefix s = "http://hl7.org/fhir/encounter-class"
  prefix t = "http://hl7.org/fhir/v3/ActCode"

  s:inpatient	= t:IMP
  s:outpatient	= t:AMB
  s:ambulatory	= t:AMB
  s:emergency	= t:EMER
  s:home	= t:HH
  s:field	= t:FLD
  s:daytime	= t:SS
  s:virtual	= t:VR
  s:other	= s:other
}


uses "http://hl7.org/fhir/DSTU2/StructureDefinition/Encounter" alias EncounterR2 as source
uses "http://hl7.org/fhir/StructureDefinition/Encounter" alias Encounter as target

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

group for type+types  Encounter extends DomainResource
  input src : EncounterR2 as source
  input tgt : Encounter as target

  "Encounter-identifier" : for src.identifier make tgt.identifier
  "Encounter-status" : for src.status make tgt.status
  "Encounter-statusHistory" : for src.statusHistory as vs0 make tgt.statusHistory as vt0 then encStatusHistory(vs0, vt0) 
  "Encounter-class" : for src.class as v make tgt.class = translate(v, "#ActEncounterCode", "Coding")
  "Encounter-type" : for src.type make tgt.type
  "Encounter-priority" : for src.priority make tgt.priority
  "Encounter-patient" : for src.patient make tgt.subject
  "Encounter-episodeOfCare" : for src.episodeOfCare make tgt.episodeOfCare
  "Encounter-incomingReferral" : for src.incomingReferral make tgt.incomingReferral
  "Encounter-participant" : for src.participant as vs0 make tgt.participant as vt0 then encParticipant(vs0, vt0)
  "Encounter-appointment" : for src.appointment make tgt.appointment
  "Encounter-period" : for src.period make tgt.period
  "Encounter-length" : for src.length as vs make tgt.length as vt then QuantityToDuration(vs, vt)
  "Encounter-reason" : for src.reason make tgt.reason
  "Encounter-indication" : for src.indication as v make tgt.diagnosis as d, d.condition = v
  "Encounter-hospitalization" : for src.hospitalization as vs0 make tgt.hospitalization as vt0 then encHospitaization(vs0, vt0, tgt) 
  "Encounter-location" : for src.location as vs0 make tgt.location as vt0 then encLocation(vs0, vt0)
  "Encounter-serviceProvider" : for src.serviceProvider make tgt.serviceProvider
  "Encounter-partOf" : for src.partOf make tgt.partOf
endgroup

group encStatusHistory extends BackboneElement
  input src as source
  input tgt as target

  "Encounter.statusHistory-status" : for src.status make tgt.status
  "Encounter.statusHistory-period" : for src.period make tgt.period
endgroup

group encParticipant extends BackboneElement
  input src as source
  input tgt as target

  "Encounter.participant-type" : for src.type make tgt.type
  "Encounter.participant-period" : for src.period make tgt.period
  "Encounter.participant-individual" : for src.individual make tgt.individual
endgroup

group encHospitaization extends BackboneElement
  input src as source
  input tgt as target
  input res as target

  "Encounter.hospitalization-preAdmissionIdentifier" : for src.preAdmissionIdentifier make tgt.preAdmissionIdentifier
  "Encounter.hospitalization-origin" : for src.origin make tgt.origin
  "Encounter.hospitalization-admitSource" : for src.admitSource make tgt.admitSource
  "Encounter.hospitalization-admittingDiagnosis" : for src.admittingDiagnosis as v make tgt.diagnosis as d, d.role = cc("http://hl7.org/fhir/diagnosis-role", "AD"), d.condition = v
  "Encounter.hospitalization-reAdmission" : for src.reAdmission make tgt.reAdmission
  "Encounter.hospitalization-dietPreference" : for src.dietPreference make tgt.dietPreference
  "Encounter.hospitalization-specialCourtesy" : for src.specialCourtesy make tgt.specialCourtesy
  "Encounter.hospitalization-specialArrangement" : for src.specialArrangement make tgt.specialArrangement
  "Encounter.hospitalization-destination" : for src.destination make tgt.destination
  "Encounter.hospitalization-dischargeDisposition" : for src.dischargeDisposition make tgt.dischargeDisposition
  "Encounter.hospitalization-dischargeDiagnosis" : for src.dischargeDiagnosis as v make tgt.diagnosis as d, d.role = cc("http://hl7.org/fhir/diagnosis-role", "DD"), d.condition = v

endgroup

group encLocation extends BackboneElement
  input src as source
  input tgt as target

  "Encounter.location-location" : for src.location make tgt.location
  "Encounter.location-status" : for src.status make tgt.status
  "Encounter.location-period" : for src.period make tgt.period
endgroup

map "http://hl7.org/fhir/StructureMap/Encounter3to2" = "R3 to R2 Conversion for Encounter"

conceptmap "ActEncounterCode" {
  prefix s = "http://hl7.org/fhir/encounter-class"
  prefix t = "http://hl7.org/fhir/v3/ActCode"

  t:IMP	= s:inpatient
  t:AMB	= s:outpatient
  t:AMB	= s:ambulatory
  t:EMER	= s:emergency
  t:HH	= s:home
  t:FLD	= s:field
  t:SS	= s:daytime
  t:VR	= s:virtual
}


uses "http://hl7.org/fhir/StructureDefinition/Encounter" alias Encounter as source
uses "http://hl7.org/fhir/DSTU2/StructureDefinition/Encounter" alias EncounterR2 as target

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

group for type+types  Encounter extends DomainResource
  input src : Encounter as source
  input tgt : EncounterR2 as target

  "Encounter-identifier" : for src.identifier make tgt.identifier
  "Encounter-status" : for src.status check status != 'entered-in-error' make tgt.status
  "Encounter-statusHistory" : for src.statusHistory as vs0 make tgt.statusHistory as vt0 then encStatusHistory(vs0, vt0) 
  "Encounter-class" : for src.class as v make tgt.class = translate(v, "#ActEncounterCode", "code")
  "Encounter-type" : for src.type make tgt.type
  "Encounter-priority" : for src.priority make tgt.priority
  "Encounter-patient" : for src.subject make tgt.patient
  "Encounter-episodeOfCare" : for src.episodeOfCare make tgt.episodeOfCare
  "Encounter-incomingReferral" : for src.incomingReferral make tgt.incomingReferral
  "Encounter-participant" : for src.participant as vs0 make tgt.participant as vt0 then encParticipant(vs0, vt0)
  "Encounter-appointment" : for src.appointment make tgt.appointment
  "Encounter-period" : for src.period make tgt.period
  "Encounter-length" : for src.length as vs make tgt.length as vt then DurationToQuantity(vs, vt)
  "Encounter-reason" : for src.reason make tgt.reason
  "Encounter-indication" : for src.diagnosis as d then encDiagnosis(d, tgt)
  "Encounter-hospitalization" : for src.hospitalization as vs0 make tgt.hospitalization as vt0 then encHospitaization(vs0, vt0) 
  "Encounter-location" : for src.location as vs0 make tgt.location as vt0 then encLocation(vs0, vt0)
  "Encounter-serviceProvider" : for src.serviceProvider make tgt.serviceProvider
  "Encounter-partOf" : for src.partOf make tgt.partOf
endgroup

group encDiagnosis extends BackboneElement
  input src as source
  input tgt as target

  "Encounter.indication-condition1" : for src.condition as v where src.role.coding.code.contains("AD").not() and role.coding.code.contains("DD").not() make tgt.indication = v
  "Encounter.indication-condition2" : for src.condition as v where src.role.coding.code.contains("AD") make tgt.hospitalization as h, h.admittingDiagnosis = v
  "Encounter.indication-condition3" : for src.condition as v where src.role.coding.code.contains("DD") make tgt.hospitalization as h, h.dischargeDiagnosis = v
endgroup

group encStatusHistory extends BackboneElement
  input src as source
  input tgt as target

  "Encounter.statusHistory-status" : for src.status make tgt.status
  "Encounter.statusHistory-period" : for src.period make tgt.period
endgroup

group encParticipant extends BackboneElement
  input src as source
  input tgt as target

  "Encounter.participant-type" : for src.type make tgt.type
  "Encounter.participant-period" : for src.period make tgt.period
  "Encounter.participant-individual" : for src.individual make tgt.individual
endgroup

group encHospitaization extends BackboneElement
  input src as source
  input tgt as target

  "Encounter.hospitalization-preAdmissionIdentifier" : for src.preAdmissionIdentifier make tgt.preAdmissionIdentifier
  "Encounter.hospitalization-origin" : for src.origin make tgt.origin
  "Encounter.hospitalization-admitSource" : for src.admitSource make tgt.admitSource
  "Encounter.hospitalization-reAdmission" : for src.reAdmission make tgt.reAdmission
  "Encounter.hospitalization-dietPreference" : for src.dietPreference make tgt.dietPreference
  "Encounter.hospitalization-specialCourtesy" : for src.specialCourtesy make tgt.specialCourtesy
  "Encounter.hospitalization-specialArrangement" : for src.specialArrangement make tgt.specialArrangement
  "Encounter.hospitalization-destination" : for src.destination make tgt.destination
  "Encounter.hospitalization-dischargeDisposition" : for src.dischargeDisposition make tgt.dischargeDisposition

endgroup

group encLocation extends BackboneElement
  input src as source
  input tgt as target

  "Encounter.location-location" : for src.location make tgt.location
  "Encounter.location-status" : for src.status make tgt.status
  "Encounter.location-period" : for src.period make tgt.period
endgroup

encounter-example
  • ERROR @ Encounter.extension: The extension http://hl7.org/fhir/StructureDefinition/encounter-relatedCondition is unknown, and not allowed here (src = InstanceValidator)
f202
  • ERROR @ Encounter.length: There SHALL be a code if there is a value and it SHALL be an expression of time. If system is present, it SHALL be UCUM. [code.exists() implies ((system = %ucum) and value.exists())] (src = InstanceValidator)