mirror of
https://github.com/pcvolkmer/mv64e-onkostar-data.git
synced 2025-07-04 03:22:53 +00:00
feat: add JSON to medication mapping for Einzelempfehlung
This commit is contained in:
@ -40,6 +40,7 @@ public class EinzelempfehlungWirkstoffDataMapper extends AbstractSubformDataMapp
|
|||||||
resultSet.getInteger("evidenzlevel_propcat_version")
|
resultSet.getInteger("evidenzlevel_propcat_version")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
.medication(JsonToMedicationMapper.map(resultSet.getString("wirkstoffe_json")))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,9 @@ public class JsonToMedicationMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<AtcUnregisteredMedicationCoding> map(String wirkstoffejson) {
|
public static List<AtcUnregisteredMedicationCoding> map(String wirkstoffejson) {
|
||||||
|
if (wirkstoffejson == null) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return new ObjectMapper().readValue(wirkstoffejson, new TypeReference<List<Wirkstoff>>() {
|
return new ObjectMapper().readValue(wirkstoffejson, new TypeReference<List<Wirkstoff>>() {
|
||||||
}).stream()
|
}).stream()
|
||||||
|
@ -12,6 +12,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
|||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.junit.jupiter.MockitoExtension;
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@ -44,7 +45,8 @@ class TherapieplanDataMapperTest {
|
|||||||
void shouldCreateCarePlan(@Mock ResultSet resultSet) {
|
void shouldCreateCarePlan(@Mock ResultSet resultSet) {
|
||||||
final var testData = Map.of(
|
final var testData = Map.of(
|
||||||
"id", "1",
|
"id", "1",
|
||||||
"patient_id", "42"
|
"patient_id", "42",
|
||||||
|
"wirkstoffe_json", "[{\"code\":\"\",\"name\":\"PARP-Inhibierung\",\"system\":\"UNREGISTERED\"}]"
|
||||||
);
|
);
|
||||||
|
|
||||||
doAnswer(invocationOnMock -> {
|
doAnswer(invocationOnMock -> {
|
||||||
@ -56,11 +58,17 @@ class TherapieplanDataMapperTest {
|
|||||||
.when(therapieplanCatalogue)
|
.when(therapieplanCatalogue)
|
||||||
.getById(anyInt());
|
.getById(anyInt());
|
||||||
|
|
||||||
|
doAnswer(invocationOnMock -> List.of(resultSet))
|
||||||
|
.when(einzelempfehlungCatalogue)
|
||||||
|
.getAllByParentId(anyInt());
|
||||||
|
|
||||||
var actual = this.dataMapper.getById(1);
|
var actual = this.dataMapper.getById(1);
|
||||||
assertThat(actual).isInstanceOf(MtbCarePlan.class);
|
assertThat(actual).isInstanceOf(MtbCarePlan.class);
|
||||||
assertThat(actual.getId()).isEqualTo("1");
|
assertThat(actual.getId()).isEqualTo("1");
|
||||||
assertThat(actual.getPatient())
|
assertThat(actual.getPatient())
|
||||||
.isEqualTo(Reference.builder().id("42").type("Patient").build());
|
.isEqualTo(Reference.builder().id("42").type("Patient").build());
|
||||||
|
|
||||||
|
assertThat(actual.getMedicationRecommendations()).hasSize(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user