workaround NPE in summary renderer

This commit is contained in:
Grahame Grieve 2020-02-13 21:21:07 +11:00
parent 42853db493
commit db2c862b1e
1 changed files with 12 additions and 8 deletions

View File

@ -5311,14 +5311,18 @@ public class ProfileUtilities extends TranslatingUtilities {
private String getCardinality(ElementDefinition ed, List<ElementDefinition> list) { private String getCardinality(ElementDefinition ed, List<ElementDefinition> list) {
int min = ed.getMin(); int min = ed.getMin();
int max = !ed.hasMax() || ed.getMax().equals("*") ? Integer.MAX_VALUE : Integer.parseInt(ed.getMax()); int max = !ed.hasMax() || ed.getMax().equals("*") ? Integer.MAX_VALUE : Integer.parseInt(ed.getMax());
while (ed != null && ed.getPath().contains(".")) { ElementDefinition ned = ed;
ed = findParent(ed, list); while (ned != null && ned.getPath().contains(".")) {
if (ed.getMax().equals("0")) ned = findParent(ned, list);
max = 0; if (ned != null) { // todo: this can happen if we've walked into a resoruce. Not sure what to about that?
else if (!ed.getMax().equals("1") && !ed.hasSlicing()) if ("0".equals(ned.getMax()))
max = Integer.MAX_VALUE; max = 0;
if (ed.getMin() == 0) else if (!ned.getMax().equals("1") && !ned.hasSlicing())
min = 0; max = Integer.MAX_VALUE;
if (ned.getMin() == 0) {
min = 0;
}
}
} }
return Integer.toString(min)+".."+(max == Integer.MAX_VALUE ? "*" : Integer.toString(max)); return Integer.toString(min)+".."+(max == Integer.MAX_VALUE ? "*" : Integer.toString(max));
} }