Fix markdown relative link issues + start working on additional bindings extension
This commit is contained in:
parent
b49e791cd1
commit
0fa757b426
|
@ -38,6 +38,11 @@ public abstract class BaseLoaderR5 implements IContextResourceLoader {
|
|||
|
||||
public void setPath(Resource r) {
|
||||
String path = lkp.getResourcePath(r);
|
||||
if (lkp.getWebRoot() != null) {
|
||||
r.setUserData("webroot", lkp.getWebRoot());
|
||||
} else {
|
||||
r.setUserData("webroot", "");
|
||||
}
|
||||
if (path != null) {
|
||||
r.setUserData("path", path);
|
||||
}
|
||||
|
|
|
@ -16,4 +16,6 @@ public interface ILoaderKnowledgeProviderR5 {
|
|||
String getResourcePath(Resource resource);
|
||||
|
||||
ILoaderKnowledgeProviderR5 forNewPackage(NpmPackage npm) throws JsonSyntaxException, IOException;
|
||||
|
||||
String getWebRoot();
|
||||
}
|
||||
|
|
|
@ -13,4 +13,9 @@ public class NullLoaderKnowledgeProviderR5 implements ILoaderKnowledgeProviderR5
|
|||
public ILoaderKnowledgeProviderR5 forNewPackage(NpmPackage npm) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWebRoot() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,6 +104,7 @@ import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingCompo
|
|||
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionSnapshotComponent;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule;
|
||||
import org.hl7.fhir.r5.model.UriType;
|
||||
import org.hl7.fhir.r5.model.UsageContext;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionComponent;
|
||||
import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent;
|
||||
|
@ -2480,19 +2481,19 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
if (webUrl != null) {
|
||||
// also, must touch up the markdown
|
||||
if (element.hasDefinition())
|
||||
element.setDefinition(processRelativeUrls(element.getDefinition(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames));
|
||||
element.setDefinition(processRelativeUrls(element.getDefinition(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, true));
|
||||
if (element.hasComment())
|
||||
element.setComment(processRelativeUrls(element.getComment(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames));
|
||||
element.setComment(processRelativeUrls(element.getComment(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, true));
|
||||
if (element.hasRequirements())
|
||||
element.setRequirements(processRelativeUrls(element.getRequirements(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames));
|
||||
element.setRequirements(processRelativeUrls(element.getRequirements(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, true));
|
||||
if (element.hasMeaningWhenMissing())
|
||||
element.setMeaningWhenMissing(processRelativeUrls(element.getMeaningWhenMissing(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames));
|
||||
element.setMeaningWhenMissing(processRelativeUrls(element.getMeaningWhenMissing(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, true));
|
||||
}
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
public static String processRelativeUrls(String markdown, String webUrl, String basePath, List<String> resourceNames, Set<String> filenames) {
|
||||
public static String processRelativeUrls(String markdown, String webUrl, String basePath, List<String> resourceNames, Set<String> filenames, boolean processRelatives) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
int i = 0;
|
||||
while (i < markdown.length()) {
|
||||
|
@ -2520,7 +2521,13 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
} else {
|
||||
b.append("](");
|
||||
// disabled 7-Dec 2021 GDG - we don't want to fool with relative URLs at all?
|
||||
// b.append(webUrl);
|
||||
// re-enabled 11-Feb 2022 GDG - we do want to do this. At least, $assemble in davinci-dtr, where the markdown comes from the SDC IG, and an SDC local reference must be changed to point to SDC. in this case, it's called when generating snapshots
|
||||
// added processRelatives parameter to deal with this (well, to try)
|
||||
if (processRelatives) {
|
||||
b.append(webUrl);
|
||||
} else {
|
||||
System.out.println("Not making "+url+" relative to '"+webUrl+"'");
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
} else
|
||||
|
@ -2778,7 +2785,9 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
profile = source.getType().size() == 1 && source.getTypeFirstRep().hasProfile() ? context.fetchResource(StructureDefinition.class, source.getTypeFirstRep().getProfile().get(0).getValue()) : null;
|
||||
if (profile != null) {
|
||||
ElementDefinition e = profile.getSnapshot().getElement().get(0);
|
||||
base.setDefinition(e.getDefinition());
|
||||
String webroot = profile.getUserString("webroot");
|
||||
|
||||
base.setDefinition(processRelativeUrls(e.getDefinition(), webroot, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, true));
|
||||
base.setShort(e.getShort());
|
||||
if (e.hasCommentElement())
|
||||
base.setCommentElement(e.getCommentElement());
|
||||
|
@ -4688,6 +4697,13 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
c.getPieces().add(gen.new Piece(null, ": ", null));
|
||||
c.addMarkdownNoPara(PublicationHacker.fixBindingDescriptions(context, binding.getDescriptionElement()).asStringValue(), checkForNoChange(PublicationHacker.fixBindingDescriptions(context, binding.getDescriptionElement())));
|
||||
}
|
||||
if (binding.hasExtension(ToolingExtensions.EXT_BINDING_ADDITIONAL)) {
|
||||
c.addPiece(gen.new Piece("br"));
|
||||
c.getPieces().add(checkForNoChange(binding, gen.new Piece(null, translate("sd.table", "Additional Bindings")+": ", null).addStyle("font-weight:bold")));
|
||||
for (Extension ext : binding.getExtensionsByUrl(ToolingExtensions.EXT_BINDING_ADDITIONAL)) {
|
||||
renderAdditionalBinding(gen, c, ext);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ElementDefinitionConstraintComponent inv : definition.getConstraint()) {
|
||||
if (!inv.hasSource() || profile == null || inv.getSource().equals(profile.getUrl()) || allInvariants) {
|
||||
|
@ -4767,6 +4783,23 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
return c;
|
||||
}
|
||||
|
||||
private void renderAdditionalBinding(HierarchicalTableGenerator gen, Cell c, Extension ext) {
|
||||
// <nsbp>2 <sp> purpose <sp> value-set-link ([context]) {documentation}
|
||||
// String purpose = ext.getExtensionString("purpose");
|
||||
// String valueSet = ext.getExtensionString("valueSet");
|
||||
// String doco = ext.getExtensionString("documentation");
|
||||
// UsageContext usage = (ext.hasExtension("usage")) ? ext.getExtensionByUrl("usage").getValueUsageContext() : null;
|
||||
//
|
||||
// purpose: code - defines how the binding is used
|
||||
// usage : UsageContext - defines the contexts in which this binding is used for it's purpose
|
||||
// valueSet : canonical(ValueSet)
|
||||
// documentation : markdown
|
||||
// !!
|
||||
// c.getPieces().add(checkForNoChange(inv, gen.new Piece(null, inv.getKey()+": ", null).addStyle("font-weight:bold")));
|
||||
// c.getPieces().add(checkForNoChange(inv, gen.new Piece(null, gt(inv.getHumanElement()), null)));
|
||||
|
||||
}
|
||||
|
||||
private BindingResolution makeNullBr(ElementDefinitionBindingComponent binding) {
|
||||
BindingResolution br = new BindingResolution();
|
||||
br.url = "http://none.none/none";
|
||||
|
|
|
@ -200,6 +200,7 @@ public class ToolingExtensions {
|
|||
public static final String EXT_VALUESET_SYSTEM = "http://hl7.org/fhir/StructureDefinition/valueset-system";
|
||||
public static final String EXT_EXPAND_RULES = "http://hl7.org/fhir/StructureDefinition/valueset-expand-rules";
|
||||
public static final String EXT_EXPAND_GROUP = "http://hl7.org/fhir/StructureDefinition/valueset-expand-group";
|
||||
public static final String EXT_BINDING_ADDITIONAL = "http://hl7.org/fhir/tools/StructureDefinition/additional-binding";
|
||||
|
||||
// specific extension helpers
|
||||
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
-------------------------------------------------------------------------------------
|
||||
{"hierarchical" : false, "valueSet" :{
|
||||
"resourceType" : "ValueSet",
|
||||
"compose" : {
|
||||
"include" : [{
|
||||
"system" : "http://loinc.org",
|
||||
"concept" : [{
|
||||
"extension" : [{
|
||||
"url" : "http://hl7.org/fhir/StructureDefinition/valueset-label",
|
||||
"valueString" : "A."
|
||||
}],
|
||||
"code" : "LA20752-4",
|
||||
"display" : "Within 24 hours"
|
||||
},
|
||||
{
|
||||
"extension" : [{
|
||||
"url" : "http://hl7.org/fhir/StructureDefinition/valueset-label",
|
||||
"valueString" : "B."
|
||||
}],
|
||||
"code" : "LA20753-2",
|
||||
"display" : "After 24 hours but before 3 days"
|
||||
},
|
||||
{
|
||||
"extension" : [{
|
||||
"url" : "http://hl7.org/fhir/StructureDefinition/valueset-label",
|
||||
"valueString" : "C."
|
||||
}],
|
||||
"code" : "LA20754-0",
|
||||
"display" : "Three days or later"
|
||||
},
|
||||
{
|
||||
"extension" : [{
|
||||
"url" : "http://hl7.org/fhir/StructureDefinition/valueset-label",
|
||||
"valueString" : "D."
|
||||
}],
|
||||
"code" : "LA4489-6",
|
||||
"display" : "Unknown"
|
||||
}]
|
||||
}]
|
||||
}
|
||||
}}####
|
||||
e: {
|
||||
"error" : "Cannot invoke \"org.hl7.fhir.r5.terminologies.TerminologyClient.expandValueset(org.hl7.fhir.r5.model.ValueSet, org.hl7.fhir.r5.model.Parameters, java.util.Map)\" because \"this.txClient\" is null"
|
||||
}
|
||||
-------------------------------------------------------------------------------------
|
|
@ -1591,3 +1591,11 @@ v: {
|
|||
"error" : "Unable to find code 10821000202101 in http://snomed.info/sct (version http://snomed.info/sct/900000000000207008/version/20210731); The code \"10821000202101\" is not valid in the system http://snomed.info/sct; The code provided (http://snomed.info/sct#10821000202101) is not valid in the value set 'no-colonoscopy-sedation-level' (from http://tx.fhir.org/r4)"
|
||||
}
|
||||
-------------------------------------------------------------------------------------
|
||||
{"code" : {
|
||||
"code" : "pdf"
|
||||
}, "url": "http://hl7.org/fhir/ValueSet/mimetypes", "version": "4.0.1", "lang":"null", "useServer":"true", "useClient":"true", "guessSystem":"true", "valueSetMode":"ALL_CHECKS", "versionFlexible":"false"}####
|
||||
v: {
|
||||
"severity" : "error",
|
||||
"error" : "The code \"pdf\" is not valid in the system urn:ietf:bcp:13; The code provided (urn:ietf:bcp:13#pdf) is not valid in the value set 'Mime Types' (from http://tx.fhir.org/r4)"
|
||||
}
|
||||
-------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue