From 7298078077d27380255ad5eb42a30876a4babede Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Thu, 11 Jun 2026 08:11:11 +0200 Subject: feat: count follow-ups to update submission type (#297) This is done in addition to the check by date. The submission type will be set to "followup" if: * It is not an initial submission * There are follow-ups in submission content * The date or the count is less than the last successful submission In the database, existing requests will be initialized with followup_count = -1.--- .../dev/dnpm/etl/processor/monitoring/Request.kt | 1 + .../etl/processor/services/RequestProcessor.kt | 39 ++++++++++++---------- 2 files changed, 23 insertions(+), 17 deletions(-) (limited to 'src/main/kotlin/dev/dnpm') diff --git a/src/main/kotlin/dev/dnpm/etl/processor/monitoring/Request.kt b/src/main/kotlin/dev/dnpm/etl/processor/monitoring/Request.kt index a1f5c3d..67f450f 100644 --- a/src/main/kotlin/dev/dnpm/etl/processor/monitoring/Request.kt +++ b/src/main/kotlin/dev/dnpm/etl/processor/monitoring/Request.kt @@ -53,6 +53,7 @@ data class Request( @LastModifiedBy var updatedBy: String? = null, @Embedded.Nullable var report: Report? = null, @Column("submission_accepted") var submissionAccepted: Boolean = false, + @Column("followup_count") var followupCount: Int = 0, ) { constructor( uuid: RequestId, 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 4b7afff..00e6b73 100644 --- a/src/main/kotlin/dev/dnpm/etl/processor/services/RequestProcessor.kt +++ b/src/main/kotlin/dev/dnpm/etl/processor/services/RequestProcessor.kt @@ -120,14 +120,15 @@ class RequestProcessor( ) { requestService.save( Request( - request.requestId, - request.patientPseudonym(), - emptyPatientId(), - fingerprint(request), - RequestType.MTB_FILE, - submissionType, - RequestStatus.BLOCKED_INITIAL, - Tan(request.content.metadata?.transferTan.orEmpty()) + uuid = request.requestId, + patientPseudonym = request.patientPseudonym(), + pid = emptyPatientId(), + fingerprint = fingerprint(request), + type = RequestType.MTB_FILE, + submissionType = submissionType, + status = RequestStatus.BLOCKED_INITIAL, + tan = Tan(request.content.metadata?.transferTan.orEmpty()), + followupCount = request.content.followUps?.size ?: 0, ) ) // Exit - no further processing @@ -157,14 +158,15 @@ class RequestProcessor( requestService.save( Request( - request.requestId, - request.patientPseudonym(), - emptyPatientId(), - fingerprint(request), - RequestType.MTB_FILE, - submissionType, - RequestStatus.UNKNOWN, - Tan(request.content.metadata?.transferTan.orEmpty()), + uuid = request.requestId, + patientPseudonym = request.patientPseudonym(), + pid = emptyPatientId(), + fingerprint = fingerprint(request), + type = RequestType.MTB_FILE, + submissionType = submissionType, + status = RequestStatus.UNKNOWN, + tan = Tan(request.content.metadata?.transferTan.orEmpty()), + followupCount = request.content.followUps?.size ?: 0, ) ) @@ -207,7 +209,10 @@ class RequestProcessor( ?.sortedBy { it.date } ?.lastOrNull { it.date != null } ?: return false - return lastSuccessfulSubmission.processedAt.isBefore( lastFollowUp.date.toInstant()) + // Follow-up after last successful submission by date or ... + return lastSuccessfulSubmission.processedAt.isBefore(lastFollowUp.date.toInstant()) || + // ... more follow-ups than on last successful submission + lastSuccessfulSubmission.followupCount < (request.content.followUps?.size ?: 0) } private fun hasSuccessfulInitialSubmission(patientPseudonym: PatientPseudonym): Boolean { -- cgit v1.2.3