@prefix fhir: <http://hl7.org/fhir/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

# - resource -------------------------------------------------------------------

<https://gematik.de/fhir/tiflow-bfarm/StructureMap/ERPTPrescriptionStructureMapCarbonCopy> a fhir:StructureMap ;
  fhir:nodeRole fhir:treeRoot ;
  fhir:id [ fhir:v "ERPTPrescriptionStructureMapCarbonCopy"] ; # 
  fhir:text [
     fhir:status [ fhir:v "generated" ] ;
     fhir:div [ fhir:v "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p class=\"res-header-id\"><b>Generated Narrative: StructureMap ERPTPrescriptionStructureMapCarbonCopy</b></p><a name=\"ERPTPrescriptionStructureMapCarbonCopy\"> </a><a name=\"hcERPTPrescriptionStructureMapCarbonCopy\"> </a><pre class=\"fml\">#xD;\n<b>map</b><span style=\"color: navy\"> \"</span>https://gematik.de/fhir/erp-t-prescription/StructureMap/ERPTPrescriptionStructureMapCarbonCopy<span style=\"color: navy\">\" = \"</span>ERPTPrescriptionStructureMapCarbonCopy<span style=\"color: navy\">\"#xD;\n#xD;\n</span><span style=\"color: navy\">// </span><span style=\"color: green\">Diese Ressource beschreibt das Mapping und führt die Mappings aller Teilressourcen zusammen. Weitere Informationen und Beschreibungen zum Mapping können auf der Seite [Mapping des digitalen Durchschlag E-T-Rezept](./trezept.html#mapping-des-digitalen-durchschlags-e-t-rezept) eingesehen werden.</span>#xD;\n#xD;\n<b>uses</b><span style=\"color: navy\"> \"</span><a href=\"http://hl7.org/fhir/R4/bundle.html\" title=\"Bundle\">http://hl7.org/fhir/StructureDefinition/Bundle</a><span style=\"color: navy\">\" </span><b>alias </b>bundle <b>as </b><b>source</b>#xD;\n<b>uses</b><span style=\"color: navy\"> \"</span><a href=\"StructureDefinition-erp-tprescription-carbon-copy.html\" title=\"Digitaler Durchschlag T-Rezept\">https://gematik.de/fhir/tiflow-bfarm/StructureDefinition/erp-tprescription-carbon-copy</a><span style=\"color: navy\">\" </span><b>alias </b>erpTCarbonCopy <b>as </b><b>target</b>#xD;\n#xD;\n<b>imports</b><span style=\"color: navy\"> \"</span><a href=\"StructureMap-ERPTPrescriptionStructureMapMedicationDispense.html\" title=\"E-T-Rezept Structure Map for MedicationDispense\">https://gematik.de/fhir/erp-t-prescription/StructureMap/ERPTPrescriptionStructureMapMedicationDispense</a><span style=\"color: navy\">\"#xD;\n</span><b>imports</b><span style=\"color: navy\"> \"</span><a href=\"StructureMap-ERPTPrescriptionStructureMapMedicationRequest.html\" title=\"E-T-Rezept Structure Map for MedicationRequest\">https://gematik.de/fhir/erp-t-prescription/StructureMap/ERPTPrescriptionStructureMapMedicationRequest</a><span style=\"color: navy\">\"#xD;\n</span><b>imports</b><span style=\"color: navy\"> \"</span><a href=\"StructureMap-ERPTPrescriptionStructureMapOrganization.html\" title=\"E-T-Rezept Structure Map for Organization\">https://gematik.de/fhir/erp-t-prescription/StructureMap/ERPTPrescriptionStructureMapOrganization</a><span style=\"color: navy\">\"#xD;\n</span><b>imports</b><span style=\"color: navy\"> \"</span><a href=\"StructureMap-ERPTPrescriptionStructureMapTask.html\" title=\"E-T-Rezept Structure Map for Task\">https://gematik.de/fhir/erp-t-prescription/StructureMap/ERPTPrescriptionStructureMapTask</a><span style=\"color: navy\">\"#xD;\n</span><b>imports</b><span style=\"color: navy\"> \"</span><a href=\"StructureMap-ERPTPrescriptionStructureMapMedication.html\" title=\"E-T-Rezept Structure Map for Medication\">https://gematik.de/fhir/erp-t-prescription/StructureMap/ERPTPrescriptionStructureMapMedication</a><span style=\"color: navy\">\"#xD;\n</span>#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">Mapping des digitalen Durchschlags T-Rezept aus einem E-Rezept Bundle in das BfArM CarbonCopy Format</span>#xD;\n<b>group </b>erpTPrescriptionCarbonCopy<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">bundle</span><span style=\"color: navy\"> : </span>bundle, <b>target</b> <span style=\"color: maroon\">erpTCarbonCopy</span><span style=\"color: navy\"> : </span>erpTCarbonCopy<span style=\"color: navy\">)</span><span style=\"color: navy\"> {#xD;\n</span>  bundle<span style=\"color: navy\"><b> -&gt; </b></span>erpTCarbonCopy.meta<b> as </b><span style=\"color: maroon\">erpTCarbonCopyMeta</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>    bundle<span style=\"color: navy\"><b> -&gt; </b></span>erpTCarbonCopyMeta.profile = <span style=\"color: blue\">'https://gematik.de/fhir/tiflow/bfarm/StructureDefinition/erp-tprescription-carbon-copy|1.1'</span> <i>\"tgtMetaProfile\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Setzt das meta.profile des digitalen Durchschlags T-Rezept</span>#xD;\n  <span style=\"color: navy\">}</span> <i>\"tgtMeta\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Setzt die Metadaten für den digitalen Durchschlag</span>#xD;\n  bundle<span style=\"color: navy\"><b> -&gt; </b></span> erpTCarbonCopy.parameter<b> as </b><span style=\"color: maroon\">tgtRxPrescription</span><span style=\"color: navy\">, </span> tgtRxPrescription.part<b> as </b><span style=\"color: maroon\">tgtRxPrescriptionPartId</span><span style=\"color: navy\">, </span> tgtRxPrescription.part<b> as </b><span style=\"color: maroon\">tgtRxPrescriptionPartMR</span><span style=\"color: navy\">, </span> tgtRxPrescription.part<b> as </b><span style=\"color: maroon\">tgtRxPrescriptionPartMed</span><span style=\"color: navy\">, </span> tgtRxPrescription.name = <span style=\"color: blue\">'rxPrescription'</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>    bundle.entry<b> as </b><span style=\"color: maroon\">srcEntryVar</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>      srcEntryVar.resource<b> as </b><span style=\"color: maroon\">srcEntryResourceVar</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>        srcEntryVar.resource<span style=\"color: navy\"> : </span>Task<b> as </b><span style=\"color: maroon\">srcEntryTaskVar</span><b> where </b>ofType(Task)<span style=\"color: navy\"><b> -&gt; </b></span> tgtRxPrescriptionPartId.name = <span style=\"color: blue\">'prescriptionId'</span><span style=\"color: navy\">, </span> tgtRxPrescriptionPartId.value = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Identifier'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">newIdentifier</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>          srcEntryTaskVar<b> then </b>ERPTPrescriptionStructureMapTask<span style=\"color: navy\">(</span><span style=\"color: maroon\">srcEntryTaskVar</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">newIdentifier</span><span style=\"color: navy\">)</span> <i>\"parameterrXPrescriptionPartIdentifier\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Mappt Task-Informationen auf Identifier für die Rezept-ID</span>#xD;\n        <span style=\"color: navy\">}</span> <i>\"parameterrXPrescriptionPart\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Extrahiert die E-Rezept-ID aus dem Task und erstellt den prescriptionId Parameter</span>#xD;\n        srcEntryVar.resource<span style=\"color: navy\"> : </span>MedicationRequest<b> as </b><span style=\"color: maroon\">srcEntryBundleMRVar</span><b> where </b>ofType(MedicationRequest)<span style=\"color: navy\"><b> -&gt; </b></span>tgtRxPrescriptionPartMR.name = <span style=\"color: blue\">'medicationRequest'</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>          srcEntryBundleMRVar<span style=\"color: navy\"><b> -&gt; </b></span>tgtRxPrescriptionPartMR.resource = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'MedicationRequest'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">newMedicationRequest</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>            srcEntryBundleMRVar<b> then </b>ERPTPrescriptionStructureMapMedicationRequest<span style=\"color: navy\">(</span><span style=\"color: maroon\">srcEntryBundleMRVar</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">newMedicationRequest</span><span style=\"color: navy\">)</span> <i>\"entryMedicationRequestPartResourceSet\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Führt die detaillierte MedicationRequest-Transformation durch</span>#xD;\n          <span style=\"color: navy\">}</span> <i>\"entryMedicationRequestPart\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Transformiert KBV-MedicationRequest in BfArM MedicationRequest Format</span>#xD;\n        <span style=\"color: navy\">}</span> <i>\"entryMedicationRequest\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Erstellt den medicationRequest Parameter für Verschreibungsdetails</span>#xD;\n        srcEntryVar<b> as </b><span style=\"color: maroon\">srcMedicationRequestId</span><b> where </b>resource.ofType(MedicationRequest)<span style=\"color: navy\"><b> -&gt; </b></span>tgtRxPrescriptionPartMed.name = <span style=\"color: blue\">'medication'</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>          bundle.entry<b> as </b><span style=\"color: maroon\">srcEntryVar2</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>            srcEntryVar2<b> as </b><span style=\"color: maroon\">srcEntryBundleMRMedIdVar</span><b> where </b>resource.ofType(Medication).where(id=%srcMedicationRequestId.resource.medication.reference.replace('urn:uuid:', '').split('/').last())<span style=\"color: navy\"><b> -&gt; </b></span>tgtRxPrescriptionPartMed.resource = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Medication'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">newMedicationPrescriptionMedication</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>              srcEntryBundleMRMedIdVar.resource<span style=\"color: navy\"> : </span>Medication<b> as </b><span style=\"color: maroon\">srcEntryBundleMRMedIdVarRes</span><b> then </b>ERPTPrescriptionStructureMapMedication<span style=\"color: navy\">(</span><span style=\"color: maroon\">srcEntryBundleMRMedIdVarRes</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">newMedicationPrescriptionMedication</span><span style=\"color: navy\">)</span> <i>\"entryMedicationPrescriptionMedicationPartResourceSet\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Führt die detaillierte Medication-Transformation für das verschriebene Arzneimittel durch</span>#xD;\n            <span style=\"color: navy\">}</span> <i>\"entryMedicationPrescriptionMedicationPart\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Findet die vom MedicationRequest referenzierte Medication und transformiert sie in BfArM Format</span>#xD;\n          <span style=\"color: navy\">}</span> <i>\"prepMedication\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Bereitet die Suche nach der referenzierten Medication vor</span>#xD;\n        <span style=\"color: navy\">}</span> <i>\"entryMedicationRequestMedication\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Erstellt den medication Parameter für das verschriebene Arzneimittel</span>#xD;\n      <span style=\"color: navy\">}</span> <i>\"rxPrescriptionParameter\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Extrahiert relevante Ressourcen für die Verschreibung</span>#xD;\n    <span style=\"color: navy\">}</span> <i>\"bundleEntries\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Verarbeitet alle Einträge des Quell-Bundles für Verschreibungsinformationen</span>#xD;\n  <span style=\"color: navy\">}</span> <i>\"rxPrescriptionRule\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Erstellt den rxPrescription Parameter mit allen Verschreibungsinformationen</span>#xD;\n  bundle<span style=\"color: navy\"><b> -&gt; </b></span> erpTCarbonCopy.parameter<b> as </b><span style=\"color: maroon\">tgtRxDispensation</span><span style=\"color: navy\">, </span> tgtRxDispensation.part<b> as </b><span style=\"color: maroon\">tgtRxDispensationPartOrg</span><span style=\"color: navy\">, </span> tgtRxDispensation.name = <span style=\"color: blue\">'rxDispensation'</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>    bundle.entry<b> as </b><span style=\"color: maroon\">srcEntryVar</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>      srcEntryVar.resource<b> as </b><span style=\"color: maroon\">srcEntryResourceVar</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>        srcEntryVar.resource<span style=\"color: navy\"> : </span>Bundle<b> as </b><span style=\"color: maroon\">srcEntryBundleOrgVar</span><b> where </b>ofType(Bundle).where(entry.first().fullUrl.contains('fhir-directory'))<span style=\"color: navy\"><b> -&gt; </b></span>tgtRxDispensationPartOrg.name = <span style=\"color: blue\">'dispenseOrganization'</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>          srcEntryBundleOrgVar<span style=\"color: navy\"><b> -&gt; </b></span>tgtRxDispensationPartOrg.resource = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Organization'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">newOrganization</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>            srcEntryBundleOrgVar<b> then </b>ERPTPrescriptionStructureMapOrganization<span style=\"color: navy\">(</span><span style=\"color: maroon\">srcEntryBundleOrgVar</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">newOrganization</span><span style=\"color: navy\">)</span> <i>\"entryOrganizationPartResourceSet\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Führt die detaillierte Organization-Transformation durch</span>#xD;\n          <span style=\"color: navy\">}</span> <i>\"entryOrganizationPart\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Transformiert VZD SearchSet in BfArM Organization Format für die abgebende Apotheke</span>#xD;\n        <span style=\"color: navy\">}</span> <i>\"entryVZDSearchSet\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Identifiziert VZD SearchSet Bundle für Apothekeninformationen</span>#xD;\n        srcEntryVar.resource<span style=\"color: navy\"> : </span>MedicationDispense<b> as </b><span style=\"color: maroon\">srcEntryBundleMDVar</span><b> where </b>ofType(MedicationDispense)<span style=\"color: navy\"><b> -&gt; </b></span>tgtRxDispensation.part<b> as </b><span style=\"color: maroon\">tgtDispenseInformationPart</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>          srcEntryBundleMDVar<span style=\"color: navy\"><b> -&gt; </b></span> tgtDispenseInformationPart.name = <span style=\"color: blue\">'dispenseInformation'</span><span style=\"color: navy\">, </span> tgtDispenseInformationPart.part<b> as </b><span style=\"color: maroon\">tgtDispenseInformationMedDispPart</span><span style=\"color: navy\">, </span> tgtDispenseInformationPart.part<b> as </b><span style=\"color: maroon\">tgtDispenseInformationMedicationPart</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>            srcEntryBundleMDVar<span style=\"color: navy\"><b> -&gt; </b></span> tgtDispenseInformationMedDispPart.name = <span style=\"color: blue\">'medicationDispense'</span><span style=\"color: navy\">, </span> tgtDispenseInformationMedDispPart.resource = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'MedicationDispense'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">newMedicationDispense</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>              srcEntryBundleMDVar<b> then </b>ERPTPrescriptionStructureMapMedicationDispense<span style=\"color: navy\">(</span><span style=\"color: maroon\">srcEntryBundleMDVar</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">newMedicationDispense</span><span style=\"color: navy\">)</span> <i>\"entryMedicationDispensePartResourceSet\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Führt die detaillierte MedicationDispense-Transformation durch</span>#xD;\n            <span style=\"color: navy\">}</span> <i>\"entryDispenseInformationMedicationDispense\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Transformiert gematik MedicationDispense in BfArM MedicationDispense Format</span>#xD;\n            srcEntryBundleMDVar<span style=\"color: navy\"><b> -&gt; </b></span>tgtDispenseInformationMedicationPart.name = <span style=\"color: blue\">'medication'</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>              bundle.entry<b> as </b><span style=\"color: maroon\">srcEntryVarDisp</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>                srcEntryVarDisp<b> as </b><span style=\"color: maroon\">srcEntryBundleMDMedIdVar</span><b> where </b>resource.ofType(Medication).where(id=%srcEntryBundleMDVar.medicationReference.reference.replace('urn:uuid:', '').split('/').last())<span style=\"color: navy\"><b> -&gt; </b></span>tgtDispenseInformationMedicationPart.resource = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Medication'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">newMedicationDispensationMedication</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>                  srcEntryBundleMDMedIdVar.resource<span style=\"color: navy\"> : </span>Medication<b> as </b><span style=\"color: maroon\">srcEntryBundleMDMedIdVarRes</span><b> then </b>ERPTPrescriptionStructureMapMedication<span style=\"color: navy\">(</span><span style=\"color: maroon\">srcEntryBundleMDMedIdVarRes</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">newMedicationDispensationMedication</span><span style=\"color: navy\">)</span> <i>\"entryMedicationDispensationMedicationPartResourceSet\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Führt die detaillierte Medication-Transformation für das abgegebene Arzneimittel durch</span>#xD;\n                <span style=\"color: navy\">}</span> <i>\"entryDispenseMedicationPart\"</i><span style=\"color: navy\">;</span>#xD;\n              <span style=\"color: navy\">}</span> <i>\"prepDispenseMedication\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Bereitet die Suche nach der referenzierten Medication im Bundle vor</span>#xD;\n            <span style=\"color: navy\">}</span> <i>\"entryDispenseInformationMedication\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Findet die vom MedicationDispense referenzierte Medication und transformiert sie in BfArM Format</span>#xD;\n          <span style=\"color: navy\">}</span> <i>\"entryDispenseInformation\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Bündelt MedicationDispense und zugehörige Medication unter dispenseInformation</span>#xD;\n        <span style=\"color: navy\">}</span> <i>\"entryMedicationDispense\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Erstellt eine dispenseInformation Part pro abgegebener MedicationDispense</span>#xD;\n      <span style=\"color: navy\">}</span> <i>\"rxDispensationParameter\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Extrahiert relevante Ressourcen für die Abgabe</span>#xD;\n    <span style=\"color: navy\">}</span> <i>\"bundleEntries\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Verarbeitet alle Einträge des Quell-Bundles für Abgabeinformationen</span>#xD;\n  <span style=\"color: navy\">}</span> <i>\"MedicationDispenseFromBundle\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Erstellt den rxDispensation Parameter mit allen Abgabeinformationen</span>#xD;\n<span style=\"color: navy\">}#xD;\n#xD;\n</span></pre></div>"^^rdf:XMLLiteral ]
  ] ; # 
  fhir:url [
     fhir:v "https://gematik.de/fhir/erp-t-prescription/StructureMap/ERPTPrescriptionStructureMapCarbonCopy"^^xsd:anyURI ;
     fhir:l <https://gematik.de/fhir/erp-t-prescription/StructureMap/ERPTPrescriptionStructureMapCarbonCopy>
  ] ; # 
  fhir:version [ fhir:v "2.0.0-ballot.1"] ; # 
  fhir:name [ fhir:v "ERPTPrescriptionStructureMapCarbonCopy"] ; # 
  fhir:title [ fhir:v "E-T-Rezept Structure Map for CarbonCopy"] ; # 
  fhir:status [ fhir:v "draft"] ; # 
  fhir:experimental [ fhir:v false] ; # 
  fhir:date [ fhir:v "2026-05-26"^^xsd:date] ; # 
  fhir:publisher [ fhir:v "gematik GmbH"] ; # 
  fhir:contact ( [
     fhir:name [ fhir:v "gematik GmbH" ] ;
     fhir:telecom ( [
       fhir:system [ fhir:v "url" ] ;
       fhir:value [ fhir:v "https://gematik.de" ]
     ] [
       fhir:system [ fhir:v "email" ] ;
       fhir:value [ fhir:v "erp-umsetzung@gematik.de" ]
     ] )
  ] ) ; # 
  fhir:description [ fhir:v "Diese Ressource beschreibt das Mapping und führt die Mappings aller Teilressourcen zusammen. Weitere Informationen und Beschreibungen zum Mapping können auf der Seite [Mapping des digitalen Durchschlag E-T-Rezept](./trezept.html#mapping-des-digitalen-durchschlags-e-t-rezept) eingesehen werden."] ; # 
  fhir:jurisdiction ( [
     fhir:coding ( [
       fhir:system [
         fhir:v "urn:iso:std:iso:3166"^^xsd:anyURI ;
         fhir:l <urn:iso:std:iso:3166>
       ] ;
       fhir:code [ fhir:v "DE" ] ;
       fhir:display [ fhir:v "Germany" ]
     ] )
  ] ) ; # 
  fhir:structure ( [
     fhir:url [
       fhir:v "http://hl7.org/fhir/StructureDefinition/Bundle"^^xsd:anyURI ;
       fhir:l <http://hl7.org/fhir/StructureDefinition/Bundle>
     ] ;
     fhir:mode [ fhir:v "source" ] ;
     fhir:alias [ fhir:v "bundle" ]
  ] [
     fhir:url [
       fhir:v "https://gematik.de/fhir/tiflow-bfarm/StructureDefinition/erp-tprescription-carbon-copy"^^xsd:anyURI ;
       fhir:l <https://gematik.de/fhir/tiflow-bfarm/StructureDefinition/erp-tprescription-carbon-copy>
     ] ;
     fhir:mode [ fhir:v "target" ] ;
     fhir:alias [ fhir:v "erpTCarbonCopy" ]
  ] ) ; # 
  fhir:import ( [
     fhir:v "https://gematik.de/fhir/erp-t-prescription/StructureMap/ERPTPrescriptionStructureMapMedicationDispense"^^xsd:anyURI ;
     fhir:l <https://gematik.de/fhir/erp-t-prescription/StructureMap/ERPTPrescriptionStructureMapMedicationDispense>
  ] [
     fhir:v "https://gematik.de/fhir/erp-t-prescription/StructureMap/ERPTPrescriptionStructureMapMedicationRequest"^^xsd:anyURI ;
     fhir:l <https://gematik.de/fhir/erp-t-prescription/StructureMap/ERPTPrescriptionStructureMapMedicationRequest>
  ] [
     fhir:v "https://gematik.de/fhir/erp-t-prescription/StructureMap/ERPTPrescriptionStructureMapOrganization"^^xsd:anyURI ;
     fhir:l <https://gematik.de/fhir/erp-t-prescription/StructureMap/ERPTPrescriptionStructureMapOrganization>
  ] [
     fhir:v "https://gematik.de/fhir/erp-t-prescription/StructureMap/ERPTPrescriptionStructureMapTask"^^xsd:anyURI ;
     fhir:l <https://gematik.de/fhir/erp-t-prescription/StructureMap/ERPTPrescriptionStructureMapTask>
  ] [
     fhir:v "https://gematik.de/fhir/erp-t-prescription/StructureMap/ERPTPrescriptionStructureMapMedication"^^xsd:anyURI ;
     fhir:l <https://gematik.de/fhir/erp-t-prescription/StructureMap/ERPTPrescriptionStructureMapMedication>
  ] ) ; # 
  fhir:group ( [
     fhir:name [ fhir:v "erpTPrescriptionCarbonCopy" ] ;
     fhir:typeMode [ fhir:v "none" ] ;
     fhir:documentation [ fhir:v "Mapping des digitalen Durchschlags T-Rezept aus einem E-Rezept Bundle in das BfArM CarbonCopy Format" ] ;
     fhir:input ( [
       fhir:name [ fhir:v "bundle" ] ;
       fhir:type [ fhir:v "bundle" ] ;
       fhir:mode [ fhir:v "source" ]
     ] [
       fhir:name [ fhir:v "erpTCarbonCopy" ] ;
       fhir:type [ fhir:v "erpTCarbonCopy" ] ;
       fhir:mode [ fhir:v "target" ]
     ] ) ;
     fhir:rule ( [
       fhir:name [ fhir:v "tgtMeta" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "bundle" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "erpTCarbonCopy" ] ;
         fhir:contextType [ fhir:v "variable" ] ;
         fhir:element [ fhir:v "meta" ] ;
         fhir:variable [ fhir:v "erpTCarbonCopyMeta" ]
       ] ) ;
       fhir:rule ( [
         fhir:name [ fhir:v "tgtMetaProfile" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "bundle" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "erpTCarbonCopyMeta" ] ;
           fhir:contextType [ fhir:v "variable" ] ;
           fhir:element [ fhir:v "profile" ] ;
           fhir:transform [ fhir:v "copy" ] ;
           fhir:parameter ( [
             fhir:value [
               a fhir:String ;
               fhir:v "https://gematik.de/fhir/tiflow/bfarm/StructureDefinition/erp-tprescription-carbon-copy|1.1"
             ]
           ] )
         ] ) ;
         fhir:documentation [ fhir:v "Setzt das meta.profile des digitalen Durchschlags T-Rezept" ]
       ] ) ;
       fhir:documentation [ fhir:v "Setzt die Metadaten für den digitalen Durchschlag" ]
     ] [
       fhir:name [ fhir:v "rxPrescriptionRule" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "bundle" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "erpTCarbonCopy" ] ;
         fhir:contextType [ fhir:v "variable" ] ;
         fhir:element [ fhir:v "parameter" ] ;
         fhir:variable [ fhir:v "tgtRxPrescription" ]
       ] [
         fhir:context [ fhir:v "tgtRxPrescription" ] ;
         fhir:contextType [ fhir:v "variable" ] ;
         fhir:element [ fhir:v "part" ] ;
         fhir:variable [ fhir:v "tgtRxPrescriptionPartId" ]
       ] [
         fhir:context [ fhir:v "tgtRxPrescription" ] ;
         fhir:contextType [ fhir:v "variable" ] ;
         fhir:element [ fhir:v "part" ] ;
         fhir:variable [ fhir:v "tgtRxPrescriptionPartMR" ]
       ] [
         fhir:context [ fhir:v "tgtRxPrescription" ] ;
         fhir:contextType [ fhir:v "variable" ] ;
         fhir:element [ fhir:v "part" ] ;
         fhir:variable [ fhir:v "tgtRxPrescriptionPartMed" ]
       ] [
         fhir:context [ fhir:v "tgtRxPrescription" ] ;
         fhir:contextType [ fhir:v "variable" ] ;
         fhir:element [ fhir:v "name" ] ;
         fhir:transform [ fhir:v "copy" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:String ;
             fhir:v "rxPrescription"
           ]
         ] )
       ] ) ;
       fhir:rule ( [
         fhir:name [ fhir:v "bundleEntries" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "bundle" ] ;
           fhir:element [ fhir:v "entry" ] ;
           fhir:variable [ fhir:v "srcEntryVar" ]
         ] ) ;
         fhir:rule ( [
           fhir:name [ fhir:v "rxPrescriptionParameter" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "srcEntryVar" ] ;
             fhir:element [ fhir:v "resource" ] ;
             fhir:variable [ fhir:v "srcEntryResourceVar" ]
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "parameterrXPrescriptionPart" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "srcEntryVar" ] ;
               fhir:type [ fhir:v "Task" ] ;
               fhir:element [ fhir:v "resource" ] ;
               fhir:variable [ fhir:v "srcEntryTaskVar" ] ;
               fhir:condition [ fhir:v "ofType(Task)" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "tgtRxPrescriptionPartId" ] ;
               fhir:contextType [ fhir:v "variable" ] ;
               fhir:element [ fhir:v "name" ] ;
               fhir:transform [ fhir:v "copy" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:String ;
                   fhir:v "prescriptionId"
                 ]
               ] )
             ] [
               fhir:context [ fhir:v "tgtRxPrescriptionPartId" ] ;
               fhir:contextType [ fhir:v "variable" ] ;
               fhir:element [ fhir:v "value" ] ;
               fhir:variable [ fhir:v "newIdentifier" ] ;
               fhir:transform [ fhir:v "create" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:String ;
                   fhir:v "Identifier"
                 ]
               ] )
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "parameterrXPrescriptionPartIdentifier" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "srcEntryTaskVar" ]
               ] ) ;
               fhir:dependent ( [
                 fhir:name [ fhir:v "ERPTPrescriptionStructureMapTask" ] ;
                 fhir:variable ( [ fhir:v "srcEntryTaskVar" ] [ fhir:v "newIdentifier" ] )
               ] ) ;
               fhir:documentation [ fhir:v "Mappt Task-Informationen auf Identifier für die Rezept-ID" ]
             ] ) ;
             fhir:documentation [ fhir:v "Extrahiert die E-Rezept-ID aus dem Task und erstellt den prescriptionId Parameter" ]
           ] [
             fhir:name [ fhir:v "entryMedicationRequest" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "srcEntryVar" ] ;
               fhir:type [ fhir:v "MedicationRequest" ] ;
               fhir:element [ fhir:v "resource" ] ;
               fhir:variable [ fhir:v "srcEntryBundleMRVar" ] ;
               fhir:condition [ fhir:v "ofType(MedicationRequest)" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "tgtRxPrescriptionPartMR" ] ;
               fhir:contextType [ fhir:v "variable" ] ;
               fhir:element [ fhir:v "name" ] ;
               fhir:transform [ fhir:v "copy" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:String ;
                   fhir:v "medicationRequest"
                 ]
               ] )
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "entryMedicationRequestPart" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "srcEntryBundleMRVar" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "tgtRxPrescriptionPartMR" ] ;
                 fhir:contextType [ fhir:v "variable" ] ;
                 fhir:element [ fhir:v "resource" ] ;
                 fhir:variable [ fhir:v "newMedicationRequest" ] ;
                 fhir:transform [ fhir:v "create" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:String ;
                     fhir:v "MedicationRequest"
                   ]
                 ] )
               ] ) ;
               fhir:rule ( [
                 fhir:name [ fhir:v "entryMedicationRequestPartResourceSet" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "srcEntryBundleMRVar" ]
                 ] ) ;
                 fhir:dependent ( [
                   fhir:name [ fhir:v "ERPTPrescriptionStructureMapMedicationRequest" ] ;
                   fhir:variable ( [ fhir:v "srcEntryBundleMRVar" ] [ fhir:v "newMedicationRequest" ] )
                 ] ) ;
                 fhir:documentation [ fhir:v "Führt die detaillierte MedicationRequest-Transformation durch" ]
               ] ) ;
               fhir:documentation [ fhir:v "Transformiert KBV-MedicationRequest in BfArM MedicationRequest Format" ]
             ] ) ;
             fhir:documentation [ fhir:v "Erstellt den medicationRequest Parameter für Verschreibungsdetails" ]
           ] [
             fhir:name [ fhir:v "entryMedicationRequestMedication" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "srcEntryVar" ] ;
               fhir:variable [ fhir:v "srcMedicationRequestId" ] ;
               fhir:condition [ fhir:v "resource.ofType(MedicationRequest)" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "tgtRxPrescriptionPartMed" ] ;
               fhir:contextType [ fhir:v "variable" ] ;
               fhir:element [ fhir:v "name" ] ;
               fhir:transform [ fhir:v "copy" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:String ;
                   fhir:v "medication"
                 ]
               ] )
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "prepMedication" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "bundle" ] ;
                 fhir:element [ fhir:v "entry" ] ;
                 fhir:variable [ fhir:v "srcEntryVar2" ]
               ] ) ;
               fhir:rule ( [
                 fhir:name [ fhir:v "entryMedicationPrescriptionMedicationPart" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "srcEntryVar2" ] ;
                   fhir:variable [ fhir:v "srcEntryBundleMRMedIdVar" ] ;
                   fhir:condition [ fhir:v "resource.ofType(Medication).where(id=%srcMedicationRequestId.resource.medication.reference.replace('urn:uuid:', '').split('/').last())" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "tgtRxPrescriptionPartMed" ] ;
                   fhir:contextType [ fhir:v "variable" ] ;
                   fhir:element [ fhir:v "resource" ] ;
                   fhir:variable [ fhir:v "newMedicationPrescriptionMedication" ] ;
                   fhir:transform [ fhir:v "create" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:String ;
                       fhir:v "Medication"
                     ]
                   ] )
                 ] ) ;
                 fhir:rule ( [
                   fhir:name [ fhir:v "entryMedicationPrescriptionMedicationPartResourceSet" ] ;
                   fhir:source ( [
                     fhir:context [ fhir:v "srcEntryBundleMRMedIdVar" ] ;
                     fhir:type [ fhir:v "Medication" ] ;
                     fhir:element [ fhir:v "resource" ] ;
                     fhir:variable [ fhir:v "srcEntryBundleMRMedIdVarRes" ]
                   ] ) ;
                   fhir:dependent ( [
                     fhir:name [ fhir:v "ERPTPrescriptionStructureMapMedication" ] ;
                     fhir:variable ( [ fhir:v "srcEntryBundleMRMedIdVarRes" ] [ fhir:v "newMedicationPrescriptionMedication" ] )
                   ] ) ;
                   fhir:documentation [ fhir:v "Führt die detaillierte Medication-Transformation für das verschriebene Arzneimittel durch" ]
                 ] ) ;
                 fhir:documentation [ fhir:v "Findet die vom MedicationRequest referenzierte Medication und transformiert sie in BfArM Format" ]
               ] ) ;
               fhir:documentation [ fhir:v "Bereitet die Suche nach der referenzierten Medication vor" ]
             ] ) ;
             fhir:documentation [ fhir:v "Erstellt den medication Parameter für das verschriebene Arzneimittel" ]
           ] ) ;
           fhir:documentation [ fhir:v "Extrahiert relevante Ressourcen für die Verschreibung" ]
         ] ) ;
         fhir:documentation [ fhir:v "Verarbeitet alle Einträge des Quell-Bundles für Verschreibungsinformationen" ]
       ] ) ;
       fhir:documentation [ fhir:v "Erstellt den rxPrescription Parameter mit allen Verschreibungsinformationen" ]
     ] [
       fhir:name [ fhir:v "MedicationDispenseFromBundle" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "bundle" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "erpTCarbonCopy" ] ;
         fhir:contextType [ fhir:v "variable" ] ;
         fhir:element [ fhir:v "parameter" ] ;
         fhir:variable [ fhir:v "tgtRxDispensation" ]
       ] [
         fhir:context [ fhir:v "tgtRxDispensation" ] ;
         fhir:contextType [ fhir:v "variable" ] ;
         fhir:element [ fhir:v "part" ] ;
         fhir:variable [ fhir:v "tgtRxDispensationPartOrg" ]
       ] [
         fhir:context [ fhir:v "tgtRxDispensation" ] ;
         fhir:contextType [ fhir:v "variable" ] ;
         fhir:element [ fhir:v "name" ] ;
         fhir:transform [ fhir:v "copy" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:String ;
             fhir:v "rxDispensation"
           ]
         ] )
       ] ) ;
       fhir:rule ( [
         fhir:name [ fhir:v "bundleEntries" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "bundle" ] ;
           fhir:element [ fhir:v "entry" ] ;
           fhir:variable [ fhir:v "srcEntryVar" ]
         ] ) ;
         fhir:rule ( [
           fhir:name [ fhir:v "rxDispensationParameter" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "srcEntryVar" ] ;
             fhir:element [ fhir:v "resource" ] ;
             fhir:variable [ fhir:v "srcEntryResourceVar" ]
           ] ) ;
           fhir:rule ( [
             fhir:name [ fhir:v "entryVZDSearchSet" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "srcEntryVar" ] ;
               fhir:type [ fhir:v "Bundle" ] ;
               fhir:element [ fhir:v "resource" ] ;
               fhir:variable [ fhir:v "srcEntryBundleOrgVar" ] ;
               fhir:condition [ fhir:v "ofType(Bundle).where(entry.first().fullUrl.contains('fhir-directory'))" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "tgtRxDispensationPartOrg" ] ;
               fhir:contextType [ fhir:v "variable" ] ;
               fhir:element [ fhir:v "name" ] ;
               fhir:transform [ fhir:v "copy" ] ;
               fhir:parameter ( [
                 fhir:value [
                   a fhir:String ;
                   fhir:v "dispenseOrganization"
                 ]
               ] )
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "entryOrganizationPart" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "srcEntryBundleOrgVar" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "tgtRxDispensationPartOrg" ] ;
                 fhir:contextType [ fhir:v "variable" ] ;
                 fhir:element [ fhir:v "resource" ] ;
                 fhir:variable [ fhir:v "newOrganization" ] ;
                 fhir:transform [ fhir:v "create" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:String ;
                     fhir:v "Organization"
                   ]
                 ] )
               ] ) ;
               fhir:rule ( [
                 fhir:name [ fhir:v "entryOrganizationPartResourceSet" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "srcEntryBundleOrgVar" ]
                 ] ) ;
                 fhir:dependent ( [
                   fhir:name [ fhir:v "ERPTPrescriptionStructureMapOrganization" ] ;
                   fhir:variable ( [ fhir:v "srcEntryBundleOrgVar" ] [ fhir:v "newOrganization" ] )
                 ] ) ;
                 fhir:documentation [ fhir:v "Führt die detaillierte Organization-Transformation durch" ]
               ] ) ;
               fhir:documentation [ fhir:v "Transformiert VZD SearchSet in BfArM Organization Format für die abgebende Apotheke" ]
             ] ) ;
             fhir:documentation [ fhir:v "Identifiziert VZD SearchSet Bundle für Apothekeninformationen" ]
           ] [
             fhir:name [ fhir:v "entryMedicationDispense" ] ;
             fhir:source ( [
               fhir:context [ fhir:v "srcEntryVar" ] ;
               fhir:type [ fhir:v "MedicationDispense" ] ;
               fhir:element [ fhir:v "resource" ] ;
               fhir:variable [ fhir:v "srcEntryBundleMDVar" ] ;
               fhir:condition [ fhir:v "ofType(MedicationDispense)" ]
             ] ) ;
             fhir:target ( [
               fhir:context [ fhir:v "tgtRxDispensation" ] ;
               fhir:contextType [ fhir:v "variable" ] ;
               fhir:element [ fhir:v "part" ] ;
               fhir:variable [ fhir:v "tgtDispenseInformationPart" ]
             ] ) ;
             fhir:rule ( [
               fhir:name [ fhir:v "entryDispenseInformation" ] ;
               fhir:source ( [
                 fhir:context [ fhir:v "srcEntryBundleMDVar" ]
               ] ) ;
               fhir:target ( [
                 fhir:context [ fhir:v "tgtDispenseInformationPart" ] ;
                 fhir:contextType [ fhir:v "variable" ] ;
                 fhir:element [ fhir:v "name" ] ;
                 fhir:transform [ fhir:v "copy" ] ;
                 fhir:parameter ( [
                   fhir:value [
                     a fhir:String ;
                     fhir:v "dispenseInformation"
                   ]
                 ] )
               ] [
                 fhir:context [ fhir:v "tgtDispenseInformationPart" ] ;
                 fhir:contextType [ fhir:v "variable" ] ;
                 fhir:element [ fhir:v "part" ] ;
                 fhir:variable [ fhir:v "tgtDispenseInformationMedDispPart" ]
               ] [
                 fhir:context [ fhir:v "tgtDispenseInformationPart" ] ;
                 fhir:contextType [ fhir:v "variable" ] ;
                 fhir:element [ fhir:v "part" ] ;
                 fhir:variable [ fhir:v "tgtDispenseInformationMedicationPart" ]
               ] ) ;
               fhir:rule ( [
                 fhir:name [ fhir:v "entryDispenseInformationMedicationDispense" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "srcEntryBundleMDVar" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "tgtDispenseInformationMedDispPart" ] ;
                   fhir:contextType [ fhir:v "variable" ] ;
                   fhir:element [ fhir:v "name" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:String ;
                       fhir:v "medicationDispense"
                     ]
                   ] )
                 ] [
                   fhir:context [ fhir:v "tgtDispenseInformationMedDispPart" ] ;
                   fhir:contextType [ fhir:v "variable" ] ;
                   fhir:element [ fhir:v "resource" ] ;
                   fhir:variable [ fhir:v "newMedicationDispense" ] ;
                   fhir:transform [ fhir:v "create" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:String ;
                       fhir:v "MedicationDispense"
                     ]
                   ] )
                 ] ) ;
                 fhir:rule ( [
                   fhir:name [ fhir:v "entryMedicationDispensePartResourceSet" ] ;
                   fhir:source ( [
                     fhir:context [ fhir:v "srcEntryBundleMDVar" ]
                   ] ) ;
                   fhir:dependent ( [
                     fhir:name [ fhir:v "ERPTPrescriptionStructureMapMedicationDispense" ] ;
                     fhir:variable ( [ fhir:v "srcEntryBundleMDVar" ] [ fhir:v "newMedicationDispense" ] )
                   ] ) ;
                   fhir:documentation [ fhir:v "Führt die detaillierte MedicationDispense-Transformation durch" ]
                 ] ) ;
                 fhir:documentation [ fhir:v "Transformiert gematik MedicationDispense in BfArM MedicationDispense Format" ]
               ] [
                 fhir:name [ fhir:v "entryDispenseInformationMedication" ] ;
                 fhir:source ( [
                   fhir:context [ fhir:v "srcEntryBundleMDVar" ]
                 ] ) ;
                 fhir:target ( [
                   fhir:context [ fhir:v "tgtDispenseInformationMedicationPart" ] ;
                   fhir:contextType [ fhir:v "variable" ] ;
                   fhir:element [ fhir:v "name" ] ;
                   fhir:transform [ fhir:v "copy" ] ;
                   fhir:parameter ( [
                     fhir:value [
                       a fhir:String ;
                       fhir:v "medication"
                     ]
                   ] )
                 ] ) ;
                 fhir:rule ( [
                   fhir:name [ fhir:v "prepDispenseMedication" ] ;
                   fhir:source ( [
                     fhir:context [ fhir:v "bundle" ] ;
                     fhir:element [ fhir:v "entry" ] ;
                     fhir:variable [ fhir:v "srcEntryVarDisp" ]
                   ] ) ;
                   fhir:rule ( [
                     fhir:name [ fhir:v "entryDispenseMedicationPart" ] ;
                     fhir:source ( [
                       fhir:context [ fhir:v "srcEntryVarDisp" ] ;
                       fhir:variable [ fhir:v "srcEntryBundleMDMedIdVar" ] ;
                       fhir:condition [ fhir:v "resource.ofType(Medication).where(id=%srcEntryBundleMDVar.medicationReference.reference.replace('urn:uuid:', '').split('/').last())" ]
                     ] ) ;
                     fhir:target ( [
                       fhir:context [ fhir:v "tgtDispenseInformationMedicationPart" ] ;
                       fhir:contextType [ fhir:v "variable" ] ;
                       fhir:element [ fhir:v "resource" ] ;
                       fhir:variable [ fhir:v "newMedicationDispensationMedication" ] ;
                       fhir:transform [ fhir:v "create" ] ;
                       fhir:parameter ( [
                         fhir:value [
                           a fhir:String ;
                           fhir:v "Medication"
                         ]
                       ] )
                     ] ) ;
                     fhir:rule ( [
                       fhir:name [ fhir:v "entryMedicationDispensationMedicationPartResourceSet" ] ;
                       fhir:source ( [
                         fhir:context [ fhir:v "srcEntryBundleMDMedIdVar" ] ;
                         fhir:type [ fhir:v "Medication" ] ;
                         fhir:element [ fhir:v "resource" ] ;
                         fhir:variable [ fhir:v "srcEntryBundleMDMedIdVarRes" ]
                       ] ) ;
                       fhir:dependent ( [
                         fhir:name [ fhir:v "ERPTPrescriptionStructureMapMedication" ] ;
                         fhir:variable ( [ fhir:v "srcEntryBundleMDMedIdVarRes" ] [ fhir:v "newMedicationDispensationMedication" ] )
                       ] ) ;
                       fhir:documentation [ fhir:v "Führt die detaillierte Medication-Transformation für das abgegebene Arzneimittel durch" ]
                     ] )
                   ] ) ;
                   fhir:documentation [ fhir:v "Bereitet die Suche nach der referenzierten Medication im Bundle vor" ]
                 ] ) ;
                 fhir:documentation [ fhir:v "Findet die vom MedicationDispense referenzierte Medication und transformiert sie in BfArM Format" ]
               ] ) ;
               fhir:documentation [ fhir:v "Bündelt MedicationDispense und zugehörige Medication unter dispenseInformation" ]
             ] ) ;
             fhir:documentation [ fhir:v "Erstellt eine dispenseInformation Part pro abgegebener MedicationDispense" ]
           ] ) ;
           fhir:documentation [ fhir:v "Extrahiert relevante Ressourcen für die Abgabe" ]
         ] ) ;
         fhir:documentation [ fhir:v "Verarbeitet alle Einträge des Quell-Bundles für Abgabeinformationen" ]
       ] ) ;
       fhir:documentation [ fhir:v "Erstellt den rxDispensation Parameter mit allen Abgabeinformationen" ]
     ] )
  ] ) . # 

# -------------------------------------------------------------------------------------

