1
0
mirror of https://github.com/pcvolkmer/etl-processor.git synced 2025-07-17 12:52:54 +00:00

refactor: simplify consent check

This commit is contained in:
Jakub Lidke
2025-07-11 14:57:23 +02:00
parent 90d1378e12
commit be592b1a2a
2 changed files with 16 additions and 17 deletions

View File

@ -125,22 +125,20 @@ class RequestProcessor(
consentService.embedBroadConsentResources(mtbFile, broadConsent) consentService.embedBroadConsentResources(mtbFile, broadConsent)
val broadConsentStatus = consentService.getProvisionTypeByPolicyCode( val broadConsentStatus = consentService.getProvisionTypeByPolicyCode(
broadConsent, broadConsent, requestDate, ConsentDomain.BroadConsent
requestDate,
ConsentDomain.BroadConsent
) )
val genomDeSequencingStatus = consentService.getProvisionTypeByPolicyCode( val genomDeSequencingStatus = consentService.getProvisionTypeByPolicyCode(
genomeDeConsent, requestDate, genomeDeConsent, requestDate, ConsentDomain.Modelvorhaben64e
ConsentDomain.Modelvorhaben64e
) )
if (Consent.ConsentProvisionType.PERMIT == broadConsentStatus) return true
if (Consent.ConsentProvisionType.DENY == broadConsentStatus && Consent.ConsentProvisionType.PERMIT == genomDeSequencingStatus) return true
if (Consent.ConsentProvisionType.NULL == broadConsentStatus) { if (Consent.ConsentProvisionType.NULL == broadConsentStatus) {
// bc not asked // bc not asked
return false return false
} }
if (Consent.ConsentProvisionType.PERMIT == broadConsentStatus ||
Consent.ConsentProvisionType.PERMIT == genomDeSequencingStatus
) return true
return false return false
} }
@ -163,7 +161,6 @@ class RequestProcessor(
} }
} }
private fun <T> saveAndSend(request: MtbFileRequest<T>, pid: PatientId) { private fun <T> saveAndSend(request: MtbFileRequest<T>, pid: PatientId) {
requestService.save( requestService.save(
Request( Request(

View File

@ -97,7 +97,9 @@ class ExtensionsTest {
mtbFile.pseudonymizeWith(pseudonymizeService) mtbFile.pseudonymizeWith(pseudonymizeService)
mtbFile.anonymizeContentWith(pseudonymizeService) mtbFile.anonymizeContentWith(pseudonymizeService)
val pattern = "\"[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}\"".toRegex().toPattern() val pattern =
"\"[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}\"".toRegex()
.toPattern()
val matcher = pattern.matcher(mtbFile.serialized()) val matcher = pattern.matcher(mtbFile.serialized())
assertThrows<IllegalStateException> { assertThrows<IllegalStateException> {
@ -238,7 +240,7 @@ class ExtensionsTest {
val mtbFile = fakeMtbFile() val mtbFile = fakeMtbFile()
mtbFile.ensureMetaDataIsInitialized() mtbFile.ensureMetaDataIsInitialized()
addConsentData(CLEAN_PATIENT_ID,mtbFile) addConsentData(mtbFile)
mtbFile.pseudonymizeWith(pseudonymizeService) mtbFile.pseudonymizeWith(pseudonymizeService)
@ -246,12 +248,12 @@ class ExtensionsTest {
assertThat(mtbFile.serialized()).doesNotContain(CLEAN_PATIENT_ID) assertThat(mtbFile.serialized()).doesNotContain(CLEAN_PATIENT_ID)
} }
private fun addConsentData(cleanPatientId: String, mtbFile: Mtb) { private fun addConsentData(mtbFile: Mtb) {
val gIcsConfigProperties = GIcsConfigProperties("","","", true) val gIcsConfigProperties = GIcsConfigProperties("", "", "", true)
val baseConsentService = object: BaseConsentService(gIcsConfigProperties){ val baseConsentService = object : BaseConsentService(gIcsConfigProperties) {
override fun getTtpBroadConsentStatus(personIdentifierValue: String?): TtpConsentStatus? { override fun getTtpBroadConsentStatus(personIdentifierValue: String?): TtpConsentStatus? {
throw NotImplementedError("dummy") throw NotImplementedError("dummy")
} }
override fun currentConsentForPersonAndTemplate( override fun currentConsentForPersonAndTemplate(
@ -273,10 +275,10 @@ class ExtensionsTest {
val bundle = Bundle() val bundle = Bundle()
val dummyConsent = TransformationServiceTest.getDummyConsent() val dummyConsent = TransformationServiceTest.getDummyConsent()
dummyConsent.patient.reference = "Patient/$cleanPatientId" dummyConsent.patient.reference = "Patient/$CLEAN_PATIENT_ID"
bundle.addEntry().resource= dummyConsent bundle.addEntry().resource = dummyConsent
baseConsentService.embedBroadConsentResources(mtbFile,bundle) baseConsentService.embedBroadConsentResources(mtbFile, bundle)
} }
@Test @Test