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