You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 5, 2026. It is now read-only.
Description
When converting KDS_Laborbericht openEHR compositions to FHIR, the generated DiagnosticReport sometimes contains duplicate contained Specimen resources (same identifier), and Observation.specimen can be set even for analytes that do not have a probe ID in openEHR.
This leads to:
redundant contained resources
incorrect linkage semantics for analytes without specimen reference data
Current Behavior
Multiple contained Specimen resources are created with identical identifiers (same system|value) instead of reusing one contained specimen reference.
For patient-1, analyte 788-0 has no at0026 (Probe ID) in openEHR, but generated Observation still has specimen.reference.
Expected Behavior
Identical specimens should be reused (single contained Specimen per identifier signature).
Observation.specimen should only be generated if analyte-level probe ID/reference input exists (e.g. at0026 present).
Likely Root Cause
Mapping flow for CLUSTER.laboratory_test_analyte.v1 (specimen mapping to Observation.specimen) is executed without strict presence guard for analyte probe ID and creates reference resources per analyte occurrence without dedup/reuse.
Add/ensure analyte-level condition so Observation.specimen is only mapped when at0026 is present.
Introduce generic contained-resource reuse/dedup strategy based on stable identifier signature, with safe reference rewriting (#old -> #kept) where needed.
Acceptance Criteria
No duplicate contained Specimen with same identifier in generated DiagnosticReport.
For analytes without probe ID, Observation.specimen is absent.
Existing Laborbericht toFHIR tests pass, plus a regression test covering the patient-1 case.
Description
When converting KDS_Laborbericht openEHR compositions to FHIR, the generated DiagnosticReport sometimes contains duplicate contained Specimen resources (same identifier), and Observation.specimen can be set even for analytes that do not have a probe ID in openEHR.
This leads to:
Current Behavior
Expected Behavior
Repro
Use existing test data:
src/test/resources/kds/laborbericht/toOpenEHR/output/Composition-mii-exa-test-data-patient-1-labreport-1.json
src/test/resources/kds/laborbericht/toFHIR/output/DiagnosticReport-mii-exa-test-data-patient-1-labreport-1.json
Evidence:
Likely Root Cause
Mapping flow for CLUSTER.laboratory_test_analyte.v1 (specimen mapping to Observation.specimen) is executed without strict presence guard for analyte probe ID and creates reference resources per analyte occurrence without dedup/reuse.
Relevant mapping file:
Suggested Fix Direction
Acceptance Criteria