From db2c862b1e3134a9652f796c9e436e2ca749ccb8 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Thu, 13 Feb 2020 21:21:07 +1100 Subject: [PATCH] workaround NPE in summary renderer --- .../fhir/r5/conformance/ProfileUtilities.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java index c80cc3877..f2d8742ec 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java @@ -5311,14 +5311,18 @@ public class ProfileUtilities extends TranslatingUtilities { private String getCardinality(ElementDefinition ed, List list) { int min = ed.getMin(); int max = !ed.hasMax() || ed.getMax().equals("*") ? Integer.MAX_VALUE : Integer.parseInt(ed.getMax()); - while (ed != null && ed.getPath().contains(".")) { - ed = findParent(ed, list); - if (ed.getMax().equals("0")) - max = 0; - else if (!ed.getMax().equals("1") && !ed.hasSlicing()) - max = Integer.MAX_VALUE; - if (ed.getMin() == 0) - min = 0; + ElementDefinition ned = ed; + while (ned != null && ned.getPath().contains(".")) { + ned = findParent(ned, list); + if (ned != null) { // todo: this can happen if we've walked into a resoruce. Not sure what to about that? + if ("0".equals(ned.getMax())) + max = 0; + else if (!ned.getMax().equals("1") && !ned.hasSlicing()) + max = Integer.MAX_VALUE; + if (ned.getMin() == 0) { + min = 0; + } + } } return Integer.toString(min)+".."+(max == Integer.MAX_VALUE ? "*" : Integer.toString(max)); }