Fix rendering of CanonicalResource.url

This commit is contained in:
Grahame Grieve 2020-12-03 12:55:20 +11:00
parent 1f2859e49b
commit 89249219fd
1 changed files with 16 additions and 19 deletions

View File

@ -222,8 +222,11 @@ public class DataRenderer extends Renderer {
StructureDefinition sd = getContext().getWorker().fetchTypeDefinition(path.substring(0, path.length()-4)); StructureDefinition sd = getContext().getWorker().fetchTypeDefinition(path.substring(0, path.length()-4));
if (sd == null) if (sd == null)
return false; return false;
if (Utilities.existsInList(path.substring(0, path.length()-4), "CapabilityStatement", "StructureDefinition", "ImplementationGuide", "SearchParameter", "MessageDefinition", "OperationDefinition", "CompartmentDefinition", "StructureMap", "GraphDefinition", if (Utilities.existsInList(path.substring(0, path.length()-4),
"ExampleScenario", "CodeSystem", "ValueSet", "ConceptMap", "NamingSystem", "TerminologyCapabilities")) "ActivityDefinition", "CapabilityStatement", "CapabilityStatement2", "ChargeItemDefinition", "Citation", "CodeSystem",
"CompartmentDefinition", "ConceptMap", "ConditionDefinition", "EventDefinition", "Evidence", "EvidenceReport", "EvidenceVariable",
"ExampleScenario", "GraphDefinition", "ImplementationGuide", "Library", "Measure", "MessageDefinition", "NamingSystem", "PlanDefinition"
))
return true; return true;
return sd.getBaseDefinitionElement().hasExtension("http://hl7.org/fhir/StructureDefinition/structuredefinition-codegen-super"); return sd.getBaseDefinitionElement().hasExtension("http://hl7.org/fhir/StructureDefinition/structuredefinition-codegen-super");
} }
@ -381,26 +384,20 @@ public class DataRenderer extends Renderer {
} }
protected void renderUri(XhtmlNode x, UriType uri, String path, String id) { protected void renderUri(XhtmlNode x, UriType uri, String path, String id) {
String url = uri.getValue();
if (isCanonical(path)) { if (isCanonical(path)) {
CanonicalResource mr = getContext().getWorker().fetchResource(null, url); x.code().tx(uri.getValue());
if (mr != null) {
if (path.startsWith(mr.fhirType()+".") && mr.getId().equals(id)) {
url = null; // don't link to self whatever
} else if (mr.hasUserData("path"))
url = mr.getUserString("path");
} else if (!getContext().isCanonicalUrlsAsLinks())
url = null;
}
if (url == null) {
x.b().tx(uri.getValue());
} else if (uri.getValue().startsWith("mailto:")) {
x.ah(uri.getValue()).addText(uri.getValue().substring(7));
} else { } else {
if (uri.getValue().contains("|")) { String url = uri.getValue();
x.ah(uri.getValue().substring(0, uri.getValue().indexOf("|"))).addText(uri.getValue()); if (url == null) {
x.b().tx(uri.getValue());
} else if (uri.getValue().startsWith("mailto:")) {
x.ah(uri.getValue()).addText(uri.getValue().substring(7));
} else { } else {
x.ah(uri.getValue()).addText(uri.getValue()); if (uri.getValue().contains("|")) {
x.ah(uri.getValue().substring(0, uri.getValue().indexOf("|"))).addText(uri.getValue());
} else {
x.ah(uri.getValue()).addText(uri.getValue());
}
} }
} }
} }