Merge pull request #1194 from hapifhir/gg-202303-r5-path-fixes

Gg 202303 r5 path fixes
This commit is contained in:
Grahame Grieve 2023-03-29 15:58:56 +11:00 committed by GitHub
commit 2313348657
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 42 additions and 46 deletions

View File

@ -4,4 +4,9 @@
## Other code changes ## Other code changes
* no changes * 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

View File

@ -725,6 +725,7 @@ public class ProfilePathProcessor {
outcome.setPath(profileUtilities.fixedPathDest(getContextPathTarget(), outcome.getPath(), getRedirector(), getContextPathSource())); outcome.setPath(profileUtilities.fixedPathDest(getContextPathTarget(), outcome.getPath(), getRedirector(), getContextPathSource()));
profileUtilities.updateFromBase(outcome, currentBase, getSourceStructureDefinition().getUrl()); profileUtilities.updateFromBase(outcome, currentBase, getSourceStructureDefinition().getUrl());
profileUtilities.updateConstraintSources(outcome, getSourceStructureDefinition().getUrl()); profileUtilities.updateConstraintSources(outcome, getSourceStructureDefinition().getUrl());
profileUtilities.updateURLs(url, webUrl, outcome);
profileUtilities.markDerived(outcome); profileUtilities.markDerived(outcome);
if (cursors.resultPathBase == null) if (cursors.resultPathBase == null)
cursors.resultPathBase = outcome.getPath(); cursors.resultPathBase = outcome.getPath();

View File

@ -1651,15 +1651,22 @@ public class ProfileUtilities extends TranslatingUtilities {
} }
if (webUrl != null) { if (webUrl != null) {
// also, must touch up the markdown // 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)); 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)); 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)); 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)); 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; return element;
} }
@ -2335,6 +2342,7 @@ public class ProfileUtilities extends TranslatingUtilities {
if (dest.hasPattern()) { if (dest.hasPattern()) {
checkTypeOk(dest, dest.getPattern().fhirType(), srcSD, "pattern"); checkTypeOk(dest, dest.getPattern().fhirType(), srcSD, "pattern");
} }
//updateURLs(url, webUrl, dest);
} }
private void addMappings(List<ElementDefinitionMappingComponent> destination, List<ElementDefinitionMappingComponent> source) { private void addMappings(List<ElementDefinitionMappingComponent> destination, List<ElementDefinitionMappingComponent> source) {

View File

@ -4,6 +4,7 @@ import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.model.CanonicalResource; import org.hl7.fhir.r5.model.CanonicalResource;
import org.hl7.fhir.r5.model.ElementDefinition; import org.hl7.fhir.r5.model.ElementDefinition;
import org.hl7.fhir.r5.model.Enumerations.BindingStrength; import org.hl7.fhir.r5.model.Enumerations.BindingStrength;
import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule;
import org.hl7.fhir.r5.model.StructureDefinition; import org.hl7.fhir.r5.model.StructureDefinition;
public class R5Hacker { public class R5Hacker {
@ -16,50 +17,22 @@ public class R5Hacker {
private static void fixSD(StructureDefinition sd) { 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()) { for (ElementDefinition ed : sd.getDifferential().getElement()) {
hackEDR5BallotError(ed); fix(ed);
} }
for (ElementDefinition ed : sd.getSnapshot().getElement()) { 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) { private static void fix(ElementDefinition ed) {
ed.getConstraint().clear(); if (ed.hasDefinition()) {
ed.setDefinition(ed.getDefinition().replace("http://hl7.org/fhir/5.0.0-snapshot3/", "http://hl7.org/fhir/R5/"));
} }
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);
}
} }

View File

@ -598,7 +598,7 @@ public class VersionUtilities {
case "3.0" : return "http://hl7.org/fhir/STU3"; case "3.0" : return "http://hl7.org/fhir/STU3";
case "4.0" : return "http://hl7.org/fhir/R4"; case "4.0" : return "http://hl7.org/fhir/R4";
case "4.3" : return "http://hl7.org/fhir/R4B"; 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: default:
return "http://hl7.org/fhir"; return "http://hl7.org/fhir";
} }

View File

@ -415,14 +415,14 @@ public class Turtle {
writer.close(); writer.close();
} }
public String asHtml() throws Exception { public String asHtml(boolean prism) throws Exception {
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
b.append("<pre class=\"rdf\" style=\"white-space: pre; overflow: hidden\"><code class=\"language-turtle\">\r\n"); b.append("<pre class=\"rdf\" style=\"white-space: pre; overflow: hidden\">"+(prism ? "<code class=\"language-turtle\">" : "")+"\r\n");
commitPrefixes(b); commitPrefixes(b);
for (Section s : sections) { for (Section s : sections) {
commitSection(b, s); commitSection(b, s);
} }
b.append("</code></pre>\r\n"); b.append((prism ? "</code>" : "")+"</pre>\r\n");
b.append("\r\n"); b.append("\r\n");
return b.toString(); return b.toString();
} }

View File

@ -563,6 +563,15 @@ public class XMLUtil {
child.setAttribute("value", text); 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 { public static void saveToFile(Element root, OutputStream stream) throws TransformerException {
Transformer transformer = TransformerFactory.newInstance().newTransformer(); Transformer transformer = TransformerFactory.newInstance().newTransformer();
Result output = new StreamResult(stream); Result output = new StreamResult(stream);

View File

@ -19,7 +19,7 @@
<properties> <properties>
<hapi_fhir_version>6.2.1</hapi_fhir_version> <hapi_fhir_version>6.2.1</hapi_fhir_version>
<validator_test_case_version>1.2.24</validator_test_case_version> <validator_test_case_version>1.2.25-SNAPSHOT</validator_test_case_version>
<junit_jupiter_version>5.7.1</junit_jupiter_version> <junit_jupiter_version>5.7.1</junit_jupiter_version>
<junit_platform_launcher_version>1.8.2</junit_platform_launcher_version> <junit_platform_launcher_version>1.8.2</junit_platform_launcher_version>
<maven_surefire_version>3.0.0-M5</maven_surefire_version> <maven_surefire_version>3.0.0-M5</maven_surefire_version>