Kerndatensatz Senologie
0.9.0 - ci-build

Kerndatensatz Senologie - Local Development build (v0.9.0) built by the FHIR (HL7® FHIR® Standard) Build Tools. See the Directory of published versions

StructureMap: SenologieToObdsSYST

Official URL: https://www.senologie.org/fhir/StructureMap/SenologieToObdsSYST Version: 0.9.0
Draft as of 2026-05-04 Computable Name: SenologieToObdsSYST

title: Senologie FHIR to oBDS Systemische Therapie (SYST) status: draft

map "https://www.senologie.org/fhir/StructureMap/SenologieToObdsSYST" = "SenologieToObdsSYST"

// title: Senologie FHIR to oBDS Systemische Therapie (SYST)
// status: draft

uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as source
uses "https://www.senologie.org/fhir/StructureDefinition/obds-meldung" alias OBDSMeldung as target

imports "https://www.senologie.org/fhir/StructureMap/SenologieToObdsTumorzuordnung"
imports "https://www.senologie.org/fhir/StructureMap/SenologieToObdsNebenwirkung"

// Known limitation: Sub-groups (MapSYST, MapSubstanz) use
// `target tgt : BackboneElement` because FML has no syntax to declare the
// Logical Model sub-path for BackboneElement slices passed from parent groups.
// The IG Publisher produces SM_TARGET_PATH errors (~16). The element names are
// correct per the oBDS Logical Model.
// ============================================================================
// Hauptgruppe: Bundle → oBDS SYST
// Ein Bundle enthaelt eine Systemtherapie-Procedure (uebergeordnet)
// und zugehoerige MedicationStatements (einzelne Substanzgaben).
// ============================================================================
group SenologieToObdsSYST(source src : Bundle, target tgt : OBDSMeldung) {
  // Systemtherapie-Procedure extrahieren
  src.entry as entry where resource.is(Procedure) and resource.meta.profile.exists($this.contains('senologie-systemtherapie-procedure')) then {
    entry.resource as proc -> tgt.syst as syst then MapSYST(proc, syst) "CallMapSYST";
    // Substanzen: MedicationStatements (moved from MapSYST)
    src.entry as medEntry where resource.is(MedicationStatement) then {
      medEntry.resource as medStmt -> syst.substanzen as subst then MapSubstanz(medStmt, subst) "CallMapSubstanz";
    } "EntrySubstanzen";
    // Nebenwirkungen (moved from MapSYST)
    proc -> syst.nebenwirkungen as nw then MapNebenwirkungenSYST(src, nw) "CallMapNebenwirkungen";
  } "EntrySYST";
}

// ============================================================================
// MapSYST: Procedure → oBDS SYST Basisdaten
// Mapped Intention, Stellung zur OP, Therapieart, Protokoll, Zeitraum
// ============================================================================
group MapSYST(source src : Procedure, target tgt : BackboneElement) {
  // SYST_ID: Procedure.id
  src.id as id -> tgt.systID = id "SetSystID";
  // Meldeanlass: abgeleitet aus Procedure.status
  // completed + performedPeriod.end vorhanden -> behandlungsende
  // completed + nur performedPeriod.start -> behandlungsbeginn
  src where performedPeriod.end.exists() -> tgt.meldeanlass = 'behandlungsende' "MeldeanlassEnde";
  src where performedPeriod.end.exists().not() -> tgt.meldeanlass = 'behandlungsbeginn' "MeldeanlassBeginn";
  // Intention: aus MII Onko Extension mii-ex-onko-systemische-therapie-intention
  // MII Onko CodeSystem nutzt bereits oBDS-Codes (K, P, D, R, S, X)
  src.extension as ext where url = 'https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/StructureDefinition/mii-ex-onko-systemische-therapie-intention' then {
    ext.value as val then {
      val.coding as c then {
        c.code as cd -> tgt.intention = cd "SetIntention";
      } "ExtractIntentionCode";
    } "ExtractIntentionCoding";
  } "MapIntention";
  // Stellung zur OP: aus Procedure.category (MII Onko StellungZurOp)
  // MII Onko CodeSystem nutzt bereits oBDS-Codes (O, A, N, I, S)
  src.category as cat then {
    cat.coding as c where system = 'https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/CodeSystem/mii-cs-onko-therapie-stellungzurop' then {
      c.code as cd -> tgt.stellungOP = cd "SetStellungOP";
    } "ExtractStellungCode";
  } "MapStellungOP";
  // Therapieart: aus Procedure.category (MII Onko Therapietyp-CodeSystem)
  // Mappt CH, HO, IM, ZS etc.
  src.category as cat then {
    cat.coding as c where system = 'https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/CodeSystem/mii-cs-onko-therapie-typ' -> tgt.therapieart = translate(c, 'https://www.senologie.org/fhir/ConceptMap/cm-sct-to-obds-therapieart', 'code') "TranslateTherapieart";
  } "MapTherapieart";
  // Protokoll: aus Procedure.usedCode.text (Protokollbezeichnung, z.B. "EC-T")
  src.usedCode as uc then {
    uc.text as t -> tgt.protokoll = t "SetProtokoll";
  } "MapProtokoll";
  // Beginn: aus Procedure.performedPeriod.start
  src.performed as perf then {
    perf.start as s -> tgt.beginn = s "SetBeginn";
  } "MapBeginn";
  // Ende: aus Procedure.performedPeriod.end
  src.performed as perf then {
    perf.end as e -> tgt.ende = e "SetEnde";
  } "MapEnde";
  // Ende-Grund: aus Procedure.outcome.coding (MII Onko Ende-Grund CodeSystem)
  // Falls keine strukturierte Codierung vorhanden, Freitext als Fallback
  src.outcome as oc then {
    oc.coding as c -> tgt.endeGrund = (c.code) "SetEndeGrundCode";
  } "MapEndeGrund";
// Substanzen and Nebenwirkungen bundle lookups moved to calling group.
}

// ============================================================================
// MapSubstanz: MedicationStatement → oBDS Substanz
// Extrahiert Substanzbezeichnung und ATC-Code aus der Medikation
// ============================================================================
group MapSubstanz(source src : MedicationStatement, target tgt : BackboneElement) {
  // Bezeichnung: aus medicationCodeableConcept.text oder coding.display
  src.medication as med then {
    med.text as t -> tgt.bezeichnung = t "SetSubstanzBezeichnung";
  } "MapSubstanzBezeichnung";
  // ATC-Code: aus medicationCodeableConcept.coding mit ATC-System
  src.medication as med then {
    med.coding as c where system = 'http://fhir.de/CodeSystem/bfarm/atc' then {
      c.code as code -> tgt.atcCode = code "SetAtcCode";
      c.version as v -> tgt.atcVersion = v "SetAtcVersion";
    } "ExtractAtcCoding";
  } "MapAtcCode";
}