From b16cd39aa622f018e318ebef2006c517708cf06e Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Tue, 23 Jun 2026 14:47:18 +0200 Subject: feat: support for asynchronous follow-up count calculation (#300) This is required if async messaging is used. The request is already gone if response gets processed. Workflow: * Keep old followup_count * Add expected_followup_count * If: DNPM:DIP accepts the request - copy to to followup_count * Else: keep old followup_count This prevents from saving unaccepted follow-up counts.--- src/main/kotlin/dev/dnpm/etl/processor/monitoring/Request.kt | 1 + .../kotlin/dev/dnpm/etl/processor/services/RequestProcessor.kt | 10 ++++++++-- .../dev/dnpm/etl/processor/services/ResponseProcessor.kt | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src/main/kotlin') 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 67f450f..d62a503 100644 --- a/src/main/kotlin/dev/dnpm/etl/processor/monitoring/Request.kt +++ b/src/main/kotlin/dev/dnpm/etl/processor/monitoring/Request.kt @@ -54,6 +54,7 @@ data class Request( @Embedded.Nullable var report: Report? = null, @Column("submission_accepted") var submissionAccepted: Boolean = false, @Column("followup_count") var followupCount: Int = 0, + @Column("expected_followup_count") var expectedFollowupCount: 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 00e6b73..e545644 100644 --- a/src/main/kotlin/dev/dnpm/etl/processor/services/RequestProcessor.kt +++ b/src/main/kotlin/dev/dnpm/etl/processor/services/RequestProcessor.kt @@ -113,6 +113,10 @@ class RequestProcessor( } } + val maxFollowUpCount = this.requestService.allRequestsByPatientPseudonym(request.patientPseudonym()) + .maxByOrNull { it.followupCount } + ?.followupCount ?: -1 + if ( appConfigProperties.postInitialSubmissionBlock && hasSuccessfulInitialSubmission(request.patientPseudonym()) && @@ -128,7 +132,8 @@ class RequestProcessor( submissionType = submissionType, status = RequestStatus.BLOCKED_INITIAL, tan = Tan(request.content.metadata?.transferTan.orEmpty()), - followupCount = request.content.followUps?.size ?: 0, + followupCount = maxFollowUpCount, + expectedFollowupCount = request.content.followUps?.size ?: 0, ) ) // Exit - no further processing @@ -166,7 +171,8 @@ class RequestProcessor( submissionType = submissionType, status = RequestStatus.UNKNOWN, tan = Tan(request.content.metadata?.transferTan.orEmpty()), - followupCount = request.content.followUps?.size ?: 0, + followupCount = maxFollowUpCount, + expectedFollowupCount = request.content.followUps?.size ?: 0, ) ) diff --git a/src/main/kotlin/dev/dnpm/etl/processor/services/ResponseProcessor.kt b/src/main/kotlin/dev/dnpm/etl/processor/services/ResponseProcessor.kt index 947ec17..2818e00 100644 --- a/src/main/kotlin/dev/dnpm/etl/processor/services/ResponseProcessor.kt +++ b/src/main/kotlin/dev/dnpm/etl/processor/services/ResponseProcessor.kt @@ -53,10 +53,12 @@ class ResponseProcessor( Report( "Keine Probleme erkannt", ) + it.followupCount = it.expectedFollowupCount } RequestStatus.WARNING -> { it.report = Report("Warnungen über mangelhafte Daten", event.body.orElse("")) + it.followupCount = it.expectedFollowupCount } RequestStatus.ERROR -> { -- cgit v1.2.3