@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/ERPTPrescriptionStructureMapGEMMedication> a fhir:StructureMap ;
  fhir:nodeRole fhir:treeRoot ;
  fhir:id [ fhir:v "ERPTPrescriptionStructureMapGEMMedication"] ; # 
  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 ERPTPrescriptionStructureMapGEMMedication</b></p><a name=\"ERPTPrescriptionStructureMapGEMMedication\"> </a><a name=\"hcERPTPrescriptionStructureMapGEMMedication\"> </a><pre class=\"fml\">#xD;\n<b>map</b><span style=\"color: navy\"> \"</span>https://gematik.de/fhir/erp-t-prescription/StructureMap/ERPTPrescriptionStructureMapGEMMedication<span style=\"color: navy\">\" = \"</span>ERPTPrescriptionStructureMapGEMMedication<span style=\"color: navy\">\"#xD;\n#xD;\n</span><span style=\"color: navy\">// </span><span style=\"color: green\">Maps GEM ERP Medication to BfArM T-Prescription Medication format</span>#xD;\n#xD;\n<b>uses</b><span style=\"color: navy\"> \"</span><a href=\"http://hl7.org/fhir/R4/medication.html\" title=\"Medication\">http://hl7.org/fhir/StructureDefinition/Medication</a><span style=\"color: navy\">\" </span><b>alias </b>gematikMedication <b>as </b><b>source</b>#xD;\n<b>uses</b><span style=\"color: navy\"> \"</span><a href=\"http://hl7.org/fhir/R4/medication.html\" title=\"Medication\">http://hl7.org/fhir/StructureDefinition/Medication</a><span style=\"color: navy\">\" </span><b>alias </b>bfarmMedication <b>as </b><b>target</b>#xD;\n#xD;\n<span style=\"color: navy\">// </span><span style=\"color: green\">Mapping-Anweisungen zur Transformation von gematik ERP-Medikamenten zu BfArM T-Prescription Format</span>#xD;\n<b>group </b>ERPTPrescriptionStructureMapGEMMedication<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">gematikMedication</span><span style=\"color: navy\"> : </span>gematikMedication, <b>target</b> <span style=\"color: maroon\">bfarmMedication</span><span style=\"color: navy\"> : </span>bfarmMedication<span style=\"color: navy\">)</span><span style=\"color: navy\"> {#xD;\n</span>  gematikMedication.id<b> as </b><span style=\"color: maroon\">IdVar</span><span style=\"color: navy\"><b> -&gt; </b></span>bfarmMedication.id = <span style=\"color: maroon\">IdVar</span> <i>\"medicationId\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Übernimmt die eindeutige Medication-ID unverändert</span>#xD;\n  gematikMedication.contained<b> as </b><span style=\"color: maroon\">ContainedVar</span><span style=\"color: navy\"><b> -&gt; </b></span>bfarmMedication.contained = <span style=\"color: maroon\">ContainedVar</span> <i>\"mapContainedRessources\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Kopiert eingebettete Ressourcen (z.B. referenzierte Medications oder Organizations)</span>#xD;\n  gematikMedication.extension<b> as </b><span style=\"color: maroon\">extVar</span><span style=\"color: navy\"><b> -&gt; </b></span>bfarmMedication.extension<b> as </b><span style=\"color: maroon\">tgtExtVar</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>    extVar<b> where </b>url='http://fhir.de/StructureDefinition/normgroesse'<span style=\"color: navy\"><b> -&gt; </b></span>tgtExtVar.url = <span style=\"color: blue\">'http://fhir.de/StructureDefinition/normgroesse'</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>      extVar.value<b> as </b><span style=\"color: maroon\">extValVar</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtExtVar.value = <span style=\"color: maroon\">extValVar</span> <i>\"copyExtensionValue\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Kopiert den Wert der Normgröße-Extension</span>#xD;\n    <span style=\"color: navy\">}</span> <i>\"copyNormgroesseExtensionUrl\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Übernimmt die Normgröße-Extension unverändert (deutsche Packungsgrößenangabe N1, N2, N3)</span>#xD;\n    extVar<b> where </b>url='https://gematik.de/fhir/epa-medication/StructureDefinition/medication-formulation-packaging-extension'<span style=\"color: navy\"><b> -&gt; </b></span>tgtExtVar.url = <span style=\"color: blue\">'https://gematik.de/fhir/epa-medication/StructureDefinition/medication-formulation-packaging-extension'</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>      extVar.value<b> as </b><span style=\"color: maroon\">extValVar</span><span style=\"color: navy\"><b> -&gt; </b></span>tgtExtVar.value = <span style=\"color: maroon\">extValVar</span> <i>\"copyExtensionValue\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Kopiert den Wert der Verpackungs-Extension</span>#xD;\n    <span style=\"color: navy\">}</span> <i>\"copyPackagingExtensionUrl\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Übernimmt die gematik-Verpackungs-Extension für Formulierungen</span>#xD;\n  <span style=\"color: navy\">}</span> <i>\"medicationExtension\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Mappt gematik-spezifische Medication-Extensions zu BfArM-Format</span>#xD;\n  gematikMedication.code<b> as </b><span style=\"color: maroon\">codeVar</span><span style=\"color: navy\"><b> -&gt; </b></span>bfarmMedication.code = <span style=\"color: maroon\">codeVar</span> <i>\"medicationCode\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Kopiert den Medikamentencode (PZN oder andere Identifikation) des abgegebenen Arzneimittels</span>#xD;\n  gematikMedication.form<b> as </b><span style=\"color: maroon\">formVar</span><span style=\"color: navy\"><b> -&gt; </b></span>bfarmMedication.form = <span style=\"color: maroon\">formVar</span> <i>\"medicationForm\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Übernimmt die Darreichungsform des tatsächlich abgegebenen Arzneimittels</span>#xD;\n  gematikMedication.amount<b> as </b><span style=\"color: maroon\">amountVar</span><span style=\"color: navy\"><b> -&gt; </b></span>bfarmMedication.amount = <span style=\"color: maroon\">amountVar</span> <i>\"medicationAmount\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Kopiert die Mengenangaben des abgegebenen Arzneimittels (tatsächlich ausgehändigte Menge)</span>#xD;\n  gematikMedication.ingredient<b> as </b><span style=\"color: maroon\">ingredientVar</span><span style=\"color: navy\"><b> -&gt; </b></span>bfarmMedication.ingredient = <span style=\"color: maroon\">ingredientVar</span> <i>\"medicationIngredient\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Übernimmt Wirkstoffinformationen des abgegebenen Arzneimittels (falls vorhanden)</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/ERPTPrescriptionStructureMapGEMMedication"^^xsd:anyURI ;
     fhir:l <https://gematik.de/fhir/erp-t-prescription/StructureMap/ERPTPrescriptionStructureMapGEMMedication>
  ] ; # 
  fhir:version [ fhir:v "2.0.0-ballot.1"] ; # 
  fhir:name [ fhir:v "ERPTPrescriptionStructureMapGEMMedication"] ; # 
  fhir:title [ fhir:v "E-T-Rezept Structure Map for Medication"] ; # 
  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 "Maps GEM ERP Medication to BfArM T-Prescription Medication format"] ; # 
  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/Medication"^^xsd:anyURI ;
       fhir:l <http://hl7.org/fhir/StructureDefinition/Medication>
     ] ;
     fhir:mode [ fhir:v "source" ] ;
     fhir:alias [ fhir:v "gematikMedication" ]
  ] [
     fhir:url [
       fhir:v "http://hl7.org/fhir/StructureDefinition/Medication"^^xsd:anyURI ;
       fhir:l <http://hl7.org/fhir/StructureDefinition/Medication>
     ] ;
     fhir:mode [ fhir:v "target" ] ;
     fhir:alias [ fhir:v "bfarmMedication" ]
  ] ) ; # 
  fhir:group ( [
     fhir:name [ fhir:v "ERPTPrescriptionStructureMapGEMMedication" ] ;
     fhir:typeMode [ fhir:v "none" ] ;
     fhir:documentation [ fhir:v "Mapping-Anweisungen zur Transformation von gematik ERP-Medikamenten zu BfArM T-Prescription Format" ] ;
     fhir:input ( [
       fhir:name [ fhir:v "gematikMedication" ] ;
       fhir:type [ fhir:v "gematikMedication" ] ;
       fhir:mode [ fhir:v "source" ]
     ] [
       fhir:name [ fhir:v "bfarmMedication" ] ;
       fhir:type [ fhir:v "bfarmMedication" ] ;
       fhir:mode [ fhir:v "target" ]
     ] ) ;
     fhir:rule ( [
       fhir:name [ fhir:v "medicationId" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "gematikMedication" ] ;
         fhir:element [ fhir:v "id" ] ;
         fhir:variable [ fhir:v "IdVar" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "bfarmMedication" ] ;
         fhir:contextType [ fhir:v "variable" ] ;
         fhir:element [ fhir:v "id" ] ;
         fhir:transform [ fhir:v "copy" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:Id ;
             fhir:v "IdVar"
           ]
         ] )
       ] ) ;
       fhir:documentation [ fhir:v "Übernimmt die eindeutige Medication-ID unverändert" ]
     ] [
       fhir:name [ fhir:v "mapContainedRessources" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "gematikMedication" ] ;
         fhir:element [ fhir:v "contained" ] ;
         fhir:variable [ fhir:v "ContainedVar" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "bfarmMedication" ] ;
         fhir:contextType [ fhir:v "variable" ] ;
         fhir:element [ fhir:v "contained" ] ;
         fhir:transform [ fhir:v "copy" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:Id ;
             fhir:v "ContainedVar"
           ]
         ] )
       ] ) ;
       fhir:documentation [ fhir:v "Kopiert eingebettete Ressourcen (z.B. referenzierte Medications oder Organizations)" ]
     ] [
       fhir:name [ fhir:v "medicationExtension" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "gematikMedication" ] ;
         fhir:element [ fhir:v "extension" ] ;
         fhir:variable [ fhir:v "extVar" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "bfarmMedication" ] ;
         fhir:contextType [ fhir:v "variable" ] ;
         fhir:element [ fhir:v "extension" ] ;
         fhir:variable [ fhir:v "tgtExtVar" ]
       ] ) ;
       fhir:rule ( [
         fhir:name [ fhir:v "copyNormgroesseExtensionUrl" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "extVar" ] ;
           fhir:condition [ fhir:v "url='http://fhir.de/StructureDefinition/normgroesse'" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "tgtExtVar" ] ;
           fhir:contextType [ fhir:v "variable" ] ;
           fhir:element [ fhir:v "url" ] ;
           fhir:transform [ fhir:v "copy" ] ;
           fhir:parameter ( [
             fhir:value [
               a fhir:String ;
               fhir:v "http://fhir.de/StructureDefinition/normgroesse"
             ]
           ] )
         ] ) ;
         fhir:rule ( [
           fhir:name [ fhir:v "copyExtensionValue" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "extVar" ] ;
             fhir:element [ fhir:v "value" ] ;
             fhir:variable [ fhir:v "extValVar" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "tgtExtVar" ] ;
             fhir:contextType [ fhir:v "variable" ] ;
             fhir:element [ fhir:v "value" ] ;
             fhir:transform [ fhir:v "copy" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:Id ;
                 fhir:v "extValVar"
               ]
             ] )
           ] ) ;
           fhir:documentation [ fhir:v "Kopiert den Wert der Normgröße-Extension" ]
         ] ) ;
         fhir:documentation [ fhir:v "Übernimmt die Normgröße-Extension unverändert (deutsche Packungsgrößenangabe N1, N2, N3)" ]
       ] [
         fhir:name [ fhir:v "copyPackagingExtensionUrl" ] ;
         fhir:source ( [
           fhir:context [ fhir:v "extVar" ] ;
           fhir:condition [ fhir:v "url='https://gematik.de/fhir/epa-medication/StructureDefinition/medication-formulation-packaging-extension'" ]
         ] ) ;
         fhir:target ( [
           fhir:context [ fhir:v "tgtExtVar" ] ;
           fhir:contextType [ fhir:v "variable" ] ;
           fhir:element [ fhir:v "url" ] ;
           fhir:transform [ fhir:v "copy" ] ;
           fhir:parameter ( [
             fhir:value [
               a fhir:String ;
               fhir:v "https://gematik.de/fhir/epa-medication/StructureDefinition/medication-formulation-packaging-extension"
             ]
           ] )
         ] ) ;
         fhir:rule ( [
           fhir:name [ fhir:v "copyExtensionValue" ] ;
           fhir:source ( [
             fhir:context [ fhir:v "extVar" ] ;
             fhir:element [ fhir:v "value" ] ;
             fhir:variable [ fhir:v "extValVar" ]
           ] ) ;
           fhir:target ( [
             fhir:context [ fhir:v "tgtExtVar" ] ;
             fhir:contextType [ fhir:v "variable" ] ;
             fhir:element [ fhir:v "value" ] ;
             fhir:transform [ fhir:v "copy" ] ;
             fhir:parameter ( [
               fhir:value [
                 a fhir:Id ;
                 fhir:v "extValVar"
               ]
             ] )
           ] ) ;
           fhir:documentation [ fhir:v "Kopiert den Wert der Verpackungs-Extension" ]
         ] ) ;
         fhir:documentation [ fhir:v "Übernimmt die gematik-Verpackungs-Extension für Formulierungen" ]
       ] ) ;
       fhir:documentation [ fhir:v "Mappt gematik-spezifische Medication-Extensions zu BfArM-Format" ]
     ] [
       fhir:name [ fhir:v "medicationCode" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "gematikMedication" ] ;
         fhir:element [ fhir:v "code" ] ;
         fhir:variable [ fhir:v "codeVar" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "bfarmMedication" ] ;
         fhir:contextType [ fhir:v "variable" ] ;
         fhir:element [ fhir:v "code" ] ;
         fhir:transform [ fhir:v "copy" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:Id ;
             fhir:v "codeVar"
           ]
         ] )
       ] ) ;
       fhir:documentation [ fhir:v "Kopiert den Medikamentencode (PZN oder andere Identifikation) des abgegebenen Arzneimittels" ]
     ] [
       fhir:name [ fhir:v "medicationForm" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "gematikMedication" ] ;
         fhir:element [ fhir:v "form" ] ;
         fhir:variable [ fhir:v "formVar" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "bfarmMedication" ] ;
         fhir:contextType [ fhir:v "variable" ] ;
         fhir:element [ fhir:v "form" ] ;
         fhir:transform [ fhir:v "copy" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:Id ;
             fhir:v "formVar"
           ]
         ] )
       ] ) ;
       fhir:documentation [ fhir:v "Übernimmt die Darreichungsform des tatsächlich abgegebenen Arzneimittels" ]
     ] [
       fhir:name [ fhir:v "medicationAmount" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "gematikMedication" ] ;
         fhir:element [ fhir:v "amount" ] ;
         fhir:variable [ fhir:v "amountVar" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "bfarmMedication" ] ;
         fhir:contextType [ fhir:v "variable" ] ;
         fhir:element [ fhir:v "amount" ] ;
         fhir:transform [ fhir:v "copy" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:Id ;
             fhir:v "amountVar"
           ]
         ] )
       ] ) ;
       fhir:documentation [ fhir:v "Kopiert die Mengenangaben des abgegebenen Arzneimittels (tatsächlich ausgehändigte Menge)" ]
     ] [
       fhir:name [ fhir:v "medicationIngredient" ] ;
       fhir:source ( [
         fhir:context [ fhir:v "gematikMedication" ] ;
         fhir:element [ fhir:v "ingredient" ] ;
         fhir:variable [ fhir:v "ingredientVar" ]
       ] ) ;
       fhir:target ( [
         fhir:context [ fhir:v "bfarmMedication" ] ;
         fhir:contextType [ fhir:v "variable" ] ;
         fhir:element [ fhir:v "ingredient" ] ;
         fhir:transform [ fhir:v "copy" ] ;
         fhir:parameter ( [
           fhir:value [
             a fhir:Id ;
             fhir:v "ingredientVar"
           ]
         ] )
       ] ) ;
       fhir:documentation [ fhir:v "Übernimmt Wirkstoffinformationen des abgegebenen Arzneimittels (falls vorhanden)" ]
     ] )
  ] ) . # 

# -------------------------------------------------------------------------------------

