summaryrefslogtreecommitdiff
path: root/src/main/java/dev/dnpm/oshelper/services/mtb
diff options
context:
space:
mode:
authorPaul-Christian Volkmer2025-10-23 11:08:10 +0200
committerPaul-Christian Volkmer2025-10-23 11:09:54 +0200
commit84fb0d829832bf1628112376bba729422b169402 (patch)
tree4828674b77105877dccfcccb380da3f7c0f75987 /src/main/java/dev/dnpm/oshelper/services/mtb
parent61e7dfcbe637f401f81ff853e9bd10c90b325acb (diff)
refactor: change package name
Diffstat (limited to 'src/main/java/dev/dnpm/oshelper/services/mtb')
-rw-r--r--src/main/java/dev/dnpm/oshelper/services/mtb/DefaultMtbService.java94
-rw-r--r--src/main/java/dev/dnpm/oshelper/services/mtb/MrMtbAnmeldungToProtocolMapper.java87
-rw-r--r--src/main/java/dev/dnpm/oshelper/services/mtb/MtbService.java55
-rw-r--r--src/main/java/dev/dnpm/oshelper/services/mtb/OsTumorkonferenzToProtocolMapper.java67
-rw-r--r--src/main/java/dev/dnpm/oshelper/services/mtb/OsTumorkonferenzVarianteUkwToProtocolMapper.java66
-rw-r--r--src/main/java/dev/dnpm/oshelper/services/mtb/ProcedureToProtocolMapper.java33
6 files changed, 402 insertions, 0 deletions
diff --git a/src/main/java/dev/dnpm/oshelper/services/mtb/DefaultMtbService.java b/src/main/java/dev/dnpm/oshelper/services/mtb/DefaultMtbService.java
new file mode 100644
index 0000000..99ee033
--- /dev/null
+++ b/src/main/java/dev/dnpm/oshelper/services/mtb/DefaultMtbService.java
@@ -0,0 +1,94 @@
+/*
+ * This file is part of onkostar-plugin-dnpm
+ *
+ * Copyright (c) 2025 the original author or authors.
+ *
+ * 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 dev.dnpm.oshelper.services.mtb;
+
+import de.itc.onkostar.api.IOnkostarApi;
+import de.itc.onkostar.api.Procedure;
+
+import java.util.Comparator;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * Standardimplementierung des MtbService
+ *
+ * @since 0.0.2
+ */
+public class DefaultMtbService implements MtbService {
+
+ private final IOnkostarApi onkostarApi;
+
+ public DefaultMtbService(final IOnkostarApi onkostarApi) {
+ this.onkostarApi = onkostarApi;
+ }
+
+ /**
+ * Zusammenfassung der Prozeduren.
+ * Dabei werden alle Prozeduren sortiert, mit ermitteltem Mapper in {@link Optional} eines {@link String}s
+ * gewandelt und, wenn dies erfolgreich war, die Zeichenkette extrahiert.
+ * Im Anschluss wird die Abfolge der Zeichenketten mit den einzelnen Prozedur-Zusammenfassungen in eine
+ * einzige Zusammenfassung zusammengefügt.
+ * @param procedures Prozeduren, die zusammen gefasst werden sollen
+ * @return Text mit Zusammenfassung aller übergebenen Prozeduren
+ */
+ @Override
+ public String getProtocol(List<Procedure> procedures) {
+ return this.sortedDistinctProcedureProtocolList(procedures.stream())
+ .collect(Collectors.joining("\n\n"));
+ }
+
+ private Stream<String> sortedDistinctProcedureProtocolList(Stream<Procedure> procedures) {
+ return procedures
+ .sorted(Comparator.comparing(Procedure::getStartDate))
+ .map(this::selectAndApplyMapper)
+ .filter(Optional::isPresent)
+ .map(Optional::get)
+ .distinct();
+ }
+
+ /**
+ * Übergibt anzuwendenden Mapper für eine Prozedur.
+ * Wurde keine Implementierung festgelegt, wird ein Mapper zurückgegeben, der eine
+ * Prozedur in ein leeres {@link Optional} zurück gibt, übergeben.
+ * @param procedure Prozedur, für die ein Mapper ermittelt werden soll
+ * @return Mapper für diese Prozedur
+ */
+ @Override
+ public ProcedureToProtocolMapper procedureToProtocolMapper(Procedure procedure) {
+ switch (procedure.getFormName()) {
+ case "OS.Tumorkonferenz":
+ return new OsTumorkonferenzToProtocolMapper();
+ case "OS.Tumorkonferenz.VarianteUKW":
+ return new OsTumorkonferenzVarianteUkwToProtocolMapper();
+ case "MR.MTB_Anmeldung":
+ return new MrMtbAnmeldungToProtocolMapper(this.onkostarApi);
+ default:
+ return p -> Optional.empty();
+ }
+ }
+
+}
diff --git a/src/main/java/dev/dnpm/oshelper/services/mtb/MrMtbAnmeldungToProtocolMapper.java b/src/main/java/dev/dnpm/oshelper/services/mtb/MrMtbAnmeldungToProtocolMapper.java
new file mode 100644
index 0000000..4224e45
--- /dev/null
+++ b/src/main/java/dev/dnpm/oshelper/services/mtb/MrMtbAnmeldungToProtocolMapper.java
@@ -0,0 +1,87 @@
+/*
+ * This file is part of onkostar-plugin-dnpm
+ *
+ * Copyright (c) 2025 the original author or authors.
+ *
+ * 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 dev.dnpm.oshelper.services.mtb;
+
+import de.itc.onkostar.api.IOnkostarApi;
+import de.itc.onkostar.api.Procedure;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Optional;
+
+public class MrMtbAnmeldungToProtocolMapper implements ProcedureToProtocolMapper {
+
+ private final IOnkostarApi onkostarApi;
+
+ public MrMtbAnmeldungToProtocolMapper(final IOnkostarApi onkostarApi) {
+ this.onkostarApi = onkostarApi;
+ }
+
+ /**
+ * Wandelt eine Prozedur mit Formularnamen "MR.MTB_Anmeldung" in ein {@link Optional} mit einer
+ * Zeichenkette oder im Fehlerfall in ein leeres Optional um.
+ *
+ * @param procedure Die Prozedur, für die eine Zusammenfassung ermittelt werden soll.
+ * @return Das {@link Optional} mit, im Erfolgsfall, der Zusammenfassung für die Prozedur.
+ */
+ @Override
+ public Optional<String> apply(Procedure procedure) {
+ if ((!procedure.getFormName().equals("MR.MTB_Anmeldung"))) {
+ throw new AssertionError("Procedure is not of form type 'MR.MTB_Anmeldung'");
+ }
+
+ var resultParts = new ArrayList<String>();
+
+ var fragestellung = procedure.getValue("Fragestellung");
+ if (null != fragestellung && !fragestellung.getString().isBlank()) {
+ resultParts.add(String.format("Fragestellung:%n%s", fragestellung.getString()));
+ }
+
+ var refEmpfehlung = procedure.getValue("Empfehlung");
+ if (null != refEmpfehlung && refEmpfehlung.getInt() > 0) {
+ var empfehlungsProzedur = onkostarApi.getProcedure(refEmpfehlung.getInt());
+ var refEinzelempfehlungen = onkostarApi.getSubprocedures(empfehlungsProzedur.getId());
+
+ if (null != refEinzelempfehlungen) {
+ refEinzelempfehlungen.stream()
+ .sorted(Comparator.comparingInt(proc -> proc.getValue("Prioritaet").getInt()))
+ .forEach(proc -> {
+ if (proc.getFormName().equals("MR.MTB_Einzelempfehlung")) {
+ var empfehlung = proc.getValue("Empfehlung");
+ if (null != empfehlung && !empfehlung.getString().isBlank()) {
+ resultParts.add(String.format("Empfehlung:%n%s", empfehlung.getString()));
+ }
+ }
+ });
+ }
+ }
+
+ if (resultParts.isEmpty()) {
+ return Optional.empty();
+ }
+
+ return Optional.of(String.join("\n\n", resultParts));
+ }
+}
diff --git a/src/main/java/dev/dnpm/oshelper/services/mtb/MtbService.java b/src/main/java/dev/dnpm/oshelper/services/mtb/MtbService.java
new file mode 100644
index 0000000..6886c53
--- /dev/null
+++ b/src/main/java/dev/dnpm/oshelper/services/mtb/MtbService.java
@@ -0,0 +1,55 @@
+/*
+ * This file is part of onkostar-plugin-dnpm
+ *
+ * Copyright (c) 2025 the original author or authors.
+ *
+ * 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 dev.dnpm.oshelper.services.mtb;
+
+import de.itc.onkostar.api.Procedure;
+
+import java.util.List;
+import java.util.Optional;
+
+public interface MtbService {
+ /**
+ * Zusammenfassung der Prozeduren
+ * @param procedures Prozeduren, die zusammen gefasst werden sollen
+ * @return Text mit Zusammenfassung der Prozeduren
+ */
+ String getProtocol(List<Procedure> procedures);
+
+ /**
+ * Übergibt anzuwendenden Mapper für eine Prozedur
+ * @param procedure Prozedur, für die ein Mapper ermittelt werden soll
+ * @return Mapper für diese Prozedur
+ */
+ ProcedureToProtocolMapper procedureToProtocolMapper(Procedure procedure);
+
+ /**
+ * Select mapper using method {@link #procedureToProtocolMapper(Procedure)} and apply procedure
+ * @param procedure The Procedure to select mapper for and apply
+ * @return {@link Optional} with protocol or empty {@link Optional}
+ */
+ default Optional<String> selectAndApplyMapper(Procedure procedure) {
+ return this.procedureToProtocolMapper(procedure).apply(procedure);
+ }
+}
diff --git a/src/main/java/dev/dnpm/oshelper/services/mtb/OsTumorkonferenzToProtocolMapper.java b/src/main/java/dev/dnpm/oshelper/services/mtb/OsTumorkonferenzToProtocolMapper.java
new file mode 100644
index 0000000..2c37431
--- /dev/null
+++ b/src/main/java/dev/dnpm/oshelper/services/mtb/OsTumorkonferenzToProtocolMapper.java
@@ -0,0 +1,67 @@
+/*
+ * This file is part of onkostar-plugin-dnpm
+ *
+ * Copyright (c) 2025 the original author or authors.
+ *
+ * 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 dev.dnpm.oshelper.services.mtb;
+
+import de.itc.onkostar.api.Procedure;
+
+import java.util.Optional;
+
+
+/**
+ * Mapper zum Ermitteln des Protokollauszugs für Formular "OS.Tumorkonferenz"
+ *
+ * @since 0.0.2
+ */
+public class OsTumorkonferenzToProtocolMapper implements ProcedureToProtocolMapper {
+
+ /**
+ * Wandelt eine Prozedur mit Formularnamen "OS.Tumorkonferenz" in ein {@link Optional} mit einer
+ * Zeichenkette oder im Fehlerfall in ein leeres Optional um.
+ * @param procedure Die Prozedur, für die eine Zusammenfassung ermittelt werden soll.
+ * @return Das {@link Optional} mit, im Erfolgsfall, der Zusammenfassung für die Prozedur.
+ */
+ @Override
+ public Optional<String> apply(Procedure procedure) {
+ if ((!procedure.getFormName().equals("OS.Tumorkonferenz"))) {
+ throw new AssertionError("Procedure is not of form type 'OS.Tumorkonferenz'");
+ }
+
+ var fragestellung = procedure.getValue("Fragestellung");
+ var empfehlung = procedure.getValue("Empfehlung");
+
+ if (
+ null != fragestellung && !fragestellung.getString().isBlank()
+ && null != empfehlung && !empfehlung.getString().isBlank()
+ ) {
+ return Optional.of(String.format("Fragestellung:%n%s%n%nEmpfehlung:%n%s", fragestellung.getString(), empfehlung.getString()));
+ } else if (null != fragestellung && !fragestellung.getString().isBlank()) {
+ return Optional.of(fragestellung.getString());
+ } else if (null != empfehlung && !empfehlung.getString().isBlank()) {
+ return Optional.of(empfehlung.getString());
+ }
+
+ return Optional.empty();
+ }
+}
diff --git a/src/main/java/dev/dnpm/oshelper/services/mtb/OsTumorkonferenzVarianteUkwToProtocolMapper.java b/src/main/java/dev/dnpm/oshelper/services/mtb/OsTumorkonferenzVarianteUkwToProtocolMapper.java
new file mode 100644
index 0000000..49a40aa
--- /dev/null
+++ b/src/main/java/dev/dnpm/oshelper/services/mtb/OsTumorkonferenzVarianteUkwToProtocolMapper.java
@@ -0,0 +1,66 @@
+/*
+ * This file is part of onkostar-plugin-dnpm
+ *
+ * Copyright (c) 2025 the original author or authors.
+ *
+ * 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 dev.dnpm.oshelper.services.mtb;
+
+import de.itc.onkostar.api.Procedure;
+
+import java.util.Optional;
+
+/**
+ * Mapper zum Ermitteln des Protokollauszugs für Formular "OS.Tumorkonferenz.VarianteUKW"
+ *
+ * @since 0.0.2
+ */
+public class OsTumorkonferenzVarianteUkwToProtocolMapper implements ProcedureToProtocolMapper {
+
+ /**
+ * Wandelt eine Prozedur mit Formularnamen "OS.Tumorkonferenz.VarianteUKW" in ein {@link Optional} mit einer
+ * Zeichenkette oder im Fehlerfall in ein leeres Optional um.
+ * @param procedure Die Prozedur, für die eine Zusammenfassung ermittelt werden soll.
+ * @return Das {@link Optional} mit, im Erfolgsfall, der Zusammenfassung für die Prozedur.
+ */
+ @Override
+ public Optional<String> apply(Procedure procedure) {
+ if ((!procedure.getFormName().equals("OS.Tumorkonferenz.VarianteUKW"))) {
+ throw new AssertionError("Procedure is not of form type 'OS.Tumorkonferenz.VarianteUKW'");
+ }
+
+
+ var fragestellung = procedure.getValue("Fragestellung");
+ var empfehlung = procedure.getValue("Empfehlung");
+
+ if (
+ null != fragestellung && !fragestellung.getString().isBlank()
+ && null != empfehlung && !empfehlung.getString().isBlank()
+ ) {
+ return Optional.of(String.format("Fragestellung:%n%s%n%nEmpfehlung:%n%s", fragestellung.getString().trim(), empfehlung.getString().trim()));
+ } else if (null != fragestellung && !fragestellung.getString().isBlank()) {
+ return Optional.of(fragestellung.getString().trim());
+ } else if (null != empfehlung && !empfehlung.getString().isBlank()) {
+ return Optional.of(empfehlung.getString().trim());
+ }
+ return Optional.empty();
+ }
+}
diff --git a/src/main/java/dev/dnpm/oshelper/services/mtb/ProcedureToProtocolMapper.java b/src/main/java/dev/dnpm/oshelper/services/mtb/ProcedureToProtocolMapper.java
new file mode 100644
index 0000000..2175ed6
--- /dev/null
+++ b/src/main/java/dev/dnpm/oshelper/services/mtb/ProcedureToProtocolMapper.java
@@ -0,0 +1,33 @@
+/*
+ * This file is part of onkostar-plugin-dnpm
+ *
+ * Copyright (c) 2025 the original author or authors.
+ *
+ * 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 dev.dnpm.oshelper.services.mtb;
+
+import de.itc.onkostar.api.Procedure;
+
+import java.util.Optional;
+import java.util.function.Function;
+
+@FunctionalInterface
+public interface ProcedureToProtocolMapper extends Function<Procedure, Optional<String>> {}