CDA-FHIR-Maps (R4)
0.1.1 - CI build

CDA-FHIR-Maps (R4), published by ahdis. This is not an authorized publication; it is the continuous build for version 0.1.1). This version is based on the current content of https://github.com/hl7ch/cda-fhir-maps/ and changes regularly. See the Directory of published versions

CDA-CH-EMED Medication Dispense document to Bundle

Format(s):

Narrative view

map "http://fhir.ch/ig/cda-fhir-maps/StructureMap/CdaChEmedMedicationDispenseDocumentToBundle" = "CdaChEmedMedicationDispenseDocumentToBundle"

// Medication Dispense document, 2.16.756.5.30.1.1.10.1.5
// 2020-02-11 Oliver Egger, Michaela Ziegler, copyright ahdis ag, Apache License
// CDA-CH-EMED:  https://art-decor.org/art-decor/decor-project--cdachemed-
// FHIR CH-EMED: http://fhir.ch/ig/ch-emed/index.html

uses "http://hl7.org/fhir/cda/StructureDefinition/ClinicalDocument" alias ClinicalDocument as source
uses "http://hl7.org/fhir/cda/StructureDefinition/AssignedAuthor" alias AssignedAuthor as source
uses "http://hl7.org/fhir/cda/StructureDefinition/AssignedEntity" alias AssignedEntity as source
uses "http://hl7.org/fhir/cda/StructureDefinition/Author" alias Author as source
uses "http://hl7.org/fhir/cda/StructureDefinition/CustodianOrganization" alias CustodianOrganization as source
uses "http://hl7.org/fhir/cda/StructureDefinition/IVL_TS" alias IVL_TS as source
uses "http://hl7.org/fhir/cda/StructureDefinition/EIVL_TS" alias EIVL_TS as source
uses "http://hl7.org/fhir/cda/StructureDefinition/Observation" alias Observation as source
uses "http://hl7.org/fhir/cda/StructureDefinition/PatientRole" alias PatientRole as source
uses "http://hl7.org/fhir/cda/StructureDefinition/RecordTarget" alias RecordTarget as source
uses "http://hl7.org/fhir/cda/StructureDefinition/Section" alias Section as source
uses "http://hl7.org/fhir/cda/StructureDefinition/SubstanceAdministration" alias SubstanceAdministration as source
uses "http://hl7.org/fhir/cda/StructureDefinition/Supply" alias Supply as source
uses "http://hl7.org/fhir/cda/StructureDefinition/SXPR_TS" alias SXPR_TS as source
uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as target
uses "http://hl7.org/fhir/StructureDefinition/Composition" alias Composition as produced
uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as produced
uses "http://hl7.org/fhir/StructureDefinition/Practitioner" alias Practitioner as produced
uses "http://hl7.org/fhir/StructureDefinition/Organization" alias Organization as produced
uses "http://hl7.org/fhir/StructureDefinition/MedicationDispense" alias MedicationDispense as produced
uses "http://hl7.org/fhir/StructureDefinition/Dosage" alias Dosage as produced

imports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/CdaToFhirTypes"
imports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/CdaToBundle"
imports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/CdaChToBundle"
imports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/CdaChEmedToBundle"

// source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.1.5
// target: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-composition-medicationdispense.html
group CdaChEmedMedicationDispenseDocumentToBundle(source cda : ClinicalDocument, target bundle : Bundle) {
  cda ->  bundle.entry as e,  e.resource = create('Composition') as composition,  composition.id = uuid() as uuid,  e.fullUrl = append('urn:uuid:', uuid),  bundle.entry as e2,  e2.resource = create('Patient') as patient,  patient.id = uuid() as uuid2,  e2.fullUrl = append('urn:uuid:', uuid2) then ClinicalDocumentChEmedMedicationDispenseDocumentToBundle(cda, patient, composition, bundle) "ClinicalDocumentToBody";
}

// source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.1.5
// target: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-composition-medicationdispense.html
group ClinicalDocumentChEmedMedicationDispenseDocumentToBundle(source cda : ClinicalDocument, target patient : Patient, target composition : Composition, target bundle : Bundle) extends ClinicalDocumentChToBundle {
  cda.component as component then {
    component.structuredBody as body then {
      body.component as component then {
        component.section as srcSection where (templateId.where(root = '2.16.756.5.30.1.1.10.3.11')) -> composition.section as tgtSection then SectionDispenseSectionContentModule(srcSection, patient, tgtSection, bundle);
      };
    } "body";
  };
}

// _________________________ Section Level Templates _________________________
// source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.3.11
// target: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-composition-medicationdispense.html
group SectionDispenseSectionContentModule(source src : Section, source patient : Patient, target tgt, target bundle : Bundle) extends ClinicalDocumentSection {
  src.entry as cdaEntry where (supply.templateId.where(root = '2.16.756.5.30.1.1.10.4.42')) ->  bundle.entry as e,  e.resource = create('MedicationDispense') as medicationdispense,  medicationdispense.id = uuid() as uuid,  e.fullUrl = append('urn:uuid:', uuid),  tgt.entry = create('Reference') as reference,  reference.type = 'MedicationDispense',  reference.reference = append('urn:uuid:', uuid) then {
    cdaEntry.supply as supply then DispenseItemEntryContentModule(src, supply, patient, medicationdispense);
  } "DispenseItemEntryContentModule";
}