From 54eb35fa1a8766d199b15b4e881c166a716475e7 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Tue, 22 Aug 2023 21:46:47 +1000 Subject: [PATCH] fix bug with client sending too much data to tx.fhir.org --- .../org/hl7/fhir/r5/context/BaseWorkerContext.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java index 4e21702d9..74a596b0b 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java @@ -1499,7 +1499,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte boolean cache = false; for (CanonicalType c : inc.getValueSet()) { ValueSet vs = fetchResource(ValueSet.class, c.getValue(), src); - if (vs != null) { + if (vs != null && !hasCanonicalResource(pin, "tx-resource", vs.getVUrl())) { pin.addParameter().setName("tx-resource").setResource(vs); if (tcc.isTxCaching() && tcc.getCacheId() == null || !tcc.getCached().contains(vs.getVUrl())) { tcc.getCached().add(vs.getVUrl()); @@ -1509,7 +1509,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte } } CodeSystem cs = fetchResource(CodeSystem.class, inc.getSystem(), src); - if (cs != null && (cs.getContent() == CodeSystemContentMode.COMPLETE || cs.getContent() == CodeSystemContentMode.FRAGMENT)) { + if (cs != null && !hasCanonicalResource(pin, "tx-resource", cs.getVUrl()) && (cs.getContent() == CodeSystemContentMode.COMPLETE || cs.getContent() == CodeSystemContentMode.FRAGMENT)) { pin.addParameter().setName("tx-resource").setResource(cs); if (tcc.isTxCaching() && tcc.getCacheId() == null || !tcc.getCached().contains(cs.getVUrl())) { tcc.getCached().add(cs.getVUrl()); @@ -1520,6 +1520,16 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte return cache; } + private boolean hasCanonicalResource(Parameters pin, String name, String vUrl) { + for (ParametersParameterComponent p : pin.getParameter()) { + if (name.equals(p.getName()) && p.hasResource() && + p.getResource() instanceof CanonicalResource && vUrl.equals(((CanonicalResource) p.getResource()).getVUrl())) { + return true; + } + } + return false; + } + public ValidationResult processValidationResult(Parameters pOut, String vs) { boolean ok = false; String message = "No Message returned";