From 809b2f68ea627b6adb1d21ec48c080004163653c Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Tue, 31 Oct 2023 16:57:25 +1100 Subject: [PATCH] Fix broken links in code system rendering of parents --- .../org/hl7/fhir/r4/context/BaseWorkerContext.java | 10 ++++++---- .../org/hl7/fhir/r4b/context/BaseWorkerContext.java | 12 +++++++----- .../org/hl7/fhir/r5/context/BaseWorkerContext.java | 12 +++++++----- .../hl7/fhir/r5/renderers/CodeSystemRenderer.java | 2 +- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/BaseWorkerContext.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/BaseWorkerContext.java index 31ffcf5aa..46c29efac 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/BaseWorkerContext.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/BaseWorkerContext.java @@ -469,10 +469,12 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte tlog("$expand on " + txCache.summary(vs)); try { ValueSet result = txClient.expandValueset(vs, p, params); - if (!result.hasUrl()) - result.setUrl(vs.getUrl()); - if (!result.hasUrl()) - throw new Error("no url in expand value set 2"); + if (result != null) { + if (!result.hasUrl()) + result.setUrl(vs.getUrl()); + if (!result.hasUrl()) + throw new Error("no url in expand value set 2"); + } res = new ValueSetExpansionOutcome(result).setTxLink(txLog.getLastId()); } catch (Exception e) { res = new ValueSetExpansionOutcome(e.getMessage() == null ? e.getClass().getName() : e.getMessage(), diff --git a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/context/BaseWorkerContext.java b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/context/BaseWorkerContext.java index 1b1e7c27b..a3e4a6fd8 100644 --- a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/context/BaseWorkerContext.java +++ b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/context/BaseWorkerContext.java @@ -805,11 +805,13 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte tlog("$expand on " + txCache.summary(vs)); try { ValueSet result = txClient.expandValueset(vs, p, params); - if (!result.hasUrl()) { - result.setUrl(vs.getUrl()); - } - if (!result.hasUrl()) { - throw new Error(formatMessage(I18nConstants.NO_URL_IN_EXPAND_VALUE_SET_2)); + if (result != null) { + if (!result.hasUrl()) { + result.setUrl(vs.getUrl()); + } + if (!result.hasUrl()) { + throw new Error(formatMessage(I18nConstants.NO_URL_IN_EXPAND_VALUE_SET_2)); + } } res = new ValueSetExpansionOutcome(result).setTxLink(txLog.getLastId()); } catch (Exception e) { 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 e5b80fd8d..4ac5070f1 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 @@ -952,11 +952,13 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte txLog("$expand on "+txCache.summary(vs)); try { ValueSet result = tcc.getClient().expandValueset(vs, p, params); - if (!result.hasUrl()) { - result.setUrl(vs.getUrl()); - } - if (!result.hasUrl()) { - throw new Error(formatMessage(I18nConstants.NO_URL_IN_EXPAND_VALUE_SET_2)); + if (result != null) { + if (!result.hasUrl()) { + result.setUrl(vs.getUrl()); + } + if (!result.hasUrl()) { + throw new Error(formatMessage(I18nConstants.NO_URL_IN_EXPAND_VALUE_SET_2)); + } } res = new ValueSetExpansionOutcome(result).setTxLink(txLog.getLastId()); } catch (Exception e) { diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/CodeSystemRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/CodeSystemRenderer.java index d4d0994d0..e84e767ac 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/CodeSystemRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/CodeSystemRenderer.java @@ -542,7 +542,7 @@ public class CodeSystemRenderer extends TerminologyRenderer { } else if (pcv.hasValueStringType() && Utilities.isAbsoluteUrlLinkable(pcv.getValue().primitiveValue())) { td.ah(pcv.getValue().primitiveValue()).tx(pcv.getValue().primitiveValue()); } else if ("parent".equals(pcv.getCode())) { - td.ah("#"+cs.getId()+"-"+pcv.getValue().primitiveValue()).addText(pcv.getValue().primitiveValue()); + td.ah("#"+cs.getId()+"-"+Utilities.nmtokenize(pcv.getValue().primitiveValue())).addText(pcv.getValue().primitiveValue()); } else { td.addText(pcv.getValue().primitiveValue()); }