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:
@ -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(
|
||||
|
@ -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,7 +248,7 @@ class ExtensionsTest {
|
||||
assertThat(mtbFile.serialized()).doesNotContain(CLEAN_PATIENT_ID)
|
||||
}
|
||||
|
||||
private fun addConsentData(cleanPatientId: String, mtbFile: Mtb) {
|
||||
private fun addConsentData(mtbFile: Mtb) {
|
||||
val gIcsConfigProperties = GIcsConfigProperties("", "", "", true)
|
||||
|
||||
val baseConsentService = object : BaseConsentService(gIcsConfigProperties) {
|
||||
@ -273,7 +275,7 @@ class ExtensionsTest {
|
||||
|
||||
val bundle = Bundle()
|
||||
val dummyConsent = TransformationServiceTest.getDummyConsent()
|
||||
dummyConsent.patient.reference = "Patient/$cleanPatientId"
|
||||
dummyConsent.patient.reference = "Patient/$CLEAN_PATIENT_ID"
|
||||
bundle.addEntry().resource = dummyConsent
|
||||
|
||||
baseConsentService.embedBroadConsentResources(mtbFile, bundle)
|
||||
|
Reference in New Issue
Block a user