Implementation Guide
TIFlow - Datenaustausch BfArM Webdienst
Version 2.0.0 - release

StructureMap: E-T-Rezept Structure Map for KBV Ingredient Medication

Official URL: https://gematik.de/fhir/tiflow-bfarm/StructureMap/ERPTPrescriptionStructureMapKBVIngredientMedication Version: 2.0.0
Active as of 2026-10-02 Computable Name: ERPTPrescriptionStructureMapKBVIngredientMedication

Maps KBV-Ingredient ERP Medication to BfArM T-Prescription Medication format

map "https://gematik.de/fhir/tiflow-bfarm/StructureMap/ERPTPrescriptionStructureMapKBVIngredientMedication" = "ERPTPrescriptionStructureMapKBVIngredientMedication"

// Maps KBV-Ingredient ERP Medication to BfArM T-Prescription Medication format

uses "http://hl7.org/fhir/StructureDefinition/Medication" alias kbvMedicationIngredient as source
uses "http://hl7.org/fhir/StructureDefinition/Medication" alias bfarmMedication as target

// Mapping-Anweisungen zur Transformation von KBV Wirkstoff-Medikamenten zu BfArM T-Prescription Format
group ERPTPrescriptionStructureMapKBVIngredientMedication(source kbvMedicationIngredient : kbvMedicationIngredient, target bfarmMedication : bfarmMedication) {
  // Übernimmt die eindeutige Medication-ID unverändert
  kbvMedicationIngredient.id as IdVar -> bfarmMedication.id = IdVar "medicationId";
  // Mappt Medication-Extensions von KBV- zu BfArM-Format
  kbvMedicationIngredient.extension as extVar -> bfarmMedication.extension as tgtExtVar then {
    // Übernimmt die Normgröße-Extension unverändert (deutsche Packungsgrößenangabe)
    extVar where (url='http://fhir.de/StructureDefinition/normgroesse') -> tgtExtVar.url = 'http://fhir.de/StructureDefinition/normgroesse' then {
      // Kopiert den Wert der Normgröße-Extension (N1, N2, N3)
      extVar.value as extValVar -> tgtExtVar.value = extValVar "copyExtensionValue";
    } "copyNormgroesseExtensionUrl";
  } "medicationExt";
  // Kopiert die gewünschte Darreichungsform für die Wirkstoff-Verordnung (Kapseln, Salbe, Lösung, etc.)
  kbvMedicationIngredient.form as formVar -> bfarmMedication.form = formVar "medicationForm";
  // Mappt die Gesamtmenge der herzustellenden Wirkstoff-Verordnung
  kbvMedicationIngredient.amount as amountVar -> bfarmMedication.amount as tgtAmountVar then {
    // Kopiert den Nenner der Mengenangabe (z.B. '1' für 'pro Herstellung')
    amountVar.denominator as amountDenominatorVar -> tgtAmountVar.denominator = amountDenominatorVar "medicationAmountDenominator";
    // Mappt die detaillierte Mengenangabe
    amountVar.numerator as amountNumeratorVar -> tgtAmountVar.numerator as tgtAmountNumeratorVar then {
      // Transformiert Packungsgrößen-Extensions von KBV- zu gematik-Format für Wirkstoff Verordnung
      amountNumeratorVar.extension as amountNumExtVar -> tgtAmountNumeratorVar.extension as tgtAmountNumExtVar then {
        // Wandelt KBV-Packungsgrößen-Extension in gematik EPA-Medication Extension um
        amountNumExtVar where (url='https://fhir.kbv.de/StructureDefinition/KBV_EX_ERP_Medication_PackagingSize') -> tgtAmountNumExtVar.url = 'https://gematik.de/fhir/epa-medication/StructureDefinition/medication-packaging-size-extension' then {
          // Übernimmt den Packungsgrößenwert
          amountNumExtVar.value as extValVar -> tgtAmountNumExtVar.value = extValVar "copyExtensionValue";
        } "copyPackagingSizeExtensionUrl";
      } "medicationAmountExt";
      // Kopiert den numerischen Wert der Gesamtmenge (z.B. '100' für 100g Salbe)
      amountNumeratorVar.value as amountNumeratorValueVar -> tgtAmountNumeratorVar.value = amountNumeratorValueVar "medicationAmountNumeratorValue";
      // Übernimmt die Mengeneinheit (g, ml, Stück, etc.)
      amountNumeratorVar.unit as amountNumeratorUnitVar -> tgtAmountNumeratorVar.unit = amountNumeratorUnitVar "medicationAmountNumeratorUnit";
      // Kopiert das Codesystem für die Mengeneinheit (meist UCUM)
      amountNumeratorVar.system as amountNumeratorSystemVar -> tgtAmountNumeratorVar.system = amountNumeratorSystemVar "medicationAmountNumeratorSystem";
      // Übernimmt den standardisierten Code für die Mengeneinheit
      amountNumeratorVar.code as amountNumeratorCodeVar -> tgtAmountNumeratorVar.code = amountNumeratorCodeVar "medicationAmountNumeratorCode";
    } "medicationAmountNumerator";
  } "medicationAmount";
  // Kopiert die detaillierten Wirkstoffinformationen mit Konzentrationen und Mengenangaben
  kbvMedicationIngredient.ingredient as ingredientVar -> bfarmMedication.ingredient = ingredientVar "medicationIngredient";
}