-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added dummy strahlentherapie mapper (#147)
* feat: added dummy strahlentherapie mapper * feat: add mapping for status This also adds custom enum binding for ST_Type.Meldeanlass * made dummy mapper profile-conformant * added further Testpatient resources and snapshots * drop timezone overrides since we're only having dates and not timestamps anyways * chore: remove now obsolete test file * validate that subject points to a patient resource * re-order commented code --------- Co-authored-by: Paul-Christian Volkmer <[email protected]>
- Loading branch information
Showing
9 changed files
with
448 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
src/main/java/org/miracum/streams/ume/obdstofhir/mapper/mii/StrahlentherapieMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
package org.miracum.streams.ume.obdstofhir.mapper.mii; | ||
|
||
import de.basisdatensatz.obds.v3.STTyp; | ||
import java.util.Objects; | ||
import org.apache.commons.lang3.Validate; | ||
import org.hl7.fhir.r4.model.CodeType; | ||
import org.hl7.fhir.r4.model.CodeableConcept; | ||
import org.hl7.fhir.r4.model.Coding; | ||
import org.hl7.fhir.r4.model.DateTimeType; | ||
import org.hl7.fhir.r4.model.Enumerations.ResourceType; | ||
import org.hl7.fhir.r4.model.Extension; | ||
import org.hl7.fhir.r4.model.Identifier; | ||
import org.hl7.fhir.r4.model.Period; | ||
import org.hl7.fhir.r4.model.Procedure; | ||
import org.hl7.fhir.r4.model.Reference; | ||
import org.miracum.streams.ume.obdstofhir.FhirProperties; | ||
import org.miracum.streams.ume.obdstofhir.mapper.ObdsToFhirMapper; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class StrahlentherapieMapper extends ObdsToFhirMapper { | ||
private static final Logger LOG = LoggerFactory.getLogger(StrahlentherapieMapper.class); | ||
|
||
public StrahlentherapieMapper(FhirProperties fhirProperties) { | ||
super(fhirProperties); | ||
} | ||
|
||
public Procedure map(STTyp st, Reference subject) { | ||
Objects.requireNonNull(st); | ||
Objects.requireNonNull(subject); | ||
|
||
Validate.notBlank(st.getSTID(), "Required ST_ID is unset"); | ||
Validate.isTrue( | ||
Objects.equals( | ||
subject.getReferenceElement().getResourceType(), ResourceType.PATIENT.toCode()), | ||
"The subject reference should point to a Patient resource"); | ||
|
||
var procedure = new Procedure(); | ||
procedure.getMeta().addProfile(fhirProperties.getProfiles().getMiiPrOnkoStrahlentherapie()); | ||
|
||
// TODO: can we be sure that this ST-ID is globally unqiue across all STs? - | ||
// if not we may instead need to construct the ID from the patient-id + others. | ||
var identifier = | ||
new Identifier() | ||
.setSystem(fhirProperties.getSystems().getStrahlentherapieProcedureId()) | ||
.setValue(st.getSTID()); | ||
procedure.addIdentifier(identifier); | ||
procedure.setId(computeResourceIdFromIdentifier(identifier)); | ||
|
||
// Status | ||
if (st.getMeldeanlass() == STTyp.Meldeanlass.BEHANDLUNGSENDE) { | ||
procedure.setStatus(Procedure.ProcedureStatus.COMPLETED); | ||
} else { | ||
procedure.setStatus(Procedure.ProcedureStatus.INPROGRESS); | ||
} | ||
|
||
procedure.setSubject(subject); | ||
|
||
var dataAbsentExtension = | ||
new Extension( | ||
fhirProperties.getExtensions().getDataAbsentReason(), new CodeType("unknown")); | ||
var dataAbsentCode = new CodeType(); | ||
dataAbsentCode.addExtension(dataAbsentExtension); | ||
|
||
var code = new CodeableConcept(); | ||
code.addCoding().setSystem(fhirProperties.getSystems().getOps()).setCodeElement(dataAbsentCode); | ||
procedure.setCode(code); | ||
|
||
var category = | ||
new CodeableConcept( | ||
new Coding( | ||
fhirProperties.getSystems().getSnomed(), "277132007", "Therapeutic procedure")); | ||
procedure.setCategory(category); | ||
|
||
var dataAbsentConcept = new CodeableConcept(); | ||
dataAbsentConcept.addExtension(dataAbsentExtension); | ||
|
||
var performedStart = new DateTimeType(); | ||
performedStart.addExtension(dataAbsentExtension); | ||
var performed = new Period().setStartElement(performedStart); | ||
procedure.setPerformed(performed); | ||
|
||
// for now, all required extensions are filled with sample values from | ||
// https://simplifier.net/guide/mii-ig-modul-onkologie-2024-de/MIIIGModulOnkologie/TechnischeImplementierung/FHIR-Profile/Strahlentherapie/Strahlentherapie-Procedure.page.md?version=current | ||
|
||
var intention = new CodeableConcept(); | ||
intention | ||
.addCoding() | ||
.setSystem(fhirProperties.getSystems().getMiiCsOnkoIntention()) | ||
.setCode("P"); | ||
procedure.addExtension( | ||
fhirProperties.getExtensions().getMiiExOnkoStrahlentherapieIntention(), intention); | ||
|
||
var bestrahlung = | ||
new Extension(fhirProperties.getExtensions().getMiiExOnkoStrahlentherapieBestrahlung()); | ||
|
||
var applikationsart = new CodeableConcept(); | ||
applikationsart | ||
.addCoding() | ||
.setSystem(fhirProperties.getSystems().getMiiCsOnkoStrahlentherapieApplikationsart()) | ||
.setCode("P-ST"); | ||
bestrahlung.addExtension("Applikationsart", applikationsart); | ||
|
||
var strahlenart = new CodeableConcept(); | ||
strahlenart | ||
.addCoding() | ||
.setSystem(fhirProperties.getSystems().getMiiCsOnkoStrahlentherapieStrahlenart()) | ||
.setCode("UH"); | ||
bestrahlung.addExtension("Strahlenart", strahlenart); | ||
|
||
var zielgebiet = new CodeableConcept(); | ||
zielgebiet | ||
.addCoding() | ||
.setSystem(fhirProperties.getSystems().getMiiCsOnkoStrahlentherapieZielgebiet()) | ||
.setCode("3.4"); | ||
bestrahlung.addExtension("Zielgebiet", zielgebiet); | ||
|
||
/* The extensions below are optional: | ||
var dataAbsentQuantity = new Quantity(); | ||
dataAbsentQuantity.setSystem(fhirProperties.getSystems().getUcum()); | ||
dataAbsentQuantity.setCodeElement(dataAbsentCode); | ||
var absentUnit = new StringType(); | ||
absentUnit.addExtension(dataAbsentExtension); | ||
dataAbsentQuantity.setUnitElement(absentUnit); | ||
bestrahlung.addExtension("Zielgebiet_Lateralitaet", dataAbsentConcept); | ||
bestrahlung.addExtension("Gesamtdosis", dataAbsentQuantity); | ||
bestrahlung.addExtension("Einzeldosis", dataAbsentQuantity); | ||
bestrahlung.addExtension("Boost", dataAbsentConcept); | ||
*/ | ||
procedure.addExtension(bestrahlung); | ||
|
||
return procedure; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/test/java/org/miracum/streams/ume/obdstofhir/mapper/mii/StrahlentherapieMapperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package org.miracum.streams.ume.obdstofhir.mapper.mii; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import ca.uhn.fhir.context.FhirContext; | ||
import com.fasterxml.jackson.databind.DeserializationFeature; | ||
import com.fasterxml.jackson.dataformat.xml.XmlMapper; | ||
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; | ||
import com.fasterxml.jackson.module.jakarta.xmlbind.JakartaXmlBindAnnotationModule; | ||
import de.basisdatensatz.obds.v3.OBDS; | ||
import java.io.IOException; | ||
import org.approvaltests.Approvals; | ||
import org.hl7.fhir.r4.model.Reference; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.CsvSource; | ||
import org.miracum.streams.ume.obdstofhir.FhirProperties; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
@SpringBootTest(classes = {FhirProperties.class}) | ||
@EnableConfigurationProperties | ||
class StrahlentherapieMapperTest { | ||
private static StrahlentherapieMapper sut; | ||
|
||
@BeforeAll | ||
static void beforeEach(@Autowired FhirProperties fhirProps) { | ||
sut = new StrahlentherapieMapper(fhirProps); | ||
} | ||
|
||
@ParameterizedTest | ||
@CsvSource({"Testpatient_1.xml", "Testpatient_2.xml", "Testpatient_3.xml"}) | ||
void map_withGivenObds_shouldCreateValidProcedure(String sourceFile) throws IOException { | ||
final var resource = this.getClass().getClassLoader().getResource("obds3/" + sourceFile); | ||
assertThat(resource).isNotNull(); | ||
|
||
final var xmlMapper = | ||
XmlMapper.builder() | ||
.defaultUseWrapper(false) | ||
.addModule(new JakartaXmlBindAnnotationModule()) | ||
.addModule(new Jdk8Module()) | ||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) | ||
.build(); | ||
|
||
final var obds = xmlMapper.readValue(resource.openStream(), OBDS.class); | ||
|
||
var obdsPatient = obds.getMengePatient().getPatient().getFirst(); | ||
|
||
var subject = new Reference("Patient/any"); | ||
var stMeldung = | ||
obdsPatient.getMengeMeldung().getMeldung().stream() | ||
.filter(m -> m.getST() != null) | ||
.findFirst() | ||
.get(); | ||
var procedure = sut.map(stMeldung.getST(), subject); | ||
|
||
var fhirParser = FhirContext.forR4().newJsonParser().setPrettyPrint(true); | ||
var fhirJson = fhirParser.encodeResourceToString(procedure); | ||
Approvals.verify( | ||
fhirJson, Approvals.NAMES.withParameters(sourceFile).forFile().withExtension(".fhir.json")); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
...perTest.map_withGivenObds_shouldCreateValidProcedure.Testpatient_1.xml.approved.fhir.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
{ | ||
"resourceType": "Procedure", | ||
"id": "bfc5c7a0c00d1c00e9ab41a4507f8cfbbc87e13953eba89e14c3fe3a54325559", | ||
"meta": { | ||
"profile": [ "https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/StructureDefinition/mii-pr-onko-strahlentherapie" ] | ||
}, | ||
"extension": [ { | ||
"url": "https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/StructureDefinition/mii-ex-onko-strahlentherapie-intention", | ||
"valueCodeableConcept": { | ||
"coding": [ { | ||
"system": "https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/CodeSystem/mii-cs-onko-intention", | ||
"code": "P" | ||
} ] | ||
} | ||
}, { | ||
"url": "https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/StructureDefinition/mii-ex-onko-strahlentherapie-bestrahlung", | ||
"extension": [ { | ||
"url": "Applikationsart", | ||
"valueCodeableConcept": { | ||
"coding": [ { | ||
"system": "https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/CodeSystem/mii-cs-onko-strahlentherapie-applikationsart", | ||
"code": "P-ST" | ||
} ] | ||
} | ||
}, { | ||
"url": "Strahlenart", | ||
"valueCodeableConcept": { | ||
"coding": [ { | ||
"system": "https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/CodeSystem/mii-cs-onko-strahlentherapie-strahlenart", | ||
"code": "UH" | ||
} ] | ||
} | ||
}, { | ||
"url": "Zielgebiet", | ||
"valueCodeableConcept": { | ||
"coding": [ { | ||
"system": "https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/CodeSystem/mii-cs-onko-strahlentherapie-zielgebiet", | ||
"code": "3.4" | ||
} ] | ||
} | ||
} ] | ||
} ], | ||
"identifier": [ { | ||
"system": "https://bzkf.github.io/obds-to-fhir/identifiers/strahlentherapie-procedure-id", | ||
"value": "101_ST-2" | ||
} ], | ||
"status": "completed", | ||
"category": { | ||
"coding": [ { | ||
"system": "http://snomed.info/sct", | ||
"code": "277132007", | ||
"display": "Therapeutic procedure" | ||
} ] | ||
}, | ||
"code": { | ||
"coding": [ { | ||
"system": "http://fhir.de/CodeSystem/bfarm/ops", | ||
"_code": { | ||
"extension": [ { | ||
"url": "http://hl7.org/fhir/StructureDefinition/data-absent-reason", | ||
"valueCode": "unknown" | ||
} ] | ||
} | ||
} ] | ||
}, | ||
"subject": { | ||
"reference": "Patient/any" | ||
}, | ||
"performedPeriod": { | ||
"_start": { | ||
"extension": [ { | ||
"url": "http://hl7.org/fhir/StructureDefinition/data-absent-reason", | ||
"valueCode": "unknown" | ||
} ] | ||
} | ||
} | ||
} |
Oops, something went wrong.