diff options
| author | Paul-Christian Volkmer | 2026-06-16 13:32:59 +0200 |
|---|---|---|
| committer | GitHub | 2026-06-16 11:32:59 +0000 |
| commit | 556577102ed8287b25351f68241264c7062fd362 (patch) | |
| tree | f3cb043706d33cffa5f66774d8e020fecde7e0d4 /src | |
| parent | efeccbd63040e5525fd574a7eb8f3180b64d7173 (diff) | |
feat: do not request research consent if reason missing is given (#298)
This is a first approach to make use of a reason missing given in MTB file at UKGM Marburg due to special handling of research consent.
Without these changes, the request will be canceled without any further processing.
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/kotlin/dev/dnpm/etl/processor/services/ConsentProcessor.kt | 25 | ||||
| -rw-r--r-- | src/test/kotlin/dev/dnpm/etl/processor/services/ConsentProcessorTest.kt | 26 |
2 files changed, 41 insertions, 10 deletions
diff --git a/src/main/kotlin/dev/dnpm/etl/processor/services/ConsentProcessor.kt b/src/main/kotlin/dev/dnpm/etl/processor/services/ConsentProcessor.kt index a95420a..20a2ba3 100644 --- a/src/main/kotlin/dev/dnpm/etl/processor/services/ConsentProcessor.kt +++ b/src/main/kotlin/dev/dnpm/etl/processor/services/ConsentProcessor.kt @@ -83,16 +83,6 @@ class ConsentProcessor( // 2.1 -> yes -> send mtb file // 2.2 -> no -> warn/info no consent given - /* - * broad consent - */ - val broadConsent = - consentService.getConsent(personIdentifierValue, requestDate, ConsentDomain.BROAD_CONSENT) - val broadConsentHasBeenAsked = broadConsent.entry.isNotEmpty() - - // fast exit - if patient has not been asked, we can skip and exit - if (!broadConsentHasBeenAsked) return false - // GenomDE_MV-Consent only if domain name available else fallback to file check val genomDeSequencingStatus = if (null != gIcsConfigProperties.genomDeConsentDomainName) { val genomeDeConsent = @@ -111,6 +101,21 @@ class ConsentProcessor( true } + /* + * broad consent + */ + if (null != mtbFile.metadata?.reasonResearchConsentMissing) { + // early return if there is a reason for missing broad consent + return false + } + + val broadConsent = + consentService.getConsent(personIdentifierValue, requestDate, ConsentDomain.BROAD_CONSENT) + val broadConsentHasBeenAsked = broadConsent.entry.isNotEmpty() + + // fast exit - if patient has not been asked, we can skip and exit + if (!broadConsentHasBeenAsked) return false + embedBroadConsentResources(mtbFile, broadConsent) val broadConsentStatus = diff --git a/src/test/kotlin/dev/dnpm/etl/processor/services/ConsentProcessorTest.kt b/src/test/kotlin/dev/dnpm/etl/processor/services/ConsentProcessorTest.kt index a85d555..8899fc6 100644 --- a/src/test/kotlin/dev/dnpm/etl/processor/services/ConsentProcessorTest.kt +++ b/src/test/kotlin/dev/dnpm/etl/processor/services/ConsentProcessorTest.kt @@ -28,8 +28,10 @@ import dev.dnpm.etl.processor.consent.ConsentDomain import dev.dnpm.etl.processor.consent.GicsConsentService import dev.dnpm.etl.processor.consent.MtbFileConsentService import dev.pcvolkmer.mv64e.mtb.Mtb +import dev.pcvolkmer.mv64e.mtb.MvhMetadata import dev.pcvolkmer.mv64e.mtb.MvhSubmissionType import dev.pcvolkmer.mv64e.mtb.Patient +import dev.pcvolkmer.mv64e.mtb.ResearchConsentReasonMissing import org.assertj.core.api.Assertions.assertThat import org.hl7.fhir.r4.model.Bundle import org.hl7.fhir.r4.model.CodeableConcept @@ -46,6 +48,8 @@ import org.mockito.junit.jupiter.MockitoExtension import org.mockito.kotlin.any import org.mockito.kotlin.doAnswer import org.mockito.kotlin.eq +import org.mockito.kotlin.times +import org.mockito.kotlin.verify import org.mockito.kotlin.whenever import org.springframework.core.io.ClassPathResource import tools.jackson.databind.json.JsonMapper @@ -267,4 +271,26 @@ class ConsentProcessorTest { assertThat(inputMtb.metadata.type).isEqualTo(MvhSubmissionType.INITIAL) } } + + @Test + fun doNotRequestBroadConsentIfReasonMissingIsGiven() { + doAnswer { Bundle() } + .whenever(gicsConsentService) + .getConsent(any(), any(), eq(ConsentDomain.MODELLVORHABEN_64E)) + + val inputMtb = + Mtb.builder() + .patient(Patient.builder().id("d611d429-5003-11f0-a144-661e92ac9503").build()) + .metadata(MvhMetadata.builder().reasonResearchConsentMissing(ResearchConsentReasonMissing.OTHER_PATIENT_REASON).build()) + .build() + val checkResult = consentProcessor.consentGatedCheckAndTryEmbedding(inputMtb) + + verify(gicsConsentService, times(1)) + .getConsent(any(), any(), eq(ConsentDomain.MODELLVORHABEN_64E)) + verify(gicsConsentService, times(0)) + .getConsent(any(), any(), eq(ConsentDomain.BROAD_CONSENT)) + + assertThat(checkResult).isFalse + assertThat(inputMtb.metadata.researchConsents).isEmpty() + } } |
