From 0ae1ade035c78b575629dec68eb3c17ec15168bc Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Tue, 17 Dec 2019 13:46:47 +1100 Subject: [PATCH] fix rendering of logical models, + fix bugs in FHIRPath type resolution --- .../fhir/r5/conformance/ProfileUtilities.java | 16 +++++++++++++--- .../org/hl7/fhir/r5/utils/FHIRPathEngine.java | 2 +- 2 files changed, 14 insertions(+), 4 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 64b0a288f..90f7bb284 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 @@ -2533,8 +2533,11 @@ public class ProfileUtilities extends TranslatingUtilities { r.setIcon(deep ? "icon_"+m+"extension_complex.png" : "icon_extension_simple.png", deep ? HierarchicalTableGenerator.TEXT_ICON_EXTENSION_COMPLEX : HierarchicalTableGenerator.TEXT_ICON_EXTENSION_SIMPLE); List children = getChildren(ed.getSnapshot().getElement(), ed.getSnapshot().getElement().get(0)); for (ElementDefinition child : children) - if (!child.getPath().endsWith(".id")) - genElement(defFile == null ? "" : defFile+"-definitions.html#extension.", gen, r.getSubRows(), child, ed.getSnapshot().getElement(), null, true, defFile, true, full, corePath, imagePath, true, false, false, false, null); + if (!child.getPath().endsWith(".id")) { + List sdl = new ArrayList<>(); + sdl.add(ed); + genElement(defFile == null ? "" : defFile+"-definitions.html#extension.", gen, r.getSubRows(), child, ed.getSnapshot().getElement(), sdl, true, defFile, true, full, corePath, imagePath, true, false, false, false, null); + } } else if (deep) { List children = new ArrayList(); for (ElementDefinition ted : ed.getSnapshot().getElement()) { @@ -2704,7 +2707,14 @@ public class ProfileUtilities extends TranslatingUtilities { c.addPiece(checkForNoChange(t, gen.new Piece((t.getProfile().get(0).getValue().startsWith(corePath)? corePath: "")+ref, t.getWorkingCode(), null))); } else { String tc = t.getWorkingCode(); - if (pkp != null && pkp.hasLinkFor(tc)) { + if (Utilities.isAbsoluteUrl(tc)) { + StructureDefinition sd = context.fetchTypeDefinition(tc); + if (sd == null) { + c.addPiece(checkForNoChange(t, gen.new Piece(pkp.getLinkFor(corePath, tc), tc, null))); + } else { + c.addPiece(checkForNoChange(t, gen.new Piece(pkp.getLinkFor(corePath, tc), sd.getName(), null))); + } + } else if (pkp != null && pkp.hasLinkFor(tc)) { c.addPiece(checkForNoChange(t, gen.new Piece(pkp.getLinkFor(corePath, tc), tc, null))); } else c.addPiece(checkForNoChange(t, gen.new Piece(null, tc, null))); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java index e0f115f6b..501379c4b 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java @@ -397,7 +397,7 @@ public class FHIRPathEngine { if (context == null) { types = null; // this is a special case; the first path reference will have to resolve to something in the context } else if (!context.contains(".")) { - StructureDefinition sd = worker.fetchResource(StructureDefinition.class, context); + StructureDefinition sd = worker.fetchTypeDefinition(context); types = new TypeDetails(CollectionStatus.SINGLETON, sd.getUrl()); } else { String ctxt = context.substring(0, context.indexOf('.'));