Skip to content

Commit

Permalink
refactor: map to list instead of bundle (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
pcvolkmer authored Nov 27, 2024
1 parent 28919e7 commit d6d1001
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,7 +32,7 @@ public SystemischeTherapieMedicationStatementMapper(FhirProperties fhirPropertie
super(fhirProperties);
}

public Bundle map(SYSTTyp syst, Reference patient, Reference procedure) {
public List<MedicationStatement> 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");
Expand All @@ -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<MedicationStatement>();

for (var substanz : syst.getMengeSubstanz().getSubstanz()) {
var systMedicationStatement = new MedicationStatement();
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
}

0 comments on commit d6d1001

Please sign in to comment.