Implementation Guide
E-T-Rezept Datenaustausch
Version 1.1.0-ballot-1 - ballot

StructureMap: E-T-Rezept Structure Map for MedicationRequest

Official URL: https://gematik.de/fhir/erp-t-prescription/StructureMap/ERPTPrescriptionStructureMapMedicationRequest Version: 1.1.0-ballot-1
Draft as of 2025-07-07 Computable Name: ERPTPrescriptionStructureMapMedicationRequest

Mapping-Anweisungen zur Transformation von KBV MedicationRequest zu BfArM T-Prescription MedicationRequest

map "https://gematik.de/fhir/erp-t-prescription/StructureMap/ERPTPrescriptionStructureMapMedicationRequest" = "ERPTPrescriptionStructureMapMedicationRequest"

// Mapping-Anweisungen zur Transformation von KBV MedicationRequest zu BfArM T-Prescription MedicationRequest

uses "https://fhir.kbv.de/StructureDefinition/KBV_PR_ERP_Prescription" alias kbvMedicationRequest as source
uses "https://gematik.de/fhir/erp-t-prescription/StructureDefinition/erp-tprescription-medication-request" alias bfarmMedicationRequest as target

// Mapping-Anweisungen zur Transformation von KBV MedicationRequest zu BfArM T-Prescription MedicationRequest
group ERPTPrescriptionStructureMapMedicationRequest(source kbvMedicationRequest : kbvMedicationRequest, target bfarmMedicationRequest : bfarmMedicationRequest) {
  kbvMedicationRequest.status as srcStatus -> bfarmMedicationRequest.status = 'completed' "medicationRequestStatus"; // Setzt den Status auf 'completed' für den digitalen Durchschlag (Verschreibung ist bereits abgeschlossen)
  kbvMedicationRequest.intent -> bfarmMedicationRequest.intent = 'order' "medicationRequestIntent"; // Setzt den Intent auf 'order' entsprechend der BfArM-Spezifikation für T-Prescription
  kbvMedicationRequest.extension as extVar -> bfarmMedicationRequest.extension as tgtExtVar then {
    extVar as extMatchVar where url='https://fhir.kbv.de/StructureDefinition/KBV_EX_ERP_Teratogenic' -> tgtExtVar.url = 'https://fhir.kbv.de/StructureDefinition/KBV_EX_ERP_Teratogenic' then {
      extMatchVar.extension as extValVar -> tgtExtVar.extension = extValVar "copyExtensionValue"; // Übernimmt den Wert der teratogenen Extension unverändert
    } "copyTPrescriptionExtensionUrl"; // Kopiert teratogene Extensions für T-Rezept Kennzeichnung
  } "medicationRequestExt"; // Mappt T-Rezept spezifische Extensions vom KBV- zum BfArM-Format
  kbvMedicationRequest.subject as srcSubject -> bfarmMedicationRequest.subject as tgtSubject then {
    kbvMedicationRequest.subject as srcSubject -> tgtSubject.extension as tgtSubjectExtension then {
      kbvMedicationRequest.subject as srcSubject ->  tgtSubjectExtension.url = 'http://hl7.org/fhir/StructureDefinition/data-absent-reason',  tgtSubjectExtension.value = cast('not-permitted', 'code') "medicationRequestsubjectExtensionContent"; // Setzt data-absent-reason auf 'not-permitted' um Patientendaten zu anonymisieren
    } "medicationRequestsubjectExtension"; // Erstellt data-absent-reason Extension für Subject
  } "medicationRequestsubject"; // Entfernt Patientenbezug durch data-absent-reason Extension für Datenschutz im digitalen Durchschlag
  kbvMedicationRequest.authoredOn as srcAuthoredOnVar -> bfarmMedicationRequest.authoredOn = srcAuthoredOnVar "medicationRequestAuthoredOn"; // Übernimmt das Verschreibungsdatum unverändert vom KBV MedicationRequest
  kbvMedicationRequest.dosageInstruction as srcDosageInstructionVar -> bfarmMedicationRequest.dosageInstruction = srcDosageInstructionVar "medicationRequestDosageInstruction"; // Kopiert die Dosierungsanweisungen vollständig für den digitalen Durchschlag
  kbvMedicationRequest.dispenseRequest as srcDispenseRequestVar -> bfarmMedicationRequest.dispenseRequest = srcDispenseRequestVar "medicationRequestDispenseRequest"; // Übernimmt Abgabeanweisungen (Menge, Wiederholungen) aus der ursprünglichen Verschreibung
  kbvMedicationRequest.medication as medicationVar -> bfarmMedicationRequest.medication = medicationVar "medicationReference"; // Kopiert die Medikamentenreferenz - das referenzierte Medication wird separat gemappt
}