mirror of
https://github.com/pcvolkmer/onkostar-plugin-dnpm.git
synced 2025-07-03 01:32:55 +00:00
Issue #29: Aktualisiere keinen EcogStatus vor Diagnosedatum
This commit is contained in:
@ -71,7 +71,7 @@ public class SystemtherapieAnalyzer implements IProcedureAnalyzer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRelevantForAnalyzer(Procedure procedure, Disease disease) {
|
public boolean isRelevantForAnalyzer(Procedure procedure, Disease disease) {
|
||||||
return null != procedure && (
|
return null != procedure && null != disease && (
|
||||||
procedure.getFormName().equals("OS.Systemische Therapie")
|
procedure.getFormName().equals("OS.Systemische Therapie")
|
||||||
|| procedure.getFormName().equals("OS.Systemische Therapie.VarianteUKW")
|
|| procedure.getFormName().equals("OS.Systemische Therapie.VarianteUKW")
|
||||||
);
|
);
|
||||||
@ -106,7 +106,11 @@ public class SystemtherapieAnalyzer implements IProcedureAnalyzer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ecogFromCompleted = systemtherapieService.ecogSatus(procedure.getPatient());
|
var ecogFromCompleted = systemtherapieService.ecogSatus(procedure.getPatient())
|
||||||
|
.stream()
|
||||||
|
.filter(ecogStatusWithDate -> ecogStatusWithDate.getDate().after(disease.getDiagnosisDate()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
if (ecogFromCompleted.isEmpty()) {
|
if (ecogFromCompleted.isEmpty()) {
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
return;
|
return;
|
||||||
|
@ -9,6 +9,8 @@ import org.mockito.ArgumentCaptor;
|
|||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.junit.jupiter.MockitoExtension;
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -25,10 +27,21 @@ class SystemtherapieAnalyzerTest {
|
|||||||
|
|
||||||
private SystemtherapieAnalyzer systemtherapieAnalyzer;
|
private SystemtherapieAnalyzer systemtherapieAnalyzer;
|
||||||
|
|
||||||
|
private Disease dummyDisease(int id, Date diagnosisDate) {
|
||||||
|
var disease = new Disease(onkostarApi);
|
||||||
|
disease.setId(id);
|
||||||
|
disease.setDiagnosisDate(diagnosisDate);
|
||||||
|
return disease;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Date daysPassed(int days) {
|
||||||
|
return Date.from(Instant.now().minus(days, ChronoUnit.DAYS));
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setUp(
|
void setUp(
|
||||||
@Mock IOnkostarApi onkostarApi,
|
@Mock IOnkostarApi onkostarApi,
|
||||||
@Mock SystemtherapieService systemtherapieService
|
@Mock SystemtherapieService systemtherapieService
|
||||||
) {
|
) {
|
||||||
this.onkostarApi = onkostarApi;
|
this.onkostarApi = onkostarApi;
|
||||||
this.systemtherapieService = systemtherapieService;
|
this.systemtherapieService = systemtherapieService;
|
||||||
@ -37,7 +50,11 @@ class SystemtherapieAnalyzerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldInsertNewEcogStatus() throws Exception {
|
void shouldInsertNewEcogStatus() throws Exception {
|
||||||
doAnswer(invocationOnMock -> List.of(new SystemtherapieService.EcogStatusWithDate(new Date(), "0")))
|
final var diagnosisDate = daysPassed(7);
|
||||||
|
final var ecogDate = daysPassed(1);
|
||||||
|
final var procedureDate = daysPassed(1);
|
||||||
|
|
||||||
|
doAnswer(invocationOnMock -> List.of(new SystemtherapieService.EcogStatusWithDate(ecogDate, "0")))
|
||||||
.when(systemtherapieService).ecogSatus(any(Patient.class));
|
.when(systemtherapieService).ecogSatus(any(Patient.class));
|
||||||
|
|
||||||
var patient = new Patient(onkostarApi);
|
var patient = new Patient(onkostarApi);
|
||||||
@ -45,21 +62,17 @@ class SystemtherapieAnalyzerTest {
|
|||||||
|
|
||||||
var procedure = new Procedure(onkostarApi);
|
var procedure = new Procedure(onkostarApi);
|
||||||
procedure.setId(1000);
|
procedure.setId(1000);
|
||||||
procedure.setStartDate(new Date());
|
procedure.setStartDate(procedureDate);
|
||||||
procedure.setEditState(ProcedureEditStateType.COMPLETED);
|
procedure.setEditState(ProcedureEditStateType.COMPLETED);
|
||||||
procedure.setPatientId(1);
|
procedure.setPatientId(1);
|
||||||
procedure.setPatient(patient);
|
procedure.setPatient(patient);
|
||||||
procedure.setValue("ECOGvorTherapie", new Item("ECOGvorTherapie", 1));
|
procedure.setValue("ECOGvorTherapie", new Item("ECOGvorTherapie", 1));
|
||||||
|
|
||||||
doAnswer(invocationOnMock -> {
|
doAnswer(invocationOnMock -> List.of(dummyDisease(42, diagnosisDate))).when(this.onkostarApi).getDiseasesByPatientId(anyInt());
|
||||||
var disease = new Disease(onkostarApi);
|
|
||||||
disease.setId(42);
|
|
||||||
return List.of(disease);
|
|
||||||
}).when(this.onkostarApi).getDiseasesByPatientId(anyInt());
|
|
||||||
|
|
||||||
doAnswer(invocationOnMock -> List.of(procedure)).when(onkostarApi).getProceduresForDiseaseByForm(anyInt(), anyString());
|
doAnswer(invocationOnMock -> List.of(procedure)).when(onkostarApi).getProceduresForDiseaseByForm(anyInt(), anyString());
|
||||||
|
|
||||||
systemtherapieAnalyzer.analyze(procedure, null);
|
systemtherapieAnalyzer.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);
|
||||||
@ -72,6 +85,9 @@ class SystemtherapieAnalyzerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldNotModifyEcogStatusIfNoCompletedSystemTherapy() throws Exception {
|
void shouldNotModifyEcogStatusIfNoCompletedSystemTherapy() throws Exception {
|
||||||
|
final var diagnosisDate = daysPassed(7);
|
||||||
|
final var procedureDate = daysPassed(1);
|
||||||
|
|
||||||
doAnswer(invocationOnMock -> List.of())
|
doAnswer(invocationOnMock -> List.of())
|
||||||
.when(systemtherapieService).ecogSatus(any(Patient.class));
|
.when(systemtherapieService).ecogSatus(any(Patient.class));
|
||||||
|
|
||||||
@ -80,13 +96,39 @@ class SystemtherapieAnalyzerTest {
|
|||||||
|
|
||||||
var procedure = new Procedure(onkostarApi);
|
var procedure = new Procedure(onkostarApi);
|
||||||
procedure.setId(1000);
|
procedure.setId(1000);
|
||||||
procedure.setStartDate(new Date());
|
procedure.setStartDate(procedureDate);
|
||||||
procedure.setEditState(ProcedureEditStateType.COMPLETED);
|
procedure.setEditState(ProcedureEditStateType.COMPLETED);
|
||||||
procedure.setPatientId(1);
|
procedure.setPatientId(1);
|
||||||
procedure.setPatient(patient);
|
procedure.setPatient(patient);
|
||||||
procedure.setValue("ECOGvorTherapie", new Item("ECOGvorTherapie", 1));
|
procedure.setValue("ECOGvorTherapie", new Item("ECOGvorTherapie", 1));
|
||||||
|
|
||||||
systemtherapieAnalyzer.analyze(procedure, null);
|
systemtherapieAnalyzer.analyze(procedure, dummyDisease(10, diagnosisDate));
|
||||||
|
|
||||||
|
verify(onkostarApi, times(0)).getProceduresForDiseaseByForm(anyInt(), anyString());
|
||||||
|
verify(onkostarApi, times(0)).saveProcedure(any(Procedure.class), anyBoolean());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldNotIncludeEcogStatusBeforeDiagnosisDate() throws Exception {
|
||||||
|
final var diagnosisDate = daysPassed(7);
|
||||||
|
final var ecogDate = daysPassed(28);
|
||||||
|
final var procedureDate = daysPassed(1);
|
||||||
|
|
||||||
|
doAnswer(invocationOnMock -> List.of(new SystemtherapieService.EcogStatusWithDate(ecogDate, "0")))
|
||||||
|
.when(systemtherapieService).ecogSatus(any(Patient.class));
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
|
systemtherapieAnalyzer.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());
|
||||||
|
Reference in New Issue
Block a user