mirror of
https://github.com/pcvolkmer/onkostar-plugin-dnpm.git
synced 2025-07-01 17:02:53 +00:00
Extraktion des Mappings Prozedur zu Prozedurwerten und Auswahl des Mappers
Aktuell sind nur die beiden Formulare * OS.Systemische Therapie * OS.Systemische Therapie.VarianteUKW bekannt. Beide lassen sich über den extrahierten Mapper in eine Map mit Prozedurwerten mappen.
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
package DNPM;
|
||||
|
||||
import ATCCodes.AtcCode;
|
||||
import DNPM.services.systemtherapie.SystemtherapieService;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import de.itc.onkostar.api.Disease;
|
||||
@ -18,7 +18,10 @@ import org.hibernate.type.StandardBasicTypes;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DNPMHelper implements IProcedureAnalyzer {
|
||||
|
||||
@ -26,8 +29,11 @@ public class DNPMHelper implements IProcedureAnalyzer {
|
||||
|
||||
private final IOnkostarApi onkostarApi;
|
||||
|
||||
public DNPMHelper(final IOnkostarApi onkostarApi) {
|
||||
private final SystemtherapieService systemtherapieService;
|
||||
|
||||
public DNPMHelper(final IOnkostarApi onkostarApi, final SystemtherapieService systemtherapieService) {
|
||||
this.onkostarApi = onkostarApi;
|
||||
this.systemtherapieService = systemtherapieService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -144,70 +150,7 @@ public class DNPMHelper implements IProcedureAnalyzer {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Map<String, String>> result = new ArrayList<>();
|
||||
for (Procedure Prozedur : onkostarApi.getProceduresForDiseaseByForm(Integer.parseInt(diagnoseId.toString()), "OS.Systemische Therapie")) {
|
||||
result.add(getProzedurwerte(Prozedur));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Map<String, String> getProzedurwerte(Procedure Prozedur) {
|
||||
List<String> wirkstoffListe = new ArrayList<>();
|
||||
// SubstanzenCodesListe enthält die Liste der SubstanzenCodes
|
||||
List<Map<String, String>> substanzenCodesListe = new ArrayList<>();
|
||||
|
||||
// alle Werte der Prozedur auslesen
|
||||
Map<String, Item> alleWerte = Prozedur.getAllValues();
|
||||
// Prozedurwerte enthält nur die interessanten Werte
|
||||
Map<String, String> prozedurwerte = new HashMap<>();
|
||||
// alle Werte durchgehen und die interessanten übernehmen
|
||||
if (alleWerte.containsKey("Beendigung")) {
|
||||
prozedurwerte.put("Beendigung", alleWerte.get("Beendigung").getValue());
|
||||
}
|
||||
if (alleWerte.containsKey("Ergebnis")) {
|
||||
prozedurwerte.put("Ergebnis", alleWerte.get("Ergebnis").getValue());
|
||||
}
|
||||
if (alleWerte.containsKey("Beginn")) {
|
||||
prozedurwerte.put("Beginn", alleWerte.get("Beginn").getString());
|
||||
}
|
||||
if (alleWerte.containsKey("Ende")) {
|
||||
prozedurwerte.put("Ende", alleWerte.get("Ende").getString());
|
||||
}
|
||||
if (alleWerte.containsKey("SubstanzenList")) {
|
||||
List<Map<String, String>> substanzList = alleWerte.get("SubstanzenList").getValue();
|
||||
for (var substanz : substanzList) {
|
||||
var substanzCodes = getSubstanzCode(substanz);
|
||||
substanzenCodesListe.add(substanzCodes);
|
||||
wirkstoffListe.add(substanzCodes.get("substance"));
|
||||
}
|
||||
}
|
||||
|
||||
prozedurwerte.put("Wirkstoffe", String.join(", ", wirkstoffListe));
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
prozedurwerte.put("WirkstoffCodes", mapper.writeValueAsString(substanzenCodesListe));
|
||||
} catch (JsonProcessingException e) {
|
||||
logger.error("Kann 'WirkstoffCodes' nicht in JSON-String mappen", e);
|
||||
}
|
||||
|
||||
return prozedurwerte;
|
||||
}
|
||||
|
||||
private static Map<String, String> getSubstanzCode(Map<String, String> substanz) {
|
||||
Map<String, String> substanzCode = new HashMap<>();
|
||||
if (substanz.containsKey("Substanz")) {
|
||||
if (AtcCode.isAtcCode(substanz.get("Substanz"))) {
|
||||
substanzCode.put("system", "ATC");
|
||||
} else {
|
||||
substanzCode.put("system", "other");
|
||||
}
|
||||
substanzCode.put("code", substanz.get("Substanz"));
|
||||
|
||||
}
|
||||
if (substanz.containsKey("Substanz_shortDescription")) {
|
||||
substanzCode.put("substance", substanz.get("Substanz_shortDescription"));
|
||||
}
|
||||
return substanzCode;
|
||||
return systemtherapieService.getSystemischeTherapienFromDiagnose(Integer.parseInt(diagnoseId.toString()));
|
||||
}
|
||||
|
||||
public Object getProzedurenFromDiagnose(final Map<String, Object> input) {
|
||||
|
@ -4,6 +4,8 @@ import DNPM.database.SettingsRepository;
|
||||
import DNPM.services.*;
|
||||
import DNPM.services.mtb.DefaultMtbService;
|
||||
import DNPM.services.mtb.MtbService;
|
||||
import DNPM.services.systemtherapie.DefaultSystemtherapieService;
|
||||
import DNPM.services.systemtherapie.SystemtherapieService;
|
||||
import de.itc.onkostar.api.IOnkostarApi;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
@ -42,6 +44,14 @@ public class PluginConfiguration {
|
||||
return new DefaultMtbService(onkostarApi);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SystemtherapieService systemtherapieService(
|
||||
final IOnkostarApi onkostarApi,
|
||||
final SettingsService settingsService
|
||||
) {
|
||||
return new DefaultSystemtherapieService(onkostarApi, settingsService);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TherapieplanServiceFactory therapieplanServiceFactory(
|
||||
final IOnkostarApi onkostarApi,
|
||||
|
@ -0,0 +1,73 @@
|
||||
package DNPM.services.systemtherapie;
|
||||
|
||||
import DNPM.services.SettingsService;
|
||||
import de.itc.onkostar.api.IOnkostarApi;
|
||||
import de.itc.onkostar.api.Procedure;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Standardimplementierung des Systemtherapieservices
|
||||
*
|
||||
* @since 0.2.0
|
||||
*/
|
||||
public class DefaultSystemtherapieService implements SystemtherapieService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DefaultSystemtherapieService.class);
|
||||
|
||||
private final IOnkostarApi onkostarApi;
|
||||
|
||||
private final SettingsService settingsService;
|
||||
|
||||
public DefaultSystemtherapieService(final IOnkostarApi onkostarApi, final SettingsService settingsService) {
|
||||
this.onkostarApi = onkostarApi;
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ermittelt eine Zusammenfassung der systemischen Therapien für eine Erkrankung
|
||||
*
|
||||
* @param diseaseId Die ID der Erkrankung
|
||||
* @return Zusammenfassung der systemischen Therapien
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, String>> getSystemischeTherapienFromDiagnose(int diseaseId) {
|
||||
var sid = this.settingsService.getSID();
|
||||
if (sid.isEmpty()) {
|
||||
logger.error("Kann SID nicht ermitteln um Formularnamen zu erhalten. Gebe 'null' zurück.");
|
||||
return null;
|
||||
}
|
||||
List<Map<String, String>> result = new ArrayList<>();
|
||||
for (Procedure prozedur : onkostarApi.getProceduresForDiseaseByForm(diseaseId, selectFormNameBySID(sid.get()))) {
|
||||
prozedurToProzedurwerteMapper(prozedur).apply(prozedur).ifPresent(result::add);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Übergibt aktuell immer den Mapper für das Formular "OS.Systemische Therapie",
|
||||
* da beide bekannte Varianten damit gemappt werden können.
|
||||
*
|
||||
* @param procedure Die Prozedur für die ein Mapper erstellt werden soll
|
||||
* @return Der Mapper für die Prozedur
|
||||
*/
|
||||
@Override
|
||||
public ProzedurToProzedurwerteMapper prozedurToProzedurwerteMapper(Procedure procedure) {
|
||||
return new OsSystemischeTherapieToProzedurwerteMapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String selectFormNameBySID(String sid) {
|
||||
switch (sid) {
|
||||
case "2011":
|
||||
case "20119":
|
||||
return "OS.Systemische Therapie.VarianteUKW";
|
||||
default:
|
||||
return "OS.Systemische Therapie";
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package DNPM.services.systemtherapie;
|
||||
|
||||
import ATCCodes.AtcCode;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import de.itc.onkostar.api.Item;
|
||||
import de.itc.onkostar.api.Procedure;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Implementierung zum Mappen des Formulars "OS.Systemische Therapie" auf die Prozedurwerte
|
||||
*
|
||||
* @since 0.2.0
|
||||
*/
|
||||
public class OsSystemischeTherapieToProzedurwerteMapper implements ProzedurToProzedurwerteMapper {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(OsSystemischeTherapieToProzedurwerteMapper.class);
|
||||
|
||||
@Override
|
||||
public Optional<Map<String, String>> apply(Procedure procedure) {
|
||||
try {
|
||||
return Optional.of(getProzedurwerte(procedure));
|
||||
} catch (Exception e) {
|
||||
logger.error("Fehler beim Mappen der Prozedur auf Prozedurwerte", e);
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<String, String> getProzedurwerte(Procedure Prozedur) {
|
||||
List<String> wirkstoffListe = new ArrayList<>();
|
||||
// SubstanzenCodesListe enthält die Liste der SubstanzenCodes
|
||||
List<Map<String, String>> substanzenCodesListe = new ArrayList<>();
|
||||
|
||||
// alle Werte der Prozedur auslesen
|
||||
Map<String, Item> alleWerte = Prozedur.getAllValues();
|
||||
// Prozedurwerte enthält nur die interessanten Werte
|
||||
Map<String, String> prozedurwerte = new HashMap<>();
|
||||
// alle Werte durchgehen und die interessanten übernehmen
|
||||
if (alleWerte.containsKey("Beendigung")) {
|
||||
prozedurwerte.put("Beendigung", alleWerte.get("Beendigung").getValue());
|
||||
}
|
||||
if (alleWerte.containsKey("Ergebnis")) {
|
||||
prozedurwerte.put("Ergebnis", alleWerte.get("Ergebnis").getValue());
|
||||
}
|
||||
if (alleWerte.containsKey("Beginn")) {
|
||||
prozedurwerte.put("Beginn", alleWerte.get("Beginn").getString());
|
||||
}
|
||||
if (alleWerte.containsKey("Ende")) {
|
||||
prozedurwerte.put("Ende", alleWerte.get("Ende").getString());
|
||||
}
|
||||
if (alleWerte.containsKey("SubstanzenList")) {
|
||||
List<Map<String, String>> substanzList = alleWerte.get("SubstanzenList").getValue();
|
||||
for (var substanz : substanzList) {
|
||||
var substanzCodes = getSubstanzCode(substanz);
|
||||
substanzenCodesListe.add(substanzCodes);
|
||||
wirkstoffListe.add(substanzCodes.get("substance"));
|
||||
}
|
||||
}
|
||||
|
||||
prozedurwerte.put("Wirkstoffe", String.join(", ", wirkstoffListe));
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
prozedurwerte.put("WirkstoffCodes", mapper.writeValueAsString(substanzenCodesListe));
|
||||
} catch (JsonProcessingException e) {
|
||||
logger.error("Kann 'WirkstoffCodes' nicht in JSON-String mappen", e);
|
||||
}
|
||||
|
||||
return prozedurwerte;
|
||||
}
|
||||
|
||||
private static Map<String, String> getSubstanzCode(Map<String, String> substanz) {
|
||||
Map<String, String> substanzCode = new HashMap<>();
|
||||
if (substanz.containsKey("Substanz")) {
|
||||
if (AtcCode.isAtcCode(substanz.get("Substanz"))) {
|
||||
substanzCode.put("system", "ATC");
|
||||
} else {
|
||||
substanzCode.put("system", "other");
|
||||
}
|
||||
substanzCode.put("code", substanz.get("Substanz"));
|
||||
|
||||
}
|
||||
if (substanz.containsKey("Substanz_shortDescription")) {
|
||||
substanzCode.put("substance", substanz.get("Substanz_shortDescription"));
|
||||
}
|
||||
return substanzCode;
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package DNPM.services.systemtherapie;
|
||||
|
||||
import de.itc.onkostar.api.Procedure;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Mapper um ein Systemtherapieformular in eine Optional-Map mit Prozedurwerten umzuwandeln
|
||||
*
|
||||
* @since 0.2.0
|
||||
*/
|
||||
public interface ProzedurToProzedurwerteMapper extends Function<Procedure, Optional<Map<String, String>>> {}
|
@ -0,0 +1,34 @@
|
||||
package DNPM.services.systemtherapie;
|
||||
|
||||
import de.itc.onkostar.api.Procedure;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Service für Systemtherapieformulare
|
||||
*
|
||||
* @since 0.2.0
|
||||
*/
|
||||
public interface SystemtherapieService {
|
||||
/**
|
||||
* Ermittelt eine Zusammenfassung der systemischen Therapien für eine Erkrankung
|
||||
* @param diseaseId Die ID der Erkrankung
|
||||
* @return Die Zusammenfassung der systemischen Therapien
|
||||
*/
|
||||
List<Map<String, String>> getSystemischeTherapienFromDiagnose(int diseaseId);
|
||||
|
||||
/**
|
||||
* Erstellt den Mapper for die Prozedur
|
||||
* @param procedure Die Prozedur für die ein Mapper erstellt werden soll
|
||||
* @return Der erstellte ProzedurToProzedurwerteMapper
|
||||
*/
|
||||
ProzedurToProzedurwerteMapper prozedurToProzedurwerteMapper(Procedure procedure);
|
||||
|
||||
/**
|
||||
* Ermittelt den Formularnamen anhand der SID
|
||||
* @param sid die SID
|
||||
* @return Den ermittelten Formularnamen
|
||||
*/
|
||||
String selectFormNameBySID(String sid);
|
||||
}
|
@ -12,6 +12,7 @@
|
||||
|
||||
<bean id="DNPMHelper" class="DNPM.DNPMHelper">
|
||||
<constructor-arg ref="localOnkostarApi" />
|
||||
<constructor-arg ref="systemtherapieService" />
|
||||
</bean>
|
||||
<bean id="Merkmalskatalog" class="DNPM.Merkmalskatalog" />
|
||||
<bean id="ConsentManager" class="DNPM.ConsentManager" />
|
||||
|
@ -1,89 +1,44 @@
|
||||
package DNPM;
|
||||
|
||||
import DNPM.services.systemtherapie.SystemtherapieService;
|
||||
import de.itc.onkostar.api.IOnkostarApi;
|
||||
import de.itc.onkostar.api.Item;
|
||||
import de.itc.onkostar.api.Procedure;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class DNPMHelperTest {
|
||||
|
||||
private IOnkostarApi onkostarApi;
|
||||
private SystemtherapieService systemtherapieService;
|
||||
|
||||
private DNPMHelper dnpmHelper;
|
||||
|
||||
@BeforeEach
|
||||
void setup(
|
||||
@Mock IOnkostarApi onkostarApi
|
||||
@Mock IOnkostarApi onkostarApi,
|
||||
@Mock SystemtherapieService systemtherapieService
|
||||
) {
|
||||
this.onkostarApi = onkostarApi;
|
||||
this.dnpmHelper = new DNPMHelper(onkostarApi);
|
||||
this.systemtherapieService = systemtherapieService;
|
||||
this.dnpmHelper = new DNPMHelper(onkostarApi, systemtherapieService);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testShouldReturnSystemischeTherapienFromDiagnose() {
|
||||
doAnswer(invocationOnMock -> {
|
||||
var procedure = new Procedure(onkostarApi);
|
||||
procedure.setFormName("OS.Systemische Therapie");
|
||||
procedure.setValue("Beginn", new Item("Beginn", Date.from(Instant.parse("2023-01-01T00:00:00Z"))));
|
||||
procedure.setValue("Ende", new Item("Ende", Date.from(Instant.parse("2023-01-31T00:00:00Z"))));
|
||||
procedure.setValue("Beendigung", new Item("Beendigungsstatus", "E"));
|
||||
procedure.setValue("Ergebnis", new Item("Ergebnis", "T"));
|
||||
void testShouldRequestSystemischeTherapienFromDiagnose() {
|
||||
dnpmHelper.getSystemischeTherapienFromDiagnose(Map.of("DiagnoseId", 1234));
|
||||
|
||||
var substanzen = new ArrayList<>();
|
||||
substanzen.add(Map.of(
|
||||
"Substanz", "Testsubstanz",
|
||||
"Substanz_shortDescription", "Testsubstanz"
|
||||
));
|
||||
substanzen.add(Map.of(
|
||||
"Substanz", "L01AA01",
|
||||
"Substanz_shortDescription", "cyclophosphamide"
|
||||
));
|
||||
|
||||
procedure.setValue("SubstanzenList", new Item("SubstanzenList", substanzen));
|
||||
|
||||
return List.of(procedure);
|
||||
}).when(this.onkostarApi).getProceduresForDiseaseByForm(anyInt(), anyString());
|
||||
|
||||
var actual = dnpmHelper.getSystemischeTherapienFromDiagnose(Map.of("DiagnoseId", 1));
|
||||
|
||||
assertThat(actual).isNotNull();
|
||||
assertThat(actual).isExactlyInstanceOf(ArrayList.class);
|
||||
assertThat(actual).hasSize(1);
|
||||
|
||||
assertThat(actual.get(0).get("Beginn"))
|
||||
.isEqualTo(Date.from(Instant.parse("2023-01-01T00:00:00Z")).toString());
|
||||
assertThat(actual.get(0).get("Ende"))
|
||||
.isEqualTo(Date.from(Instant.parse("2023-01-31T00:00:00Z")).toString());
|
||||
assertThat(actual.get(0).get("Beendigung"))
|
||||
.isEqualTo("E");
|
||||
assertThat(actual.get(0).get("Ergebnis"))
|
||||
.isEqualTo("T");
|
||||
assertThat(actual.get(0).get("Wirkstoffe"))
|
||||
.isEqualTo("Testsubstanz, cyclophosphamide");
|
||||
assertThat(actual.get(0).get("WirkstoffCodes"))
|
||||
.isEqualTo(
|
||||
"[" +
|
||||
"{\"system\":\"other\",\"code\":\"Testsubstanz\",\"substance\":\"Testsubstanz\"}," +
|
||||
"{\"system\":\"ATC\",\"code\":\"L01AA01\",\"substance\":\"cyclophosphamide\"}" +
|
||||
"]"
|
||||
);
|
||||
var captor = ArgumentCaptor.forClass(Integer.class);
|
||||
verify(systemtherapieService, times(1)).getSystemischeTherapienFromDiagnose(captor.capture());
|
||||
assertThat(captor.getValue()).isEqualTo(1234);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -0,0 +1,90 @@
|
||||
package DNPM.services.systemtherapie;
|
||||
|
||||
import DNPM.services.SettingsService;
|
||||
import de.itc.onkostar.api.IOnkostarApi;
|
||||
import de.itc.onkostar.api.Procedure;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class DefaultSystemtherapieServiceTest {
|
||||
|
||||
private IOnkostarApi onkostarApi;
|
||||
|
||||
private SettingsService settingsService;
|
||||
|
||||
private DefaultSystemtherapieService service;
|
||||
|
||||
@BeforeEach
|
||||
void setup(
|
||||
@Mock IOnkostarApi onkostarApi,
|
||||
@Mock SettingsService settingsService
|
||||
) {
|
||||
this.onkostarApi = onkostarApi;
|
||||
this.settingsService = settingsService;
|
||||
this.service = new DefaultSystemtherapieService(onkostarApi, settingsService);
|
||||
}
|
||||
|
||||
private static Set<Map.Entry<String, Class<OsSystemischeTherapieToProzedurwerteMapper>>> expectedMapperMappings() {
|
||||
return Map.ofEntries(
|
||||
Map.entry("OS.Systemische Therapie", OsSystemischeTherapieToProzedurwerteMapper.class),
|
||||
Map.entry("OS.Systemische Therapie.VarianteUKW", OsSystemischeTherapieToProzedurwerteMapper.class)
|
||||
).entrySet();
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("expectedMapperMappings")
|
||||
void testShouldMapFormNameToMapper(Map.Entry<String, Class<?>> expectedMapping) {
|
||||
var procedure = new Procedure(onkostarApi);
|
||||
procedure.setFormName(expectedMapping.getKey());
|
||||
|
||||
var actual = service.prozedurToProzedurwerteMapper(procedure);
|
||||
|
||||
assertThat(actual).isExactlyInstanceOf(expectedMapping.getValue());
|
||||
}
|
||||
|
||||
private static Set<Map.Entry<String, String>> expectedFormnameMappings() {
|
||||
return Map.ofEntries(
|
||||
Map.entry("2011", "OS.Systemische Therapie.VarianteUKW"),
|
||||
Map.entry("20119", "OS.Systemische Therapie.VarianteUKW"),
|
||||
Map.entry("Defaultwert", "OS.Systemische Therapie")
|
||||
).entrySet();
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("expectedFormnameMappings")
|
||||
void testShouldMapSidToFormName(Map.Entry<String, String> expectedMapping) {
|
||||
var actual = service.selectFormNameBySID(expectedMapping.getKey());
|
||||
assertThat(actual).isEqualTo(expectedMapping.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testShouldReturnSystemischeTherapienFromDiagnose() {
|
||||
when(settingsService.getSID()).thenReturn(Optional.of("12345"));
|
||||
|
||||
doAnswer(invocationOnMock -> {
|
||||
var procedure = new Procedure(onkostarApi);
|
||||
procedure.setFormName("OS.Systemische Therapie");
|
||||
return List.of(procedure);
|
||||
}).when(this.onkostarApi).getProceduresForDiseaseByForm(anyInt(), anyString());
|
||||
|
||||
var actual = service.getSystemischeTherapienFromDiagnose(1);
|
||||
|
||||
assertThat(actual).isNotNull();
|
||||
assertThat(actual).isExactlyInstanceOf(ArrayList.class);
|
||||
assertThat(actual).hasSize(1);
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package DNPM.services.systemtherapie;
|
||||
|
||||
import de.itc.onkostar.api.IOnkostarApi;
|
||||
import de.itc.onkostar.api.Item;
|
||||
import de.itc.onkostar.api.Procedure;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class ProzedurToProzedurwerteMapperTest {
|
||||
|
||||
private IOnkostarApi onkostarApi;
|
||||
|
||||
private OsSystemischeTherapieToProzedurwerteMapper mapper;
|
||||
|
||||
@BeforeEach
|
||||
void setup(
|
||||
@Mock IOnkostarApi onkostarApi
|
||||
) {
|
||||
this.onkostarApi = onkostarApi;
|
||||
this.mapper = new OsSystemischeTherapieToProzedurwerteMapper();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testShouldReturnSystemischeTherapienFromDiagnose() {
|
||||
var procedure = new Procedure(onkostarApi);
|
||||
procedure.setFormName("OS.Systemische Therapie");
|
||||
procedure.setValue("Beginn", new Item("Beginn", Date.from(Instant.parse("2023-01-01T00:00:00Z"))));
|
||||
procedure.setValue("Ende", new Item("Ende", Date.from(Instant.parse("2023-01-31T00:00:00Z"))));
|
||||
procedure.setValue("Beendigung", new Item("Beendigungsstatus", "E"));
|
||||
procedure.setValue("Ergebnis", new Item("Ergebnis", "T"));
|
||||
|
||||
var substanzen = new ArrayList<>();
|
||||
substanzen.add(Map.of(
|
||||
"Substanz", "Testsubstanz",
|
||||
"Substanz_shortDescription", "Testsubstanz"
|
||||
));
|
||||
substanzen.add(Map.of(
|
||||
"Substanz", "L01AA01",
|
||||
"Substanz_shortDescription", "cyclophosphamide"
|
||||
));
|
||||
procedure.setValue("SubstanzenList", new Item("SubstanzenList", substanzen));
|
||||
|
||||
var actual = mapper.apply(procedure);
|
||||
|
||||
assertThat(actual).isPresent();
|
||||
|
||||
assertThat(actual.get().get("Beginn"))
|
||||
.isEqualTo(Date.from(Instant.parse("2023-01-01T00:00:00Z")).toString());
|
||||
assertThat(actual.get().get("Ende"))
|
||||
.isEqualTo(Date.from(Instant.parse("2023-01-31T00:00:00Z")).toString());
|
||||
assertThat(actual.get().get("Beendigung"))
|
||||
.isEqualTo("E");
|
||||
assertThat(actual.get().get("Ergebnis"))
|
||||
.isEqualTo("T");
|
||||
assertThat(actual.get().get("Wirkstoffe"))
|
||||
.isEqualTo("Testsubstanz, cyclophosphamide");
|
||||
assertThat(actual.get().get("WirkstoffCodes"))
|
||||
.isEqualTo(
|
||||
"[" +
|
||||
"{\"system\":\"other\",\"code\":\"Testsubstanz\",\"substance\":\"Testsubstanz\"}," +
|
||||
"{\"system\":\"ATC\",\"code\":\"L01AA01\",\"substance\":\"cyclophosphamide\"}" +
|
||||
"]"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user