CDA-FHIR-Maps (R4)
0.3.0 - DSTU 1

This page is part of the CDA-FHIR-Maps (R4) (v0.3.0: DSTU 1) based on FHIR R4. . For a full list of available versions, see the Directory of published versions

StructureMap: Bundle to CDA-CH-EMED Pharmaceutical Advice document

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

// Pharmaceutical Advice document, 2.16.756.5.30.1.1.10.1.6
// 2020-11-12 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 target
uses "http://hl7.org/fhir/cda/StructureDefinition/AssignedAuthor" alias AssignedAuthor as target
uses "http://hl7.org/fhir/cda/StructureDefinition/AssignedEntity" alias AssignedEntity as target
uses "http://hl7.org/fhir/cda/StructureDefinition/Author" alias Author as target
uses "http://hl7.org/fhir/cda/StructureDefinition/CustodianOrganization" alias CustodianOrganization as target
uses "http://hl7.org/fhir/cda/StructureDefinition/IVL_TS" alias IVL_TS as target
uses "http://hl7.org/fhir/cda/StructureDefinition/EIVL_TS" alias EIVL_TS as target
uses "http://hl7.org/fhir/cda/StructureDefinition/PatientRole" alias PatientRole as target
uses "http://hl7.org/fhir/cda/StructureDefinition/RecordTarget" alias RecordTarget as target
uses "http://hl7.org/fhir/cda/StructureDefinition/Section" alias Section as target
uses "http://hl7.org/fhir/cda/StructureDefinition/SubstanceAdministration" alias SubstanceAdministration as target
uses "http://hl7.org/fhir/cda/StructureDefinition/SXPR_TS" alias SXPR_TS as target
uses "http://hl7.org/fhir/cda/StructureDefinition/Supply" alias Supply as target
uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as source
uses "http://hl7.org/fhir/StructureDefinition/Composition" alias Composition as source
uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as source
uses "http://hl7.org/fhir/StructureDefinition/Practitioner" alias Practitioner as source
uses "http://hl7.org/fhir/StructureDefinition/Organization" alias Organization as source
uses "http://hl7.org/fhir/StructureDefinition/Observation" alias Observation as source
uses "http://hl7.org/fhir/StructureDefinition/Dosage" alias Dosage as source

imports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/FhirToCdaTypes"
imports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCda"
imports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCdaCh"
imports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCdaChEmed"

// source: http://build.fhir.org/ig/hl7ch/ch-emed/StructureDefinition-ch-emed-composition-pharmaceuticaladvice.html
// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.1.6
group BundleToCdaChEmedPharmaceuticalAdviceDocument(source bundle : Bundle, target cda : ClinicalDocument) {
  bundle ->  cda.recordTarget as recordTarget,  cda.author as author then BundleToClinicalDocumentEmedPharmaceuticalAdviceDocument(bundle, recordTarget, author, cda) "bundle";
}

// source: http://build.fhir.org/ig/hl7ch/ch-emed/StructureDefinition-ch-emed-composition-pharmaceuticaladvice.html
// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.1.6
group CompositionClinicalDocumentChEmedPharmaceuticalAdviceDocument(source bundle : Bundle, source composition : Composition, target cda : ClinicalDocument) {
  composition.type ->  cda.code as code,  code.codeSystem = '2.16.840.1.113883.6.1',  code.codeSystemName = 'LOINC',  code.code = '61356-2',  code.displayName = 'Medication pharmaceutical advice.extended' "fixloinc";
  composition.section as section where $this.code.coding.where((system = 'http://loinc.org') and (code = '61357-0')) -> cda.component as component then {
    section -> component.contextConductionInd = true "contextConductionInd";
    section ->  component.structuredBody as structuredBody,  structuredBody.component as component,  component.section as cdasection then SectionPharmaceuticalAdviceSectionContentModule(bundle, section, cdasection) "cdasection";
  } "SectionPharmaceuticalAdviceSectionContentModule";
  composition.section as section where $this.code.coding.where((system = 'http://loinc.org') and (code = '48767-8')) -> cda.component as component then {
    section -> component.contextConductionInd = true "contextConductionInd";
    section ->  component.structuredBody as structuredBody,  structuredBody.component as component,  component.section as cdasection then SectionCdaRemarksCoded(bundle, section, cdasection) "cdasection";
  } "SectionRemarksCoded";
  composition.section as section where $this.code.coding.where((system = 'http://loinc.org') and (code = '55108-5')) -> cda.component as component then {
    section -> component.contextConductionInd = true "contextConductionInd";
    section ->  component.structuredBody as structuredBody,  structuredBody.component as component,  component.section as cdasection then SectionCdaOriginalRepresentation(bundle, section, cdasection) "cdasection";
  } "SectionCdaOriginalRepresentation";
}

// _________________________ Section Level Templates _________________________
// source: http://build.fhir.org/ig/hl7ch/ch-emed/StructureDefinition-ch-emed-composition-pharmaceuticaladvice.html
// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.3.12
group SectionPharmaceuticalAdviceSectionContentModule(source bundle : Bundle, source section : Section, target cdasection : CdaSection) extends SectionCdaSection {
  section ->  cdasection.templateId as templateId,  templateId.root = '2.16.756.5.30.1.1.10.3.12' "CH-PHARM-PharmaceuticalAdviceSectionContentModule";
  section ->  cdasection.templateId as templateId,  templateId.root = '1.3.6.1.4.1.19376.1.9.1.2.2' "IHE-PHARM-PADV";
  section where text.exists() = false -> cdasection.text = '<div xmlns=\"http://www.w3.org/1999/xhtml\"><span id=\"refpdf\">see pdf</span></div>' "Section";
  bundle.entry as entry then {
    entry.fullUrl where ($this in %section.entry.reference) and $this.startsWith('urn:uuid') then {
      entry.resource as fhirobservation where $this.ofType(FHIR.Observation) ->  cdasection.entry as entry,  entry.observation as cdaobservation then PharmaceuticalAdviceItemEntryContentModule(bundle, fhirobservation, cdaobservation) "Observation";
    } "fullUrlAsUuid";
    entry.resource as fhirobservation where $this.ofType(FHIR.Observation) and (('Observation' + '/' + $this.id) in %section.entry.reference) ->  cdasection.entry as entry,  entry.observation as cdaobservation then PharmaceuticalAdviceItemEntryContentModule(bundle, fhirobservation, cdaobservation) "Observation";
  };
}

// _________________________ Header Level Templates _________________________
// source: http://build.fhir.org/ig/hl7ch/ch-emed/StructureDefinition-ch-emed-composition-pharmaceuticaladvice.html
// target: 2.16.756.5.30.1.1.10.9.42
group BundleToClinicalDocumentEmedPharmaceuticalAdviceDocument(source bundle : Bundle, target recordTarget : RecordTarget, target author : Author, target cda : ClinicalDocument) extends BundleToClinicalDocumentCh {
  bundle ->  cda.templateId as templateId,  templateId.root = '2.16.756.5.30.1.127.1.4' "exchangeFormatAccordingToTheSwissEPR";
  bundle ->  cda.templateId as templateId,  templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.1.1' "IHE-PCC";
  bundle ->  cda.templateId as templateId,  templateId.root = '1.3.6.1.4.1.19376.1.9.1.1.2' "IHE-PHARM-PADV";
  bundle ->  cda.templateId as templateId,  templateId.root = '2.16.756.5.30.1.1.10.1.6' "CDA-PHARM-PharmaceuticalAdvice";
  bundle.entry as entry then {
    entry.resource as resource where $this.ofType(FHIR.Composition) then CompositionClinicalDocumentChEmedPharmaceuticalAdviceDocument(bundle, resource, cda);
  };
}