Fix broken links Bundle and Profile rendering
This commit is contained in:
parent
2628010dff
commit
487094ccc7
|
@ -92,6 +92,12 @@ public abstract class ResourceRenderer extends DataRenderer {
|
||||||
XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
|
XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
|
||||||
boolean hasExtensions;
|
boolean hasExtensions;
|
||||||
hasExtensions = render(x, r);
|
hasExtensions = render(x, r);
|
||||||
|
String an = r.fhirType()+"_"+r.getId();
|
||||||
|
if (context.isAddName()) {
|
||||||
|
if (!hasAnchorName(x, an)) {
|
||||||
|
injectAnchorName(x, an);
|
||||||
|
}
|
||||||
|
}
|
||||||
inject(r, x, hasExtensions ? NarrativeStatus.EXTENSIONS : NarrativeStatus.GENERATED);
|
inject(r, x, hasExtensions ? NarrativeStatus.EXTENSIONS : NarrativeStatus.GENERATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,12 +105,53 @@ public abstract class ResourceRenderer extends DataRenderer {
|
||||||
assert r.getContext() == context;
|
assert r.getContext() == context;
|
||||||
XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
|
XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
|
||||||
boolean hasExtensions = render(x, r);
|
boolean hasExtensions = render(x, r);
|
||||||
|
|
||||||
|
String an = r.fhirType()+"_"+r.getId();
|
||||||
|
if (context.isAddName()) {
|
||||||
|
if (!hasAnchorName(x, an)) {
|
||||||
|
injectAnchorName(x, an);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (r.hasNarrative()) {
|
if (r.hasNarrative()) {
|
||||||
r.injectNarrative(x, hasExtensions ? NarrativeStatus.EXTENSIONS : NarrativeStatus.GENERATED);
|
r.injectNarrative(x, hasExtensions ? NarrativeStatus.EXTENSIONS : NarrativeStatus.GENERATED);
|
||||||
}
|
}
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public XhtmlNode checkNarrative(ResourceWrapper r) throws IOException, FHIRException, EOperationOutcome {
|
||||||
|
assert r.getContext() == context;
|
||||||
|
XhtmlNode x = r.getNarrative();
|
||||||
|
String an = r.fhirType()+"_"+r.getId();
|
||||||
|
if (context.isAddName()) {
|
||||||
|
if (!hasAnchorName(x, an)) {
|
||||||
|
injectAnchorName(x, an);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void injectAnchorName(XhtmlNode x, String an) {
|
||||||
|
XhtmlNode ip = x;
|
||||||
|
while (ip.hasChildren() && "div".equals(ip.getChildNodes().get(0).getName())) {
|
||||||
|
ip = ip.getChildNodes().get(0);
|
||||||
|
}
|
||||||
|
ip.addTag(0, "a").setAttribute("name", an).tx(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean hasAnchorName(XhtmlNode x, String an) {
|
||||||
|
if ("a".equals(x.getName()) && an.equals(x.getAttribute("name"))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (x.hasChildren()) {
|
||||||
|
for (XhtmlNode c : x.getChildNodes()) {
|
||||||
|
if (hasAnchorName(c, an)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract boolean render(XhtmlNode x, Resource r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome;
|
public abstract boolean render(XhtmlNode x, Resource r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome;
|
||||||
|
|
||||||
public boolean render(XhtmlNode x, ResourceWrapper r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome {
|
public boolean render(XhtmlNode x, ResourceWrapper r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome {
|
||||||
|
@ -438,7 +485,11 @@ public abstract class ResourceRenderer extends DataRenderer {
|
||||||
String bundleUrl = null;
|
String bundleUrl = null;
|
||||||
Element br = bundleElement.getNamedChild("resource", false);
|
Element br = bundleElement.getNamedChild("resource", false);
|
||||||
if (br.getChildValue("id") != null) {
|
if (br.getChildValue("id") != null) {
|
||||||
|
if ("Bundle".equals(br.fhirType())) {
|
||||||
|
bundleUrl = "#";
|
||||||
|
} else {
|
||||||
bundleUrl = "#" + br.fhirType() + "_" + br.getChildValue("id");
|
bundleUrl = "#" + br.fhirType() + "_" + br.getChildValue("id");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
bundleUrl = "#" +fullUrlToAnchor(bundleElement.getChildValue("fullUrl"));
|
bundleUrl = "#" +fullUrlToAnchor(bundleElement.getChildValue("fullUrl"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -792,8 +792,9 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
|
||||||
UnusedTracker used = new UnusedTracker();
|
UnusedTracker used = new UnusedTracker();
|
||||||
String ref = defPath == null ? null : defPath + anchorPrefix + element.getId();
|
String ref = defPath == null ? null : defPath + anchorPrefix + element.getId();
|
||||||
String sName = tail(element.getPath());
|
String sName = tail(element.getPath());
|
||||||
if (element.hasSliceName())
|
if (element.hasSliceName()) {
|
||||||
sName = sName +":"+element.getSliceName();
|
sName = sName +":"+element.getSliceName();
|
||||||
|
}
|
||||||
used.used = true;
|
used.used = true;
|
||||||
if (logicalModel) {
|
if (logicalModel) {
|
||||||
if (element.hasRepresentation(PropertyRepresentation.XMLATTR)) {
|
if (element.hasRepresentation(PropertyRepresentation.XMLATTR)) {
|
||||||
|
@ -1332,9 +1333,6 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
|
||||||
String fixedUrl = null;
|
String fixedUrl = null;
|
||||||
if (ed != null) {
|
if (ed != null) {
|
||||||
String p = ed.getWebPath();
|
String p = ed.getWebPath();
|
||||||
if (p != null) {
|
|
||||||
ref = p.startsWith("http:") || context.getRules() == GenerationRules.IG_PUBLISHER ? p : Utilities.pathURL(corePath, p);
|
|
||||||
}
|
|
||||||
fixedUrl = getFixedUrl(ed);
|
fixedUrl = getFixedUrl(ed);
|
||||||
if (fixedUrl != null) {// if its null, we guess that it's not a profiled extension?
|
if (fixedUrl != null) {// if its null, we guess that it's not a profiled extension?
|
||||||
if (fixedUrl.equals(url))
|
if (fixedUrl.equals(url))
|
||||||
|
@ -3315,6 +3313,7 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
|
||||||
if (!tl.contains(tc)) {
|
if (!tl.contains(tc)) {
|
||||||
aliases.add(name.replace("[x]", Utilities.capitalize(tc)));
|
aliases.add(name.replace("[x]", Utilities.capitalize(tc)));
|
||||||
aliases.add(name+":"+name.replace("[x]", Utilities.capitalize(tc)));
|
aliases.add(name+":"+name.replace("[x]", Utilities.capitalize(tc)));
|
||||||
|
aliases.add(name.replace("[x]", Utilities.capitalize(tc))+":"+name.replace("[x]", Utilities.capitalize(tc)));
|
||||||
tl.add(tc);
|
tl.add(tc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3334,7 +3333,6 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
|
||||||
list.addAll(generated);
|
list.addAll(generated);
|
||||||
}
|
}
|
||||||
ElementDefinition ed = stack.get(stack.size()-1);
|
ElementDefinition ed = stack.get(stack.size()-1);
|
||||||
|
|
||||||
// now we have all the possible names, but some of them might be inappropriate if we've
|
// now we have all the possible names, but some of them might be inappropriate if we've
|
||||||
// already generated a type slicer. On the other hand, if we've already done that, we're
|
// already generated a type slicer. On the other hand, if we've already done that, we're
|
||||||
// going to steal any type specific ones off it.
|
// going to steal any type specific ones off it.
|
||||||
|
|
Loading…
Reference in New Issue