From 914ba6e987f5874e3796e3f44c174dfdb2588ba3 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Mon, 25 Nov 2024 13:16:31 +0100 Subject: [PATCH] extract and change substance id generation from plain name --- ...ystemischeTherapieMedicationStatementMapper.java | 13 +++++++++++-- ...onStatement.Testpatient_2.xml.approved.fhir.json | 8 ++++---- ...onStatement.Testpatient_3.xml.approved.fhir.json | 8 ++++---- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/mii/SystemischeTherapieMedicationStatementMapper.java b/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/mii/SystemischeTherapieMedicationStatementMapper.java index d2556e65..c9901ac2 100644 --- a/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/mii/SystemischeTherapieMedicationStatementMapper.java +++ b/src/main/java/org/miracum/streams/ume/obdstofhir/mapper/mii/SystemischeTherapieMedicationStatementMapper.java @@ -1,8 +1,9 @@ package org.miracum.streams.ume.obdstofhir.mapper.mii; +import com.google.common.hash.Hashing; import de.basisdatensatz.obds.v3.SYSTTyp; import de.basisdatensatz.obds.v3.SYSTTyp.Meldeanlass; - +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Objects; import org.apache.commons.lang3.Validate; @@ -65,7 +66,7 @@ public Bundle map(SYSTTyp syst, Reference patient, Reference procedure) { fhirProperties.getSystems().getAtcBfarm(), substanz.getATC().getCode(), ""); systMedicationStatement.setMedication(new CodeableConcept(atcCoding)); } else { - substanzId = substanz.getBezeichnung().replaceAll("[^A-Za-z0-9]", ""); + substanzId = createSubstanzIdFromPlain(substanz.getBezeichnung()); systMedicationStatement.setMedication( new CodeableConcept().setText(substanz.getBezeichnung())); } @@ -108,4 +109,12 @@ public Bundle map(SYSTTyp syst, Reference patient, Reference procedure) { return bundle; } + + private String createSubstanzIdFromPlain(String plainName) { + Validate.notBlank(plainName, "Required substance name is unset"); + return String.format( + "%s_%s", + plainName.replaceAll("[^A-Za-z0-9]+", ""), + Hashing.sha256().hashString(plainName, StandardCharsets.UTF_8).toString().substring(0, 4)); + } } diff --git a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/SystemischeTherapieMedicationStatementMapperTest.map_withGivenObds_shouldCreateValidMedicationStatement.Testpatient_2.xml.approved.fhir.json b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/SystemischeTherapieMedicationStatementMapperTest.map_withGivenObds_shouldCreateValidMedicationStatement.Testpatient_2.xml.approved.fhir.json index 603fc53d..4c6b013c 100644 --- a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/SystemischeTherapieMedicationStatementMapperTest.map_withGivenObds_shouldCreateValidMedicationStatement.Testpatient_2.xml.approved.fhir.json +++ b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/SystemischeTherapieMedicationStatementMapperTest.map_withGivenObds_shouldCreateValidMedicationStatement.Testpatient_2.xml.approved.fhir.json @@ -2,16 +2,16 @@ "resourceType": "Bundle", "type": "transaction", "entry": [ { - "fullUrl": "MedicationStatement/d5925147316a1e8c6e69c3f663fad0301c1666ca5bf1b14f4c75cdda22ffce3b", + "fullUrl": "MedicationStatement/2be692115f7383b050211e2c4b857655192448b28772b0a5af15839b1a84fa5e", "resource": { "resourceType": "MedicationStatement", - "id": "d5925147316a1e8c6e69c3f663fad0301c1666ca5bf1b14f4c75cdda22ffce3b", + "id": "2be692115f7383b050211e2c4b857655192448b28772b0a5af15839b1a84fa5e", "meta": { "profile": [ "https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/StructureDefinition/mii-pr-onko-systemische-therapie-medikation" ] }, "identifier": [ { "system": "https://bzkf.github.io/obds-to-fhir/identifiers/systemische-therapie-procedure-id", - "value": "11_1_Innere.1_Bicalutamid" + "value": "11_1_Innere.1_Bicalutamid_fa96" } ], "partOf": [ { "reference": "Procedure/any" @@ -29,7 +29,7 @@ }, "request": { "method": "PUT", - "url": "MedicationStatement/d5925147316a1e8c6e69c3f663fad0301c1666ca5bf1b14f4c75cdda22ffce3b" + "url": "MedicationStatement/2be692115f7383b050211e2c4b857655192448b28772b0a5af15839b1a84fa5e" } } ] } diff --git a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/SystemischeTherapieMedicationStatementMapperTest.map_withGivenObds_shouldCreateValidMedicationStatement.Testpatient_3.xml.approved.fhir.json b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/SystemischeTherapieMedicationStatementMapperTest.map_withGivenObds_shouldCreateValidMedicationStatement.Testpatient_3.xml.approved.fhir.json index de40ff90..3235e9ba 100644 --- a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/SystemischeTherapieMedicationStatementMapperTest.map_withGivenObds_shouldCreateValidMedicationStatement.Testpatient_3.xml.approved.fhir.json +++ b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/SystemischeTherapieMedicationStatementMapperTest.map_withGivenObds_shouldCreateValidMedicationStatement.Testpatient_3.xml.approved.fhir.json @@ -2,16 +2,16 @@ "resourceType": "Bundle", "type": "transaction", "entry": [ { - "fullUrl": "MedicationStatement/9d5246fd9512f352552a8ea37cbb65991f06e7497c6bf0575f81a49e1b9bfa35", + "fullUrl": "MedicationStatement/69e986083bed8b3ee0519fda269bfa44104d421348ccd8214f1af901b26650df", "resource": { "resourceType": "MedicationStatement", - "id": "9d5246fd9512f352552a8ea37cbb65991f06e7497c6bf0575f81a49e1b9bfa35", + "id": "69e986083bed8b3ee0519fda269bfa44104d421348ccd8214f1af901b26650df", "meta": { "profile": [ "https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/StructureDefinition/mii-pr-onko-systemische-therapie-medikation" ] }, "identifier": [ { "system": "https://bzkf.github.io/obds-to-fhir/identifiers/systemische-therapie-procedure-id", - "value": "12_1_Innere.1_Paclitaxel" + "value": "12_1_Innere.1_Paclitaxel_a0a4" } ], "partOf": [ { "reference": "Procedure/any" @@ -29,7 +29,7 @@ }, "request": { "method": "PUT", - "url": "MedicationStatement/9d5246fd9512f352552a8ea37cbb65991f06e7497c6bf0575f81a49e1b9bfa35" + "url": "MedicationStatement/69e986083bed8b3ee0519fda269bfa44104d421348ccd8214f1af901b26650df" } } ] }