summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul-Christian Volkmer2026-09-04 08:14:28 +0200
committerGitHub2026-09-04 08:14:28 +0200
commitcdcdb21eca393b17ac5d075c5a002d30ccf038c5 (patch)
tree5d7ed46e6febfe9fd1c4150f702841b40986cbbd
parentfb91356b7777dfa5b6088bcc3a48b43924c1c0fd (diff)
refactor: remove deprecated ConsentManagerService (#294)
-rw-r--r--README.md53
-rw-r--r--src/main/java/dev/dnpm/oshelper/analyzer/ConsentManager.java17
-rw-r--r--src/main/java/dev/dnpm/oshelper/config/PluginConfiguration.java6
-rw-r--r--src/main/java/dev/dnpm/oshelper/services/consent/ConsentManagerService.java48
-rw-r--r--src/main/java/dev/dnpm/oshelper/services/consent/ConsentManagerServiceFactory.java45
-rw-r--r--src/main/java/dev/dnpm/oshelper/services/consent/MrConsentManagerService.java153
-rw-r--r--src/main/java/dev/dnpm/oshelper/services/consent/UkwConsentManagerService.java93
-rw-r--r--src/test/java/dev/dnpm/oshelper/ConsentManagerTest.java80
-rw-r--r--src/test/java/dev/dnpm/oshelper/config/PluginConfigurationTest.java7
-rw-r--r--src/test/java/dev/dnpm/oshelper/services/consent/ConsentManagerServiceFactoryTest.java65
-rw-r--r--src/test/java/dev/dnpm/oshelper/services/consent/MrConsentManagerServiceTest.java76
-rw-r--r--src/test/java/dev/dnpm/oshelper/services/consent/UkwConsentManagerServiceTest.java158
12 files changed, 2 insertions, 799 deletions
diff --git a/README.md b/README.md
index e34f95a..5be2dca 100644
--- a/README.md
+++ b/README.md
@@ -42,59 +42,6 @@ curl \
| sed '/^\s*$/d' | sed 's/\t\t/\t/g' | sed 's/^/2026\t/g' | sed '0,/2026/{s/2026/Version/}' > src/main/resources/atc.csv
```
-
-## DNPM-Consent (Veraltet)
-
-*Achtung!* Dieser Teil ist veraltet und wird durch den allgemeinen MV-Consent abgelöst.
-
-Das Plugin ist auf die Übernahme des DNPM-Consents ausgelegt. Hierzu muss die Einstellung `consentform` festgelegt werden.
-Diese Einstellung muss manuell in der Datenbank angelegt werden und kann danach in Onkostar verändert werden.
-
-```
-INSERT INTO einstellung (name, wert, kategorie, beschreibung)
-VALUES (
- 'consentform',
- 'MR.Consent',
- 'DNPM',
- 'Zu verwendendes Consent-Formular'
-);
-```
-
-Aktuell werden folgende Consent-Formulare unterstützt:
-
-* `MR.Consent`
-* `Excel-Formular` (UKW - beinhaltet Consent-Angaben)
-
-```mermaid
-classDiagram
-class ConsentManagerService {
-<<Interface>>
- + applyConsent(Procedure) void
- + canApply(Procedure) boolean
-}
-class ConsentManagerServiceFactory {
- + ConsentManagerServiceFactory(IOnkostarApi)
- + currentUsableInstance() ConsentManagerService
-}
-class MrConsentManagerService {
- + MrConsentManagerService(IOnkostarApi)
- + canApply(Procedure) boolean
- + applyConsent(Procedure) void
-}
-class UkwConsentManagerService {
- + UkwConsentManagerService(IOnkostarApi)
- + canApply(Procedure) boolean
- + applyConsent(Procedure) void
-}
-
-ConsentManagerServiceFactory ..> MrConsentManagerService : «create»
-ConsentManagerServiceFactory ..> UkwConsentManagerService : «create»
-MrConsentManagerService ..|> ConsentManagerService
-UkwConsentManagerService ..|> ConsentManagerService
-```
-
-Eine Übernahme von Consent-Daten aus unbekannten Formularen ist nur manuell möglich.
-
## Therapieplan
### Mehrere MTBs in Therapieplan (Veraltet - nicht mehr unterstützt!)
diff --git a/src/main/java/dev/dnpm/oshelper/analyzer/ConsentManager.java b/src/main/java/dev/dnpm/oshelper/analyzer/ConsentManager.java
index 924e726..946c5e0 100644
--- a/src/main/java/dev/dnpm/oshelper/analyzer/ConsentManager.java
+++ b/src/main/java/dev/dnpm/oshelper/analyzer/ConsentManager.java
@@ -23,7 +23,6 @@ import de.itc.onkostar.api.Disease;
import de.itc.onkostar.api.IOnkostarApi;
import de.itc.onkostar.api.Procedure;
import de.itc.onkostar.api.analysis.AnalyzerRequirement;
-import dev.dnpm.oshelper.services.consent.ConsentManagerServiceFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,13 +32,8 @@ public class ConsentManager extends Analyzer {
private final IOnkostarApi onkostarApi;
- private final ConsentManagerServiceFactory consentManagerServiceFactory;
-
- public ConsentManager(
- final IOnkostarApi onkostarApi,
- final ConsentManagerServiceFactory consentManagerServiceFactory) {
+ public ConsentManager(final IOnkostarApi onkostarApi) {
this.onkostarApi = onkostarApi;
- this.consentManagerServiceFactory = consentManagerServiceFactory;
}
@Override
@@ -70,13 +64,6 @@ public class ConsentManager extends Analyzer {
@Override
public void analyze(Procedure prozedur, Disease erkrankung) {
- var consentManagerService = consentManagerServiceFactory.currentUsableInstance();
- if (!consentManagerService.canApply(prozedur)) {
- logger.error(
- "Fehler im ConsentManagement: Kann Prozedur mit Formularnamen '{}' nicht anwenden",
- prozedur.getFormName());
- return;
- }
- consentManagerService.applyConsent(prozedur);
+ // Left for removal
}
}
diff --git a/src/main/java/dev/dnpm/oshelper/config/PluginConfiguration.java b/src/main/java/dev/dnpm/oshelper/config/PluginConfiguration.java
index 3e2ea44..5fc80d0 100644
--- a/src/main/java/dev/dnpm/oshelper/config/PluginConfiguration.java
+++ b/src/main/java/dev/dnpm/oshelper/config/PluginConfiguration.java
@@ -25,7 +25,6 @@ import dev.dnpm.oshelper.atc.services.CsvAgentCodeService;
import dev.dnpm.oshelper.atc.services.OnkostarAgentCodeService;
import dev.dnpm.oshelper.database.SettingsRepository;
import dev.dnpm.oshelper.services.*;
-import dev.dnpm.oshelper.services.consent.ConsentManagerServiceFactory;
import dev.dnpm.oshelper.services.molekulargenetik.MolekulargenetikFormService;
import dev.dnpm.oshelper.services.molekulargenetik.OsMolekulargenetikFormService;
import dev.dnpm.oshelper.services.strahlentherapie.DefaultStrahlentherapieService;
@@ -77,11 +76,6 @@ public class PluginConfiguration {
}
@Bean
- public ConsentManagerServiceFactory consentManagerServiceFactory(final IOnkostarApi onkostarApi) {
- return new ConsentManagerServiceFactory(onkostarApi);
- }
-
- @Bean
public TherapieplanServiceFactory therapieplanServiceFactory(
final IOnkostarApi onkostarApi,
final SettingsService settingsService,
diff --git a/src/main/java/dev/dnpm/oshelper/services/consent/ConsentManagerService.java b/src/main/java/dev/dnpm/oshelper/services/consent/ConsentManagerService.java
deleted file mode 100644
index edfeddd..0000000
--- a/src/main/java/dev/dnpm/oshelper/services/consent/ConsentManagerService.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * This file is part of onkostar-plugin-dnpm
- *
- * Copyright (C) 2023-2026 the original author or authors.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package dev.dnpm.oshelper.services.consent;
-
-import de.itc.onkostar.api.Procedure;
-
-/**
- * Schnittstelle für die Anwendung von Consent-Änderungen
- *
- * @since 0.2.0
- */
-@Deprecated(forRemoval = true, since = "2.0.0")
-public interface ConsentManagerService {
-
- /**
- * Wende Consent an, wenn dieses Consent-Formular gespeichert wird
- *
- * @param procedure Prozedur des Consent-Formulars
- */
- void applyConsent(Procedure procedure);
-
- /**
- * Optionale Prüfung, ob die angegebene Prozedur angewendet werden kann.
- *
- * @param procedure Anzuwendende Prozedur
- * @return Gibt <code>true</code> zurück, wenn die Prozedur angewendet werden kann.
- */
- default boolean canApply(Procedure procedure) {
- return null != procedure;
- }
-}
diff --git a/src/main/java/dev/dnpm/oshelper/services/consent/ConsentManagerServiceFactory.java b/src/main/java/dev/dnpm/oshelper/services/consent/ConsentManagerServiceFactory.java
deleted file mode 100644
index 81d864b..0000000
--- a/src/main/java/dev/dnpm/oshelper/services/consent/ConsentManagerServiceFactory.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * This file is part of onkostar-plugin-dnpm
- *
- * Copyright (C) 2023-2026 the original author or authors.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package dev.dnpm.oshelper.services.consent;
-
-import de.itc.onkostar.api.IOnkostarApi;
-
-@Deprecated(forRemoval = true, since = "2.0.0")
-public class ConsentManagerServiceFactory {
-
- private final IOnkostarApi onkostarApi;
-
- public ConsentManagerServiceFactory(final IOnkostarApi onkostarApi) {
- this.onkostarApi = onkostarApi;
- }
-
- public ConsentManagerService currentUsableInstance() {
- var consentFormName = onkostarApi.getGlobalSetting("consentform");
-
- switch (consentFormName) {
- case "Excel-Formular":
- return new UkwConsentManagerService(this.onkostarApi);
- case "MR.Consent":
- return new MrConsentManagerService(this.onkostarApi);
- default:
- return procedure -> {};
- }
- }
-}
diff --git a/src/main/java/dev/dnpm/oshelper/services/consent/MrConsentManagerService.java b/src/main/java/dev/dnpm/oshelper/services/consent/MrConsentManagerService.java
deleted file mode 100644
index c01568a..0000000
--- a/src/main/java/dev/dnpm/oshelper/services/consent/MrConsentManagerService.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * This file is part of onkostar-plugin-dnpm
- *
- * Copyright (C) 2023-2026 the original author or authors.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package dev.dnpm.oshelper.services.consent;
-
-import de.itc.onkostar.api.IOnkostarApi;
-import de.itc.onkostar.api.Item;
-import de.itc.onkostar.api.Procedure;
-import dev.dnpm.oshelper.VerweisVon;
-import java.util.List;
-import java.util.Map;
-import org.hibernate.SQLQuery;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.transform.Transformers;
-import org.hibernate.type.StandardBasicTypes;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Detailimplementierung für das Formular `MR.Consent`
- *
- * @since 0.2.0
- */
-@Deprecated(forRemoval = true, since = "2.0.0")
-public class MrConsentManagerService implements ConsentManagerService {
-
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- private final IOnkostarApi onkostarApi;
-
- public MrConsentManagerService(final IOnkostarApi onkostarApi) {
- this.onkostarApi = onkostarApi;
- }
-
- @Override
- public boolean canApply(Procedure procedure) {
- return null != procedure && procedure.getFormName().equals("MR.Consent");
- }
-
- /**
- * Wende Consent an, wenn dieses Consent-Formular gespeichert wird
- *
- * @param procedure Prozedur des Consent-Formulars
- */
- @Override
- public void applyConsent(Procedure procedure) {
- int value = 0;
- try {
- SessionFactory sessionFactory = onkostarApi.getSessionFactory();
- Session session = sessionFactory.getCurrentSession();
- // geänderte Werte checken
- String sql1 =
- "select id, max(timestamp) AS datum from aenderungsprotokoll where entity_id = '"
- + procedure.getId()
- + "'";
- SQLQuery query1 =
- session
- .createSQLQuery(sql1)
- .addScalar("id", StandardBasicTypes.INTEGER)
- .addScalar("datum", StandardBasicTypes.TIMESTAMP);
- logger.info("Wert-Check: {}", query1.uniqueResult());
-
- String sql =
- "SELECT prozedur.id AS procedure_id, prozedur.data_form_id, data_catalogue.name AS data_catalogue, data_catalogue_entry.name AS data_catalogue_entry, data_form.description AS formname, prozedur.beginndatum AS datum "
- + "FROM prozedur "
- + "LEFT JOIN data_form_data_catalogue ON data_form_data_catalogue.data_form_id = prozedur.data_form_id "
- + "LEFT JOIN data_catalogue_entry ON data_catalogue_entry.data_catalogue_id = data_form_data_catalogue.data_catalogue_id "
- + "LEFT JOIN data_catalogue ON data_catalogue.id = data_catalogue_entry.data_catalogue_id "
- + "LEFT JOIN data_form ON data_form.id = prozedur.data_form_id "
- + "WHERE patient_id = "
- + procedure.getPatientId()
- + " "
- + "AND geloescht = 0 "
- + "AND data_catalogue_entry.type = 'formReference' "
- + "GROUP BY prozedur.id, prozedur.data_form_id, data_catalogue.name, data_catalogue_entry.name";
-
- SQLQuery query =
- session
- .createSQLQuery(sql)
- .addScalar("procedure_id", StandardBasicTypes.INTEGER)
- .addScalar("data_form_id", StandardBasicTypes.INTEGER)
- .addScalar("data_catalogue", StandardBasicTypes.STRING)
- .addScalar("data_catalogue_entry", StandardBasicTypes.STRING)
- .addScalar("formname", StandardBasicTypes.STRING)
- .addScalar("datum", StandardBasicTypes.DATE);
-
- query.setResultTransformer(Transformers.aliasToBean(VerweisVon.class));
-
- @SuppressWarnings("unchecked")
- List<VerweisVon> result = query.list();
-
- for (VerweisVon verweisVon : result) {
- sql = verweisVon.getSQL();
- query = session.createSQLQuery(sql).addScalar("value", StandardBasicTypes.INTEGER);
- if (query.uniqueResult() != null) {
- value = (Integer) query.uniqueResult();
- }
- if (value == procedure.getId()) {
- saveReferencedProcedure(procedure, verweisVon);
- value = 0;
- }
- }
- } catch (RuntimeException e) {
- logger.error("Sonstiger Fehler bei der Ausführung von analyze()", e);
- }
- }
-
- private void saveReferencedProcedure(Procedure prozedur, VerweisVon verweisVon) {
- Procedure andereprozedur = onkostarApi.getProcedure(verweisVon.getProcedure_id());
- try {
- Map<String, Item> felder = prozedur.getAllValues();
- for (Map.Entry<String, Item> feld : felder.entrySet()) {
- if (feld.getKey().startsWith("Consent")) {
- if (feld.getKey().equals("ConsentStatusEinwilligungDNPM")) {
- switch (feld.getValue().getValue().toString()) {
- case "z":
- andereprozedur.setValue(feld.getKey(), new Item(feld.getKey(), "active"));
- break;
- case "a":
- case "w":
- andereprozedur.setValue(feld.getKey(), new Item(feld.getKey(), "rejected"));
- break;
- default:
- break;
- }
- } else {
- andereprozedur.setValue(feld.getKey(), prozedur.getValue(feld.getKey()));
- }
- }
- }
- onkostarApi.saveProcedure(andereprozedur);
- } catch (Exception e) {
- logger.error("Kann Prozedur nicht speichern", e);
- }
- }
-}
diff --git a/src/main/java/dev/dnpm/oshelper/services/consent/UkwConsentManagerService.java b/src/main/java/dev/dnpm/oshelper/services/consent/UkwConsentManagerService.java
deleted file mode 100644
index 32f7219..0000000
--- a/src/main/java/dev/dnpm/oshelper/services/consent/UkwConsentManagerService.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * This file is part of onkostar-plugin-dnpm
- *
- * Copyright (C) 2023-2026 the original author or authors.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package dev.dnpm.oshelper.services.consent;
-
-import de.itc.onkostar.api.IOnkostarApi;
-import de.itc.onkostar.api.Item;
-import de.itc.onkostar.api.Procedure;
-import java.util.Comparator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Detailimplementierung für das Formular `Excel-Formular`
- *
- * @since 0.2.0
- */
-@Deprecated(forRemoval = true, since = "2.0.0")
-public class UkwConsentManagerService implements ConsentManagerService {
-
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- private final IOnkostarApi onkostarApi;
-
- public UkwConsentManagerService(final IOnkostarApi onkostarApi) {
- this.onkostarApi = onkostarApi;
- }
-
- @Override
- public boolean canApply(Procedure procedure) {
- return null != procedure && procedure.getFormName().equals("Excel-Formular");
- }
-
- /**
- * Wende Consent an, wenn dieses Consent-Formular gespeichert wird
- *
- * @param procedure Prozedur des Consent-Formulars
- */
- @Override
- public void applyConsent(Procedure procedure) {
- var refdnpmklinikanamnese = procedure.getValue("refdnpmklinikanamnese").getInt();
- var dnpmKlinikAnamnese = this.onkostarApi.getProcedure(refdnpmklinikanamnese);
-
- if (null == dnpmKlinikAnamnese) {
- return;
- }
-
- var consents = procedure.getSubProceduresMap().get("ufdnpmconsent");
-
- if (null == consents) {
- return;
- }
-
- consents.stream()
- .max(Comparator.comparing(Procedure::getStartDate))
- .ifPresent(
- lastConsent -> {
- var date = lastConsent.getStartDate();
- var status = lastConsent.getValue("status");
- if (null == date || null == status || status.getString().isBlank()) {
- logger.warn("Kein DNPM-Einwilligungstatus angegeben");
- return;
- }
-
- dnpmKlinikAnamnese.setValue(
- "ConsentStatusEinwilligungDNPM", new Item("Einwilligung", status.getString()));
- dnpmKlinikAnamnese.setValue(
- "ConsentDatumEinwilligungDNPM", new Item("DatumEinwilligung", date));
-
- try {
- onkostarApi.saveProcedure(dnpmKlinikAnamnese, false);
- } catch (Exception e) {
- logger.error("Kann DNPM-Einwilligungstatus nicht aktualisieren", e);
- }
- });
- }
-}
diff --git a/src/test/java/dev/dnpm/oshelper/ConsentManagerTest.java b/src/test/java/dev/dnpm/oshelper/ConsentManagerTest.java
deleted file mode 100644
index 80e7298..0000000
--- a/src/test/java/dev/dnpm/oshelper/ConsentManagerTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * This file is part of onkostar-plugin-dnpm
- *
- * Copyright (C) 2023-2026 the original author or authors.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package dev.dnpm.oshelper;
-
-import static org.mockito.Mockito.*;
-
-import de.itc.onkostar.api.IOnkostarApi;
-import de.itc.onkostar.api.Procedure;
-import dev.dnpm.oshelper.analyzer.ConsentManager;
-import dev.dnpm.oshelper.services.consent.ConsentManagerServiceFactory;
-import dev.dnpm.oshelper.services.consent.MrConsentManagerService;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-
-@ExtendWith(MockitoExtension.class)
-class ConsentManagerTest {
-
- private IOnkostarApi onkostarApi;
-
- private ConsentManagerServiceFactory consentManagerServiceFactory;
-
- private ConsentManager consentManager;
-
- @BeforeEach
- void setup(
- @Mock IOnkostarApi onkostarApi,
- @Mock ConsentManagerServiceFactory consentManagerServiceFactory) {
- this.onkostarApi = onkostarApi;
- this.consentManagerServiceFactory = consentManagerServiceFactory;
- this.consentManager = new ConsentManager(onkostarApi, consentManagerServiceFactory);
- }
-
- @Test
- void shouldRunServiceMethodsOnAnalyzeCalled() {
- var consentManagerServiceMock = mock(MrConsentManagerService.class);
-
- when(consentManagerServiceMock.canApply(any(Procedure.class))).thenReturn(true);
-
- when(this.consentManagerServiceFactory.currentUsableInstance())
- .thenReturn(consentManagerServiceMock);
-
- this.consentManager.analyze(new Procedure(onkostarApi), null);
-
- verify(consentManagerServiceMock, times(1)).applyConsent(any(Procedure.class));
- }
-
- @Test
- void shouldNotRunServiceMethodsIfProcedureCannotBeAppliesForForm() {
- var consentManagerServiceMock = mock(MrConsentManagerService.class);
-
- when(consentManagerServiceMock.canApply(any(Procedure.class))).thenReturn(false);
-
- when(this.consentManagerServiceFactory.currentUsableInstance())
- .thenReturn(consentManagerServiceMock);
-
- this.consentManager.analyze(new Procedure(onkostarApi), null);
-
- verify(consentManagerServiceMock, times(0)).applyConsent(any(Procedure.class));
- }
-}
diff --git a/src/test/java/dev/dnpm/oshelper/config/PluginConfigurationTest.java b/src/test/java/dev/dnpm/oshelper/config/PluginConfigurationTest.java
index 42583ca..bb483f1 100644
--- a/src/test/java/dev/dnpm/oshelper/config/PluginConfigurationTest.java
+++ b/src/test/java/dev/dnpm/oshelper/config/PluginConfigurationTest.java
@@ -24,7 +24,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import de.itc.onkostar.api.IOnkostarApi;
import dev.dnpm.oshelper.services.FormService;
import dev.dnpm.oshelper.services.SettingsService;
-import dev.dnpm.oshelper.services.consent.ConsentManagerServiceFactory;
import dev.dnpm.oshelper.services.therapieplan.TherapieplanServiceFactory;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -49,12 +48,6 @@ class PluginConfigurationTest {
}
@Test
- void testShouldReturnConsentManagerServiceFactory() {
- var actual = this.configuration.consentManagerServiceFactory(onkostarApi);
- assertThat(actual).isInstanceOf(ConsentManagerServiceFactory.class);
- }
-
- @Test
void testShouldReturnTherapieplanServiceFactory() {
var actual =
this.configuration.therapieplanServiceFactory(onkostarApi, settingsService, formService);
diff --git a/src/test/java/dev/dnpm/oshelper/services/consent/ConsentManagerServiceFactoryTest.java b/src/test/java/dev/dnpm/oshelper/services/consent/ConsentManagerServiceFactoryTest.java
deleted file mode 100644
index 7d086de..0000000
--- a/src/test/java/dev/dnpm/oshelper/services/consent/ConsentManagerServiceFactoryTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * This file is part of onkostar-plugin-dnpm
- *
- * Copyright (C) 2023-2026 the original author or authors.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package dev.dnpm.oshelper.services.consent;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.when;
-
-import de.itc.onkostar.api.IOnkostarApi;
-import java.util.Map;
-import java.util.Set;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.MethodSource;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-
-@ExtendWith(MockitoExtension.class)
-class ConsentManagerServiceFactoryTest {
-
- private IOnkostarApi onkostarApi;
-
- private ConsentManagerServiceFactory consentManagerServiceFactory;
-
- @BeforeEach
- void setup(@Mock IOnkostarApi onkostarApi) {
- this.onkostarApi = onkostarApi;
- this.consentManagerServiceFactory = new ConsentManagerServiceFactory(onkostarApi);
- }
-
- private static Set<Map.Entry<String, Class<? extends ConsentManagerService>>> expectedMappings() {
- return Map.ofEntries(
- Map.entry("MR.Consent", MrConsentManagerService.class),
- Map.entry("Excel-Formular", UkwConsentManagerService.class))
- .entrySet();
- }
-
- @ParameterizedTest
- @MethodSource("expectedMappings")
- void testShouldMapFormNameToService(Map.Entry<String, Class<?>> expectedMapping) {
- when(onkostarApi.getGlobalSetting(anyString())).thenReturn(expectedMapping.getKey());
-
- var actual = consentManagerServiceFactory.currentUsableInstance();
-
- assertThat(actual).isExactlyInstanceOf(expectedMapping.getValue());
- }
-}
diff --git a/src/test/java/dev/dnpm/oshelper/services/consent/MrConsentManagerServiceTest.java b/src/test/java/dev/dnpm/oshelper/services/consent/MrConsentManagerServiceTest.java
deleted file mode 100644
index b747987..0000000
--- a/src/test/java/dev/dnpm/oshelper/services/consent/MrConsentManagerServiceTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * This file is part of onkostar-plugin-dnpm
- *
- * Copyright (C) 2023-2026 the original author or authors.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package dev.dnpm.oshelper.services.consent;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.*;
-
-import de.itc.onkostar.api.IOnkostarApi;
-import de.itc.onkostar.api.Procedure;
-import org.hibernate.SQLQuery;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.type.Type;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-
-@ExtendWith(MockitoExtension.class)
-class MrConsentManagerServiceTest {
-
- private IOnkostarApi onkostarApi;
-
- private MrConsentManagerService service;
-
- @BeforeEach
- void setup(@Mock IOnkostarApi onkostarApi) {
- this.onkostarApi = onkostarApi;
- this.service = new MrConsentManagerService(onkostarApi);
- }
-
- @Test
- void testShouldCreateSqlQueriesWithRelatedEntityIds() {
- var sessionFactory = mock(SessionFactory.class);
- var session = mock(Session.class);
- var query = mock(SQLQuery.class);
-
- when(onkostarApi.getSessionFactory()).thenReturn(sessionFactory);
- when(sessionFactory.getCurrentSession()).thenReturn(session);
- when(session.createSQLQuery(anyString())).thenReturn(query);
- when(query.addScalar(anyString(), any(Type.class))).thenReturn(query);
- when(query.uniqueResult()).thenReturn("");
-
- var dummyProzedur = new Procedure(this.onkostarApi);
- dummyProzedur.setId(111);
- dummyProzedur.setPatientId(123);
-
- this.service.applyConsent(dummyProzedur);
-
- var argumentCaptor = ArgumentCaptor.forClass(String.class);
- verify(session, times(2)).createSQLQuery(argumentCaptor.capture());
- assertThat(argumentCaptor.getAllValues()).hasSize(2);
- assertThat(argumentCaptor.getAllValues().get(0)).contains("where entity_id = '111'");
- assertThat(argumentCaptor.getAllValues().get(1))
- .contains("WHERE patient_id = 123 AND geloescht = 0");
- }
-}
diff --git a/src/test/java/dev/dnpm/oshelper/services/consent/UkwConsentManagerServiceTest.java b/src/test/java/dev/dnpm/oshelper/services/consent/UkwConsentManagerServiceTest.java
deleted file mode 100644
index e28dd64..0000000
--- a/src/test/java/dev/dnpm/oshelper/services/consent/UkwConsentManagerServiceTest.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * This file is part of onkostar-plugin-dnpm
- *
- * Copyright (C) 2023-2026 the original author or authors.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package dev.dnpm.oshelper.services.consent;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.*;
-
-import de.itc.onkostar.api.IOnkostarApi;
-import de.itc.onkostar.api.Item;
-import de.itc.onkostar.api.Procedure;
-import java.sql.Date;
-import java.time.Instant;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-
-@ExtendWith(MockitoExtension.class)
-class UkwConsentManagerServiceTest {
-
- private IOnkostarApi onkostarApi;
-
- private UkwConsentManagerService service;
-
- @BeforeEach
- void setup(@Mock IOnkostarApi onkostarApi) {
- this.onkostarApi = onkostarApi;
- this.service = new UkwConsentManagerService(onkostarApi);
- }
-
- @Test
- void testShouldSkipUpdateRelatedDnpmKlinikAnamneseFormIfNoConsentAvailable() throws Exception {
-
- var excelForm = new Procedure(this.onkostarApi);
- excelForm.setId(111);
- excelForm.setPatientId(123);
- excelForm.setValue("refdnpmklinikanamnese", new Item("refdnpmklinikanamnese", 2));
-
- var dnpmKlinikAnamneseForm = new Procedure(this.onkostarApi);
- dnpmKlinikAnamneseForm.setId(2);
- dnpmKlinikAnamneseForm.setPatientId(123);
-
- when(onkostarApi.getProcedure(anyInt())).thenReturn(dnpmKlinikAnamneseForm);
-
- this.service.applyConsent(excelForm);
-
- verify(onkostarApi, times(0)).saveProcedure(any(Procedure.class), anyBoolean());
- }
-
- @Test
- void testShouldSkipUpdateRelatedDnpmKlinikAnamneseFormIfNoConsentDateAvailable()
- throws Exception {
-
- var consentSubForm = new Procedure(this.onkostarApi);
- consentSubForm.setId(1);
- consentSubForm.setPatientId(123);
- consentSubForm.setValue("status", new Item("status", "accepted"));
-
- var excelForm = new Procedure(this.onkostarApi);
- excelForm.setId(111);
- excelForm.setPatientId(123);
- excelForm.setValue("refdnpmklinikanamnese", new Item("refdnpmklinikanamnese", 2));
- excelForm.addSubProcedure("ufdnpmconsent", consentSubForm);
-
- var dnpmKlinikAnamneseForm = new Procedure(this.onkostarApi);
- dnpmKlinikAnamneseForm.setId(2);
- dnpmKlinikAnamneseForm.setPatientId(123);
-
- when(onkostarApi.getProcedure(anyInt())).thenReturn(dnpmKlinikAnamneseForm);
-
- this.service.applyConsent(excelForm);
-
- verify(onkostarApi, times(0)).saveProcedure(any(Procedure.class), anyBoolean());
- }
-
- @Test
- void testShouldSkipUpdateRelatedDnpmKlinikAnamneseFormIfNoConsentValueAvailable()
- throws Exception {
-
- var consentSubForm = new Procedure(this.onkostarApi);
- consentSubForm.setId(1);
- consentSubForm.setPatientId(123);
- consentSubForm.setStartDate(Date.from(Instant.parse("2023-04-03T12:00:00Z")));
- consentSubForm.setValue(
- "datum", new Item("datum", Date.from(Instant.parse("2023-04-03T12:00:00Z"))));
-
- var excelForm = new Procedure(this.onkostarApi);
- excelForm.setId(111);
- excelForm.setPatientId(123);
- excelForm.setValue("refdnpmklinikanamnese", new Item("refdnpmklinikanamnese", 2));
- excelForm.addSubProcedure("ufdnpmconsent", consentSubForm);
-
- var dnpmKlinikAnamneseForm = new Procedure(this.onkostarApi);
- dnpmKlinikAnamneseForm.setId(2);
- dnpmKlinikAnamneseForm.setPatientId(123);
-
- when(onkostarApi.getProcedure(anyInt())).thenReturn(dnpmKlinikAnamneseForm);
-
- this.service.applyConsent(excelForm);
-
- verify(onkostarApi, times(0)).saveProcedure(any(Procedure.class), anyBoolean());
- }
-
- @Test
- void testShouldUpdateRelatedDnpmKlinikAnamneseFormOnFormSave() throws Exception {
-
- var consentSubForm = new Procedure(this.onkostarApi);
- consentSubForm.setId(1);
- consentSubForm.setPatientId(123);
- consentSubForm.setStartDate(Date.from(Instant.parse("2023-04-03T12:00:00Z")));
- consentSubForm.setValue(
- "datum", new Item("datum", Date.from(Instant.parse("2023-04-03T12:00:00Z"))));
- consentSubForm.setValue("status", new Item("status", "accepted"));
-
- var excelForm = new Procedure(this.onkostarApi);
- excelForm.setId(111);
- excelForm.setPatientId(123);
- excelForm.setValue("refdnpmklinikanamnese", new Item("refdnpmklinikanamnese", 2));
- excelForm.addSubProcedure("ufdnpmconsent", consentSubForm);
-
- var dnpmKlinikAnamneseForm = new Procedure(this.onkostarApi);
- dnpmKlinikAnamneseForm.setId(2);
- dnpmKlinikAnamneseForm.setPatientId(123);
-
- when(onkostarApi.getProcedure(anyInt())).thenReturn(dnpmKlinikAnamneseForm);
-
- this.service.applyConsent(excelForm);
-
- var argumentCaptor = ArgumentCaptor.forClass(Procedure.class);
- verify(onkostarApi, times(1)).saveProcedure(argumentCaptor.capture(), anyBoolean());
-
- var savedForm = argumentCaptor.getValue();
- assertThat(savedForm).isExactlyInstanceOf(Procedure.class);
- assertThat(savedForm.getValue("ConsentStatusEinwilligungDNPM").getString())
- .isEqualTo("accepted");
- assertThat(savedForm.getValue("ConsentDatumEinwilligungDNPM").getDate())
- .isEqualTo("2023-04-03T12:00:00Z");
- }
-}