mirror of
https://github.com/pcvolkmer/onkostar-plugin-dnpm.git
synced 2025-07-04 10:02:55 +00:00
Merge pull request #57 from CCC-MF/issue_54
Übernahme des ECOG-Status aus anderen Therapieformularen
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
package DNPM.analyzer;
|
package DNPM.analyzer;
|
||||||
|
|
||||||
|
import DNPM.dto.EcogStatusWithDate;
|
||||||
import DNPM.VerweisVon;
|
import DNPM.VerweisVon;
|
||||||
import DNPM.security.DelegatingDataBasedPermissionEvaluator;
|
import DNPM.security.DelegatingDataBasedPermissionEvaluator;
|
||||||
import DNPM.security.IllegalSecuredObjectAccessException;
|
import DNPM.security.IllegalSecuredObjectAccessException;
|
||||||
@ -237,7 +238,7 @@ public class DNPMHelper extends BackendService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SystemtherapieService.EcogStatusWithDate> getEcogStatus(final Map<String, Object> input) {
|
public List<EcogStatusWithDate> getEcogStatus(final Map<String, Object> input) {
|
||||||
var pid = AnalyzerUtils.getRequiredId(input, "PatientId");
|
var pid = AnalyzerUtils.getRequiredId(input, "PatientId");
|
||||||
if (pid.isEmpty()) {
|
if (pid.isEmpty()) {
|
||||||
logger.error("Kein Parameter 'PatientId' angegeben, gebe leere Liste zurück");
|
logger.error("Kein Parameter 'PatientId' angegeben, gebe leere Liste zurück");
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package DNPM.analyzer;
|
package DNPM.analyzer;
|
||||||
|
|
||||||
|
import DNPM.dto.EcogStatusWithDate;
|
||||||
|
import DNPM.services.strahlentherapie.StrahlentherapieService;
|
||||||
import DNPM.services.systemtherapie.SystemtherapieService;
|
import DNPM.services.systemtherapie.SystemtherapieService;
|
||||||
import de.itc.onkostar.api.Disease;
|
import de.itc.onkostar.api.Disease;
|
||||||
import de.itc.onkostar.api.IOnkostarApi;
|
import de.itc.onkostar.api.IOnkostarApi;
|
||||||
@ -20,28 +22,31 @@ import java.util.stream.Collectors;
|
|||||||
/**
|
/**
|
||||||
* Diese Klasse implementiert ein Plugin, welches Aktionen nach Bearbeitung eines Formulars zur Systemtherapie durchführt.
|
* Diese Klasse implementiert ein Plugin, welches Aktionen nach Bearbeitung eines Formulars zur Systemtherapie durchführt.
|
||||||
*
|
*
|
||||||
* @since 0.4.0
|
* @since 0.6.0
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class SystemtherapieAnalyzer extends Analyzer {
|
public class TherapieMitEcogAnalyzer extends Analyzer {
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||||
|
|
||||||
private final IOnkostarApi onkostarApi;
|
private final IOnkostarApi onkostarApi;
|
||||||
|
|
||||||
|
private final StrahlentherapieService strahlentherapieService;
|
||||||
private final SystemtherapieService systemtherapieService;
|
private final SystemtherapieService systemtherapieService;
|
||||||
|
|
||||||
public SystemtherapieAnalyzer(
|
public TherapieMitEcogAnalyzer(
|
||||||
final IOnkostarApi onkostarApi,
|
final IOnkostarApi onkostarApi,
|
||||||
|
final StrahlentherapieService strahlentherapieService,
|
||||||
final SystemtherapieService systemtherapieService
|
final SystemtherapieService systemtherapieService
|
||||||
) {
|
) {
|
||||||
this.onkostarApi = onkostarApi;
|
this.onkostarApi = onkostarApi;
|
||||||
|
this.strahlentherapieService = strahlentherapieService;
|
||||||
this.systemtherapieService = systemtherapieService;
|
this.systemtherapieService = systemtherapieService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Aktualisiert verknüpfte Formulare nach Änderungen im Formularen vom Typ Systemtherapie";
|
return "Aktualisiert verknüpfte Formulare nach Änderungen in Formularen vom Typ Strahlen-/Systemtherapie mit ECOG-Status";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,7 +60,9 @@ public class SystemtherapieAnalyzer extends Analyzer {
|
|||||||
@Override
|
@Override
|
||||||
public boolean isRelevantForAnalyzer(Procedure procedure, Disease disease) {
|
public boolean isRelevantForAnalyzer(Procedure procedure, Disease disease) {
|
||||||
return null != procedure && null != disease && (
|
return null != procedure && null != disease && (
|
||||||
procedure.getFormName().equals("OS.Systemische Therapie")
|
procedure.getFormName().equals("OS.Strahlentherapie")
|
||||||
|
|| procedure.getFormName().equals("OS.Strahlentherapie.VarianteUKW")
|
||||||
|
|| procedure.getFormName().equals("OS.Systemische Therapie")
|
||||||
|| procedure.getFormName().equals("OS.Systemische Therapie.VarianteUKW")
|
|| procedure.getFormName().equals("OS.Systemische Therapie.VarianteUKW")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -89,12 +96,18 @@ public class SystemtherapieAnalyzer extends Analyzer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ecogFromCompleted = systemtherapieService.ecogStatus(procedure.getPatient())
|
var ecog = strahlentherapieService.ecogStatus(procedure.getPatient())
|
||||||
.stream()
|
.stream()
|
||||||
.filter(ecogStatusWithDate -> ecogStatusWithDate.getDate().after(disease.getDiagnosisDate()))
|
.filter(ecogStatusWithDate -> ecogStatusWithDate.getDate().after(disease.getDiagnosisDate()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
if (ecogFromCompleted.isEmpty()) {
|
ecog.addAll(systemtherapieService.ecogStatus(procedure.getPatient())
|
||||||
|
.stream()
|
||||||
|
.filter(ecogStatusWithDate -> ecogStatusWithDate.getDate().after(disease.getDiagnosisDate()))
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
|
||||||
|
|
||||||
|
if (ecog.isEmpty()) {
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -104,14 +117,14 @@ public class SystemtherapieAnalyzer extends Analyzer {
|
|||||||
.forEach(p -> {
|
.forEach(p -> {
|
||||||
var ufEcog = p.getValue("ECOGVerlauf");
|
var ufEcog = p.getValue("ECOGVerlauf");
|
||||||
if (null != ufEcog && ufEcog.getValue() instanceof List) {
|
if (null != ufEcog && ufEcog.getValue() instanceof List) {
|
||||||
updateExistingEcogVerlauf(p, ecogFromCompleted, ufEcog);
|
updateExistingEcogVerlauf(p, ecog, ufEcog);
|
||||||
} else {
|
} else {
|
||||||
newEcogverlauf(p, ecogFromCompleted);
|
newEcogverlauf(p, ecog);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateExistingEcogVerlauf(Procedure p, List<SystemtherapieService.EcogStatusWithDate> ecogFromCompleted, Item ufEcog) {
|
private void updateExistingEcogVerlauf(Procedure p, List<EcogStatusWithDate> ecogFromCompleted, Item ufEcog) {
|
||||||
var shouldSave = false;
|
var shouldSave = false;
|
||||||
var existingDates = ufEcog.<List<Map<String, String>>>getValue().stream()
|
var existingDates = ufEcog.<List<Map<String, String>>>getValue().stream()
|
||||||
.map(v -> v.get("Datum"))
|
.map(v -> v.get("Datum"))
|
||||||
@ -136,7 +149,7 @@ public class SystemtherapieAnalyzer extends Analyzer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void newEcogverlauf(Procedure p, List<SystemtherapieService.EcogStatusWithDate> ecogFromCompleted) {
|
private void newEcogverlauf(Procedure p, List<EcogStatusWithDate> ecogFromCompleted) {
|
||||||
p.setValue("ECOGVerlauf", new Item("ECOGVerlauf", List.of()));
|
p.setValue("ECOGVerlauf", new Item("ECOGVerlauf", List.of()));
|
||||||
for (var ecog : ecogFromCompleted) {
|
for (var ecog : ecogFromCompleted) {
|
||||||
var newSubProcedure = new Procedure(onkostarApi);
|
var newSubProcedure = new Procedure(onkostarApi);
|
68
src/main/java/DNPM/dto/EcogStatusWithDate.java
Normal file
68
src/main/java/DNPM/dto/EcogStatusWithDate.java
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* 2023 Comprehensive Cancer Center Mainfranken
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package DNPM.dto;
|
||||||
|
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Datenklasse zum Abbilden des ECOG-Status und Datum
|
||||||
|
*/
|
||||||
|
public class EcogStatusWithDate {
|
||||||
|
private Date date;
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
public EcogStatusWithDate(Date date, String status) {
|
||||||
|
Assert.notNull(date, "Date cannot be null");
|
||||||
|
Assert.hasText(status, "Status cannot be empty String");
|
||||||
|
Assert.isTrue(isValidEcogCode(status), "Not a valid ADT.LeistungszustandECOG code");
|
||||||
|
this.date = date;
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isValidEcogCode(String status) {
|
||||||
|
switch (status) {
|
||||||
|
case "0":
|
||||||
|
case "1":
|
||||||
|
case "2":
|
||||||
|
case "3":
|
||||||
|
case "4":
|
||||||
|
case "5":
|
||||||
|
case "U":
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getDate() {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
30
src/main/java/DNPM/services/TherapieMitEcogService.java
Normal file
30
src/main/java/DNPM/services/TherapieMitEcogService.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package DNPM.services;
|
||||||
|
|
||||||
|
import DNPM.dto.EcogStatusWithDate;
|
||||||
|
import de.itc.onkostar.api.Patient;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schnittstelle zum Ermitteln von ECOG-Statusinformationen
|
||||||
|
*
|
||||||
|
* @since 0.6.0
|
||||||
|
*/
|
||||||
|
public interface TherapieMitEcogService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ermittelt den letzten bekannten ECOG-Status aus allen Therapieformularen des Patienten
|
||||||
|
* @param patient Der zu verwendende Patient
|
||||||
|
* @return Der ECOG-Status als String oder leeres Optional
|
||||||
|
*/
|
||||||
|
Optional<String> latestEcogStatus(Patient patient);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ermittelt jeden bekannten ECOG-Status aus allen Therapieformularen des Patienten
|
||||||
|
* @param patient Der zu verwendende Patient
|
||||||
|
* @return Eine Liste mit Datum und ECOG-Status als String
|
||||||
|
*/
|
||||||
|
List<EcogStatusWithDate> ecogStatus(Patient patient);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
package DNPM.services.strahlentherapie;
|
||||||
|
|
||||||
|
import DNPM.dto.EcogStatusWithDate;
|
||||||
|
import DNPM.services.SettingsService;
|
||||||
|
import de.itc.onkostar.api.IOnkostarApi;
|
||||||
|
import de.itc.onkostar.api.Patient;
|
||||||
|
import de.itc.onkostar.api.Procedure;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standardimplementierung des StrahlentherapieServices
|
||||||
|
*
|
||||||
|
* @since 0.6.0
|
||||||
|
*/
|
||||||
|
public class DefaultStrahlentherapieService implements StrahlentherapieService {
|
||||||
|
|
||||||
|
private static final String ECOG_FIELD = "ECOGvorTherapie";
|
||||||
|
|
||||||
|
private final IOnkostarApi onkostarApi;
|
||||||
|
|
||||||
|
private final SettingsService settingsService;
|
||||||
|
|
||||||
|
public DefaultStrahlentherapieService(final IOnkostarApi onkostarApi, final SettingsService settingsService) {
|
||||||
|
this.onkostarApi = onkostarApi;
|
||||||
|
this.settingsService = settingsService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ermittelt den letzten bekannten ECOG-Status aus allen Systemtherapieformularen des Patienten
|
||||||
|
*
|
||||||
|
* @param patient Der zu verwendende Patient
|
||||||
|
* @return Der ECOG-Status als String oder leeres Optional
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Optional<String> latestEcogStatus(Patient patient) {
|
||||||
|
return ecogStatus(patient).stream()
|
||||||
|
.max(Comparator.comparing(EcogStatusWithDate::getDate))
|
||||||
|
.map(EcogStatusWithDate::getStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ermittelt jeden bekannten ECOG-Status aus allen Systemtherapieformularen des Patienten
|
||||||
|
*
|
||||||
|
* @param patient Der zu verwendende Patient
|
||||||
|
* @return Eine Liste mit Datum und ECOG-Status als String
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<EcogStatusWithDate> ecogStatus(Patient patient) {
|
||||||
|
return patient.getDiseases().stream()
|
||||||
|
.flatMap(disease -> onkostarApi.getProceduresForDiseaseByForm(disease.getId(), getFormName()).stream())
|
||||||
|
.filter(procedure -> null != procedure.getStartDate())
|
||||||
|
.sorted(Comparator.comparing(Procedure::getStartDate))
|
||||||
|
.map(procedure -> {
|
||||||
|
try {
|
||||||
|
return new EcogStatusWithDate(procedure.getStartDate(), procedure.getValue(ECOG_FIELD).getString());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getFormName() {
|
||||||
|
return settingsService
|
||||||
|
.getSetting("strahlentherapieform")
|
||||||
|
.orElse("OS.Strahlentherapie");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package DNPM.services.strahlentherapie;
|
||||||
|
|
||||||
|
import DNPM.services.TherapieMitEcogService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service für Systemtherapieformulare
|
||||||
|
*
|
||||||
|
* @since 0.6.0
|
||||||
|
*/
|
||||||
|
public interface StrahlentherapieService extends TherapieMitEcogService {}
|
@ -1,5 +1,6 @@
|
|||||||
package DNPM.services.systemtherapie;
|
package DNPM.services.systemtherapie;
|
||||||
|
|
||||||
|
import DNPM.dto.EcogStatusWithDate;
|
||||||
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.Patient;
|
import de.itc.onkostar.api.Patient;
|
||||||
|
@ -1,20 +1,17 @@
|
|||||||
package DNPM.services.systemtherapie;
|
package DNPM.services.systemtherapie;
|
||||||
|
|
||||||
import de.itc.onkostar.api.Patient;
|
import DNPM.services.TherapieMitEcogService;
|
||||||
import de.itc.onkostar.api.Procedure;
|
import de.itc.onkostar.api.Procedure;
|
||||||
import org.springframework.util.Assert;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service für Systemtherapieformulare
|
* Service für Systemtherapieformulare
|
||||||
*
|
*
|
||||||
* @since 0.2.0
|
* @since 0.2.0
|
||||||
*/
|
*/
|
||||||
public interface SystemtherapieService {
|
public interface SystemtherapieService extends TherapieMitEcogService {
|
||||||
/**
|
/**
|
||||||
* Ermittelt eine Zusammenfassung der systemischen Therapien für eine Erkrankung
|
* Ermittelt eine Zusammenfassung der systemischen Therapien für eine Erkrankung
|
||||||
* @param diseaseId Die ID der Erkrankung
|
* @param diseaseId Die ID der Erkrankung
|
||||||
@ -29,57 +26,4 @@ public interface SystemtherapieService {
|
|||||||
*/
|
*/
|
||||||
ProzedurToProzedurwerteMapper prozedurToProzedurwerteMapper(Procedure procedure);
|
ProzedurToProzedurwerteMapper prozedurToProzedurwerteMapper(Procedure procedure);
|
||||||
|
|
||||||
/**
|
|
||||||
* Ermittelt den letzten bekannten ECOG-Status aus allen Systemtherapieformularen des Patienten
|
|
||||||
* @param patient Der zu verwendende Patient
|
|
||||||
* @return Der ECOG-Status als String oder leeres Optional
|
|
||||||
*/
|
|
||||||
Optional<String> latestEcogStatus(Patient patient);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ermittelt jeden bekannten ECOG-Status aus allen Systemtherapieformularen des Patienten
|
|
||||||
* @param patient Der zu verwendende Patient
|
|
||||||
* @return Eine Liste mit Datum und ECOG-Status als String
|
|
||||||
*/
|
|
||||||
List<EcogStatusWithDate> ecogStatus(Patient patient);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Datenklasse zum Abbilden des ECOG-Status und Datum
|
|
||||||
*/
|
|
||||||
class EcogStatusWithDate {
|
|
||||||
private Date date;
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
public EcogStatusWithDate(Date date, String status) {
|
|
||||||
Assert.notNull(date, "Date cannot be null");
|
|
||||||
Assert.hasText(status, "Status cannot be empty String");
|
|
||||||
Assert.isTrue(isValidEcogCode(status), "Not a valid ADT.LeistungszustandECOG code");
|
|
||||||
this.date = date;
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isValidEcogCode(String status) {
|
|
||||||
switch (status) {
|
|
||||||
case "0":
|
|
||||||
case "1":
|
|
||||||
case "2":
|
|
||||||
case "3":
|
|
||||||
case "4":
|
|
||||||
case "5":
|
|
||||||
case "U":
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getDate() {
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package DNPM.analyzer;
|
package DNPM.analyzer;
|
||||||
|
|
||||||
|
import DNPM.dto.EcogStatusWithDate;
|
||||||
|
import DNPM.services.strahlentherapie.StrahlentherapieService;
|
||||||
import DNPM.services.systemtherapie.SystemtherapieService;
|
import DNPM.services.systemtherapie.SystemtherapieService;
|
||||||
import de.itc.onkostar.api.*;
|
import de.itc.onkostar.api.*;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
@ -19,13 +21,15 @@ import static org.mockito.ArgumentMatchers.anyInt;
|
|||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
@ExtendWith(MockitoExtension.class)
|
@ExtendWith(MockitoExtension.class)
|
||||||
class SystemtherapieAnalyzerTest {
|
class TherapieMitEcogAnalyzerTest {
|
||||||
|
|
||||||
private IOnkostarApi onkostarApi;
|
private IOnkostarApi onkostarApi;
|
||||||
|
|
||||||
|
private StrahlentherapieService strahlentherapieService;
|
||||||
|
|
||||||
private SystemtherapieService systemtherapieService;
|
private SystemtherapieService systemtherapieService;
|
||||||
|
|
||||||
private SystemtherapieAnalyzer systemtherapieAnalyzer;
|
private TherapieMitEcogAnalyzer therapieMitEcogAnalyzer;
|
||||||
|
|
||||||
private Disease dummyDisease(int id, Date diagnosisDate) {
|
private Disease dummyDisease(int id, Date diagnosisDate) {
|
||||||
var disease = new Disease(onkostarApi);
|
var disease = new Disease(onkostarApi);
|
||||||
@ -41,11 +45,13 @@ class SystemtherapieAnalyzerTest {
|
|||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setUp(
|
void setUp(
|
||||||
@Mock IOnkostarApi onkostarApi,
|
@Mock IOnkostarApi onkostarApi,
|
||||||
|
@Mock StrahlentherapieService strahlentherapieService,
|
||||||
@Mock SystemtherapieService systemtherapieService
|
@Mock SystemtherapieService systemtherapieService
|
||||||
) {
|
) {
|
||||||
this.onkostarApi = onkostarApi;
|
this.onkostarApi = onkostarApi;
|
||||||
|
this.strahlentherapieService = strahlentherapieService;
|
||||||
this.systemtherapieService = systemtherapieService;
|
this.systemtherapieService = systemtherapieService;
|
||||||
this.systemtherapieAnalyzer = new SystemtherapieAnalyzer(onkostarApi, systemtherapieService);
|
this.therapieMitEcogAnalyzer = new TherapieMitEcogAnalyzer(onkostarApi, strahlentherapieService, systemtherapieService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -54,7 +60,7 @@ class SystemtherapieAnalyzerTest {
|
|||||||
final var ecogDate = daysPassed(1);
|
final var ecogDate = daysPassed(1);
|
||||||
final var procedureDate = daysPassed(1);
|
final var procedureDate = daysPassed(1);
|
||||||
|
|
||||||
doAnswer(invocationOnMock -> List.of(new SystemtherapieService.EcogStatusWithDate(ecogDate, "0")))
|
doAnswer(invocationOnMock -> List.of(new EcogStatusWithDate(ecogDate, "0")))
|
||||||
.when(systemtherapieService).ecogStatus(any(Patient.class));
|
.when(systemtherapieService).ecogStatus(any(Patient.class));
|
||||||
|
|
||||||
var patient = new Patient(onkostarApi);
|
var patient = new Patient(onkostarApi);
|
||||||
@ -72,7 +78,7 @@ class SystemtherapieAnalyzerTest {
|
|||||||
|
|
||||||
doAnswer(invocationOnMock -> List.of(procedure)).when(onkostarApi).getProceduresForDiseaseByForm(anyInt(), anyString());
|
doAnswer(invocationOnMock -> List.of(procedure)).when(onkostarApi).getProceduresForDiseaseByForm(anyInt(), anyString());
|
||||||
|
|
||||||
systemtherapieAnalyzer.analyze(procedure, dummyDisease(10, diagnosisDate));
|
therapieMitEcogAnalyzer.analyze(procedure, dummyDisease(10, diagnosisDate));
|
||||||
|
|
||||||
var idCaptor = ArgumentCaptor.forClass(Integer.class);
|
var idCaptor = ArgumentCaptor.forClass(Integer.class);
|
||||||
var formNameCaptor = ArgumentCaptor.forClass(String.class);
|
var formNameCaptor = ArgumentCaptor.forClass(String.class);
|
||||||
@ -102,7 +108,7 @@ class SystemtherapieAnalyzerTest {
|
|||||||
procedure.setPatient(patient);
|
procedure.setPatient(patient);
|
||||||
procedure.setValue("ECOGvorTherapie", new Item("ECOGvorTherapie", 1));
|
procedure.setValue("ECOGvorTherapie", new Item("ECOGvorTherapie", 1));
|
||||||
|
|
||||||
systemtherapieAnalyzer.analyze(procedure, dummyDisease(10, diagnosisDate));
|
therapieMitEcogAnalyzer.analyze(procedure, dummyDisease(10, diagnosisDate));
|
||||||
|
|
||||||
verify(onkostarApi, times(0)).getProceduresForDiseaseByForm(anyInt(), anyString());
|
verify(onkostarApi, times(0)).getProceduresForDiseaseByForm(anyInt(), anyString());
|
||||||
verify(onkostarApi, times(0)).saveProcedure(any(Procedure.class), anyBoolean());
|
verify(onkostarApi, times(0)).saveProcedure(any(Procedure.class), anyBoolean());
|
||||||
@ -114,7 +120,7 @@ class SystemtherapieAnalyzerTest {
|
|||||||
final var ecogDate = daysPassed(28);
|
final var ecogDate = daysPassed(28);
|
||||||
final var procedureDate = daysPassed(1);
|
final var procedureDate = daysPassed(1);
|
||||||
|
|
||||||
doAnswer(invocationOnMock -> List.of(new SystemtherapieService.EcogStatusWithDate(ecogDate, "0")))
|
doAnswer(invocationOnMock -> List.of(new EcogStatusWithDate(ecogDate, "0")))
|
||||||
.when(systemtherapieService).ecogStatus(any(Patient.class));
|
.when(systemtherapieService).ecogStatus(any(Patient.class));
|
||||||
|
|
||||||
var patient = new Patient(onkostarApi);
|
var patient = new Patient(onkostarApi);
|
||||||
@ -128,10 +134,32 @@ class SystemtherapieAnalyzerTest {
|
|||||||
procedure.setPatient(patient);
|
procedure.setPatient(patient);
|
||||||
procedure.setValue("ECOGvorTherapie", new Item("ECOGvorTherapie", 1));
|
procedure.setValue("ECOGvorTherapie", new Item("ECOGvorTherapie", 1));
|
||||||
|
|
||||||
systemtherapieAnalyzer.analyze(procedure, dummyDisease(10, diagnosisDate));
|
therapieMitEcogAnalyzer.analyze(procedure, dummyDisease(10, diagnosisDate));
|
||||||
|
|
||||||
verify(onkostarApi, times(0)).getProceduresForDiseaseByForm(anyInt(), anyString());
|
verify(onkostarApi, times(0)).getProceduresForDiseaseByForm(anyInt(), anyString());
|
||||||
verify(onkostarApi, times(0)).saveProcedure(any(Procedure.class), anyBoolean());
|
verify(onkostarApi, times(0)).saveProcedure(any(Procedure.class), anyBoolean());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRequestEcogFromStrahlentherapieAndSystemtherapie() {
|
||||||
|
final var diagnosisDate = daysPassed(7);
|
||||||
|
final var procedureDate = daysPassed(1);
|
||||||
|
|
||||||
|
var patient = new Patient(onkostarApi);
|
||||||
|
patient.setId(1);
|
||||||
|
|
||||||
|
var procedure = new Procedure(onkostarApi);
|
||||||
|
procedure.setId(1000);
|
||||||
|
procedure.setStartDate(procedureDate);
|
||||||
|
procedure.setEditState(ProcedureEditStateType.COMPLETED);
|
||||||
|
procedure.setPatientId(1);
|
||||||
|
procedure.setPatient(patient);
|
||||||
|
procedure.setValue("ECOGvorTherapie", new Item("ECOGvorTherapie", 1));
|
||||||
|
|
||||||
|
therapieMitEcogAnalyzer.analyze(procedure, dummyDisease(10, diagnosisDate));
|
||||||
|
|
||||||
|
verify(strahlentherapieService, times(1)).ecogStatus(any());
|
||||||
|
verify(systemtherapieService, times(1)).ecogStatus(any());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,106 @@
|
|||||||
|
package DNPM.services.strahlentherapie;
|
||||||
|
|
||||||
|
import DNPM.services.SettingsService;
|
||||||
|
import de.itc.onkostar.api.*;
|
||||||
|
import org.assertj.core.util.Lists;
|
||||||
|
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.time.Instant;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
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.*;
|
||||||
|
|
||||||
|
@ExtendWith(MockitoExtension.class)
|
||||||
|
class DefaultStrahlentherapieServiceTest {
|
||||||
|
|
||||||
|
private IOnkostarApi onkostarApi;
|
||||||
|
|
||||||
|
private SettingsService settingsService;
|
||||||
|
|
||||||
|
private DefaultStrahlentherapieService service;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setup(@Mock IOnkostarApi onkostarApi, @Mock SettingsService settingsService) {
|
||||||
|
this.onkostarApi = onkostarApi;
|
||||||
|
this.settingsService = settingsService;
|
||||||
|
this.service = new DefaultStrahlentherapieService(onkostarApi, settingsService);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testShouldRequestProceduresWithDefaultFormName() {
|
||||||
|
when(this.settingsService.getSetting(anyString())).thenReturn(Optional.empty());
|
||||||
|
|
||||||
|
doAnswer(invocationOnMock -> {
|
||||||
|
var procedure = new Procedure(onkostarApi);
|
||||||
|
procedure.setId(1);
|
||||||
|
procedure.setFormName("OS.Strahlentherapie");
|
||||||
|
procedure.setStartDate(Date.from(Instant.parse("2023-07-01T06:00:00Z")));
|
||||||
|
procedure.setEditState(ProcedureEditStateType.COMPLETED);
|
||||||
|
procedure.setValue("ECOGvorTherapie", new Item("ECOGvorTherapie", 1));
|
||||||
|
return Lists.list(procedure);
|
||||||
|
}).when(this.onkostarApi).getProceduresForDiseaseByForm(anyInt(), anyString());
|
||||||
|
|
||||||
|
doAnswer(invocationOnMock -> {
|
||||||
|
var disease = new Disease(onkostarApi);
|
||||||
|
disease.setId(1);
|
||||||
|
disease.setPatientId(123);
|
||||||
|
return Lists.list(disease);
|
||||||
|
}).when(this.onkostarApi).getDiseasesByPatientId(anyInt());
|
||||||
|
|
||||||
|
var patient = new Patient(onkostarApi);
|
||||||
|
patient.setId(123);
|
||||||
|
|
||||||
|
service.ecogStatus(patient);
|
||||||
|
|
||||||
|
var argumentCaptor = ArgumentCaptor.forClass(String.class);
|
||||||
|
verify(onkostarApi, times(1)).getProceduresForDiseaseByForm(anyInt(), argumentCaptor.capture());
|
||||||
|
assertThat(argumentCaptor.getValue()).isEqualTo("OS.Strahlentherapie");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testShouldReturnListOfEcogStatusWithDate() {
|
||||||
|
doAnswer(invocationOnMock -> {
|
||||||
|
var disease = new Disease(onkostarApi);
|
||||||
|
disease.setId(1);
|
||||||
|
return List.of(disease);
|
||||||
|
}).when(this.onkostarApi).getDiseasesByPatientId(anyInt());
|
||||||
|
|
||||||
|
doAnswer(invocationOnMock -> {
|
||||||
|
var procedure1 = new Procedure(onkostarApi);
|
||||||
|
procedure1.setId(1);
|
||||||
|
procedure1.setFormName("OS.Strahlentherapie");
|
||||||
|
procedure1.setStartDate(Date.from(Instant.parse("2023-07-01T06:00:00Z")));
|
||||||
|
procedure1.setEditState(ProcedureEditStateType.COMPLETED);
|
||||||
|
procedure1.setValue("ECOGvorTherapie", new Item("ECOGvorTherapie", 1));
|
||||||
|
|
||||||
|
var procedure2 = new Procedure(onkostarApi);
|
||||||
|
procedure2.setId(2);
|
||||||
|
procedure2.setFormName("OS.Strahlentherapie");
|
||||||
|
procedure2.setStartDate(Date.from(Instant.parse("2023-07-12T06:00:00Z")));
|
||||||
|
procedure2.setEditState(ProcedureEditStateType.COMPLETED);
|
||||||
|
procedure2.setValue("ECOGvorTherapie", new Item("ECOGvorTherapie", 2));
|
||||||
|
return List.of(procedure1, procedure2);
|
||||||
|
}).when(this.onkostarApi).getProceduresForDiseaseByForm(anyInt(), anyString());
|
||||||
|
|
||||||
|
var patient = new Patient(onkostarApi);
|
||||||
|
patient.setId(1);
|
||||||
|
|
||||||
|
var actual = service.ecogStatus(patient);
|
||||||
|
|
||||||
|
assertThat(actual)
|
||||||
|
.isNotNull()
|
||||||
|
.isExactlyInstanceOf(ArrayList.class)
|
||||||
|
.hasSize(2);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user