diff options
| author | Paul-Christian Volkmer | 2023-10-10 13:03:55 +0200 |
|---|---|---|
| committer | GitHub | 2023-10-10 13:03:55 +0200 |
| commit | 1b27a9c290c435d483226ae9a79e2f17fffe60ac (patch) | |
| tree | e3a562b059e0bbaac9c50f67372fa62d57012ca3 /src/main/java | |
| parent | c1ccac5c16d89579ca6876e28cd0a7259c1ec7b7 (diff) | |
| parent | 9c503d2244f61221fdf9716ded30f86aa758f957 (diff) | |
Merge pull request #57 from CCC-MF/issue_54
Übernahme des ECOG-Status aus anderen Therapieformularen
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/DNPM/analyzer/DNPMHelper.java | 3 | ||||
| -rw-r--r-- | src/main/java/DNPM/analyzer/TherapieMitEcogAnalyzer.java (renamed from src/main/java/DNPM/analyzer/SystemtherapieAnalyzer.java) | 35 | ||||
| -rw-r--r-- | src/main/java/DNPM/dto/EcogStatusWithDate.java | 68 | ||||
| -rw-r--r-- | src/main/java/DNPM/services/TherapieMitEcogService.java | 30 | ||||
| -rw-r--r-- | src/main/java/DNPM/services/strahlentherapie/DefaultStrahlentherapieService.java | 74 | ||||
| -rw-r--r-- | src/main/java/DNPM/services/strahlentherapie/StrahlentherapieService.java | 10 | ||||
| -rw-r--r-- | src/main/java/DNPM/services/systemtherapie/DefaultSystemtherapieService.java | 1 | ||||
| -rw-r--r-- | src/main/java/DNPM/services/systemtherapie/SystemtherapieService.java | 60 |
8 files changed, 211 insertions, 70 deletions
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<SystemtherapieService.EcogStatusWithDate> getEcogStatus(final Map<String, Object> input) { + public List<EcogStatusWithDate> getEcogStatus(final Map<String, Object> 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/TherapieMitEcogAnalyzer.java index f886f3d..46841e1 100644 --- a/src/main/java/DNPM/analyzer/SystemtherapieAnalyzer.java +++ b/src/main/java/DNPM/analyzer/TherapieMitEcogAnalyzer.java @@ -1,5 +1,7 @@ package DNPM.analyzer; +import DNPM.dto.EcogStatusWithDate; +import DNPM.services.strahlentherapie.StrahlentherapieService; import DNPM.services.systemtherapie.SystemtherapieService; import de.itc.onkostar.api.Disease; 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. * - * @since 0.4.0 + * @since 0.6.0 */ @Component -public class SystemtherapieAnalyzer extends Analyzer { +public class TherapieMitEcogAnalyzer extends Analyzer { private final Logger logger = LoggerFactory.getLogger(this.getClass()); private final IOnkostarApi onkostarApi; + private final StrahlentherapieService strahlentherapieService; private final SystemtherapieService systemtherapieService; - public SystemtherapieAnalyzer( + public TherapieMitEcogAnalyzer( final IOnkostarApi onkostarApi, + final StrahlentherapieService strahlentherapieService, final SystemtherapieService systemtherapieService ) { this.onkostarApi = onkostarApi; + this.strahlentherapieService = strahlentherapieService; this.systemtherapieService = systemtherapieService; } @Override 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 public boolean isRelevantForAnalyzer(Procedure procedure, Disease 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") ); } @@ -89,12 +96,18 @@ public class SystemtherapieAnalyzer extends Analyzer { return; } - var ecogFromCompleted = systemtherapieService.ecogStatus(procedure.getPatient()) + var ecog = strahlentherapieService.ecogStatus(procedure.getPatient()) .stream() .filter(ecogStatusWithDate -> ecogStatusWithDate.getDate().after(disease.getDiagnosisDate())) .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 return; } @@ -104,14 +117,14 @@ public class SystemtherapieAnalyzer extends Analyzer { .forEach(p -> { var ufEcog = p.getValue("ECOGVerlauf"); if (null != ufEcog && ufEcog.getValue() instanceof List) { - updateExistingEcogVerlauf(p, ecogFromCompleted, ufEcog); + updateExistingEcogVerlauf(p, ecog, ufEcog); } 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 existingDates = ufEcog.<List<Map<String, String>>>getValue().stream() .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())); 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<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); + +} diff --git a/src/main/java/DNPM/services/strahlentherapie/DefaultStrahlentherapieService.java b/src/main/java/DNPM/services/strahlentherapie/DefaultStrahlentherapieService.java new file mode 100644 index 0000000..a318a81 --- /dev/null +++ b/src/main/java/DNPM/services/strahlentherapie/DefaultStrahlentherapieService.java @@ -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"); + } +} diff --git a/src/main/java/DNPM/services/strahlentherapie/StrahlentherapieService.java b/src/main/java/DNPM/services/strahlentherapie/StrahlentherapieService.java new file mode 100644 index 0000000..a8de923 --- /dev/null +++ b/src/main/java/DNPM/services/strahlentherapie/StrahlentherapieService.java @@ -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 {} 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<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; - } - } - } |
