From 126ce65e344dbf8a7f4c2a4b2303312e5b0ca6e0 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Mon, 7 Sep 2026 11:03:35 +0200 Subject: fix: handle possible missing start/end in FHIR period (#320) --- .../dev/dnpm/etl/processor/services/ConsentProcessor.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/main') diff --git a/src/main/kotlin/dev/dnpm/etl/processor/services/ConsentProcessor.kt b/src/main/kotlin/dev/dnpm/etl/processor/services/ConsentProcessor.kt index 5a31b42..f7df389 100644 --- a/src/main/kotlin/dev/dnpm/etl/processor/services/ConsentProcessor.kt +++ b/src/main/kotlin/dev/dnpm/etl/processor/services/ConsentProcessor.kt @@ -325,7 +325,18 @@ class ConsentProcessor( } } + /** + * Checks if the given request date is within the range specified by the provided period. + * + * @param requestDate The date to check, can be null. + * @param provPeriod The period containing the start and end dates for the range, where both `start` and `end` must not be null. + * @return `true` if the request date is within the range (inclusive of start and end), otherwise `false`. + */ fun isRequestDateInRange(requestDate: Date?, provPeriod: Period): Boolean { + if (null == requestDate || null == provPeriod.start || null == provPeriod.end) { + return false + } + val isRequestDateAfterOrEqualStart = provPeriod.start.compareTo(requestDate) val isRequestDateBeforeOrEqualEnd = provPeriod.end.compareTo(requestDate) return isRequestDateAfterOrEqualStart <= 0 && isRequestDateBeforeOrEqualEnd >= 0 -- cgit v1.2.3