-
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.
chore: added dummy mapper classes and tests
- Loading branch information
Showing
7 changed files
with
165 additions
and
7 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
13 changes: 7 additions & 6 deletions
13
...ofhir/mapper/mii/ObdsConditionMapper.java → ...bdstofhir/mapper/mii/ConditionMapper.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
31 changes: 31 additions & 0 deletions
31
src/main/java/org/miracum/streams/ume/obdstofhir/mapper/mii/PatientMapper.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,31 @@ | ||
package org.miracum.streams.ume.obdstofhir.mapper.mii; | ||
|
||
import de.basisdatensatz.obds.v3.OBDS; | ||
import de.basisdatensatz.obds.v3.PatientenStammdatenMelderTyp; | ||
import java.util.List; | ||
import org.hl7.fhir.r4.model.*; | ||
import org.miracum.streams.ume.obdstofhir.FhirProperties; | ||
import org.miracum.streams.ume.obdstofhir.mapper.ObdsToFhirMapper; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class PatientMapper extends ObdsToFhirMapper { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(PatientMapper.class); | ||
|
||
@Autowired | ||
public PatientMapper(FhirProperties fhirProperties) { | ||
super(fhirProperties); | ||
} | ||
|
||
public Patient map( | ||
PatientenStammdatenMelderTyp stammdaten, | ||
Check notice Code scanning / CodeQL Useless parameter Note
The parameter 'stammdaten' is never used.
|
||
List<OBDS.MengePatient.Patient.MengeMeldung.Meldung> meldungen) { | ||
Check notice Code scanning / CodeQL Useless parameter Note
The parameter 'meldungen' is never used.
|
||
var patient = new Patient(); | ||
patient.getMeta().addProfile(fhirProperties.getProfiles().getMiiPatientPseudonymisiert()); | ||
return patient; | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/test/java/org/miracum/streams/ume/obdstofhir/mapper/mii/ConditionMapperTest.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,56 @@ | ||
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.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.approvaltests.core.Options; | ||
import org.hl7.fhir.r4.model.Reference; | ||
import org.junit.jupiter.api.Test; | ||
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 ConditionMapperTest { | ||
private final ConditionMapper sut; | ||
|
||
@Autowired | ||
ConditionMapperTest(FhirProperties fhirProps) { | ||
sut = new ConditionMapper(fhirProps); | ||
} | ||
|
||
@Test | ||
void map_withGivenObds_shouldCreateValidConditionResource() throws IOException { | ||
// TODO: refactor to use a data provider for parameterized tests | ||
final var resource = this.getClass().getClassLoader().getResource("obds3/test1.xml"); | ||
assertThat(resource).isNotNull(); | ||
|
||
final var xmlMapper = | ||
XmlMapper.builder() | ||
.defaultUseWrapper(false) | ||
.addModule(new JakartaXmlBindAnnotationModule()) | ||
.addModule(new Jdk8Module()) | ||
.build(); | ||
|
||
final var obds = xmlMapper.readValue(resource.openStream(), OBDS.class); | ||
|
||
var obdsPatient = obds.getMengePatient().getPatient().getFirst(); | ||
|
||
final var condition = | ||
sut.map( | ||
obdsPatient.getMengeMeldung().getMeldung().getFirst().getDiagnose(), | ||
new Reference("Patient/1")); | ||
|
||
var fhirParser = FhirContext.forR4().newJsonParser().setPrettyPrint(true); | ||
var fhirJson = fhirParser.encodeResourceToString(condition); | ||
Approvals.verify(fhirJson, new Options().forFile().withExtension(".fhir.json")); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/test/java/org/miracum/streams/ume/obdstofhir/mapper/mii/PatientMapperTest.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,54 @@ | ||
package org.miracum.streams.ume.obdstofhir.mapper.mii; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import ca.uhn.fhir.context.FhirContext; | ||
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.approvaltests.core.Options; | ||
import org.junit.jupiter.api.Test; | ||
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 PatientMapperTest { | ||
private final PatientMapper sut; | ||
|
||
@Autowired | ||
PatientMapperTest(FhirProperties fhirProps) { | ||
sut = new PatientMapper(fhirProps); | ||
} | ||
|
||
@Test | ||
void map_withGivenObds_shouldCreateValidPatientResource() throws IOException { | ||
// TODO: refactor to use a data provider for parameterized tests | ||
final var resource = this.getClass().getClassLoader().getResource("obds3/test1.xml"); | ||
assertThat(resource).isNotNull(); | ||
|
||
final var xmlMapper = | ||
XmlMapper.builder() | ||
.defaultUseWrapper(false) | ||
.addModule(new JakartaXmlBindAnnotationModule()) | ||
.addModule(new Jdk8Module()) | ||
.build(); | ||
|
||
final var obds = xmlMapper.readValue(resource.openStream(), OBDS.class); | ||
|
||
var obdsPatient = obds.getMengePatient().getPatient().getFirst(); | ||
|
||
final var patient = | ||
sut.map(obdsPatient.getPatientenStammdaten(), obdsPatient.getMengeMeldung().getMeldung()); | ||
|
||
var fhirParser = FhirContext.forR4().newJsonParser().setPrettyPrint(true); | ||
var fhirJson = fhirParser.encodeResourceToString(patient); | ||
Approvals.verify(fhirJson, new Options().forFile().withExtension(".fhir.json")); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...nditionMapperTest.map_withGivenObds_shouldCreateValidConditionResource.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,9 @@ | ||
{ | ||
"resourceType": "Condition", | ||
"meta": { | ||
"profile": [ "https://www.medizininformatik-initiative.de/fhir/ext/modul-onko/StructureDefinition/mii-pr-onko-diagnose-primaertumor" ] | ||
}, | ||
"subject": { | ||
"reference": "Patient/1" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...i/PatientMapperTest.map_withGivenObds_shouldCreateValidPatientResource.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,6 @@ | ||
{ | ||
"resourceType": "Patient", | ||
"meta": { | ||
"profile": [ "https://www.medizininformatik-initiative.de/fhir/core/modul-person/StructureDefinition/PatientPseudonymisiert" ] | ||
} | ||
} |