diff options
| author | Paul-Christian Volkmer | 2026-09-07 10:09:06 +0200 |
|---|---|---|
| committer | GitHub | 2026-09-07 10:09:06 +0200 |
| commit | 4de37a89c564292a95a2529aa2681ba5d7d5dbad (patch) | |
| tree | 99f85cc96099884e5e5b18d114afe11a4b51928b /src | |
| parent | a0b85ed6a990e8cf533be4ace3b1fabb5ad14d6f (diff) | |
feat: extract resource ID from URL if missing (#319)
This extracts FHIR resource ID from URL if ID is missing.
If there is also no URL, skip processing. No need to hash anything - but DNPM:DIP might not validate invalid bundles in later versions.
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/java/dev/dnpm/etl/processor/consent/GicsConsentService.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/java/dev/dnpm/etl/processor/consent/GicsConsentService.java b/src/main/java/dev/dnpm/etl/processor/consent/GicsConsentService.java index 35fc3be..4c8e820 100644 --- a/src/main/java/dev/dnpm/etl/processor/consent/GicsConsentService.java +++ b/src/main/java/dev/dnpm/etl/processor/consent/GicsConsentService.java @@ -380,6 +380,19 @@ public class GicsConsentService extends AbstractConsentService { private static void hashBundleEntry(Bundle.BundleEntryComponent entry) { String id = entry.getResource().getIdPart(); + + // Extract ID from FullUrl if ID is blank + if (id.isBlank() && entry.getFullUrl() != null && entry.getFullUrl().contains("/")) { + final var fullUrl = entry.getFullUrl(); + id = fullUrl.substring(fullUrl.lastIndexOf("/") + 1); + } + + // Still no ID found, skip processing - no hashing possible. + // DNPM:DIP might not validate this bundle in later versions + if (id.isBlank()) { + return; + } + var hash = DigestUtils.sha256Hex("%s_%s".formatted(Random.Default.toString(), id)); entry.getResource().setId(hash); |
