From 1ff49fd83150f48886439f7f83cca729ab44e2c4 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 26 Feb 2025 15:37:26 +1100 Subject: [PATCH] Fix consistency problem in name presentation generating slices --- .../StructureDefinitionComparer.java | 4 ++-- .../r5/renderers/ProfileDrivenRenderer.java | 2 -- .../StructureDefinitionRenderer.java | 22 ++++++++++++------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/StructureDefinitionComparer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/StructureDefinitionComparer.java index bc2824fdc3..90a0f118b8 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/StructureDefinitionComparer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/StructureDefinitionComparer.java @@ -1338,12 +1338,12 @@ else if (isDataType(combined)) nc = sdrRight.genElementNameCell(gen, combined.getRight().getDef(), "??", true, corePath, prefix, root, false, false, combined.getRight().getSrc(), typesRow, row, false, ext, used , ref, sName, null); } if (combined.hasLeft()) { - frame(sdrLeft.genElementCells(new RenderingStatus(), gen, combined.getLeft().getDef(), "??", true, corePath, prefix, root, false, false, combined.getLeft().getSrc(), typesRow, row, true, ext, used , ref, sName, nc, false, false, sdrLeft.getContext(), children.size() > 0, defPath, anchorPrefix, new ArrayList(), null), leftColor); + frame(sdrLeft.genElementCells(new RenderingStatus(), gen, combined.getLeft().getDef(), "??", true, corePath, prefix, root, false, false, combined.getLeft().getSrc(), typesRow, row, true, ext, used , ref, nc, false, false, sdrLeft.getContext(), children.size() > 0, defPath, anchorPrefix, new ArrayList(), null), leftColor); } else { frame(spacers(row, 4, gen), leftColor); } if (combined.hasRight()) { - frame(sdrRight.genElementCells(new RenderingStatus(), gen, combined.getRight().getDef(), "??", true, corePath, prefix, root, false, false, combined.getRight().getSrc(), typesRow, row, true, ext, used, ref, sName, nc, false, false, sdrRight.getContext(), children.size() > 0, defPath, anchorPrefix, new ArrayList(), null), rightColor); + frame(sdrRight.genElementCells(new RenderingStatus(), gen, combined.getRight().getDef(), "??", true, corePath, prefix, root, false, false, combined.getRight().getSrc(), typesRow, row, true, ext, used, ref, nc, false, false, sdrRight.getContext(), children.size() > 0, defPath, anchorPrefix, new ArrayList(), null), rightColor); } else { frame(spacers(row, 4, gen), rightColor); } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ProfileDrivenRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ProfileDrivenRenderer.java index cc94029ab8..5efdc0e5f0 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ProfileDrivenRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ProfileDrivenRenderer.java @@ -68,8 +68,6 @@ public String buildSummary(ResourceWrapper res) throws UnsupportedEncodingExcept if (profile == null) return "unknown resource type " +res.fhirType(); else { - boolean firstElement = true; - boolean last = false; List children = res.children(); ContextUtilities cu = res.getContextUtilities(); for (ResourceWrapper p : children) { diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/StructureDefinitionRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/StructureDefinitionRenderer.java index f81b0c33d0..7545b6eaef 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/StructureDefinitionRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/StructureDefinitionRenderer.java @@ -384,7 +384,8 @@ public String display(StructureDefinition sd) { public static final String RIM_MAPPING = "http://hl7.org/v3"; public static final String v2_MAPPING = "http://hl7.org/v2"; public static final String LOINC_MAPPING = "http://loinc.org"; - public static final String SNOMED_MAPPING = "http://snomed.info"; + public static final String SNOMED_MAPPING = "http://snomed.info"; + private static final boolean PREFIX_SLICES = true; private final boolean ADD_REFERENCE_TO_TABLE = true; @@ -819,10 +820,15 @@ else if (element.hasSliceName()) } UnusedTracker used = new UnusedTracker(); String ref = defPath == null ? null : defPath + element.getId(); - String sName = tail(element.getPath()); - if (element.hasSliceName()) { - sName = sName +":"+element.getSliceName(); - } + String sName = null; + if (PREFIX_SLICES) { + sName = tail(element.getPath()); + if (element.hasSliceName()) { + sName = sName + ":" + element.getSliceName(); + } + } else { + sName = element.hasSliceName() ? element.getSliceName() : tail(element.getPath()); + } used.used = true; if (logicalModel) { if (element.hasRepresentation(PropertyRepresentation.XMLATTR)) { @@ -843,7 +849,7 @@ else if (element.hasSliceName()) genElementObligations(gen, element, columns, row, corePath, profile); break; case SUMMARY: - genElementCells(status, gen, element, profileBaseFileName, snapshot, corePath, imagePath, root, logicalModel, allInvariants, profile, typesRow, row, hasDef, ext, used, ref, sName, nc, mustSupport, true, rc, children.size() > 0, defPath, anchorPrefix, all, res); + genElementCells(status, gen, element, profileBaseFileName, snapshot, corePath, imagePath, root, logicalModel, allInvariants, profile, typesRow, row, hasDef, ext, used, ref, nc, mustSupport, true, rc, children.size() > 0, defPath, anchorPrefix, all, res); break; } if (element.hasSlicing()) { @@ -1132,7 +1138,7 @@ public Cell genElementNameCell(HierarchicalTableGenerator gen, ElementDefinition public List genElementCells(RenderingStatus status, HierarchicalTableGenerator gen, ElementDefinition element, String profileBaseFileName, boolean snapshot, String corePath, String imagePath, boolean root, boolean logicalModel, boolean allInvariants, StructureDefinition profile, Row typesRow, Row row, boolean hasDef, - boolean ext, UnusedTracker used, String ref, String sName, Cell nameCell, boolean mustSupport, boolean allowSubRows, RenderingContext rc, boolean walksIntoThis, String defPath, String anchorPrefix, List inScopeElements, ResourceWrapper resource) throws IOException { + boolean ext, UnusedTracker used, String ref, Cell nameCell, boolean mustSupport, boolean allowSubRows, RenderingContext rc, boolean walksIntoThis, String defPath, String anchorPrefix, List inScopeElements, ResourceWrapper resource) throws IOException { List res = new ArrayList<>(); Cell gc = gen.new Cell(); row.getCells().add(gc); @@ -1178,7 +1184,7 @@ public List genElementCells(RenderingStatus status, HierarchicalTableGener res.add(generateDescription(status, gen, row, element, (ElementDefinition) element.getUserData(UserDataNames.SNAPSHOT_DERIVATION_POINTER), used.used, profile == null ? "" : profile.getUrl(), eurl, profile, corePath, imagePath, root, logicalModel, allInvariants, snapshot, mustSupport, allowSubRows, rc, inScopeElements, resource)); } else { String name = element.hasSliceName() ? element.getSliceName() : urltail(eurl); - nameCell.getPieces().get(0).setText(name); +// disable 26-02-2025 GDG - this just makes things inconsistent, and why do this? nameCell.getPieces().get(0).setText(name); // left.getPieces().get(0).setReference((String) extDefn.getExtensionStructure().getTag("filename")); nameCell.getPieces().get(0).setHint((context.formatPhrase(RenderingContext.STRUC_DEF_EX_URL, extDefn.getUrl()))); res.add(genCardinality(gen, element, row, hasDef, used, extDefn.getElement()));