further revisions to rendering framework for id uniqueness, main spec rendering, and various reported issues
This commit is contained in:
parent
dd02db3aae
commit
d8f7b98573
|
@ -343,6 +343,24 @@ public class Element extends Base implements NamedItem {
|
|||
}
|
||||
}
|
||||
|
||||
public void setChildValue(String name, Base value) {
|
||||
if (children == null)
|
||||
children = new NamedItemList<Element>();
|
||||
for (Element child : children) {
|
||||
if (name.equals(child.getName())) {
|
||||
if (!child.isPrimitive())
|
||||
throw new Error("Cannot set a value of a non-primitive type ("+name+" on "+this.getName()+")");
|
||||
child.setValue(value.primitiveValue());
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
setProperty(name.hashCode(), name, value);
|
||||
} catch (FHIRException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Element> getChildren(String name) {
|
||||
List<Element> res = new ArrayList<Element>();
|
||||
if (children.size() > 20) {
|
||||
|
@ -478,6 +496,11 @@ public class Element extends Base implements NamedItem {
|
|||
children.add(i, ne);
|
||||
childForValue = ne;
|
||||
break;
|
||||
} else if (p.getName().endsWith("[x]") && name.startsWith(p.getName().replace("[x]", ""))) {
|
||||
Element ne = new Element(p.getName(), p).setFormat(format);
|
||||
children.add(i, ne);
|
||||
childForValue = ne;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -485,7 +508,7 @@ public class Element extends Base implements NamedItem {
|
|||
throw new Error("Cannot set property "+name+" on "+this.name);
|
||||
else if (value.isPrimitive()) {
|
||||
if (childForValue.property.getName().endsWith("[x]"))
|
||||
childForValue.name = name+Utilities.capitalize(value.fhirType());
|
||||
childForValue.name = childForValue.name.replace("[x]", "")+Utilities.capitalize(value.fhirType());
|
||||
childForValue.setValue(value.primitiveValue());
|
||||
} else {
|
||||
Element ve = (Element) value;
|
||||
|
@ -693,6 +716,7 @@ public class Element extends Base implements NamedItem {
|
|||
public Element getNamedChild(String name) {
|
||||
return getNamedChild(name, true);
|
||||
}
|
||||
|
||||
public Element getNamedChild(String name, boolean exception) {
|
||||
if (children == null)
|
||||
return null;
|
||||
|
@ -1163,7 +1187,9 @@ public class Element extends Base implements NamedItem {
|
|||
}
|
||||
|
||||
public void removeChild(String name) {
|
||||
children.removeIf(n -> name.equals(n.getName()));
|
||||
if (children.removeIf(n -> name.equals(n.getName()))) {
|
||||
children.clearMap();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isProhibited() {
|
||||
|
|
|
@ -24,13 +24,9 @@ public class ActorDefinitionRenderer extends ResourceRenderer {
|
|||
|
||||
@Override
|
||||
public void buildNarrative(RenderingStatus status, XhtmlNode x, ResourceWrapper r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome {
|
||||
if (r.isDirect()) {
|
||||
renderResourceTechDetails(r, x);
|
||||
genSummaryTable(status, x, (ActorDefinition) r.getBase());
|
||||
render(status, x, (ActorDefinition) r.getBase(), r);
|
||||
} else {
|
||||
throw new Error("ActorDefinitionRenderer only renders native resources directly");
|
||||
}
|
||||
renderResourceTechDetails(r, x);
|
||||
genSummaryTable(status, x, r);
|
||||
render(status, x, r);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -38,35 +34,35 @@ public class ActorDefinitionRenderer extends ResourceRenderer {
|
|||
return canonicalTitle(r);
|
||||
}
|
||||
|
||||
public void render(RenderingStatus status, XhtmlNode x, ActorDefinition acd, ResourceWrapper r) throws FHIRFormatError, DefinitionException, IOException {
|
||||
public void render(RenderingStatus status, XhtmlNode x, ResourceWrapper acd) throws FHIRFormatError, DefinitionException, IOException {
|
||||
XhtmlNode tbl = x.table("grid");
|
||||
XhtmlNode tr = tbl.tr();
|
||||
tr.td().b().tx(context.formatPhrase(RenderingContext.ACTOR_DEF_ACT, acd.getName()) + " ");
|
||||
tr.td().tx(acd.getTitle());
|
||||
tr.td().tx(context.formatPhrase(RenderingContext.ACTOR_DEF_TYP, acd.getType().toCode()) + " ");
|
||||
tr.td().b().tx(context.formatPhrase(RenderingContext.ACTOR_DEF_ACT, context.getTranslated(acd.child("name"))) + " ");
|
||||
tr.td().tx(context.getTranslated(acd.child("title")));
|
||||
tr.td().tx(context.formatPhrase(RenderingContext.ACTOR_DEF_TYP, acd.primitiveValue("type")) + " ");
|
||||
XhtmlNode td = tbl.tr().td().colspan("3");
|
||||
addMarkdown(td, acd.getDocumentation());
|
||||
if (acd.hasReference()) {
|
||||
addMarkdown(td, context.getTranslated(acd.child("documentation")));
|
||||
if (acd.has("reference")) {
|
||||
tbl.tr().td().tx(context.formatPhrase(RenderingContext.GENERAL_REFS));
|
||||
td = tr.td().colspan("2");
|
||||
boolean first = true;
|
||||
for (UrlType t : acd.getReference()) {
|
||||
for (ResourceWrapper t : acd.children("reference")) {
|
||||
if (first) first = false; else x.br();
|
||||
renderUri(status, td, wrapWC(r, t));
|
||||
renderUri(status, td, t);
|
||||
}
|
||||
}
|
||||
if (acd.hasCapabilities()) {
|
||||
if (acd.has("capabilities")) {
|
||||
tbl.tr().td().tx(context.formatPhrase(RenderingContext.ACTOR_DEF_CAP));
|
||||
td = tr.td().colspan("2");
|
||||
renderCanonical(status, r, td, CapabilityStatement.class, acd.getCapabilitiesElement());
|
||||
renderCanonical(status, td, acd.child("capabilities"));
|
||||
}
|
||||
if (acd.hasDerivedFrom()) {
|
||||
if (acd.has("derivedFrom")) {
|
||||
tbl.tr().td().tx(context.formatPhrase(RenderingContext.ACTOR_DEF_DER));
|
||||
td = tr.td().colspan("2");
|
||||
boolean first = true;
|
||||
for (UrlType t : acd.getReference()) {
|
||||
for (ResourceWrapper t : acd.children("reference")) {
|
||||
if (first) first = false; else x.br();
|
||||
renderUri(status, r, td, t);
|
||||
renderUri(status, td, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,11 @@ public class BundleRenderer extends ResourceRenderer {
|
|||
if (id != null && !context.hasAnchor(anchor)) {
|
||||
context.addAnchor(anchor);
|
||||
root.an(context.prefixAnchor(anchor));
|
||||
root.an(context.prefixAnchor("hc"+anchor));
|
||||
}
|
||||
anchor = "hc"+anchor;
|
||||
if (id != null && !context.hasAnchor(anchor)) {
|
||||
context.addAnchor(anchor);
|
||||
root.an(context.prefixAnchor(anchor));
|
||||
}
|
||||
}
|
||||
root.hr();
|
||||
|
@ -100,8 +104,10 @@ public class BundleRenderer extends ResourceRenderer {
|
|||
xn = new XhtmlNode();
|
||||
xn.para().b().tx(context.formatPhrase(RenderingContext.BUNDLE_REV_EXCP, e.getMessage()) + " ");
|
||||
}
|
||||
} else {
|
||||
xn.stripAnchorsByName(context.getAnchors());
|
||||
}
|
||||
root.blockquote().para().addChildren(xn);
|
||||
root.blockquote().addChildren(xn);
|
||||
}
|
||||
if (be.has("request")) {
|
||||
renderRequest(x, be.child("request"));
|
||||
|
|
|
@ -1830,7 +1830,7 @@ public class DataRenderer extends Renderer implements CodeResolver {
|
|||
x.addText(q.child("high").primitiveValue("value").toString());
|
||||
else
|
||||
x.tx("?");
|
||||
if (q.child("low").has("unit"))
|
||||
if (q.has("low") && q.child("low").has("unit"))
|
||||
x.tx(" "+q.child("low").child("unit"));
|
||||
}
|
||||
|
||||
|
@ -2071,7 +2071,7 @@ public class DataRenderer extends Renderer implements CodeResolver {
|
|||
|
||||
private boolean renderExpression(CommaSeparatedStringBuilder c, ResourceWrapper p) {
|
||||
ResourceWrapper exp = p.extensionValue("http://hl7.org/fhir/StructureDefinition/cqf-expression");
|
||||
if (exp == null) {
|
||||
if (exp == null || !exp.has("value")) {
|
||||
return false;
|
||||
}
|
||||
c.append(exp.child("value").primitiveValue("expression"));
|
||||
|
|
|
@ -52,8 +52,10 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
|
|||
generateByProfile(status, r, sd, r, sd.getSnapshot().getElement(), ed, context.getProfileUtilities().getChildList(sd, ed), x, r.fhirType(), context.isTechnicalMode(), 0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(context.formatPhrase(RenderingContext.PROF_DRIV_ERR_GEN_NARR) +r.fhirType()+"/"+r.getId()+": "+e.getMessage());
|
||||
e.printStackTrace();
|
||||
if (DEBUG) {
|
||||
System.out.println(context.formatPhrase(RenderingContext.PROF_DRIV_ERR_GEN_NARR) +r.fhirType()+"/"+r.getId()+": "+e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
x.para().b().style("color: maroon").tx(context.formatPhrase(RenderingContext.PROF_DRIV_EXCP, e.getMessage())+" ");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -362,7 +362,7 @@ public class QuestionnaireRenderer extends TerminologyRenderer {
|
|||
defn.getPieces().add(gen.new Piece(null, (context.formatPhrase(RenderingContext.QUEST_OPTIONS)+" "), null));
|
||||
if (context.getDefinitionsTarget() == null) {
|
||||
// if we don't have a definitions target, we'll add them below.
|
||||
defn.getPieces().add(gen.new Piece("#opt-item."+i.primitiveValue("linkId"), Integer.toString(i.children("answerOption").size())+" "+Utilities.pluralize("option", i.children("answerOption").size()), null));
|
||||
defn.getPieces().add(gen.new Piece("#"+context.prefixAnchor("opt-item."+i.primitiveValue("linkId")), Integer.toString(i.children("answerOption").size())+" "+Utilities.pluralize("option", i.children("answerOption").size()), null));
|
||||
} else {
|
||||
defn.getPieces().add(gen.new Piece(context.getDefinitionsTarget()+"#item."+i.primitiveValue("linkId"), Integer.toString(i.children("answerOption").size())+" "+Utilities.pluralize("option", i.children("answerOption").size()), null));
|
||||
}
|
||||
|
|
|
@ -40,6 +40,8 @@ import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
|||
*/
|
||||
public class Renderer {
|
||||
|
||||
protected static final boolean DEBUG = false;
|
||||
|
||||
public static class RenderingStatus {
|
||||
private boolean extensions;
|
||||
|
||||
|
|
|
@ -245,7 +245,6 @@ public abstract class ResourceRenderer extends DataRenderer {
|
|||
actual = type;
|
||||
}
|
||||
if (actual != null && actual.hasPrimitiveValue()) {
|
||||
System.out.println("displayReference: "+actual);
|
||||
if ("#".equals(actual.primitiveValue())) {
|
||||
return "this resource";
|
||||
} else {
|
||||
|
@ -344,9 +343,12 @@ public abstract class ResourceRenderer extends DataRenderer {
|
|||
} else if (rr.getResource() == null) {
|
||||
String disp = display != null && display.hasPrimitiveValue() ? displayDataType(display) : "??";
|
||||
x.ah(context.prefixLocalHref(rr.getWebPath())).tx(disp);
|
||||
} else {
|
||||
} else if (rr.getResource() != null) {
|
||||
String disp = display != null && display.hasPrimitiveValue() ? displayDataType(display) : RendererFactory.factory(rr.getResource(), context.forContained()).buildSummary(rr.getResource());
|
||||
x.ah(context.prefixLocalHref(rr.getWebPath())).tx(disp);
|
||||
} else {
|
||||
String disp = display != null && display.hasPrimitiveValue() ? displayDataType(display) : "??";
|
||||
x.ah(context.prefixLocalHref(rr.getWebPath())).tx(disp);
|
||||
}
|
||||
} else if (display != null && id != null) {
|
||||
renderDataType(status, x, display);
|
||||
|
@ -829,12 +831,24 @@ public abstract class ResourceRenderer extends DataRenderer {
|
|||
// first thing we do is lay down the resource anchors.
|
||||
if (!Utilities.noString(r.getId())) {
|
||||
if (!context.isSecondaryLang()) {
|
||||
x.an(context.prefixAnchor(r.getScopedId()));
|
||||
x.an(context.prefixAnchor("hc"+r.getScopedId()));
|
||||
String sid = r.getScopedId();
|
||||
if (!context.hasAnchor(sid)) {
|
||||
context.addAnchor(sid);
|
||||
x.an(context.prefixAnchor(sid));
|
||||
}
|
||||
sid = "hc"+sid;
|
||||
if (!context.hasAnchor(sid)) {
|
||||
context.addAnchor(sid);
|
||||
x.an(context.prefixAnchor(sid));
|
||||
}
|
||||
}
|
||||
if (context.getLocale() != null) {
|
||||
String langSuffix = "-"+context.getLocale().toLanguageTag();
|
||||
x.an(context.prefixAnchor("hc"+r.getScopedId()+langSuffix));
|
||||
String sid = r.getScopedId()+langSuffix;
|
||||
if (!context.hasAnchor(sid)) {
|
||||
context.addAnchor(sid);
|
||||
x.an(context.prefixAnchor(sid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1050,6 +1064,99 @@ public abstract class ResourceRenderer extends DataRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void genSummaryTable(RenderingStatus status, XhtmlNode x, ResourceWrapper cr) throws IOException {
|
||||
if (context.isShowSummaryTable() && cr != null) {
|
||||
XhtmlNode tbl = x.table("grid");
|
||||
genSummaryTableContent(status, tbl, cr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void genSummaryTableContent(RenderingStatus status, XhtmlNode tbl, ResourceWrapper cr) throws IOException {
|
||||
XhtmlNode tr;
|
||||
if (cr.has("url")) {
|
||||
tr = tbl.tr();
|
||||
tr.td().tx(context.formatPhrase(RenderingContext.GENERAL_DEFINING_URL)+":");
|
||||
tr.td().code().tx(cr.primitiveValue("url"));
|
||||
} else if (cr.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-NamingSystem.url")) {
|
||||
status.setExtensions(true);
|
||||
tr = tbl.tr();
|
||||
tr.td().tx(context.formatPhrase(RenderingContext.GENERAL_DEFINING_URL)+":");
|
||||
tr.td().code().tx(cr.extensionString("http://hl7.org/fhir/5.0/StructureDefinition/extension-NamingSystem.url"));
|
||||
} else if (!context.isContained()) {
|
||||
tr = tbl.tr();
|
||||
tr.td().tx(context.formatPhrase(RenderingContext.GENERAL_DEFINING_URL));
|
||||
tr.td();
|
||||
}
|
||||
if (cr.has("version")) {
|
||||
tr = tbl.tr();
|
||||
tr.td().tx(context.formatPhrase(RenderingContext.GENERAL_VER)+":");
|
||||
renderDataType(status, tr.td(), cr.child("version"));
|
||||
} else if (cr.hasExtension("http://terminology.hl7.org/StructureDefinition/ext-namingsystem-version")) {
|
||||
status.setExtensions(true);
|
||||
tr = tbl.tr();
|
||||
tr.td().tx(context.formatPhrase(RenderingContext.GENERAL_VER)+":");
|
||||
renderDataType(status, tr.td(), cr.extensionValue("http://hl7.org/fhir/5.0/StructureDefinition/extension-NamingSystem.version"));
|
||||
}
|
||||
|
||||
String name = context.getTranslated(cr.child("name"));
|
||||
String title = context.getTranslated(cr.child("title"));
|
||||
|
||||
if (name != null) {
|
||||
tr = tbl.tr();
|
||||
tr.td().tx(context.formatPhrase(RenderingContext.GENERAL_NAME)+":");
|
||||
tr.td().tx(name);
|
||||
}
|
||||
|
||||
if (title != null && !title.equalsIgnoreCase(name)) {
|
||||
tr = tbl.tr();
|
||||
tr.td().tx(context.formatPhrase(RenderingContext.GENERAL_TITLE)+":");
|
||||
tr.td().tx(title);
|
||||
}
|
||||
|
||||
if (cr.has("status") && !context.isContained()) {
|
||||
tr = tbl.tr();
|
||||
tr.td().tx(context.formatPhrase(RenderingContext.GENERAL_STATUS)+":");
|
||||
tr.td().tx(describeStatus(status, cr));
|
||||
}
|
||||
|
||||
if (cr.has("description")) {
|
||||
tr = tbl.tr();
|
||||
tr.td().tx(context.formatPhrase(RenderingContext.GENERAL_DEFINITION)+":");
|
||||
tr.td().markdown(context.getTranslated(cr.child("description")), "description");
|
||||
}
|
||||
|
||||
if (cr.has("publisher")) {
|
||||
tr = tbl.tr();
|
||||
tr.td().tx(context.formatPhrase(RenderingContext.CANON_REND_PUBLISHER)+":");
|
||||
buildPublisherLinks( tr.td(), cr);
|
||||
}
|
||||
|
||||
if (cr.hasExtension(ToolingExtensions.EXT_WORKGROUP)) {
|
||||
status.setExtensions(true);
|
||||
tr = tbl.tr();
|
||||
tr.td().tx(context.formatPhrase(RenderingContext.CANON_REND_COMMITTEE)+":");
|
||||
renderCommitteeLink(tr.td(), cr);
|
||||
}
|
||||
|
||||
if (cr.has("copyright")) {
|
||||
tr = tbl.tr();
|
||||
tr.td().tx(context.formatPhrase(RenderingContext.GENERAL_COPYRIGHT)+":");
|
||||
tr.td().markdown(context.getTranslated(cr.child("copyright")), "copyright");
|
||||
}
|
||||
|
||||
if (cr.hasExtension(ToolingExtensions.EXT_FMM_LEVEL)) {
|
||||
status.setExtensions(true);
|
||||
// Use hard-coded spec link to point to current spec because DSTU2 had maturity listed on a different page
|
||||
tr = tbl.tr();
|
||||
tr.td().ah("http://hl7.org/fhir/versions.html#maturity", "Maturity Level").attribute("class", "fmm").tx(context.formatPhrase(RenderingContext.CANON_REND_COMMITTEE)+":");
|
||||
renderDataType(status, tr.td(), cr.extensionValue(ToolingExtensions.EXT_FMM_LEVEL));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void genSummaryTable(RenderingStatus status, XhtmlNode x, CanonicalResource cr) throws IOException {
|
||||
if (context.isShowSummaryTable() && cr != null) {
|
||||
XhtmlNode tbl = x.table("grid");
|
||||
|
@ -1063,12 +1170,12 @@ public abstract class ResourceRenderer extends DataRenderer {
|
|||
if (cr.hasUrl()) {
|
||||
tr = tbl.tr();
|
||||
tr.td().tx(context.formatPhrase(RenderingContext.GENERAL_DEFINING_URL)+":");
|
||||
tr.td().tx(cr.getUrl());
|
||||
tr.td().code().tx(cr.getUrl());
|
||||
} else if (cr.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-NamingSystem.url")) {
|
||||
status.setExtensions(true);
|
||||
tr = tbl.tr();
|
||||
tr.td().tx(context.formatPhrase(RenderingContext.GENERAL_DEFINING_URL));
|
||||
tr.td().tx(ToolingExtensions.readStringExtension(cr, "http://hl7.org/fhir/5.0/StructureDefinition/extension-NamingSystem.url")+":");
|
||||
tr.td().code().tx(ToolingExtensions.readStringExtension(cr, "http://hl7.org/fhir/5.0/StructureDefinition/extension-NamingSystem.url")+":");
|
||||
} else if (!context.isContained()) {
|
||||
tr = tbl.tr();
|
||||
tr.td().tx(context.formatPhrase(RenderingContext.GENERAL_DEFINING_URL));
|
||||
|
@ -1115,14 +1222,14 @@ public abstract class ResourceRenderer extends DataRenderer {
|
|||
if (cr.hasPublisher()) {
|
||||
tr = tbl.tr();
|
||||
tr.td().tx(context.formatPhrase(RenderingContext.CANON_REND_PUBLISHER)+":");
|
||||
tr.td().tx(buildPublisherLinks(cr));
|
||||
buildPublisherLinks(tr.td(), cr);
|
||||
}
|
||||
|
||||
if (cr.hasExtension(ToolingExtensions.EXT_WORKGROUP)) {
|
||||
status.setExtensions(true);
|
||||
tr = tbl.tr();
|
||||
tr.td().tx(context.formatPhrase(RenderingContext.CANON_REND_COMMITTEE)+":");
|
||||
tr.td().tx(renderCommitteeLink(cr));
|
||||
renderCommitteeLink(tr.td(), cr);
|
||||
}
|
||||
|
||||
if (cr.hasCopyright()) {
|
||||
|
@ -1141,68 +1248,137 @@ public abstract class ResourceRenderer extends DataRenderer {
|
|||
}
|
||||
|
||||
|
||||
protected String renderCommitteeLink(CanonicalResource cr) {
|
||||
String code = ToolingExtensions.readStringExtension(cr, ToolingExtensions.EXT_WORKGROUP);
|
||||
protected void renderCommitteeLink(XhtmlNode x, ResourceWrapper cr) {
|
||||
String code = cr.extensionString(ToolingExtensions.EXT_WORKGROUP);
|
||||
CodeSystem cs = context.getContext().fetchCodeSystem("http://terminology.hl7.org/CodeSystem/hl7-work-group");
|
||||
if (cs == null || !cs.hasWebPath())
|
||||
return code;
|
||||
x.tx(code);
|
||||
else {
|
||||
ConceptDefinitionComponent cd = CodeSystemUtilities.findCode(cs.getConcept(), code);
|
||||
if (cd == null) {
|
||||
return code;
|
||||
x.tx(code);
|
||||
} else {
|
||||
return "<a href=\""+cs.getWebPath()+"#"+cs.getId()+"-"+cd.getCode()+"\">"+cd.getDisplay()+"</a>";
|
||||
x.ah(cs.getWebPath()+"#"+cs.getId()+"-"+cd.getCode()).tx(cd.getDisplay());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String buildPublisherLinks(CanonicalResource cr) {
|
||||
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(". ");
|
||||
private void buildPublisherLinks(XhtmlNode x, CanonicalResource cr) {
|
||||
boolean useName = false;
|
||||
for (ContactDetail cd : cr.getContact()) {
|
||||
if (!cd.hasName()) {
|
||||
useName = true;
|
||||
}
|
||||
}
|
||||
boolean first = true;
|
||||
if (!useName) {
|
||||
b.append(Utilities.escapeXml(cr.getPublisher()));
|
||||
x.tx(Utilities.escapeXml(cr.getPublisher()));
|
||||
first = false;
|
||||
}
|
||||
for (ContactDetail cd : cr.getContact()) {
|
||||
String name = cd.hasName() ? cd.getName() : cr.getPublisher();
|
||||
b.append(renderContact(name, cd.getTelecom()));
|
||||
if (cd.hasTelecom()) {
|
||||
if (first) first = false; else x.tx(". ");
|
||||
renderContact(x, name, cd.getTelecom());
|
||||
}
|
||||
}
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
private String renderContact(String name, List<ContactPoint> telecom) {
|
||||
private void buildPublisherLinks(XhtmlNode x, ResourceWrapper cr) {
|
||||
boolean useName = false;
|
||||
for (ResourceWrapper cd : cr.children("contact")) {
|
||||
if (!cd.has("name")) {
|
||||
useName = true;
|
||||
}
|
||||
}
|
||||
boolean first = true;
|
||||
if (!useName) {
|
||||
x.tx(Utilities.escapeXml(cr.primitiveValue("publisher")));
|
||||
first = false;
|
||||
}
|
||||
for (ResourceWrapper cd : cr.children("contact")) {
|
||||
String name = cd.has("name") ? cd.primitiveValue("name") : cr.primitiveValue("publisher");
|
||||
if (cd.has("telecom")) {
|
||||
if (first) first = false; else x.tx(". ");
|
||||
renderContactW(x, name, cd.children("telecom"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void renderContactW(XhtmlNode x, String name, List<ResourceWrapper> telecom) {
|
||||
List<String> urls = new ArrayList<>();
|
||||
for (ResourceWrapper t : telecom) {
|
||||
if ("url".equals(t.primitiveValue()) && t.has("value")) {
|
||||
urls.add(t.primitiveValue("value"));
|
||||
}
|
||||
}
|
||||
if (urls.size() == 1) {
|
||||
x.ah(urls.get(0)).tx(name);
|
||||
} else { // if (urls.size() == 0) {
|
||||
x.tx(name);
|
||||
}
|
||||
for (ResourceWrapper t : telecom) {
|
||||
String system = t.primitiveValue("system");
|
||||
String value = t.primitiveValue("value");
|
||||
if ("url".equals(system) && value != null && urls.size() != 1) {
|
||||
x.tx(", ");
|
||||
x.ah(t.primitiveValue("value")).tx("Link");
|
||||
}
|
||||
if ("email".equals(system) && value != null) {
|
||||
x.tx(", ");
|
||||
x.ah("mailto:"+t.primitiveValue("value")).tx("Email");
|
||||
}
|
||||
if ("phone".equals(system) && value != null) {
|
||||
x.tx(", ");
|
||||
x.tx(t.primitiveValue("value"));
|
||||
}
|
||||
if ("fax".equals(system) && value != null) {
|
||||
x.tx(", ");
|
||||
x.tx("Fax:"+t.primitiveValue("value"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderContact(XhtmlNode x, String name, List<ContactPoint> telecom) {
|
||||
List<String> urls = new ArrayList<>();
|
||||
for (ContactPoint t : telecom) {
|
||||
if (t.getSystem() == ContactPointSystem.URL && t.hasValue()) {
|
||||
urls.add(t.getValue());
|
||||
}
|
||||
}
|
||||
StringBuilder b = new StringBuilder();
|
||||
if (urls.size() == 1) {
|
||||
b.append("<a href=\""+Utilities.escapeXml(urls.get(0))+"\">"+Utilities.escapeXml(name)+"</a>");
|
||||
} else if (urls.size() == 1) {
|
||||
b.append(Utilities.escapeXml(name));
|
||||
x.ah(urls.get(0)).tx(name);
|
||||
} else { // if (urls.size() == 0) {
|
||||
x.tx(name);
|
||||
}
|
||||
for (ContactPoint t : telecom) {
|
||||
b.append(", ");
|
||||
if (t.getSystem() == ContactPointSystem.URL && t.hasValue() && urls.size() > 1) {
|
||||
b.append("<a href=\""+Utilities.escapeXml(t.getValue())+"\">Link</a>");
|
||||
if (t.getSystem() == ContactPointSystem.URL && t.hasValue() && urls.size() != 1) {
|
||||
x.tx(", ");
|
||||
x.ah(t.getValue()).tx("Link");
|
||||
}
|
||||
if (t.getSystem() == ContactPointSystem.EMAIL && t.hasValue()) {
|
||||
b.append("<a href=\"mailto:"+Utilities.escapeXml(t.getValue())+"\">Email</a>");
|
||||
x.tx(", ");
|
||||
x.ah("mailto:"+t.getValue()).tx("Email");
|
||||
}
|
||||
if (t.getSystem() == ContactPointSystem.PHONE && t.hasValue()) {
|
||||
b.append(Utilities.escapeXml(t.getValue()));
|
||||
x.tx(", ");
|
||||
x.tx(t.getValue());
|
||||
}
|
||||
if (t.getSystem() == ContactPointSystem.FAX && t.hasValue()) {
|
||||
b.append("Fax:"+Utilities.escapeXml(t.getValue()));
|
||||
x.tx(", ");
|
||||
x.tx("Fax:"+t.getValue());
|
||||
}
|
||||
}
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
protected String describeStatus(RenderingStatus status, ResourceWrapper cr) {
|
||||
String s = describeStatus(cr.primitiveValue("status"), cr.primitiveValue("experimental"), cr.child("date"), cr.extensionString("http://hl7.org/fhir/StructureDefinition/valueset-deprecated"));
|
||||
if (cr.hasExtension(ToolingExtensions.EXT_STANDARDS_STATUS)) {
|
||||
status.setExtensions(true);
|
||||
s = s + presentStandardsStatus(cr.extensionString(ToolingExtensions.EXT_STANDARDS_STATUS));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
protected String describeStatus(RenderingStatus status, CanonicalResource cr) {
|
||||
|
@ -1245,4 +1421,21 @@ public abstract class ResourceRenderer extends DataRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
protected String describeStatus(String status, String experimental, ResourceWrapper dt, String deprecated) {
|
||||
String sfx = dt != null ? " as of "+displayDataType(dt) : "";
|
||||
if ("true".equals(deprecated)) {
|
||||
if ("retired".equals(status)) {
|
||||
return "Deprecated + Retired"+sfx;
|
||||
} else {
|
||||
return "Deprecated"+sfx;
|
||||
}
|
||||
} else {
|
||||
switch (status) {
|
||||
case "active": return ("true".equals(experimental) ? "Experimental" : "Active")+sfx;
|
||||
case "draft": return "Draft"+sfx;
|
||||
case "retired": return "Retired"+sfx;
|
||||
default: return "Unknown"+sfx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2779,7 +2779,9 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
|
|||
} else {
|
||||
StructureDefinition sd = context.getWorker().fetchTypeDefinition(t);
|
||||
if (sd == null) {
|
||||
System.out.println("Unable to find "+t);
|
||||
if (DEBUG) {
|
||||
System.out.println("Unable to find "+t);
|
||||
}
|
||||
sd = context.getWorker().fetchTypeDefinition(t);
|
||||
} else if (sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE) {
|
||||
used = true;
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
|||
|
||||
public abstract class TerminologyRenderer extends ResourceRenderer {
|
||||
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
|
||||
public TerminologyRenderer(RenderingContext context) {
|
||||
|
|
|
@ -1012,4 +1012,8 @@ public class RenderingContext extends RenderingI18nContext {
|
|||
public void addAnchor(String anchor) {
|
||||
anchors.add(anchor);
|
||||
}
|
||||
|
||||
public Set<String> getAnchors() {
|
||||
return anchors;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue