From 459ad59c1d988a5b3ecc60d844f4fa6c9bce11f5 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Fri, 4 Aug 2023 11:43:23 +0200 Subject: [PATCH] Do not detect duplicates after deletion request --- .../dev/dnpm/etl/processor/services/RequestProcessor.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/dev/dnpm/etl/processor/services/RequestProcessor.kt b/src/main/kotlin/dev/dnpm/etl/processor/services/RequestProcessor.kt index afac40b..bdf2827 100644 --- a/src/main/kotlin/dev/dnpm/etl/processor/services/RequestProcessor.kt +++ b/src/main/kotlin/dev/dnpm/etl/processor/services/RequestProcessor.kt @@ -46,12 +46,15 @@ class RequestProcessor( val pid = mtbFile.patient.id val pseudonymized = pseudonymizeService.pseudonymize(mtbFile) - val lastRequestForPatient = - requestRepository.findAllByPatientIdOrderByProcessedAtDesc(pseudonymized.patient.id) + val allRequests = requestRepository.findAllByPatientIdOrderByProcessedAtDesc(pseudonymized.patient.id) + + val lastMtbFileRequestForPatient = allRequests .filter { it.type == RequestType.MTB_FILE } .firstOrNull { it.status == RequestStatus.SUCCESS || it.status == RequestStatus.WARNING } - if (null != lastRequestForPatient && lastRequestForPatient.fingerprint == fingerprint(mtbFile)) { + val isLastRequestDeletion = allRequests.firstOrNull()?.type == RequestType.DELETE + + if (null != lastMtbFileRequestForPatient && lastMtbFileRequestForPatient.fingerprint == fingerprint(mtbFile) && !isLastRequestDeletion) { requestRepository.save( Request( patientId = pseudonymized.patient.id,