mirror of
https://github.com/pcvolkmer/onkostar-plugin-dnpm.git
synced 2025-07-02 01:02:55 +00:00
Issue #22: Verwende Angabe des Systemtherapie-Formulars in den Einstellungen
Standardwert, wenn die Einstellung nicht vorhanden ist, ist "OS.Systemische Therapie". closes #22
This commit is contained in:
16
README.md
16
README.md
@ -80,7 +80,21 @@ Laufzeit verwendet werden soll. Der Mapper muss hierbei das Interface `ProzedurT
|
||||
|
||||
In der Klasse `DefaultSystemtherapieService` wird zur Laufzeit der erforderliche Mapper für das verwendete Formular ausgewählt.
|
||||
|
||||
An dieser Stelle kann auch eine eigene Implementierung - eine neue Klasse, die das Interface `ProzedurToProzedurwerteMapper` implementiert - integriert werden, indem das zu verwendende Formular (Formularname) je `SID` und die zu verwendende Mapping-Klasse für den Formularnamen angegeben wird.
|
||||
An dieser Stelle kann auch eine eigene Implementierung - eine neue Klasse, die das Interface `ProzedurToProzedurwerteMapper` implementiert -
|
||||
integriert werden, indem das zu verwendende Formular (Formularname) und die zu verwendende Mapping-Klasse für den Formularnamen angegeben wird.
|
||||
|
||||
Hierbei kann in der Einstellung `systemtherapieform` festgelegt werden, dass ein anderes Formular als "OS.Systemische Therapie" verwendet werden soll.
|
||||
Diese Einstellung muss manuell in der Datenbank angelegt werden und kann danach in Onkostar verändert werden.
|
||||
|
||||
```
|
||||
INSERT INTO einstellung (name, wert, kategorie, beschreibung)
|
||||
VALUES (
|
||||
'systemtherapieform',
|
||||
'OS.Systemische Therapie',
|
||||
'DNPM',
|
||||
'Zu verwendendes Formular für die systemische Therapie'
|
||||
);
|
||||
```
|
||||
|
||||
## Bauen des Plugins
|
||||
|
||||
|
@ -3,8 +3,6 @@ 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;
|
||||
@ -17,8 +15,6 @@ import java.util.Map;
|
||||
*/
|
||||
public class DefaultSystemtherapieService implements SystemtherapieService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DefaultSystemtherapieService.class);
|
||||
|
||||
private final IOnkostarApi onkostarApi;
|
||||
|
||||
private final SettingsService settingsService;
|
||||
@ -36,13 +32,8 @@ public class DefaultSystemtherapieService implements SystemtherapieService {
|
||||
*/
|
||||
@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()))) {
|
||||
for (Procedure prozedur : onkostarApi.getProceduresForDiseaseByForm(diseaseId, getFormName())) {
|
||||
prozedurToProzedurwerteMapper(prozedur).apply(prozedur).ifPresent(result::add);
|
||||
}
|
||||
return result;
|
||||
@ -60,14 +51,9 @@ public class DefaultSystemtherapieService implements SystemtherapieService {
|
||||
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";
|
||||
}
|
||||
private String getFormName() {
|
||||
return settingsService
|
||||
.getSetting("systemtherapieform")
|
||||
.orElse("OS.Systemische Therapie");
|
||||
}
|
||||
}
|
||||
|
@ -25,10 +25,4 @@ public interface SystemtherapieService {
|
||||
*/
|
||||
ProzedurToProzedurwerteMapper prozedurToProzedurwerteMapper(Procedure procedure);
|
||||
|
||||
/**
|
||||
* Ermittelt den Formularnamen anhand der SID
|
||||
* @param sid die SID
|
||||
* @return Den ermittelten Formularnamen
|
||||
*/
|
||||
String selectFormNameBySID(String sid);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ 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.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
@ -16,8 +17,7 @@ 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;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class DefaultSystemtherapieServiceTest {
|
||||
@ -50,21 +50,37 @@ class DefaultSystemtherapieServiceTest {
|
||||
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();
|
||||
private static List<String> formnameSetting() {
|
||||
return List.of("OS.Systemische Therapie", "OS.Systemische Therapie.VarianteUKW");
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("expectedFormnameMappings")
|
||||
void testShouldMapSidToFormName(Map.Entry<String, String> expectedMapping) {
|
||||
var actual = service.selectFormNameBySID(expectedMapping.getKey());
|
||||
assertThat(actual).isEqualTo(expectedMapping.getValue());
|
||||
@MethodSource("formnameSetting")
|
||||
void testShouldRequestProceduresWithExpectedFormName(String expectedFormName) {
|
||||
when(this.settingsService.getSetting(anyString())).thenReturn(Optional.of(expectedFormName));
|
||||
when(this.onkostarApi.getProceduresForDiseaseByForm(anyInt(), anyString())).thenReturn(List.of());
|
||||
|
||||
service.getSystemischeTherapienFromDiagnose(123);
|
||||
|
||||
var argumentCaptor = ArgumentCaptor.forClass(String.class);
|
||||
verify(onkostarApi, times(1)).getProceduresForDiseaseByForm(anyInt(), argumentCaptor.capture());
|
||||
assertThat(argumentCaptor.getValue()).isEqualTo(expectedFormName);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testShouldRequestProceduresWithDefaultFormName() {
|
||||
when(this.settingsService.getSetting(anyString())).thenReturn(Optional.empty());
|
||||
when(this.onkostarApi.getProceduresForDiseaseByForm(anyInt(), anyString())).thenReturn(List.of());
|
||||
|
||||
service.getSystemischeTherapienFromDiagnose(123);
|
||||
|
||||
var argumentCaptor = ArgumentCaptor.forClass(String.class);
|
||||
verify(onkostarApi, times(1)).getProceduresForDiseaseByForm(anyInt(), argumentCaptor.capture());
|
||||
assertThat(argumentCaptor.getValue()).isEqualTo("OS.Systemische Therapie");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testShouldReturnSystemischeTherapienFromDiagnose() {
|
||||
when(settingsService.getSID()).thenReturn(Optional.of("12345"));
|
||||
|
||||
doAnswer(invocationOnMock -> {
|
||||
var procedure = new Procedure(onkostarApi);
|
||||
procedure.setFormName("OS.Systemische Therapie");
|
||||
|
Reference in New Issue
Block a user