From eca93b0a76625893e29c835b37aa3a8effc4b8cd Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Tue, 20 Sep 2022 04:50:07 -0400 Subject: [PATCH] Fix NPE rendering terminology resources --- .../hl7/fhir/r5/renderers/TerminologyRenderer.java | 10 ++++++++-- .../org/hl7/fhir/r5/renderers/ValueSetRenderer.java | 2 +- .../hl7/fhir/r5/renderers/utils/RenderingContext.java | 11 ++++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/TerminologyRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/TerminologyRenderer.java index c8b2302ef..ad114701f 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/TerminologyRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/TerminologyRenderer.java @@ -34,6 +34,9 @@ import org.hl7.fhir.utilities.xhtml.XhtmlNode; public abstract class TerminologyRenderer extends ResourceRenderer { + private static final boolean DEBUG = false; + + public TerminologyRenderer(RenderingContext context) { super(context); } @@ -309,8 +312,11 @@ public abstract class TerminologyRenderer extends ResourceRenderer { a.tx("SNOMED-CT"); } else { - if (value.startsWith("http://hl7.org") && !Utilities.existsInList(value, "http://hl7.org/fhir/sid/icd-10-us")) - System.out.println("Unable to resolve value set "+value); + if (value.startsWith("http://hl7.org") && !Utilities.existsInList(value, "http://hl7.org/fhir/sid/icd-10-us")) { + if (DEBUG) { + System.out.println("Unable to resolve value set "+value); + } + } li.addText(value); } } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ValueSetRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ValueSetRenderer.java index 01a6a812e..7333c0175 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ValueSetRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ValueSetRenderer.java @@ -1292,7 +1292,7 @@ public class ValueSetRenderer extends TerminologyRenderer { for (ConceptReferenceComponent cc : inc.getConcept()) { String code = cc.getCode(); ConceptDefinitionComponent v = null; - if (e != null) { + if (e != null && code != null) { v = getConceptForCode(e.getConcept(), code); } if (v == null && vse != null) { diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/RenderingContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/RenderingContext.java index 370e4a2ad..ab59b006d 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/RenderingContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/RenderingContext.java @@ -134,6 +134,7 @@ public class RenderingContext { private DateTimeFormatter dateYearFormat; private DateTimeFormatter dateYearMonthFormat; private boolean copyButton; + private ProfileKnowledgeProvider pkp; /** * @@ -194,6 +195,7 @@ public class RenderingContext { res.locale = locale; res.showComments = showComments; res.copyButton = copyButton; + res.pkp = pkp; res.terminologyServiceOptions = terminologyServiceOptions.copy(); return res; @@ -210,7 +212,7 @@ public class RenderingContext { public ProfileUtilities getProfileUtilities() { if (profileUtilitiesR == null) { - profileUtilitiesR = new ProfileUtilities(worker, null, null); + profileUtilitiesR = new ProfileUtilities(worker, null, pkp); } return profileUtilitiesR; } @@ -608,5 +610,12 @@ public class RenderingContext { return this; } + public void setPkp(ProfileKnowledgeProvider pkp) { + this.pkp = pkp; + } + public ProfileKnowledgeProvider getPkp() { + return pkp; + } + } \ No newline at end of file