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: SenologieToObdsFernmetastasen

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

title: Senologie Fernmetastasen Observations to oBDS Fernmetastasen BackboneElement status: draft

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

// title: Senologie Fernmetastasen Observations to oBDS Fernmetastasen BackboneElement
// status: draft

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

// Known limitation: Sub-groups 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. The element names are correct per the oBDS Logical Model.
// ============================================================================
// Gemeinsame Fernmetastasen-Map: Extrahiert Fernmetastasen-Observations
// aus dem Bundle und mappt auf das oBDS Fernmetastasen-BackboneElement.
// Wird von Diagnose und Verlauf importiert.
// MII Onko Profil: mii-pr-onko-fernmetastasen
// - LOINC 21907-1: Distant metastases.clinical Cancer
// - Alternative: LOINC 97956-3 (Fernmetastasen-Assessment)
// Jede Fernmetastasen-Observation erzeugt einen separaten Eintrag mit
// Diagnosedatum und Lokalisation. Die Lokalisation wird via ConceptMap
// von SNOMED zu oBDS-Kuerzeln (PUL, OSS, HEP, BRA, etc.) uebersetzt.
// ============================================================================
// ============================================================================
// MapFernmetastasenFromBundle: Bundle -> oBDS Fernmetastasen (repeating)
// Iteriert ueber alle Fernmetastasen-Observations im Bundle
// ============================================================================
group MapFernmetastasenFromBundle(source src : Bundle, target tgt : BackboneElement) {
  // Fernmetastasen: LOINC 21907-1 (Distant metastases.clinical)
  src.entry as fmEntry where resource.is(Observation) and resource.code.coding.exists(code = '21907-1') then {
    fmEntry.resource as fmObs -> tgt.fernmetastasen as fm then MapFernmetastase(fmObs, fm) "CallMapFernmetastase";
  } "EntryFernmetastasen";
  // Alternative: LOINC 97956-3 (Fernmetastasen-Assessment)
  src.entry as fmEntry where resource.is(Observation) and resource.code.coding.exists(code = '97956-3') then {
    fmEntry.resource as fmObs -> tgt.fernmetastasen as fm then MapFernmetastase(fmObs, fm) "CallMapFernmetastaseAlt";
  } "EntryFernmetastasenAlt";
}

// ============================================================================
// MapFernmetastase: Observation -> oBDS Fernmetastase (einzeln)
// Diagnosedatum und Lokalisation einer Fernmetastase
// ============================================================================
group MapFernmetastase(source src : Observation, target tgt : BackboneElement) {
  // Diagnosedatum: aus Observation.effectiveDateTime
  src.effective as eff where $this.is(dateTime) -> tgt.diagnosedatum = eff "SetFMDiagnosedatum";
  // Lokalisation: aus Observation.bodySite, Uebersetzung SNOMED -> oBDS
  src.bodySite as bs then {
    bs.coding as c where system = 'http://snomed.info/sct' -> tgt.lokalisation = translate(c, 'https://www.senologie.org/fhir/ConceptMap/cm-sct-to-obds-fm-lokalisation', 'code') "TranslateFMLokalisation";
  } "MapFMLokalisation";
  // Fallback: Lokalisation aus Observation.value (falls bodySite nicht vorhanden)
  src.value as val then {
    val.coding as c where system = 'http://snomed.info/sct' -> tgt.lokalisation = translate(c, 'https://www.senologie.org/fhir/ConceptMap/cm-sct-to-obds-fm-lokalisation', 'code') "TranslateFMLokalisationValue";
  } "MapFMLokalisationValue";
}