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

View File

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