summaryrefslogtreecommitdiff
path: root/src/main/java/dev/dnpm/oshelper/services/therapieplan
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/dev/dnpm/oshelper/services/therapieplan')
-rw-r--r--src/main/java/dev/dnpm/oshelper/services/therapieplan/AbstractTherapieplanService.java66
-rw-r--r--src/main/java/dev/dnpm/oshelper/services/therapieplan/DefaultTherapieplanService.java220
-rw-r--r--src/main/java/dev/dnpm/oshelper/services/therapieplan/MultipleMtbTherapieplanService.java95
-rw-r--r--src/main/java/dev/dnpm/oshelper/services/therapieplan/TherapieplanService.java73
-rw-r--r--src/main/java/dev/dnpm/oshelper/services/therapieplan/TherapieplanServiceFactory.java57
5 files changed, 511 insertions, 0 deletions
diff --git a/src/main/java/dev/dnpm/oshelper/services/therapieplan/AbstractTherapieplanService.java b/src/main/java/dev/dnpm/oshelper/services/therapieplan/AbstractTherapieplanService.java
new file mode 100644
index 0000000..5d7825e
--- /dev/null
+++ b/src/main/java/dev/dnpm/oshelper/services/therapieplan/AbstractTherapieplanService.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.therapieplan;
+
+import dev.dnpm.oshelper.services.FormService;
+import de.itc.onkostar.api.IOnkostarApi;
+import de.itc.onkostar.api.Procedure;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+public abstract class AbstractTherapieplanService implements TherapieplanService {
+
+ protected final IOnkostarApi onkostarApi;
+
+ protected final FormService formService;
+
+ protected AbstractTherapieplanService(final IOnkostarApi onkostarApi, final FormService formService) {
+ this.onkostarApi = onkostarApi;
+ this.formService = formService;
+ }
+
+ @Override
+ public List<Procedure> findReferencedFollowUpsForSubform(Procedure procedure) {
+ if (null == procedure || !"DNPM UF Einzelempfehlung".equals(procedure.getFormName())) {
+ return List.of();
+ }
+
+ return procedure.getDiseaseIds().stream()
+ .flatMap(diseaseId -> onkostarApi.getProceduresForDiseaseByForm(diseaseId, "DNPM FollowUp").stream())
+ .filter(p -> p.getValue("LinkTherapieempfehlung").getInt() == procedure.getId())
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ public List<Procedure> findReferencedFollowUpsForSubform(int procedureId) {
+ var procedure = this.onkostarApi.getProcedure(procedureId);
+ if (null == procedure || !"DNPM UF Einzelempfehlung".equals(procedure.getFormName())) {
+ return List.of();
+ }
+ return findReferencedFollowUpsForSubform(procedure);
+ }
+
+}
diff --git a/src/main/java/dev/dnpm/oshelper/services/therapieplan/DefaultTherapieplanService.java b/src/main/java/dev/dnpm/oshelper/services/therapieplan/DefaultTherapieplanService.java
new file mode 100644
index 0000000..028b6c3
--- /dev/null
+++ b/src/main/java/dev/dnpm/oshelper/services/therapieplan/DefaultTherapieplanService.java
@@ -0,0 +1,220 @@
+/*
+ * 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.therapieplan;
+
+import dev.dnpm.oshelper.services.FormService;
+import de.itc.onkostar.api.IOnkostarApi;
+import de.itc.onkostar.api.Item;
+import de.itc.onkostar.api.Procedure;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+
+import static dev.dnpm.oshelper.services.FormService.hasValue;
+import static dev.dnpm.oshelper.services.FormService.isYes;
+
+public class DefaultTherapieplanService extends AbstractTherapieplanService {
+
+ public static final String FORMFIELD_REFERSTEMTB = "referstemtb";
+ public static final String FORMFIELD_HUMANGENBERATUNG = "humangenberatung";
+ public static final String FORMFIELD_REEVALUATION = "reevaluation";
+ public static final String FORMFIELD_DATUM = "datum";
+ public static final String FORMFIELD_REFTKHUMANGENBER = "reftkhumangenber";
+ public static final String FORMFIELD_DATUMTKHUMANGENBER = "datumtkhumangenber";
+ public static final String FORMFIELD_REFTKREEVALUATION = "reftkreevaluation";
+ public static final String FORMFIELD_DATUMTKREEVALUATION = "datumtkreevaluation";
+ public static final String FORMFIELD_MTB = "mtb";
+ public static final String FORMFIELD_UFEEDATUM = "ufeedatum";
+ public static final String FORMFIELD_REFTUMORKONFERENZ = "reftumorkonferenz";
+ public static final String FORMFIELD_UFRBDATUM = "ufrbdatum";
+
+ public static final String DATAFIELD_REF_TK_HUMANGENBER = "ref_tk_humangenber";
+ public static final String DATAFIELD_DATUM_TK_HUMANGENBER = "datum_tk_humangenber";
+ public static final String DATAFIELD_DATUM = "datum";
+
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ public DefaultTherapieplanService(final IOnkostarApi onkostarApi, final FormService formService) {
+ super(onkostarApi, formService);
+ }
+
+ /**
+ * Verlinke MTB und Übernahme Datum aus Hauptformular in weiteren Bereichen
+ * "Humangenetische Beratung" und "Reevaluation" und Unterformularen, wenn erforderlich.
+ *
+ * @param procedure Die Prozedur mit Hauptformular
+ */
+ @Override
+ public void updateRequiredMtbEntries(Procedure procedure) {
+ this.updateMtbInSections(procedure);
+ this.updateMtbInSubforms(procedure);
+ }
+
+ /**
+ * Finde verlinkte MTBs in Hauptformular und Unterformularen
+ *
+ * @param procedure Die Prozedur mit Hauptformular
+ * @return Liste mit verlinkten MTBs
+ */
+ @Override
+ public List<Procedure> findReferencedMtbs(Procedure procedure) {
+ if (!hasValue(procedure, FORMFIELD_REFERSTEMTB)) {
+ return List.of();
+ }
+
+ var mtbProcedure = this.onkostarApi.getProcedure(procedure.getValue(FORMFIELD_REFERSTEMTB).getInt());
+ if (null == mtbProcedure) {
+ return List.of();
+ }
+ return List.of(mtbProcedure);
+ }
+
+ /**
+ * Finde verlinkte MTBs in Hauptformular und Unterformularen
+ *
+ * @param procedureId ID der Prozedur mit Hauptformular
+ * @return Liste mit verlinkten MTBs
+ */
+ @Override
+ public List<Procedure> findReferencedMtbs(int procedureId) {
+ var procedure = this.onkostarApi.getProcedure(procedureId);
+ if (null == procedure) {
+ return List.of();
+ }
+ return findReferencedMtbs(procedure);
+ }
+
+ private void updateMtbInSections(Procedure procedure) {
+ if (!isYes(procedure, FORMFIELD_HUMANGENBERATUNG) && !isYes(procedure, FORMFIELD_REEVALUATION)) {
+ return;
+ }
+
+ var mtbReference = procedure.getValue(FORMFIELD_REFERSTEMTB).getInt();
+ var mtbDate = procedure.getValue(FORMFIELD_DATUM).getDate();
+ var noUpdateRequired = true;
+
+ if (
+ isYes(procedure, FORMFIELD_HUMANGENBERATUNG) && (
+ !hasValue(procedure, FORMFIELD_REFTKHUMANGENBER)
+ || mtbReference != procedure.getValue(FORMFIELD_REFTKHUMANGENBER).getInt()
+ )
+ ) {
+ procedure.setValue(FORMFIELD_REFTKHUMANGENBER, new Item(DATAFIELD_REF_TK_HUMANGENBER, mtbReference));
+ noUpdateRequired = false;
+ }
+
+ if (
+ isYes(procedure, FORMFIELD_HUMANGENBERATUNG) && (
+ !hasValue(procedure, FORMFIELD_DATUMTKHUMANGENBER)
+ || !mtbDate.equals(procedure.getValue(FORMFIELD_DATUMTKHUMANGENBER).getDate())
+ )
+ ) {
+ procedure.setValue(FORMFIELD_DATUMTKHUMANGENBER, new Item(DATAFIELD_DATUM_TK_HUMANGENBER, mtbDate));
+ noUpdateRequired = false;
+ }
+
+ if (
+ isYes(procedure, FORMFIELD_REEVALUATION) && (
+ !hasValue(procedure, FORMFIELD_REFTKREEVALUATION)
+ || mtbReference != procedure.getValue(FORMFIELD_REFTKREEVALUATION).getInt()
+ )
+ ) {
+ procedure.setValue(FORMFIELD_REFTKREEVALUATION, new Item("ref_tk_reevaluation", mtbReference));
+ noUpdateRequired = false;
+ }
+
+ if (
+ isYes(procedure, FORMFIELD_REEVALUATION) && (
+ !hasValue(procedure, FORMFIELD_DATUMTKREEVALUATION)
+ || !mtbDate.equals(procedure.getValue(FORMFIELD_DATUMTKREEVALUATION).getDate())
+ )
+ ) {
+ procedure.setValue(FORMFIELD_DATUMTKREEVALUATION, new Item("datum_tk_reevaluation", mtbDate));
+ noUpdateRequired = false;
+ }
+
+ if (noUpdateRequired) {
+ return;
+ }
+
+ try {
+ onkostarApi.saveProcedure(procedure, false);
+ } catch (Exception e) {
+ logger.error("Formular 'DNPM Therapieplan' konnte nicht aktualisiert werden", e);
+ }
+ }
+
+ private void updateMtbInSubforms(Procedure procedure) {
+ if (
+ !hasValue(procedure, FORMFIELD_REFERSTEMTB) || !hasValue(procedure, FORMFIELD_DATUM)
+ ) {
+ return;
+ }
+
+ var mtbReference = procedure.getValue(FORMFIELD_REFERSTEMTB).getInt();
+ var mtbDate = procedure.getValue(FORMFIELD_DATUM).getDate();
+
+ formService.getSubFormProcedureIds(procedure.getId()).stream()
+ .map(onkostarApi::getProcedure)
+ .filter(Objects::nonNull)
+ .forEach(subform -> {
+ if (isUsableEinzelempfehlung(subform, mtbReference, mtbDate)) {
+ subform.setValue(FORMFIELD_MTB, new Item("ref_tumorkonferenz", mtbReference));
+ subform.setValue(FORMFIELD_UFEEDATUM, new Item(DATAFIELD_DATUM, mtbDate));
+
+ try {
+ onkostarApi.saveProcedure(subform, false);
+ } catch (Exception e) {
+ logger.error("Formular 'DNPM UF Einzelempfehlung' konnte nicht aktualisiert werden", e);
+ }
+ }
+
+
+ if (isUsableRebiopsie(subform, mtbReference, mtbDate)) {
+ subform.setValue(FORMFIELD_REFTUMORKONFERENZ, new Item("ref_tumorkonferenz", mtbReference));
+ subform.setValue(FORMFIELD_UFRBDATUM, new Item(DATAFIELD_DATUM, mtbDate));
+
+ try {
+ onkostarApi.saveProcedure(subform, false);
+ } catch (Exception e) {
+ logger.error("Formular 'DNPM UF Rebiopsie' konnte nicht aktualisiert werden", e);
+ }
+ }
+
+ });
+ }
+
+ private static boolean isUsableRebiopsie(Procedure subform, int mtbReference, Date mtbDate) {
+ return subform.getFormName().equals("DNPM UF Rebiopsie") && mtbReference != subform.getValue(FORMFIELD_REFTUMORKONFERENZ).getInt() && !mtbDate.equals(subform.getValue(FORMFIELD_UFRBDATUM).getDate());
+ }
+
+ private static boolean isUsableEinzelempfehlung(Procedure subform, int mtbReference, Date mtbDate) {
+ return subform.getFormName().equals("DNPM UF Einzelempfehlung") && mtbReference != subform.getValue(FORMFIELD_MTB).getInt() && !mtbDate.equals(subform.getValue(FORMFIELD_UFEEDATUM).getDate());
+ }
+
+}
diff --git a/src/main/java/dev/dnpm/oshelper/services/therapieplan/MultipleMtbTherapieplanService.java b/src/main/java/dev/dnpm/oshelper/services/therapieplan/MultipleMtbTherapieplanService.java
new file mode 100644
index 0000000..78612de
--- /dev/null
+++ b/src/main/java/dev/dnpm/oshelper/services/therapieplan/MultipleMtbTherapieplanService.java
@@ -0,0 +1,95 @@
+/*
+ * 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.therapieplan;
+
+import dev.dnpm.oshelper.services.FormService;
+import de.itc.onkostar.api.IOnkostarApi;
+import de.itc.onkostar.api.Procedure;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import static dev.dnpm.oshelper.services.FormService.hasValue;
+import static dev.dnpm.oshelper.services.FormService.isYes;
+
+public class MultipleMtbTherapieplanService extends AbstractTherapieplanService {
+
+ public MultipleMtbTherapieplanService(final IOnkostarApi onkostarApi, final FormService formService) {
+ super(onkostarApi, formService);
+ }
+
+ @Override
+ public void updateRequiredMtbEntries(Procedure procedure) {
+ // No action required
+ }
+
+ @Override
+ public List<Procedure> findReferencedMtbs(Procedure procedure) {
+ var procedureIds = new ArrayList<Integer>();
+
+ var mtbReference = procedure.getValue("referstemtb").getInt();
+ procedureIds.add(mtbReference);
+
+ if (isYes(procedure, "humangenberatung") && hasValue(procedure, "reftkhumangenber")) {
+ procedureIds.add(procedure.getValue("reftkhumangenber").getInt());
+ }
+
+ if (isYes(procedure, "reevaluation") && hasValue(procedure, "reftkreevaluation")) {
+ procedureIds.add(procedure.getValue("reftkreevaluation").getInt());
+ }
+
+ formService.getSubFormProcedureIds(procedure.getId()).stream()
+ .map(onkostarApi::getProcedure)
+ .filter(Objects::nonNull)
+ .forEach(subform -> {
+ if (subform.getFormName().equals("DNPM UF Einzelempfehlung")) {
+ procedureIds.add(subform.getValue("mtb").getInt());
+ }
+
+ if (subform.getFormName().equals("DNPM UF Rebiopsie")) {
+ procedureIds.add(subform.getValue("reftumorkonferenz").getInt());
+ }
+ });
+
+ return procedureIds.stream()
+ .distinct()
+ .map(onkostarApi::getProcedure)
+ .filter(Objects::nonNull)
+ .sorted(Comparator.comparing(Procedure::getStartDate))
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ public List<Procedure> findReferencedMtbs(int procedureId) {
+ var procedure = this.onkostarApi.getProcedure(procedureId);
+ if (null == procedure) {
+ return List.of();
+ }
+ return findReferencedMtbs(procedure);
+ }
+}
diff --git a/src/main/java/dev/dnpm/oshelper/services/therapieplan/TherapieplanService.java b/src/main/java/dev/dnpm/oshelper/services/therapieplan/TherapieplanService.java
new file mode 100644
index 0000000..fecdd1d
--- /dev/null
+++ b/src/main/java/dev/dnpm/oshelper/services/therapieplan/TherapieplanService.java
@@ -0,0 +1,73 @@
+/*
+ * 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.therapieplan;
+
+import de.itc.onkostar.api.Procedure;
+
+import java.util.List;
+
+public interface TherapieplanService {
+
+ /**
+ * Verlinke MTB und Übernahme Datum aus Hauptformular in weiteren Bereichen
+ * "Humangenetische Beratung" und "Reevaluation" und Unterformularen, wenn erforderlich.
+ *
+ * @param procedure Die Prozedur mit Hauptformular
+ */
+ void updateRequiredMtbEntries(Procedure procedure);
+
+ /**
+ * Finde verlinkte MTBs in Hauptformular und Unterformularen
+ *
+ * @param procedure Die Prozedur mit Hauptformular
+ * @return Liste mit verlinkten MTBs
+ */
+ List<Procedure> findReferencedMtbs(Procedure procedure);
+
+ /**
+ * Finde verlinkte MTBs in Hauptformular und Unterformularen
+ *
+ * @param procedureId ID der Prozedur mit Hauptformular
+ * @return Liste mit verlinkten MTBs
+ */
+ List<Procedure> findReferencedMtbs(int procedureId);
+
+ /**
+ * Finde verlinkte FollowUps für DNPM UF Einzelempfehlung
+ *
+ * @param procedure Die DNPM UF Einzelempfehlung Prozedur
+ * @return Liste mit verlinkten FollowUps
+ */
+ List<Procedure> findReferencedFollowUpsForSubform(Procedure procedure);
+
+ /**
+ * Finde verlinkte FollowUps für DNPM UF Einzelempfehlung
+ *
+ * @param procedureId ID der Prozedur
+ * @return Liste mit verlinkten FollowUps
+ */
+ List<Procedure> findReferencedFollowUpsForSubform(int procedureId);
+
+}
diff --git a/src/main/java/dev/dnpm/oshelper/services/therapieplan/TherapieplanServiceFactory.java b/src/main/java/dev/dnpm/oshelper/services/therapieplan/TherapieplanServiceFactory.java
new file mode 100644
index 0000000..2edf3fb
--- /dev/null
+++ b/src/main/java/dev/dnpm/oshelper/services/therapieplan/TherapieplanServiceFactory.java
@@ -0,0 +1,57 @@
+/*
+ * 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.therapieplan;
+
+import dev.dnpm.oshelper.services.FormService;
+import dev.dnpm.oshelper.services.SettingsService;
+import de.itc.onkostar.api.IOnkostarApi;
+
+public class TherapieplanServiceFactory {
+
+ private final IOnkostarApi onkostarApi;
+
+ private final SettingsService settingsService;
+
+ private final FormService formService;
+
+ public TherapieplanServiceFactory(
+ final IOnkostarApi onkostarApi,
+ final SettingsService settingsService,
+ final FormService formService
+ ) {
+ this.onkostarApi = onkostarApi;
+ this.settingsService = settingsService;
+ this.formService = formService;
+ }
+
+ public TherapieplanService currentUsableInstance() {
+ if (settingsService.multipleMtbsInMtbEpisode()) {
+ return new MultipleMtbTherapieplanService(onkostarApi, formService);
+ }
+
+ return new DefaultTherapieplanService(onkostarApi, formService);
+ }
+
+}