From 14e9fcab1a400d04b21c2ea5cf3a3e02dd30f043 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Tue, 10 Oct 2023 12:21:27 +0200 Subject: [PATCH] Issue #54: Add common EcogService interface --- src/main/java/DNPM/analyzer/DNPMHelper.java | 3 +- .../DNPM/analyzer/SystemtherapieAnalyzer.java | 5 +- .../java/DNPM/dto/EcogStatusWithDate.java | 68 +++++++++++++++++++ .../DNPM/services/TherapieMitEcogService.java | 30 ++++++++ .../DefaultStrahlentherapieService.java | 1 + .../StrahlentherapieService.java | 64 +---------------- .../DefaultSystemtherapieService.java | 1 + .../systemtherapie/SystemtherapieService.java | 60 +--------------- .../analyzer/SystemtherapieAnalyzerTest.java | 5 +- 9 files changed, 112 insertions(+), 125 deletions(-) create mode 100644 src/main/java/DNPM/dto/EcogStatusWithDate.java create mode 100644 src/main/java/DNPM/services/TherapieMitEcogService.java diff --git a/src/main/java/DNPM/analyzer/DNPMHelper.java b/src/main/java/DNPM/analyzer/DNPMHelper.java index 376333e..bb21fa0 100644 --- a/src/main/java/DNPM/analyzer/DNPMHelper.java +++ b/src/main/java/DNPM/analyzer/DNPMHelper.java @@ -1,5 +1,6 @@ package DNPM.analyzer; +import DNPM.dto.EcogStatusWithDate; import DNPM.VerweisVon; import DNPM.security.DelegatingDataBasedPermissionEvaluator; import DNPM.security.IllegalSecuredObjectAccessException; @@ -237,7 +238,7 @@ public class DNPMHelper extends BackendService { } - public List getEcogStatus(final Map input) { + public List getEcogStatus(final Map input) { var pid = AnalyzerUtils.getRequiredId(input, "PatientId"); if (pid.isEmpty()) { logger.error("Kein Parameter 'PatientId' angegeben, gebe leere Liste zurück"); diff --git a/src/main/java/DNPM/analyzer/SystemtherapieAnalyzer.java b/src/main/java/DNPM/analyzer/SystemtherapieAnalyzer.java index f886f3d..e8936cf 100644 --- a/src/main/java/DNPM/analyzer/SystemtherapieAnalyzer.java +++ b/src/main/java/DNPM/analyzer/SystemtherapieAnalyzer.java @@ -1,5 +1,6 @@ package DNPM.analyzer; +import DNPM.dto.EcogStatusWithDate; import DNPM.services.systemtherapie.SystemtherapieService; import de.itc.onkostar.api.Disease; import de.itc.onkostar.api.IOnkostarApi; @@ -111,7 +112,7 @@ public class SystemtherapieAnalyzer extends Analyzer { }); } - private void updateExistingEcogVerlauf(Procedure p, List ecogFromCompleted, Item ufEcog) { + private void updateExistingEcogVerlauf(Procedure p, List ecogFromCompleted, Item ufEcog) { var shouldSave = false; var existingDates = ufEcog.>>getValue().stream() .map(v -> v.get("Datum")) @@ -136,7 +137,7 @@ public class SystemtherapieAnalyzer extends Analyzer { } } - private void newEcogverlauf(Procedure p, List ecogFromCompleted) { + private void newEcogverlauf(Procedure p, List ecogFromCompleted) { p.setValue("ECOGVerlauf", new Item("ECOGVerlauf", List.of())); for (var ecog : ecogFromCompleted) { var newSubProcedure = new Procedure(onkostarApi); diff --git a/src/main/java/DNPM/dto/EcogStatusWithDate.java b/src/main/java/DNPM/dto/EcogStatusWithDate.java new file mode 100644 index 0000000..d48a3ff --- /dev/null +++ b/src/main/java/DNPM/dto/EcogStatusWithDate.java @@ -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; + } +} diff --git a/src/main/java/DNPM/services/TherapieMitEcogService.java b/src/main/java/DNPM/services/TherapieMitEcogService.java new file mode 100644 index 0000000..e8cbae4 --- /dev/null +++ b/src/main/java/DNPM/services/TherapieMitEcogService.java @@ -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 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 ecogStatus(Patient patient); + +} diff --git a/src/main/java/DNPM/services/strahlentherapie/DefaultStrahlentherapieService.java b/src/main/java/DNPM/services/strahlentherapie/DefaultStrahlentherapieService.java index b899d56..a318a81 100644 --- a/src/main/java/DNPM/services/strahlentherapie/DefaultStrahlentherapieService.java +++ b/src/main/java/DNPM/services/strahlentherapie/DefaultStrahlentherapieService.java @@ -1,5 +1,6 @@ package DNPM.services.strahlentherapie; +import DNPM.dto.EcogStatusWithDate; import DNPM.services.SettingsService; import de.itc.onkostar.api.IOnkostarApi; import de.itc.onkostar.api.Patient; diff --git a/src/main/java/DNPM/services/strahlentherapie/StrahlentherapieService.java b/src/main/java/DNPM/services/strahlentherapie/StrahlentherapieService.java index f5cef46..a8de923 100644 --- a/src/main/java/DNPM/services/strahlentherapie/StrahlentherapieService.java +++ b/src/main/java/DNPM/services/strahlentherapie/StrahlentherapieService.java @@ -1,70 +1,10 @@ package DNPM.services.strahlentherapie; -import de.itc.onkostar.api.Patient; -import org.springframework.util.Assert; - -import java.util.Date; -import java.util.List; -import java.util.Optional; +import DNPM.services.TherapieMitEcogService; /** * Service für Systemtherapieformulare * * @since 0.6.0 */ -public interface StrahlentherapieService { - - /** - * 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 latestEcogStatus(Patient patient); - - /** - * Ermittelt jeden bekannten ECOG-Status aus allen Strahlentherapieformularen des Patienten - * @param patient Der zu verwendende Patient - * @return Eine Liste mit Datum und ECOG-Status als String - */ - List 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; - } - } - -} +public interface StrahlentherapieService extends TherapieMitEcogService {} diff --git a/src/main/java/DNPM/services/systemtherapie/DefaultSystemtherapieService.java b/src/main/java/DNPM/services/systemtherapie/DefaultSystemtherapieService.java index 4b9c1a2..578613f 100644 --- a/src/main/java/DNPM/services/systemtherapie/DefaultSystemtherapieService.java +++ b/src/main/java/DNPM/services/systemtherapie/DefaultSystemtherapieService.java @@ -1,5 +1,6 @@ package DNPM.services.systemtherapie; +import DNPM.dto.EcogStatusWithDate; import DNPM.services.SettingsService; import de.itc.onkostar.api.IOnkostarApi; import de.itc.onkostar.api.Patient; diff --git a/src/main/java/DNPM/services/systemtherapie/SystemtherapieService.java b/src/main/java/DNPM/services/systemtherapie/SystemtherapieService.java index ea26c0c..a7ac1bd 100644 --- a/src/main/java/DNPM/services/systemtherapie/SystemtherapieService.java +++ b/src/main/java/DNPM/services/systemtherapie/SystemtherapieService.java @@ -1,20 +1,17 @@ package DNPM.services.systemtherapie; -import de.itc.onkostar.api.Patient; +import DNPM.services.TherapieMitEcogService; import de.itc.onkostar.api.Procedure; -import org.springframework.util.Assert; -import java.util.Date; import java.util.List; import java.util.Map; -import java.util.Optional; /** * Service für Systemtherapieformulare * * @since 0.2.0 */ -public interface SystemtherapieService { +public interface SystemtherapieService extends TherapieMitEcogService { /** * Ermittelt eine Zusammenfassung der systemischen Therapien für eine Erkrankung * @param diseaseId Die ID der Erkrankung @@ -29,57 +26,4 @@ public interface SystemtherapieService { */ 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 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 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; - } - } - } diff --git a/src/test/java/DNPM/analyzer/SystemtherapieAnalyzerTest.java b/src/test/java/DNPM/analyzer/SystemtherapieAnalyzerTest.java index 1fa57c0..d500059 100644 --- a/src/test/java/DNPM/analyzer/SystemtherapieAnalyzerTest.java +++ b/src/test/java/DNPM/analyzer/SystemtherapieAnalyzerTest.java @@ -1,5 +1,6 @@ package DNPM.analyzer; +import DNPM.dto.EcogStatusWithDate; import DNPM.services.systemtherapie.SystemtherapieService; import de.itc.onkostar.api.*; import org.junit.jupiter.api.BeforeEach; @@ -54,7 +55,7 @@ class SystemtherapieAnalyzerTest { final var ecogDate = 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)); var patient = new Patient(onkostarApi); @@ -114,7 +115,7 @@ class SystemtherapieAnalyzerTest { final var ecogDate = daysPassed(28); 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)); var patient = new Patient(onkostarApi);