Skip to content

Commit

Permalink
feat: initial ResidualstatusMapper
Browse files Browse the repository at this point in the history
  • Loading branch information
pcvolkmer committed Nov 26, 2024
1 parent 15525dc commit 97b61db
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public static class FhirSystems {
private String systemischeTherapieMedicationStatementId;
private String miiCsOnkoSystemischeTherapieArt;
private String miiCsOnkoSeitenlokalisation;
private String miiCsOnkoResidualstatus;
private String miiCsTherapieGrundEnde;
private String conditionVerStatus;
private String icdo3MorphologieOid;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.miracum.streams.ume.obdstofhir.mapper.mii;

import de.basisdatensatz.obds.v3.ResidualstatusTyp;
import java.util.Objects;
import org.apache.commons.lang3.Validate;
import org.hl7.fhir.r4.model.CodeableConcept;
import org.hl7.fhir.r4.model.Enumerations.ResourceType;
import org.hl7.fhir.r4.model.Observation;
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 ResidualstatusMapper extends ObdsToFhirMapper {

private static final Logger LOG = LoggerFactory.getLogger(ResidualstatusMapper.class);

public ResidualstatusMapper(FhirProperties fhirProperties) {
super(fhirProperties);
}

public Observation map(ResidualstatusTyp rs, Reference patient) {
Objects.requireNonNull(rs, "Residualstatus must not be null");
Objects.requireNonNull(patient, "Reference to Patient must not be null");

Validate.isTrue(
Objects.equals(
patient.getReferenceElement().getResourceType(), ResourceType.PATIENT.toCode()),
"The subject reference should point to a Patient resource");

var observation = new Observation();

// Gesamtbeurteilung des Residualstatus
var code = new CodeableConcept();
code.addCoding()
.setSystem(fhirProperties.getSystems().getMiiCsOnkoResidualstatus())
.setCode(rs.getGesamtbeurteilungResidualstatus().value());
observation.setValue(code);

return observation;
}
}
1 change: 1 addition & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ fhir:
mii-cs-onko-strahlentherapie-zielgebiet: "https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/CodeSystem/mii-cs-onko-strahlentherapie-zielgebiet"
mii-cs-onko-seitenlokalisation: "https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/CodeSystem/mii-cs-onko-seitenlokalisation"
mii-cs-onko-systemische-therapie-art: "https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/CodeSystem/mii-cs-onko-therapie-typ"
mii-cs-onko-residualstatus: "https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/CodeSystem/mii-cs-onko-residualstatus"
mii-cs-therapie-grund-ende: "https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/CodeSystem/mii-cs-therapie-grund-ende"
atcBfarm: "http://fhir.de/CodeSystem/bfarm/atc"
atcWho: "http://www.whocc.no/atc"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
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 ResidualstatusMapperTest {
private static ResidualstatusMapper sut;

@BeforeAll
static void beforeAll(@Autowired FhirProperties fhirProps) {
sut = new ResidualstatusMapper(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");
obdsPatient.getMengeMeldung().getMeldung().stream()
.filter(m -> m.getOP() != null && m.getOP().getResidualstatus() != null)
.map(m -> m.getOP().getResidualstatus())
.findFirst()
.ifPresent(
rs -> {
var procedure = sut.map(rs, subject);

var fhirParser = FhirContext.forR4().newJsonParser().setPrettyPrint(true);
var fhirJson = fhirParser.encodeResourceToString(procedure);
Approvals.verify(
fhirJson,
Approvals.NAMES.withParameters(sourceFile).forFile().withExtension(".fhir.json"));
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"resourceType": "Observation",
"valueCodeableConcept": {
"coding": [ {
"system": "https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/CodeSystem/mii-cs-onko-residualstatus",
"code": "R2"
} ]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"resourceType": "Observation",
"valueCodeableConcept": {
"coding": [ {
"system": "https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/CodeSystem/mii-cs-onko-residualstatus",
"code": "R0"
} ]
}
}

0 comments on commit 97b61db

Please sign in to comment.