summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul-Christian Volkmer2023-04-03 17:41:50 +0200
committerPaul-Christian Volkmer2023-04-03 17:42:59 +0200
commit0914dd21d26eaa83bb057d0bc0af74f9cd3df20c (patch)
treea222ac26b5135d73cceabcdb70c95ed5a49c6da8
parent783dfedd60a80ab4eeca720e7c5644a1a1042698 (diff)
Issue #20: Kein Consent-Update, wenn kein Datum oder Wert angegeben
closes #20
-rw-r--r--src/main/java/DNPM/services/consent/UkwConsentManagerService.java6
-rw-r--r--src/test/java/DNPM/services/consent/UkwConsentManagerServiceTest.java52
2 files changed, 55 insertions, 3 deletions
diff --git a/src/main/java/DNPM/services/consent/UkwConsentManagerService.java b/src/main/java/DNPM/services/consent/UkwConsentManagerService.java
index 46b7d05..c22a6e4 100644
--- a/src/main/java/DNPM/services/consent/UkwConsentManagerService.java
+++ b/src/main/java/DNPM/services/consent/UkwConsentManagerService.java
@@ -15,7 +15,7 @@ import java.util.Comparator;
*/
public class UkwConsentManagerService implements ConsentManagerService {
- private Logger logger = LoggerFactory.getLogger(this.getClass());
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final IOnkostarApi onkostarApi;
@@ -48,10 +48,10 @@ public class UkwConsentManagerService implements ConsentManagerService {
.ifPresent(lastConsent -> {
var date = lastConsent.getStartDate();
var status = lastConsent.getValue("status");
- if (null == 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));
diff --git a/src/test/java/DNPM/services/consent/UkwConsentManagerServiceTest.java b/src/test/java/DNPM/services/consent/UkwConsentManagerServiceTest.java
index 824b4ff..fdcd6e3 100644
--- a/src/test/java/DNPM/services/consent/UkwConsentManagerServiceTest.java
+++ b/src/test/java/DNPM/services/consent/UkwConsentManagerServiceTest.java
@@ -52,6 +52,58 @@ public class UkwConsentManagerServiceTest {
}
@Test
+ void testShouldSkipUpdateRelatedDnpmKlinikAnamneseFormIfNoConsentDateAvailable() throws Exception {
+
+ var consentSubForm = new Procedure(this.onkostarApi);
+ consentSubForm.setId(1);
+ consentSubForm.setPatientId(123);
+ consentSubForm.setValue("status", new Item("status", "accepted"));
+
+
+ var excelForm = new Procedure(this.onkostarApi);
+ excelForm.setId(111);
+ excelForm.setPatientId(123);
+ excelForm.setValue("refdnpmklinikanamnese", new Item("refdnpmklinikanamnese", 2));
+ excelForm.addSubProcedure("ufdnpmconsent", consentSubForm);
+
+ var dnpmKlinikAnamneseForm = new Procedure(this.onkostarApi);
+ dnpmKlinikAnamneseForm.setId(2);
+ dnpmKlinikAnamneseForm.setPatientId(123);
+
+ when(onkostarApi.getProcedure(anyInt())).thenReturn(dnpmKlinikAnamneseForm);
+
+ this.service.applyConsent(excelForm);
+
+ verify(onkostarApi, times(0)).saveProcedure(any(Procedure.class), anyBoolean());
+ }
+
+ @Test
+ void testShouldSkipUpdateRelatedDnpmKlinikAnamneseFormIfNoConsentValueAvailable() throws Exception {
+
+ var consentSubForm = new Procedure(this.onkostarApi);
+ consentSubForm.setId(1);
+ consentSubForm.setPatientId(123);
+ consentSubForm.setStartDate(Date.from(Instant.parse("2023-04-03T12:00:00Z")));
+ consentSubForm.setValue("datum", new Item("datum", Date.from(Instant.parse("2023-04-03T12:00:00Z"))));
+
+ var excelForm = new Procedure(this.onkostarApi);
+ excelForm.setId(111);
+ excelForm.setPatientId(123);
+ excelForm.setValue("refdnpmklinikanamnese", new Item("refdnpmklinikanamnese", 2));
+ excelForm.addSubProcedure("ufdnpmconsent", consentSubForm);
+
+ var dnpmKlinikAnamneseForm = new Procedure(this.onkostarApi);
+ dnpmKlinikAnamneseForm.setId(2);
+ dnpmKlinikAnamneseForm.setPatientId(123);
+
+ when(onkostarApi.getProcedure(anyInt())).thenReturn(dnpmKlinikAnamneseForm);
+
+ this.service.applyConsent(excelForm);
+
+ verify(onkostarApi, times(0)).saveProcedure(any(Procedure.class), anyBoolean());
+ }
+
+ @Test
void testShouldUpdateRelatedDnpmKlinikAnamneseFormOnFormSave() throws Exception {
var consentSubForm = new Procedure(this.onkostarApi);