diff options
| author | Paul-Christian Volkmer | 2025-10-23 11:08:10 +0200 |
|---|---|---|
| committer | Paul-Christian Volkmer | 2025-10-23 11:09:54 +0200 |
| commit | 84fb0d829832bf1628112376bba729422b169402 (patch) | |
| tree | 4828674b77105877dccfcccb380da3f7c0f75987 /src/main/java/dev/dnpm/services | |
| parent | 61e7dfcbe637f401f81ff853e9bd10c90b325acb (diff) | |
refactor: change package name
Diffstat (limited to 'src/main/java/dev/dnpm/services')
29 files changed, 0 insertions, 2260 deletions
diff --git a/src/main/java/dev/dnpm/services/DefaultFormService.java b/src/main/java/dev/dnpm/services/DefaultFormService.java deleted file mode 100644 index e3f0aca..0000000 --- a/src/main/java/dev/dnpm/services/DefaultFormService.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.services; - -import dev.dnpm.exceptions.FormException; -import org.springframework.jdbc.core.JdbcTemplate; - -import javax.sql.DataSource; -import java.util.List; - -/** - * Standardimplementierung zum Ermitteln von Unter- und Hauptformularen - * - * @since 0.0.2 - */ -public class DefaultFormService implements FormService { - - private final JdbcTemplate jdbcTemplate; - - public DefaultFormService(final DataSource dataSource) { - this.jdbcTemplate = new JdbcTemplate(dataSource); - } - - @Override - public int getMainFormProcedureId(int procedureId) throws FormException { - var sql = "SELECT hauptprozedur_id FROM prozedur WHERE id = ?"; - try { - return jdbcTemplate.queryForObject(sql, (resultSet, i) -> resultSet.getInt("hauptprozedur_id"), procedureId); - } catch (Exception e) { - throw new FormException(String.format("No main form found for subform with ID '%d'", procedureId)); - } - } - - @Override - public List<Integer> getSubFormProcedureIds(int procedureId) { - var sql = "SELECT id FROM prozedur WHERE hauptprozedur_id = ?"; - return jdbcTemplate.queryForList(sql, Integer.class, procedureId); - } -} diff --git a/src/main/java/dev/dnpm/services/DefaultStudienService.java b/src/main/java/dev/dnpm/services/DefaultStudienService.java deleted file mode 100644 index 47b4637..0000000 --- a/src/main/java/dev/dnpm/services/DefaultStudienService.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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.services; - -import dev.dnpm.dto.Studie; -import org.springframework.jdbc.core.JdbcTemplate; - -import javax.sql.DataSource; -import java.util.List; -import java.util.stream.Collectors; - -/** - * Standardimplementierung zum Ermitteln von Studien - * - * @since 0.0.2 - */ -public class DefaultStudienService implements StudienService { - - private final JdbcTemplate jdbcTemplate; - - public DefaultStudienService(final DataSource dataSource) { - this.jdbcTemplate = new JdbcTemplate(dataSource); - } - - @Override - public List<Studie> findAll() { - var sql = "SELECT pcc.name, pcv.version_number, TRIM(studie.studien_nummer) AS studien_nummer, studie.startdatum, studie.endedatum, pcve.code, pcve.shortdesc, pcve.description, studie.aktiv FROM studie " - + "LEFT JOIN category_entry ce ON ce.version_entry_id = studie.property_version_entry " - + "LEFT JOIN property_catalogue_category pcc ON pcc.id = ce.category_id " - + "JOIN property_catalogue_version_entry pcve ON pcve.id = studie.property_version_entry " - + "JOIN property_catalogue_version pcv ON pcv.id = pcve.property_version_id " - + "JOIN property_catalogue pc ON pc.id = pcv.datacatalog_id " - + "WHERE pc.name = 'OS.Studien'" - + "ORDER BY TRIM(studie.studien_nummer)"; - - return this.jdbcTemplate.query(sql, (resultSet, i) -> new Studie( - resultSet.getString("name"), - resultSet.getInt("version_number"), - resultSet.getString("code"), - resultSet.getString("studien_nummer"), - resultSet.getString("shortdesc"), - resultSet.getString("description"), - resultSet.getBoolean("aktiv") - )); - } - - @Override - public List<Studie> findByQuery(String query) { - var sql = "SELECT pcc.name, pcv.version_number, TRIM(studie.studien_nummer) AS studien_nummer, studie.startdatum, studie.endedatum, pcve.code, pcve.shortdesc, pcve.description, studie.aktiv FROM studie " - + "LEFT JOIN category_entry ce ON ce.version_entry_id = studie.property_version_entry " - + "LEFT JOIN property_catalogue_category pcc ON pcc.id = ce.category_id " - + "JOIN property_catalogue_version_entry pcve ON pcve.id = studie.property_version_entry " - + "JOIN property_catalogue_version pcv ON pcv.id = pcve.property_version_id " - + "JOIN property_catalogue pc ON pc.id = pcv.datacatalog_id " - + "WHERE pc.name = 'OS.Studien' AND (pcve.shortdesc LIKE ? OR pcve.description LIKE ? OR studie.studien_nummer LIKE ?)" - + "ORDER BY TRIM(studie.studien_nummer)"; - - var like = String.format("%%%s%%", query); - - return this.jdbcTemplate.query(sql, new Object[]{like, like, like}, (resultSet, i) -> new Studie( - resultSet.getString("name"), - resultSet.getInt("version_number"), - resultSet.getString("code"), - resultSet.getString("studien_nummer"), - resultSet.getString("shortdesc"), - resultSet.getString("description"), - resultSet.getBoolean("aktiv") - )); - } - - @Override - public List<Studie> findActive() { - return findAll().stream().filter(Studie::isActive).collect(Collectors.toList()); - } - - @Override - public List<Studie> findActiveByQuery(String query) { - return findByQuery(query).stream().filter(Studie::isActive).collect(Collectors.toList()); - } -} diff --git a/src/main/java/dev/dnpm/services/FormService.java b/src/main/java/dev/dnpm/services/FormService.java deleted file mode 100644 index bc65110..0000000 --- a/src/main/java/dev/dnpm/services/FormService.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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.services; - -import dev.dnpm.exceptions.FormException; -import de.itc.onkostar.api.Procedure; -import de.itc.onkostar.api.constants.JaNeinUnbekannt; - -import java.util.List; - -public interface FormService { - - /** - * Diese Methode übergibt die Prozedur-ID des zugehörigen Hauptformulars zu einem Unterformular - * Siehe auch: <a href="https://github.com/CCC-MF/onkostar-plugin-forminfo/blob/master/src/main/java/de/ukw/ccc/onkostar/forminfo/services/FormInfoService.java">FormInfoService.java</a> - * - * @param procedureId Die Prozedur-ID des Unterformulars - * @return Die Prozedur-ID des zugehörigen Hauptformulars - * @throws FormException Wird geworfen, wenn ein Fehler auftrat - */ - int getMainFormProcedureId(int procedureId) throws FormException; - - /** - * Diese Methode übergibt die Prozedur-IDs von Unterformularen zu einem Formular - * Siehe auch: <a href="https://github.com/CCC-MF/onkostar-plugin-forminfo/blob/master/src/main/java/de/ukw/ccc/onkostar/forminfo/services/FormInfoService.java">FormInfoService.java</a> - * - * @param procedureId Die Prozedur-ID des Formulars - * @return Eine Liste mit Prozedur-IDs der Unterformulare - */ - List<Integer> getSubFormProcedureIds(int procedureId); - - /** - * Prüft, ob ein Formularfeld in der Prozedur einen Wert hat oder null ist - * @param procedure Die zu prüfende Prozedur - * @param fieldName Der Formularfeldname - * @return Gibt <code>true</code> zurück, wenn das Feld einen Wert hat - */ - static boolean hasValue(final Procedure procedure, final String fieldName) { - return null != procedure.getValue(fieldName); - } - - /** - * Prüft, ob ein Formularfeld mit Ja/Nein/Unbekannt den Wert Ja hat - * @param procedure Die zu prüfende Prozedur - * @param fieldName Der Formularfeldname - * @return Gibt <code>true</code> zurück, wenn das Feld den Wert "Ja" hat - */ - static boolean isYes(final Procedure procedure, final String fieldName) { - return hasValue(procedure, fieldName) - && procedure.getValue(fieldName).getString().equals(JaNeinUnbekannt.JA.getCode()); - } - -} diff --git a/src/main/java/dev/dnpm/services/SettingsService.java b/src/main/java/dev/dnpm/services/SettingsService.java deleted file mode 100644 index cec0bdc..0000000 --- a/src/main/java/dev/dnpm/services/SettingsService.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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.services; - -import dev.dnpm.database.SettingsRepository; - -import java.util.Optional; - -/** - * Implementiert den Dienst zur Ermittlung von Systemeinstellungen - */ -public class SettingsService { - - private final SettingsRepository settingsRepository; - - public SettingsService(final SettingsRepository settingsRepository) { - this.settingsRepository = settingsRepository; - } - - /** - * Übergibt ein <code>Optional</code> für die Einstellung mit angegebenen Namen - * @param name Name der Einstellung - * @return Optional mit Wert der Einstellung oder ein leeres Optional, wenn Einstellung nicht gefunden - */ - public Optional<String> getSetting(String name) { - var sid = settingsRepository.findByName(name); - if (null == sid) { - return Optional.empty(); - } - return Optional.of(sid.getValue()); - } - - /** - * Übergibt die SID als <code>Optional</code> - * @return Optional mit Wert der SID - */ - public Optional<String> getSID() { - return getSetting("SID"); - } - - /** - * Übergibt die Einstellung für <code>mehrere_mtb_in_mtbepisode</code> - * @return Übergibt <code>true</code>, wenn <code>mehrere_mtb_in_mtbepisode</code> auf "Ja" gesetzt ist. - */ - public boolean multipleMtbsInMtbEpisode() { - var setting = getSetting("mehrere_mtb_in_mtbepisode"); - return setting.isPresent() && setting.get().equals("true"); - } -} diff --git a/src/main/java/dev/dnpm/services/StudienService.java b/src/main/java/dev/dnpm/services/StudienService.java deleted file mode 100644 index 6b01699..0000000 --- a/src/main/java/dev/dnpm/services/StudienService.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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.services; - -import dev.dnpm.dto.Studie; - -import java.util.List; - -public interface StudienService { - - /** - * Übergibt eine Liste mit allen Studien - * - * @return Liste mit allen Studien - */ - List<Studie> findAll(); - - /** - * Übergibt eine Liste mit Studien, deren (Kurz-)Beschreibung oder Studiennummer den übergebenen Wert enthalten - * - * @param query Wert der enthalten sein muss - * @return Gefilterte Liste mit Studien - */ - List<Studie> findByQuery(String query); - - /** - * Übergibt eine Liste mit aktiven Studien - * - * @return Liste mit aktiven Studien - */ - List<Studie> findActive(); - - /** - * Übergibt eine Liste mit aktiven Studien, deren (Kurz-)Beschreibung oder Studiennummer den übergebenen Wert enthalten - * - * @param query Wert der enthalten sein muss - * @return Gefilterte Liste mit aktiven Studien - */ - List<Studie> findActiveByQuery(String query); - -} diff --git a/src/main/java/dev/dnpm/services/TherapieMitEcogService.java b/src/main/java/dev/dnpm/services/TherapieMitEcogService.java deleted file mode 100644 index 81b8436..0000000 --- a/src/main/java/dev/dnpm/services/TherapieMitEcogService.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.services; - -import dev.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/dev/dnpm/services/consent/ConsentManagerService.java b/src/main/java/dev/dnpm/services/consent/ConsentManagerService.java deleted file mode 100644 index 1879da7..0000000 --- a/src/main/java/dev/dnpm/services/consent/ConsentManagerService.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.services.consent; - -import de.itc.onkostar.api.Procedure; - -/** - * Schnittstelle für die Anwendung von Consent-Änderungen - * - * @since 0.2.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/services/consent/ConsentManagerServiceFactory.java b/src/main/java/dev/dnpm/services/consent/ConsentManagerServiceFactory.java deleted file mode 100644 index a35ac1b..0000000 --- a/src/main/java/dev/dnpm/services/consent/ConsentManagerServiceFactory.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.services.consent; - -import de.itc.onkostar.api.IOnkostarApi; - -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/services/consent/MrConsentManagerService.java b/src/main/java/dev/dnpm/services/consent/MrConsentManagerService.java deleted file mode 100644 index e7f48ec..0000000 --- a/src/main/java/dev/dnpm/services/consent/MrConsentManagerService.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * 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.services.consent; - -import dev.dnpm.VerweisVon; -import de.itc.onkostar.api.IOnkostarApi; -import de.itc.onkostar.api.Item; -import de.itc.onkostar.api.Procedure; -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; - -import java.util.List; -import java.util.Map; - -/** - * Detailimplementierung für das Formular `MR.Consent` - * - * @since 0.2.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/services/consent/UkwConsentManagerService.java b/src/main/java/dev/dnpm/services/consent/UkwConsentManagerService.java deleted file mode 100644 index cb35b2f..0000000 --- a/src/main/java/dev/dnpm/services/consent/UkwConsentManagerService.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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.services.consent; - -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.Comparator; - -/** - * Detailimplementierung für das Formular `Excel-Formular` - * - * @since 0.2.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/main/java/dev/dnpm/services/molekulargenetik/MolekulargenetikFormService.java b/src/main/java/dev/dnpm/services/molekulargenetik/MolekulargenetikFormService.java deleted file mode 100644 index 6a2603a..0000000 --- a/src/main/java/dev/dnpm/services/molekulargenetik/MolekulargenetikFormService.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.services.molekulargenetik; - -import dev.dnpm.dto.Variant; -import de.itc.onkostar.api.Procedure; - -import java.util.List; - -/** - * Schnittstellenbeschreibung für Methoden zum Formular "OS.Molekulargenetik" - */ -public interface MolekulargenetikFormService { - - /** - * Ermittelt alle (unterstützten) Varianten zur Prozedur eines Formulars "OS.Molekulargenetik" - * @param procedure Die Prozedur zum Formular "OS.Molekulargenetik" - * @return Die unterstützten Varianten oder eine leere Liste, wenn keine Varianten gefunden wurden. - */ - List<Variant> getVariants(Procedure procedure); - -} diff --git a/src/main/java/dev/dnpm/services/molekulargenetik/OsMolekulargenetikFormService.java b/src/main/java/dev/dnpm/services/molekulargenetik/OsMolekulargenetikFormService.java deleted file mode 100644 index 4c9c804..0000000 --- a/src/main/java/dev/dnpm/services/molekulargenetik/OsMolekulargenetikFormService.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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.services.molekulargenetik; - -import dev.dnpm.dto.Variant; -import de.itc.onkostar.api.Procedure; - -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -public class OsMolekulargenetikFormService implements MolekulargenetikFormService { - - /** - * Ermittelt alle (unterstützten) Varianten zur Prozedur eines Formulars "OS.Molekulargenetik" (oder Variante) - * Unterstützte Varianten sind: - * <uL> - * <li>Einfache Variante - * <li>CNV - * <li>Fusion - * @param procedure Die Prozedur zum Formular "OS.Molekulargenetik" (oder Variante) - * @return Die unterstützten Varianten oder eine leere Liste, wenn keine Varianten gefunden wurden. - */ - @Override - public List<Variant> getVariants(Procedure procedure) { - if (! procedureWithUsableFormVariant(procedure)) { - return List.of(); - } - - var subforms = procedure.getSubProceduresMap().get("MolekulargenetischeUntersuchung"); - if (null == subforms) { - return List.of(); - } - - return subforms.stream() - .map(Variant::fromProcedure) - .filter(Optional::isPresent) - .map(Optional::get) - .collect(Collectors.toList()); - - } - - private boolean procedureWithUsableFormVariant(Procedure procedure) { - return "OS.Molekulargenetik".equals(procedure.getFormName()) - || "UKER.Molekulargenetik".equals(procedure.getFormName()); - } -} diff --git a/src/main/java/dev/dnpm/services/mtb/DefaultMtbService.java b/src/main/java/dev/dnpm/services/mtb/DefaultMtbService.java deleted file mode 100644 index 5237d02..0000000 --- a/src/main/java/dev/dnpm/services/mtb/DefaultMtbService.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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.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/services/mtb/MrMtbAnmeldungToProtocolMapper.java b/src/main/java/dev/dnpm/services/mtb/MrMtbAnmeldungToProtocolMapper.java deleted file mode 100644 index 203edd7..0000000 --- a/src/main/java/dev/dnpm/services/mtb/MrMtbAnmeldungToProtocolMapper.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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.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/services/mtb/MtbService.java b/src/main/java/dev/dnpm/services/mtb/MtbService.java deleted file mode 100644 index a8b8f9d..0000000 --- a/src/main/java/dev/dnpm/services/mtb/MtbService.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.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/services/mtb/OsTumorkonferenzToProtocolMapper.java b/src/main/java/dev/dnpm/services/mtb/OsTumorkonferenzToProtocolMapper.java deleted file mode 100644 index 21e056e..0000000 --- a/src/main/java/dev/dnpm/services/mtb/OsTumorkonferenzToProtocolMapper.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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.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/services/mtb/OsTumorkonferenzVarianteUkwToProtocolMapper.java b/src/main/java/dev/dnpm/services/mtb/OsTumorkonferenzVarianteUkwToProtocolMapper.java deleted file mode 100644 index a29b580..0000000 --- a/src/main/java/dev/dnpm/services/mtb/OsTumorkonferenzVarianteUkwToProtocolMapper.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.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/services/mtb/ProcedureToProtocolMapper.java b/src/main/java/dev/dnpm/services/mtb/ProcedureToProtocolMapper.java deleted file mode 100644 index ce9a514..0000000 --- a/src/main/java/dev/dnpm/services/mtb/ProcedureToProtocolMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.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>> {} diff --git a/src/main/java/dev/dnpm/services/strahlentherapie/DefaultStrahlentherapieService.java b/src/main/java/dev/dnpm/services/strahlentherapie/DefaultStrahlentherapieService.java deleted file mode 100644 index 52bd1fb..0000000 --- a/src/main/java/dev/dnpm/services/strahlentherapie/DefaultStrahlentherapieService.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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.services.strahlentherapie; - -import dev.dnpm.dto.EcogStatusWithDate; -import dev.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/dev/dnpm/services/strahlentherapie/StrahlentherapieService.java b/src/main/java/dev/dnpm/services/strahlentherapie/StrahlentherapieService.java deleted file mode 100644 index 595d14d..0000000 --- a/src/main/java/dev/dnpm/services/strahlentherapie/StrahlentherapieService.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.services.strahlentherapie; - -import dev.dnpm.services.TherapieMitEcogService; - -/** - * Service für Systemtherapieformulare - * - * @since 0.6.0 - */ -public interface StrahlentherapieService extends TherapieMitEcogService {} diff --git a/src/main/java/dev/dnpm/services/systemtherapie/DefaultSystemtherapieService.java b/src/main/java/dev/dnpm/services/systemtherapie/DefaultSystemtherapieService.java deleted file mode 100644 index fdac25c..0000000 --- a/src/main/java/dev/dnpm/services/systemtherapie/DefaultSystemtherapieService.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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.services.systemtherapie; - -import dev.dnpm.dto.EcogStatusWithDate; -import dev.dnpm.services.SettingsService; -import de.itc.onkostar.api.IOnkostarApi; -import de.itc.onkostar.api.Patient; -import de.itc.onkostar.api.Procedure; - -import java.util.*; -import java.util.stream.Collectors; - -/** - * Standardimplementierung des Systemtherapieservices - * - * @since 0.2.0 - */ -public class DefaultSystemtherapieService implements SystemtherapieService { - - private static final String ECOG_FIELD = "ECOGvorTherapie"; - - private final IOnkostarApi onkostarApi; - - private final SettingsService settingsService; - - public DefaultSystemtherapieService(final IOnkostarApi onkostarApi, final SettingsService settingsService) { - this.onkostarApi = onkostarApi; - this.settingsService = settingsService; - } - - /** - * Ermittelt eine Zusammenfassung der systemischen Therapien für eine Erkrankung - * - * @param diseaseId Die ID der Erkrankung - * @return Zusammenfassung der systemischen Therapien - */ - @Override - public List<Map<String, String>> getSystemischeTherapienFromDiagnose(int diseaseId) { - List<Map<String, String>> result = new ArrayList<>(); - for (Procedure prozedur : onkostarApi.getProceduresForDiseaseByForm(diseaseId, getFormName())) { - prozedurToProzedurwerteMapper(prozedur).apply(prozedur).ifPresent(result::add); - } - return result; - } - - /** - * Übergibt aktuell immer den Mapper für das Formular "OS.Systemische Therapie", - * da beide bekannte Varianten damit gemappt werden können. - * - * @param procedure Die Prozedur für die ein Mapper erstellt werden soll - * @return Der Mapper für die Prozedur - */ - @Override - public ProzedurToProzedurwerteMapper prozedurToProzedurwerteMapper(Procedure procedure) { - return new OsSystemischeTherapieToProzedurwerteMapper(); - } - - /** - * 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("systemtherapieform") - .orElse("OS.Systemische Therapie"); - } -} diff --git a/src/main/java/dev/dnpm/services/systemtherapie/OsSystemischeTherapieToProzedurwerteMapper.java b/src/main/java/dev/dnpm/services/systemtherapie/OsSystemischeTherapieToProzedurwerteMapper.java deleted file mode 100644 index 8db1e93..0000000 --- a/src/main/java/dev/dnpm/services/systemtherapie/OsSystemischeTherapieToProzedurwerteMapper.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * 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.services.systemtherapie; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import de.itc.onkostar.api.Item; -import de.itc.onkostar.api.Procedure; -import de.ukw.ccc.onkostar.atccodes.AtcCode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.*; - -/** - * Implementierung zum Mappen des Formulars "OS.Systemische Therapie" auf die Prozedurwerte - * - * @since 0.2.0 - */ -public class OsSystemischeTherapieToProzedurwerteMapper implements ProzedurToProzedurwerteMapper { - - private static final Logger logger = LoggerFactory.getLogger(OsSystemischeTherapieToProzedurwerteMapper.class); - - @Override - public Optional<Map<String, String>> apply(Procedure procedure) { - try { - return Optional.of(getProzedurwerte(procedure)); - } catch (Exception e) { - logger.error("Fehler beim Mappen der Prozedur auf Prozedurwerte", e); - return Optional.empty(); - } - } - - private static Map<String, String> getProzedurwerte(Procedure prozedur) { - List<String> wirkstoffListe = new ArrayList<>(); - // SubstanzenCodesListe enthält die Liste der SubstanzenCodes - List<Map<String, String>> substanzenCodesListe = new ArrayList<>(); - - // alle Werte der Prozedur auslesen - Map<String, Item> alleWerte = prozedur.getAllValues(); - // Prozedurwerte enthält nur die interessanten Werte - Map<String, String> prozedurwerte = new HashMap<>(); - // alle Werte durchgehen und die interessanten übernehmen - if (alleWerte.containsKey("Beendigung")) { - prozedurwerte.put("Beendigung", alleWerte.get("Beendigung").getValue()); - } - if (alleWerte.containsKey("Ergebnis")) { - prozedurwerte.put("Ergebnis", alleWerte.get("Ergebnis").getValue()); - } - if (alleWerte.containsKey("Beginn")) { - prozedurwerte.put("Beginn", alleWerte.get("Beginn").getString()); - } - if (alleWerte.containsKey("Ende")) { - prozedurwerte.put("Ende", alleWerte.get("Ende").getString()); - } - if (alleWerte.containsKey("SubstanzenList")) { - List<Map<String, String>> substanzList = alleWerte.get("SubstanzenList").getValue(); - for (var substanz : substanzList) { - var substanzCodes = getSubstanzCode(substanz); - substanzenCodesListe.add(substanzCodes); - wirkstoffListe.add(substanzCodes.get("substance")); - } - } - - prozedurwerte.put("Wirkstoffe", String.join(", ", wirkstoffListe)); - try { - ObjectMapper mapper = new ObjectMapper(); - prozedurwerte.put("WirkstoffCodes", mapper.writeValueAsString(substanzenCodesListe)); - } catch (JsonProcessingException e) { - logger.error("Kann 'WirkstoffCodes' nicht in JSON-String mappen", e); - } - - return prozedurwerte; - } - - private static Map<String, String> getSubstanzCode(Map<String, String> substanz) { - Map<String, String> substanzCode = new HashMap<>(); - if (substanz.containsKey("Substanz")) { - if (AtcCode.isAtcCode(substanz.get("Substanz"))) { - substanzCode.put("system", "ATC"); - } else { - substanzCode.put("system", "other"); - } - substanzCode.put("code", substanz.get("Substanz")); - - } - if (substanz.containsKey("Substanz_shortDescription")) { - substanzCode.put("substance", substanz.get("Substanz_shortDescription")); - } - return substanzCode; - } -} diff --git a/src/main/java/dev/dnpm/services/systemtherapie/ProzedurToProzedurwerteMapper.java b/src/main/java/dev/dnpm/services/systemtherapie/ProzedurToProzedurwerteMapper.java deleted file mode 100644 index de5bdb8..0000000 --- a/src/main/java/dev/dnpm/services/systemtherapie/ProzedurToProzedurwerteMapper.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.services.systemtherapie; - -import de.itc.onkostar.api.Procedure; - -import java.util.Map; -import java.util.Optional; -import java.util.function.Function; - -/** - * Mapper um ein Systemtherapieformular in eine Optional-Map mit Prozedurwerten umzuwandeln - * - * @since 0.2.0 - */ -public interface ProzedurToProzedurwerteMapper extends Function<Procedure, Optional<Map<String, String>>> {} diff --git a/src/main/java/dev/dnpm/services/systemtherapie/SystemtherapieService.java b/src/main/java/dev/dnpm/services/systemtherapie/SystemtherapieService.java deleted file mode 100644 index 0a1f1b8..0000000 --- a/src/main/java/dev/dnpm/services/systemtherapie/SystemtherapieService.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.services.systemtherapie; - -import dev.dnpm.services.TherapieMitEcogService; -import de.itc.onkostar.api.Procedure; - -import java.util.List; -import java.util.Map; - -/** - * Service für Systemtherapieformulare - * - * @since 0.2.0 - */ -public interface SystemtherapieService extends TherapieMitEcogService { - /** - * Ermittelt eine Zusammenfassung der systemischen Therapien für eine Erkrankung - * @param diseaseId Die ID der Erkrankung - * @return Die Zusammenfassung der systemischen Therapien - */ - List<Map<String, String>> getSystemischeTherapienFromDiagnose(int diseaseId); - - /** - * Erstellt den Mapper for die Prozedur - * @param procedure Die Prozedur für die ein Mapper erstellt werden soll - * @return Der erstellte ProzedurToProzedurwerteMapper - */ - ProzedurToProzedurwerteMapper prozedurToProzedurwerteMapper(Procedure procedure); - -} diff --git a/src/main/java/dev/dnpm/services/therapieplan/AbstractTherapieplanService.java b/src/main/java/dev/dnpm/services/therapieplan/AbstractTherapieplanService.java deleted file mode 100644 index 01c6861..0000000 --- a/src/main/java/dev/dnpm/services/therapieplan/AbstractTherapieplanService.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.services.therapieplan; - -import dev.dnpm.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/services/therapieplan/DefaultTherapieplanService.java b/src/main/java/dev/dnpm/services/therapieplan/DefaultTherapieplanService.java deleted file mode 100644 index 6b162c0..0000000 --- a/src/main/java/dev/dnpm/services/therapieplan/DefaultTherapieplanService.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * 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.services.therapieplan; - -import dev.dnpm.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.services.FormService.hasValue; -import static dev.dnpm.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/services/therapieplan/MultipleMtbTherapieplanService.java b/src/main/java/dev/dnpm/services/therapieplan/MultipleMtbTherapieplanService.java deleted file mode 100644 index 3df8b98..0000000 --- a/src/main/java/dev/dnpm/services/therapieplan/MultipleMtbTherapieplanService.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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.services.therapieplan; - -import dev.dnpm.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.services.FormService.hasValue; -import static dev.dnpm.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/services/therapieplan/TherapieplanService.java b/src/main/java/dev/dnpm/services/therapieplan/TherapieplanService.java deleted file mode 100644 index 13a6352..0000000 --- a/src/main/java/dev/dnpm/services/therapieplan/TherapieplanService.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.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/services/therapieplan/TherapieplanServiceFactory.java b/src/main/java/dev/dnpm/services/therapieplan/TherapieplanServiceFactory.java deleted file mode 100644 index 28e2621..0000000 --- a/src/main/java/dev/dnpm/services/therapieplan/TherapieplanServiceFactory.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.services.therapieplan; - -import dev.dnpm.services.FormService; -import dev.dnpm.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); - } - -} |
