From d6d1001a864449aa7a1599b83fb405a96525f004 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Wed, 27 Nov 2024 11:12:43 +0100 Subject: [PATCH] refactor: map to list instead of bundle (#184) --- ...scheTherapieMedicationStatementMapper.java | 11 ++-- ...TherapieMedicationStatementMapperTest.java | 6 +- ...ement.Testpatient_1.xml.approved.fhir.json | 63 ++++++++----------- ...ement.Testpatient_2.xml.approved.fhir.json | 55 +++++++--------- ...ement.Testpatient_3.xml.approved.fhir.json | 55 +++++++--------- 5 files changed, 79 insertions(+), 111 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 a5950d03..0120703d 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 @@ -4,10 +4,10 @@ import de.basisdatensatz.obds.v3.SYSTTyp; import de.basisdatensatz.obds.v3.SYSTTyp.Meldeanlass; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; import java.util.List; import java.util.Objects; import org.apache.commons.lang3.Validate; -import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.CodeableConcept; import org.hl7.fhir.r4.model.Coding; import org.hl7.fhir.r4.model.Enumerations.ResourceType; @@ -32,7 +32,7 @@ public SystemischeTherapieMedicationStatementMapper(FhirProperties fhirPropertie super(fhirProperties); } - public Bundle map(SYSTTyp syst, Reference patient, Reference procedure) { + public List map(SYSTTyp syst, Reference patient, Reference procedure) { Objects.requireNonNull(syst, "Systemtherapie must not be null"); Objects.requireNonNull(patient, "Reference to Patient must not be null"); Objects.requireNonNull(procedure, "Reference to Procedure must not be null"); @@ -47,8 +47,7 @@ public Bundle map(SYSTTyp syst, Reference patient, Reference procedure) { procedure.getReferenceElement().getResourceType(), ResourceType.PROCEDURE.toCode()), "The subject reference should point to a Procedure resource"); - var bundle = new Bundle(); - bundle.setType(Bundle.BundleType.TRANSACTION); + var result = new ArrayList(); for (var substanz : syst.getMengeSubstanz().getSubstanz()) { var systMedicationStatement = new MedicationStatement(); @@ -104,11 +103,11 @@ public Bundle map(SYSTTyp syst, Reference patient, Reference procedure) { // Part of systMedicationStatement.setPartOf(List.of(procedure)); - bundle = addResourceAsEntryInBundle(bundle, systMedicationStatement); + result.add(systMedicationStatement); } } - return bundle; + return result; } private String createSubstanzIdFromPlain(String plainName) { diff --git a/src/test/java/org/miracum/streams/ume/obdstofhir/mapper/mii/SystemischeTherapieMedicationStatementMapperTest.java b/src/test/java/org/miracum/streams/ume/obdstofhir/mapper/mii/SystemischeTherapieMedicationStatementMapperTest.java index 97987ce2..e6634bb1 100644 --- a/src/test/java/org/miracum/streams/ume/obdstofhir/mapper/mii/SystemischeTherapieMedicationStatementMapperTest.java +++ b/src/test/java/org/miracum/streams/ume/obdstofhir/mapper/mii/SystemischeTherapieMedicationStatementMapperTest.java @@ -55,10 +55,12 @@ void map_withGivenObds_shouldCreateValidMedicationStatement(String sourceFile) .filter(m -> m.getSYST() != null) .findFirst() .get(); - var bundle = sut.map(systMeldung.getSYST(), patient, procedure); + var list = sut.map(systMeldung.getSYST(), patient, procedure); + + assertThat(list).hasSize(1); var fhirParser = FhirContext.forR4().newJsonParser().setPrettyPrint(true); - var fhirJson = fhirParser.encodeResourceToString(bundle); + var fhirJson = fhirParser.encodeResourceToString(list.get(0)); Approvals.verify( fhirJson, Approvals.NAMES.withParameters(sourceFile).forFile().withExtension(".fhir.json")); diff --git a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/SystemischeTherapieMedicationStatementMapperTest.map_withGivenObds_shouldCreateValidMedicationStatement.Testpatient_1.xml.approved.fhir.json b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/SystemischeTherapieMedicationStatementMapperTest.map_withGivenObds_shouldCreateValidMedicationStatement.Testpatient_1.xml.approved.fhir.json index 432b740b..104308e3 100644 --- a/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/SystemischeTherapieMedicationStatementMapperTest.map_withGivenObds_shouldCreateValidMedicationStatement.Testpatient_1.xml.approved.fhir.json +++ b/src/test/java/snapshots/org/miracum/streams/ume/obdstofhir/mapper/mii/SystemischeTherapieMedicationStatementMapperTest.map_withGivenObds_shouldCreateValidMedicationStatement.Testpatient_1.xml.approved.fhir.json @@ -1,39 +1,28 @@ { - "resourceType": "Bundle", - "type": "transaction", - "entry": [ { - "fullUrl": "MedicationStatement/050a031e5a9043c28c565c6b60550c3d34cd059bc2f24c195cdb807f099cd978", - "resource": { - "resourceType": "MedicationStatement", - "id": "050a031e5a9043c28c565c6b60550c3d34cd059bc2f24c195cdb807f099cd978", - "meta": { - "profile": [ "https://www.medizininformatik-initiative.de/fhir/core/modul-medikation/StructureDefinition/MedicationStatement" ] - }, - "identifier": [ { - "system": "https://bzkf.github.io/obds-to-fhir/identifiers/systemische-therapie-medication-statement-id", - "value": "101_IN-1_L01FF05" - } ], - "partOf": [ { - "reference": "Procedure/any" - } ], - "status": "completed", - "medicationCodeableConcept": { - "coding": [ { - "system": "http://fhir.de/CodeSystem/bfarm/atc", - "code": "L01FF05" - } ] - }, - "subject": { - "reference": "Patient/any" - }, - "effectivePeriod": { - "start": "2020-05", - "end": "2020-10-15" - } - }, - "request": { - "method": "PUT", - "url": "MedicationStatement/050a031e5a9043c28c565c6b60550c3d34cd059bc2f24c195cdb807f099cd978" - } - } ] + "resourceType": "MedicationStatement", + "id": "050a031e5a9043c28c565c6b60550c3d34cd059bc2f24c195cdb807f099cd978", + "meta": { + "profile": [ "https://www.medizininformatik-initiative.de/fhir/core/modul-medikation/StructureDefinition/MedicationStatement" ] + }, + "identifier": [ { + "system": "https://bzkf.github.io/obds-to-fhir/identifiers/systemische-therapie-medication-statement-id", + "value": "101_IN-1_L01FF05" + } ], + "partOf": [ { + "reference": "Procedure/any" + } ], + "status": "completed", + "medicationCodeableConcept": { + "coding": [ { + "system": "http://fhir.de/CodeSystem/bfarm/atc", + "code": "L01FF05" + } ] + }, + "subject": { + "reference": "Patient/any" + }, + "effectivePeriod": { + "start": "2020-05", + "end": "2020-10-15" + } } 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 6c8f7289..315f6973 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 @@ -1,35 +1,24 @@ { - "resourceType": "Bundle", - "type": "transaction", - "entry": [ { - "fullUrl": "MedicationStatement/e4b35c4756c9668e9c2b92f281667382020c401482e0a674566a695cd20a4cfa", - "resource": { - "resourceType": "MedicationStatement", - "id": "e4b35c4756c9668e9c2b92f281667382020c401482e0a674566a695cd20a4cfa", - "meta": { - "profile": [ "https://www.medizininformatik-initiative.de/fhir/core/modul-medikation/StructureDefinition/MedicationStatement" ] - }, - "identifier": [ { - "system": "https://bzkf.github.io/obds-to-fhir/identifiers/systemische-therapie-medication-statement-id", - "value": "11_1_Innere.1_Bicalutamid_fa96" - } ], - "partOf": [ { - "reference": "Procedure/any" - } ], - "status": "active", - "medicationCodeableConcept": { - "text": "Bicalutamid" - }, - "subject": { - "reference": "Patient/any" - }, - "effectivePeriod": { - "start": "2021-11-08" - } - }, - "request": { - "method": "PUT", - "url": "MedicationStatement/e4b35c4756c9668e9c2b92f281667382020c401482e0a674566a695cd20a4cfa" - } - } ] + "resourceType": "MedicationStatement", + "id": "e4b35c4756c9668e9c2b92f281667382020c401482e0a674566a695cd20a4cfa", + "meta": { + "profile": [ "https://www.medizininformatik-initiative.de/fhir/core/modul-medikation/StructureDefinition/MedicationStatement" ] + }, + "identifier": [ { + "system": "https://bzkf.github.io/obds-to-fhir/identifiers/systemische-therapie-medication-statement-id", + "value": "11_1_Innere.1_Bicalutamid_fa96" + } ], + "partOf": [ { + "reference": "Procedure/any" + } ], + "status": "active", + "medicationCodeableConcept": { + "text": "Bicalutamid" + }, + "subject": { + "reference": "Patient/any" + }, + "effectivePeriod": { + "start": "2021-11-08" + } } 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 e5a45a30..607a9dcb 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 @@ -1,35 +1,24 @@ { - "resourceType": "Bundle", - "type": "transaction", - "entry": [ { - "fullUrl": "MedicationStatement/da9d78a5d066bba6acd32a9a903c8663ecc1421cb373dcb51566b6d23dd30df7", - "resource": { - "resourceType": "MedicationStatement", - "id": "da9d78a5d066bba6acd32a9a903c8663ecc1421cb373dcb51566b6d23dd30df7", - "meta": { - "profile": [ "https://www.medizininformatik-initiative.de/fhir/core/modul-medikation/StructureDefinition/MedicationStatement" ] - }, - "identifier": [ { - "system": "https://bzkf.github.io/obds-to-fhir/identifiers/systemische-therapie-medication-statement-id", - "value": "12_1_Innere.1_Paclitaxel_a0a4" - } ], - "partOf": [ { - "reference": "Procedure/any" - } ], - "status": "active", - "medicationCodeableConcept": { - "text": "Paclitaxel" - }, - "subject": { - "reference": "Patient/any" - }, - "effectivePeriod": { - "start": "2018-03-17" - } - }, - "request": { - "method": "PUT", - "url": "MedicationStatement/da9d78a5d066bba6acd32a9a903c8663ecc1421cb373dcb51566b6d23dd30df7" - } - } ] + "resourceType": "MedicationStatement", + "id": "da9d78a5d066bba6acd32a9a903c8663ecc1421cb373dcb51566b6d23dd30df7", + "meta": { + "profile": [ "https://www.medizininformatik-initiative.de/fhir/core/modul-medikation/StructureDefinition/MedicationStatement" ] + }, + "identifier": [ { + "system": "https://bzkf.github.io/obds-to-fhir/identifiers/systemische-therapie-medication-statement-id", + "value": "12_1_Innere.1_Paclitaxel_a0a4" + } ], + "partOf": [ { + "reference": "Procedure/any" + } ], + "status": "active", + "medicationCodeableConcept": { + "text": "Paclitaxel" + }, + "subject": { + "reference": "Patient/any" + }, + "effectivePeriod": { + "start": "2018-03-17" + } }