summaryrefslogtreecommitdiff
path: root/src/main/kotlin/dev/dnpm/etl
diff options
context:
space:
mode:
authorPaul-Christian Volkmer2026-06-23 14:47:18 +0200
committerGitHub2026-06-23 12:47:18 +0000
commitb16cd39aa622f018e318ebef2006c517708cf06e (patch)
tree9030296dd05dc8c543b35732a78dc1b2995040e2 /src/main/kotlin/dev/dnpm/etl
parentd0fc0ed8eff036c0c01247e638625cdfef118efd (diff)
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.
Diffstat (limited to 'src/main/kotlin/dev/dnpm/etl')
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/monitoring/Request.kt1
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/services/RequestProcessor.kt10
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/services/ResponseProcessor.kt2
3 files changed, 11 insertions, 2 deletions
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 -> {