From c2fb9e8fd3d2cebbeb9ff623d5dd1e2f525ee3c4 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 25 Sep 2020 03:25:09 +1000 Subject: [PATCH] Add rendering for must support on types, profiles, targets --- .../fhir/r5/conformance/ProfileUtilities.java | 80 ++++++++++++++++--- .../hl7/fhir/r5/utils/ToolingExtensions.java | 3 + 2 files changed, 72 insertions(+), 11 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 532fef47d..fbb99dd77 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 @@ -3245,14 +3245,22 @@ public class ProfileUtilities extends TranslatingUtilities { tl = t; if (t.hasTarget()) { c.getPieces().add(gen.new Piece(corePath+"references.html", t.getWorkingCode(), null)); + if (isMustSupportDirect(t) && e.getMustSupport()) { + c.addPiece(gen.new Piece(null, " ", null)); + c.addStyledText(translate("sd.table", "This type must be supported"), "S", "white", "red", null, false); + } c.getPieces().add(gen.new Piece(null, "(", null)); boolean tfirst = true; - for (UriType u : t.getTargetProfile()) { + for (CanonicalType u : t.getTargetProfile()) { if (tfirst) tfirst = false; else c.addPiece(gen.new Piece(null, " | ", null)); genTargetLink(gen, profileBaseFileName, corePath, c, t, u.getValue()); + if (isMustSupport(u) && e.getMustSupport()) { + c.addPiece(gen.new Piece(null, " ", null)); + c.addStyledText(translate("sd.table", "This target must be supported"), "S", "white", "red", null, false); + } } c.getPieces().add(gen.new Piece(null, ")", null)); if (t.getAggregation().size() > 0) { @@ -3289,6 +3297,10 @@ public class ProfileUtilities extends TranslatingUtilities { } } else c.addPiece(checkForNoChange(t, gen.new Piece((p.getValue().startsWith(corePath)? corePath: "")+ref, t.getWorkingCode(), null))); + if (isMustSupport(p) && e.getMustSupport()) { + c.addPiece(gen.new Piece(null, " ", null)); + c.addStyledText(translate("sd.table", "This profile must be supported"), "S", "white", "red", null, false); + } } } else { String tc = t.getWorkingCode(); @@ -3301,8 +3313,13 @@ public class ProfileUtilities extends TranslatingUtilities { } } else if (pkp != null && pkp.hasLinkFor(tc)) { c.addPiece(checkForNoChange(t, gen.new Piece(pkp.getLinkFor(corePath, tc), tc, null))); - } else + } else { c.addPiece(checkForNoChange(t, gen.new Piece(null, tc, null))); + } + if (isMustSupportDirect(t) && e.getMustSupport()) { + c.addPiece(gen.new Piece(null, " ", null)); + c.addStyledText(translate("sd.table", "This type must be supported"), "S", "white", "red", null, false); + } } } return c; @@ -3931,6 +3948,10 @@ public class ProfileUtilities extends TranslatingUtilities { c.getPieces().add(gen.new Piece(corePath+"datatypes.html#canonical", "canonical", null)); else c.getPieces().add(gen.new Piece(corePath+"references.html#Reference", "Reference", null)); + if (isMustSupportDirect(tr) && element.getMustSupport()) { + c.addPiece(gen.new Piece(null, " ", null)); + c.addStyledText(translate("sd.table", "This type must be supported"), "S", "white", "red", null, false); + } c.getPieces().add(gen.new Piece(null, "(", null)); } boolean first = true; @@ -3938,6 +3959,10 @@ public class ProfileUtilities extends TranslatingUtilities { if (!first) c.getPieces().add(gen.new Piece(null, " | ", null)); genTargetLink(gen, profileBaseFileName, corePath, c, tr, rt.getValue()); + if (isMustSupport(rt) && element.getMustSupport()) { + c.addPiece(gen.new Piece(null, " ", null)); + c.addStyledText(translate("sd.table", "This target must be supported"), "S", "white", "red", null, false); + } first = false; } if (first) @@ -3956,20 +3981,23 @@ public class ProfileUtilities extends TranslatingUtilities { choicerow.getCells().add(gen.new Cell()); choicerow.getCells().add(gen.new Cell(null, null, "", null, null)); choicerow.setIcon("icon_primitive.png", HierarchicalTableGenerator.TEXT_ICON_PRIMITIVE); - choicerow.getCells().add(gen.new Cell(null, corePath+"datatypes.html#"+t, sd.getType(), null, null)); - // } else if (definitions.getConstraints().contthnsKey(t)) { - // ProfiledType pt = definitions.getConstraints().get(t); - // choicerow.getCells().add(gen.new Cell(null, null, e.getName().replace("[x]", Utilities.capitalize(pt.getBaseType())), definitions.getTypes().containsKey(t) ? definitions.getTypes().get(t).getDefinition() : null, null)); - // choicerow.getCells().add(gen.new Cell()); - // choicerow.getCells().add(gen.new Cell(null, null, "", null, null)); - // choicerow.setIcon("icon_datatype.gif", HierarchicalTableGenerator.TEXT_ICON_DATATYPE); - // choicerow.getCells().add(gen.new Cell(null, definitions.getSrcFile(t)+".html#"+t.replace("*", "open"), t, null, null)); + Cell c = gen.new Cell(null, corePath+"datatypes.html#"+t, sd.getType(), null, null); + choicerow.getCells().add(c); + if (isMustSupport(tr) && element.getMustSupport()) { + c.addPiece(gen.new Piece(null, " ", null)); + c.addStyledText(translate("sd.table", "This type must be supported"), "S", "white", "red", null, false); + } } else { choicerow.getCells().add(gen.new Cell(null, null, tail(element.getPath()).replace("[x]", Utilities.capitalize(t)), sd.getDescription(), null)); choicerow.getCells().add(gen.new Cell()); choicerow.getCells().add(gen.new Cell(null, null, "", null, null)); choicerow.setIcon("icon_datatype.gif", HierarchicalTableGenerator.TEXT_ICON_DATATYPE); - choicerow.getCells().add(gen.new Cell(null, pkp.getLinkFor(corePath, t), sd.getType(), null, null)); + Cell c = gen.new Cell(null, pkp.getLinkFor(corePath, t), sd.getType(), null, null); + choicerow.getCells().add(c); + if (isMustSupport(tr) && element.getMustSupport()) { + c.addPiece(gen.new Piece(null, " ", null)); + c.addStyledText(translate("sd.table", "This type must be supported"), "S", "white", "red", null, false); + } } if (tr.hasProfile()) { Cell typeCell = choicerow.getCells().get(3); @@ -3982,6 +4010,10 @@ public class ProfileUtilities extends TranslatingUtilities { typeCell.addPiece(gen.new Piece(null, "?gen-e2?", null)); else typeCell.addPiece(gen.new Piece(psd.getUserString("path"), psd.getName(), psd.present())); + if (isMustSupport(pt) && element.getMustSupport()) { + typeCell.addPiece(gen.new Piece(null, " ", null)); + typeCell.addStyledText(translate("sd.table", "This profile must be supported"), "S", "white", "red", null, false); + } } typeCell.addPiece(gen.new Piece(null, ")", null)); @@ -6177,6 +6209,32 @@ public class ProfileUtilities extends TranslatingUtilities { return grp; } + public static boolean isMustSupportDirect(TypeRefComponent tr) { + return ("true".equals(ToolingExtensions.readStringExtension(tr, ToolingExtensions.EXT_MUST_SUPPORT))); + } + public static boolean isMustSupport(TypeRefComponent tr) { + if ("true".equals(ToolingExtensions.readStringExtension(tr, ToolingExtensions.EXT_MUST_SUPPORT))) { + return true; + } + if (isMustSupport(tr.getProfile())) { + return true; + } + return isMustSupport(tr.getTargetProfile()); + } + + public static boolean isMustSupport(List profiles) { + for (CanonicalType ct : profiles) { + if (isMustSupport(ct)) { + return true; + } + } + return false; + } + + + public static boolean isMustSupport(CanonicalType profile) { + return "true".equals(ToolingExtensions.readStringExtension(profile, ToolingExtensions.EXT_MUST_SUPPORT)); + } } \ No newline at end of file diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java index 40f5f73f6..175fec654 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java @@ -180,6 +180,7 @@ public class ToolingExtensions { public static final String EXT_OLD_CONCEPTMAP_EQUIVALENCE = "http://hl7.org/fhir/1.0/StructureDefinition/extension-ConceptMap.element.target.equivalence"; public static final String EXT_EXP_FRAGMENT = "http://hl7.org/fhir/tools/StructureDefinition/expansion-codesystem-fragment"; public static final String EXT_EXP_TOOCOSTLY = "http://hl7.org/fhir/StructureDefinition/valueset-toocostly"; + public static final String EXT_MUST_SUPPORT = "http://hl7.org/fhir/StructureDefinition/elementdefinition-type-must-support"; // specific extension helpers @@ -335,6 +336,8 @@ public class ToolingExtensions { return ((DecimalType) ex.getValue()).asStringValue(); if ((ex.getValue() instanceof MarkdownType)) return ((MarkdownType) ex.getValue()).getValue(); + if ((ex.getValue() instanceof PrimitiveType)) + return ((PrimitiveType) ex.getValue()).primitiveValue(); if (!(ex.getValue() instanceof StringType)) return null; return ((StringType) ex.getValue()).getValue();