mirror of
https://github.com/pcvolkmer/onkostar-plugin-dnpm.git
synced 2025-07-02 09:12:54 +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.
|
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
|
## Bauen des Plugins
|
||||||
|
|
||||||
|
@ -3,8 +3,6 @@ package DNPM.services.systemtherapie;
|
|||||||
import DNPM.services.SettingsService;
|
import DNPM.services.SettingsService;
|
||||||
import de.itc.onkostar.api.IOnkostarApi;
|
import de.itc.onkostar.api.IOnkostarApi;
|
||||||
import de.itc.onkostar.api.Procedure;
|
import de.itc.onkostar.api.Procedure;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -17,8 +15,6 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class DefaultSystemtherapieService implements SystemtherapieService {
|
public class DefaultSystemtherapieService implements SystemtherapieService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DefaultSystemtherapieService.class);
|
|
||||||
|
|
||||||
private final IOnkostarApi onkostarApi;
|
private final IOnkostarApi onkostarApi;
|
||||||
|
|
||||||
private final SettingsService settingsService;
|
private final SettingsService settingsService;
|
||||||
@ -36,13 +32,8 @@ public class DefaultSystemtherapieService implements SystemtherapieService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, String>> getSystemischeTherapienFromDiagnose(int diseaseId) {
|
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<>();
|
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);
|
prozedurToProzedurwerteMapper(prozedur).apply(prozedur).ifPresent(result::add);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -60,14 +51,9 @@ public class DefaultSystemtherapieService implements SystemtherapieService {
|
|||||||
return new OsSystemischeTherapieToProzedurwerteMapper();
|
return new OsSystemischeTherapieToProzedurwerteMapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private String getFormName() {
|
||||||
public String selectFormNameBySID(String sid) {
|
return settingsService
|
||||||
switch (sid) {
|
.getSetting("systemtherapieform")
|
||||||
case "2011":
|
.orElse("OS.Systemische Therapie");
|
||||||
case "20119":
|
|
||||||
return "OS.Systemische Therapie.VarianteUKW";
|
|
||||||
default:
|
|
||||||
return "OS.Systemische Therapie";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,10 +25,4 @@ public interface SystemtherapieService {
|
|||||||
*/
|
*/
|
||||||
ProzedurToProzedurwerteMapper prozedurToProzedurwerteMapper(Procedure procedure);
|
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.api.extension.ExtendWith;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.junit.jupiter.MockitoExtension;
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
|
||||||
@ -16,8 +17,7 @@ import java.util.*;
|
|||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.Mockito.doAnswer;
|
import static org.mockito.Mockito.*;
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
@ExtendWith(MockitoExtension.class)
|
@ExtendWith(MockitoExtension.class)
|
||||||
class DefaultSystemtherapieServiceTest {
|
class DefaultSystemtherapieServiceTest {
|
||||||
@ -50,21 +50,37 @@ class DefaultSystemtherapieServiceTest {
|
|||||||
assertThat(actual).isExactlyInstanceOf(expectedMapping.getValue());
|
assertThat(actual).isExactlyInstanceOf(expectedMapping.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Set<Map.Entry<String, String>> expectedFormnameMappings() {
|
private static List<String> formnameSetting() {
|
||||||
return Map.ofEntries(Map.entry("2011", "OS.Systemische Therapie.VarianteUKW"), Map.entry("20119", "OS.Systemische Therapie.VarianteUKW"), Map.entry("Defaultwert", "OS.Systemische Therapie")).entrySet();
|
return List.of("OS.Systemische Therapie", "OS.Systemische Therapie.VarianteUKW");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource("expectedFormnameMappings")
|
@MethodSource("formnameSetting")
|
||||||
void testShouldMapSidToFormName(Map.Entry<String, String> expectedMapping) {
|
void testShouldRequestProceduresWithExpectedFormName(String expectedFormName) {
|
||||||
var actual = service.selectFormNameBySID(expectedMapping.getKey());
|
when(this.settingsService.getSetting(anyString())).thenReturn(Optional.of(expectedFormName));
|
||||||
assertThat(actual).isEqualTo(expectedMapping.getValue());
|
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
|
@Test
|
||||||
void testShouldReturnSystemischeTherapienFromDiagnose() {
|
void testShouldReturnSystemischeTherapienFromDiagnose() {
|
||||||
when(settingsService.getSID()).thenReturn(Optional.of("12345"));
|
|
||||||
|
|
||||||
doAnswer(invocationOnMock -> {
|
doAnswer(invocationOnMock -> {
|
||||||
var procedure = new Procedure(onkostarApi);
|
var procedure = new Procedure(onkostarApi);
|
||||||
procedure.setFormName("OS.Systemische Therapie");
|
procedure.setFormName("OS.Systemische Therapie");
|
||||||
|
Reference in New Issue
Block a user