From 0914dd21d26eaa83bb057d0bc0af74f9cd3df20c Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Mon, 3 Apr 2023 17:41:50 +0200 Subject: Issue #20: Kein Consent-Update, wenn kein Datum oder Wert angegeben closes #20 --- .../consent/UkwConsentManagerServiceTest.java | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'src/test/java/DNPM/services') 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 @@ -51,6 +51,58 @@ public class UkwConsentManagerServiceTest { verify(onkostarApi, times(0)).saveProcedure(any(Procedure.class), anyBoolean()); } + @Test + void testShouldSkipUpdateRelatedDnpmKlinikAnamneseFormIfNoConsentDateAvailable() throws Exception { + + var consentSubForm = new Procedure(this.onkostarApi); + consentSubForm.setId(1); + consentSubForm.setPatientId(123); + consentSubForm.setValue("status", new Item("status", "accepted")); + + + var excelForm = new Procedure(this.onkostarApi); + excelForm.setId(111); + excelForm.setPatientId(123); + excelForm.setValue("refdnpmklinikanamnese", new Item("refdnpmklinikanamnese", 2)); + excelForm.addSubProcedure("ufdnpmconsent", consentSubForm); + + var dnpmKlinikAnamneseForm = new Procedure(this.onkostarApi); + dnpmKlinikAnamneseForm.setId(2); + dnpmKlinikAnamneseForm.setPatientId(123); + + when(onkostarApi.getProcedure(anyInt())).thenReturn(dnpmKlinikAnamneseForm); + + this.service.applyConsent(excelForm); + + verify(onkostarApi, times(0)).saveProcedure(any(Procedure.class), anyBoolean()); + } + + @Test + void testShouldSkipUpdateRelatedDnpmKlinikAnamneseFormIfNoConsentValueAvailable() throws Exception { + + var consentSubForm = new Procedure(this.onkostarApi); + consentSubForm.setId(1); + consentSubForm.setPatientId(123); + consentSubForm.setStartDate(Date.from(Instant.parse("2023-04-03T12:00:00Z"))); + consentSubForm.setValue("datum", new Item("datum", Date.from(Instant.parse("2023-04-03T12:00:00Z")))); + + var excelForm = new Procedure(this.onkostarApi); + excelForm.setId(111); + excelForm.setPatientId(123); + excelForm.setValue("refdnpmklinikanamnese", new Item("refdnpmklinikanamnese", 2)); + excelForm.addSubProcedure("ufdnpmconsent", consentSubForm); + + var dnpmKlinikAnamneseForm = new Procedure(this.onkostarApi); + dnpmKlinikAnamneseForm.setId(2); + dnpmKlinikAnamneseForm.setPatientId(123); + + when(onkostarApi.getProcedure(anyInt())).thenReturn(dnpmKlinikAnamneseForm); + + this.service.applyConsent(excelForm); + + verify(onkostarApi, times(0)).saveProcedure(any(Procedure.class), anyBoolean()); + } + @Test void testShouldUpdateRelatedDnpmKlinikAnamneseFormOnFormSave() throws Exception { -- cgit v1.2.3