From 77e771af2ab4e059a5324d9b5583d2a310c7ca85 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 29 Mar 2023 15:02:45 +1100 Subject: [PATCH 1/8] Fix up URLs for untouched elements when generating --- .../hl7/fhir/r5/conformance/profile/ProfilePathProcessor.java | 1 + 1 file changed, 1 insertion(+) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/profile/ProfilePathProcessor.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/profile/ProfilePathProcessor.java index 2c51968a8..f295632cf 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/profile/ProfilePathProcessor.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/profile/ProfilePathProcessor.java @@ -725,6 +725,7 @@ public class ProfilePathProcessor { outcome.setPath(profileUtilities.fixedPathDest(getContextPathTarget(), outcome.getPath(), getRedirector(), getContextPathSource())); profileUtilities.updateFromBase(outcome, currentBase, getSourceStructureDefinition().getUrl()); profileUtilities.updateConstraintSources(outcome, getSourceStructureDefinition().getUrl()); + profileUtilities.updateURLs(url, webUrl, outcome); profileUtilities.markDerived(outcome); if (cursors.resultPathBase == null) cursors.resultPathBase = outcome.getPath(); From d82bec0f907bac6a935a1064fa0983e4cae5062d Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 29 Mar 2023 15:03:08 +1100 Subject: [PATCH 2/8] Add binding.description to markdown fields that get their URLs processed --- .../r5/conformance/profile/ProfileUtilities.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/profile/ProfileUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/profile/ProfileUtilities.java index 918535e4e..2ea201427 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/profile/ProfileUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/profile/ProfileUtilities.java @@ -1651,14 +1651,21 @@ public class ProfileUtilities extends TranslatingUtilities { } if (webUrl != null) { // also, must touch up the markdown - if (element.hasDefinition()) + if (element.hasDefinition()) { element.setDefinition(processRelativeUrls(element.getDefinition(), webUrl, context.getSpecUrl(), context.getResourceNames(), masterSourceFileNames, null, false)); - if (element.hasComment()) + } + if (element.hasComment()) { element.setComment(processRelativeUrls(element.getComment(), webUrl, context.getSpecUrl(), context.getResourceNames(), masterSourceFileNames, null, false)); - if (element.hasRequirements()) + } + if (element.hasRequirements()) { element.setRequirements(processRelativeUrls(element.getRequirements(), webUrl, context.getSpecUrl(), context.getResourceNames(), masterSourceFileNames, null, false)); - if (element.hasMeaningWhenMissing()) + } + if (element.hasMeaningWhenMissing()) { element.setMeaningWhenMissing(processRelativeUrls(element.getMeaningWhenMissing(), webUrl, context.getSpecUrl(), context.getResourceNames(), masterSourceFileNames, null, false)); + } + if (element.hasBinding() && element.getBinding().hasDescription()) { + element.getBinding().setDescription(processRelativeUrls(element.getBinding().getDescription(), webUrl, context.getSpecUrl(), context.getResourceNames(), masterSourceFileNames, null, false)); + } } } return element; @@ -2335,6 +2342,7 @@ public class ProfileUtilities extends TranslatingUtilities { if (dest.hasPattern()) { checkTypeOk(dest, dest.getPattern().fhirType(), srcSD, "pattern"); } + //updateURLs(url, webUrl, dest); } private void addMappings(List destination, List source) { From 25d7affba47118090280605a90d5386f809cd50a Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 29 Mar 2023 15:05:50 +1100 Subject: [PATCH 3/8] fix up R5 paths that are wrong in Extensions package --- .../java/org/hl7/fhir/r5/utils/R5Hacker.java | 45 ++++--------------- 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/R5Hacker.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/R5Hacker.java index 31345c245..cc55c1534 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/R5Hacker.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/R5Hacker.java @@ -4,6 +4,7 @@ import org.hl7.fhir.r5.context.IWorkerContext; import org.hl7.fhir.r5.model.CanonicalResource; import org.hl7.fhir.r5.model.ElementDefinition; import org.hl7.fhir.r5.model.Enumerations.BindingStrength; +import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule; import org.hl7.fhir.r5.model.StructureDefinition; public class R5Hacker { @@ -16,50 +17,22 @@ public class R5Hacker { private static void fixSD(StructureDefinition sd) { - if ("5.0.0-ballot".equals(sd.getVersion()) && "ElementDefinition".equals(sd.getType())) { + if (sd.getDerivation() == TypeDerivationRule.CONSTRAINT) { for (ElementDefinition ed : sd.getDifferential().getElement()) { - hackEDR5BallotError(ed); + fix(ed); } for (ElementDefinition ed : sd.getSnapshot().getElement()) { - hackEDR5BallotError(ed); + fix(ed); } } - if ("5.0.0-ballot".equals(sd.getVersion()) && "Base".equals(sd.getType())) { - for (ElementDefinition ed : sd.getDifferential().getElement()) { - hackBaseR5BallotError(ed); - } - for (ElementDefinition ed : sd.getSnapshot().getElement()) { - hackBaseR5BallotError(ed); - } - } - if ("5.0.0-ballot".equals(sd.getVersion()) && "Bundle".equals(sd.getType())) { - for (ElementDefinition ed : sd.getDifferential().getElement()) { - hackBundleR5BallotError(ed); - } - for (ElementDefinition ed : sd.getSnapshot().getElement()) { - hackBundleR5BallotError(ed); - } - } - if ("5.0.0-ballot".equals(sd.getVersion()) && "http://hl7.org/fhir/StructureDefinition/elementdefinition-defaulttype".equals(sd.getUrl())) { - sd.getContextFirstRep().setExpression("ElementDefinition"); - } } - private static void hackBaseR5BallotError(ElementDefinition ed) { - ed.getConstraint().clear(); - } - - private static void hackBundleR5BallotError(ElementDefinition ed) { - if (ed.getPath().equals("Bundle.link.relation")) { - ToolingExtensions.removeExtension(ed.getBinding(), ToolingExtensions.EXT_BINDING_NAME); - } - } - - private static void hackEDR5BallotError(ElementDefinition ed) { - if (ed.getPath().equals("ElementDefinition.type.code")) { - ed.getBinding().setStrength(BindingStrength.EXTENSIBLE); - } + private static void fix(ElementDefinition ed) { + if (ed.hasDefinition()) { + ed.setDefinition(ed.getDefinition().replace("http://hl7.org/fhir/5.0.0-snapshot3/", "http://hl7.org/fhir/R5/")); + } + } From 0233e48a1c72a5359a3d501735f5a9c6ea4dd55b Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 29 Mar 2023 15:06:24 +1100 Subject: [PATCH 4/8] suppress prism if ttl source is too big --- .../src/main/java/org/hl7/fhir/utilities/turtle/Turtle.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/turtle/Turtle.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/turtle/Turtle.java index 59fd5e916..91aed55bb 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/turtle/Turtle.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/turtle/Turtle.java @@ -415,14 +415,14 @@ public class Turtle { writer.close(); } - public String asHtml() throws Exception { + public String asHtml(boolean prism) throws Exception { StringBuilder b = new StringBuilder(); - b.append("
\r\n");
+    b.append("
"+(prism ? "" : "")+"\r\n");
     commitPrefixes(b);
     for (Section s : sections) {
       commitSection(b, s);
     }
-    b.append("
\r\n"); + b.append((prism ? "
" : "")+"
\r\n"); b.append("\r\n"); return b.toString(); } From 520d13ab5135bad2098960383831a19fa336dfd0 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 29 Mar 2023 15:06:35 +1100 Subject: [PATCH 5/8] fix R5 path for spec --- .../src/main/java/org/hl7/fhir/utilities/VersionUtilities.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtilities.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtilities.java index d29a849b2..4a31d736b 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtilities.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtilities.java @@ -598,7 +598,7 @@ public class VersionUtilities { case "3.0" : return "http://hl7.org/fhir/STU3"; case "4.0" : return "http://hl7.org/fhir/R4"; case "4.3" : return "http://hl7.org/fhir/R4B"; - case "5.0" : return "http://hl7.org/fhir/5.0.0-snapshot3"; + case "5.0" : return "http://hl7.org/fhir/R5"; default: return "http://hl7.org/fhir"; } From d7817c785a66cc501aeb8fea35da29da35453403 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 29 Mar 2023 15:06:59 +1100 Subject: [PATCH 6/8] XML utils - add tag --- .../main/java/org/hl7/fhir/utilities/xml/XMLUtil.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLUtil.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLUtil.java index e2b6f6679..c70e2d2f4 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLUtil.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLUtil.java @@ -563,6 +563,15 @@ public class XMLUtil { child.setAttribute("value", text); } + public static Element addTextTag(Document doc, Element element, String name, String text, int indent) { + Node node = doc.createTextNode("\n"+Utilities.padLeft("", ' ', indent)); + element.appendChild(node); + Element child = doc.createElement(name); + element.appendChild(child); + child.appendChild(doc.createTextNode(text)); + return child; + } + public static void saveToFile(Element root, OutputStream stream) throws TransformerException { Transformer transformer = TransformerFactory.newInstance().newTransformer(); Result output = new StreamResult(stream); From 6a78bcf25bf1295f30b06c351278898ee4f29dcf Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 29 Mar 2023 15:07:08 +1100 Subject: [PATCH 7/8] bump test cases --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bc14fb8a1..5c437b940 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 6.2.1 - 1.2.24 + 1.2.25-SNAPSHOT 5.7.1 1.8.2 3.0.0-M5 From 49e3026d3c78c75857644e0388544fcf2d832b17 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 29 Mar 2023 15:10:04 +1100 Subject: [PATCH 8/8] release notes --- RELEASE_NOTES.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 7b06c6ab5..246da41ab 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -4,4 +4,9 @@ ## Other code changes -* no changes \ No newline at end of file +* Fix R5 path for spec in generated narratives +* Hack to fix wrong R5 paths in generated narratives in extensions pack +* Suppress Prism rendering if ttl source is too big +* Fix up URLs in untouched elements when processing snapshots +* Fix up URLs in binding.description when generating snapshots +