use of org.hl7.fhir.r4.model.Expression in project kindling by HL7.
the class PageProcessor method genConstraints.
private String genConstraints(String name, String prefix) throws Exception {
Map<String, String> invs = new HashMap<String, String>();
if (definitions.getConstraints().containsKey(name)) {
ProfiledType cnst = definitions.getConstraints().get(name);
generateConstraintsTable(name, cnst, invs, true, prefix);
} else {
ElementDefn e = definitions.getElementDefn(name);
generateConstraintsTable(name, e, invs, true, prefix);
}
List<String> ids = new ArrayList<String>();
for (String n : invs.keySet()) {
ids.add(n);
}
Collections.sort(ids, new ConstraintsSorter());
StringBuilder b = new StringBuilder();
for (String n : ids) {
b.append(invs.get(n));
}
if (b.length() > 0)
return "<a name=\"" + name + "-inv\"> </a><table class=\"grid\"><tr><td width=\"60\"><b>id</b></td><td><b>Level</b></td><td><b>Location</b></td><td><b>Description</b></td><td><b><a href=\"" + prefix + "fhirpath.html\">Expression</a></b></td></tr>" + b + "</table>";
else
return "";
}
use of org.hl7.fhir.r4.model.Expression in project kindling by HL7.
the class PageProcessor method getInvariantList.
private String getInvariantList(StructureDefinition profile) throws FHIRException, Exception {
List<String> txlist = new ArrayList<String>();
Map<String, List<ElementDefinitionConstraintComponent>> txmap = new HashMap<String, List<ElementDefinitionConstraintComponent>>();
for (ElementDefinition ed : profile.getSnapshot().getElement()) {
if (!"0".equals(ed.getMax())) {
List<ElementDefinitionConstraintComponent> list = new ArrayList<ElementDefinition.ElementDefinitionConstraintComponent>();
for (ElementDefinitionConstraintComponent t : ed.getConstraint()) {
if (!t.hasSource() || t.getSource().equals(profile.getUrl())) {
list.add(t);
}
}
if (!list.isEmpty()) {
txlist.add(ed.getPath());
txmap.put(ed.getPath(), list);
}
}
}
if (txlist.isEmpty())
return "";
else {
StringBuilder b = new StringBuilder();
b.append("<h4>Constraints</h4>\r\n");
b.append("<table class=\"list\">\r\n");
b.append("<tr><td width=\"60\"><b>Id</b></td><td><b>Path</b></td><td><b>Details</b></td><td><b>Requirements</b></td></tr>\r\n");
for (String path : txlist) {
List<ElementDefinitionConstraintComponent> invs = txmap.get(path);
for (ElementDefinitionConstraintComponent inv : invs) {
b.append("<tr>" + presentLevel(inv) + " <td>").append(inv.getKey()).append("</td><td>").append(path).append("</td><td>").append(Utilities.escapeXml(inv.getHuman())).append("<br/><a href=\"http://hl7.org/fhirpath\">Expression</a>: ").append(Utilities.escapeXml(inv.getExpression())).append("</td><td>").append(Utilities.escapeXml(inv.getRequirements()));
if (inv.hasExtension(ToolingExtensions.EXT_BEST_PRACTICE_EXPLANATION))
b.append(". This is (only) a best practice guideline because: <blockquote>" + processMarkdown("best practice guideline", inv.getExtensionString(ToolingExtensions.EXT_BEST_PRACTICE_EXPLANATION), "") + "</blockquote>");
b.append("</td></tr>\r\n");
}
}
b.append("</table>\r\n");
return b.toString();
}
}
use of org.hl7.fhir.r4.model.Expression in project kindling by HL7.
the class PageProcessor method generateConstraints.
private void generateConstraints(String path, ElementDefn e, Map<String, String> invs, boolean base, String prefix) throws Exception {
for (Invariant inv : e.getInvariants().values()) {
String s = "";
if (base)
s = "<li>" + presentLevel(inv) + " <b title=\"Formal Invariant Identifier\">" + inv.getId() + "</b>: " + Utilities.escapeXml(inv.getEnglish()) + " (<a href=\"http://hl7.org/fhirpath\">expression</a>: <span style=\"font-family: Courier New, monospace\">" + Utilities.escapeXml(inv.getExpression()) + "</span>)";
else
s = "<li>" + presentLevel(inv) + " <b title=\"Formal Invariant Identifier\">" + inv.getId() + "</b>: On " + path + ": " + Utilities.escapeXml(inv.getEnglish()) + " (<a href=\"http://hl7.org/fhirpath\">expression</a> on " + presentPath(path) + ": <span style=\"font-family: Courier New, monospace\">" + Utilities.escapeXml(inv.getExpression()) + "</span>)";
if (!Utilities.noString(inv.getExplanation()))
s = s + ". This is (only) a best practice guideline because: <blockquote>" + processMarkdown("best practice guideline", inv.getExplanation(), prefix) + "</blockquote>";
invs.put(inv.getId(), s + "</li>");
}
for (ElementDefn c : e.getElements()) {
generateConstraints(path + "." + c.getName(), c, invs, false, prefix);
}
}
use of org.hl7.fhir.r4.model.Expression in project kindling by HL7.
the class PageProcessor method getSearch.
/*
private String prepWikiName(String name) {
return Utilities.noString(name) ? "Index" : Utilities.capitalize(Utilities.fileTitle(name));
}
*/
private String getSearch(ResourceDefn resource, String searchAdditions) {
if (resource.getSearchParams().size() == 0)
return "";
else {
StandardsStatus st = resource.getStatus();
StringBuilder b = new StringBuilder();
b.append("<h2>Search Parameters</h2>\r\n");
if (resource.getName().equals("Query"))
b.append("<p>Search parameters for this resource. The <a href=\"#all\">common parameters</a> also apply.</p>\r\n");
else
b.append("<p>Search parameters for this resource. The <a href=\"search.html#all\">common parameters</a> also apply. See <a href=\"search.html\">Searching</a> for more information about searching in REST, messaging, and services.</p>\r\n");
b.append("<table class=\"list\">\r\n");
b.append("<tr><td><b>Name</b></td><td><b>Type</b></td><td><b>Description</b></td><td><b>Expression</b></td><td><b>In Common</b></td></tr>\r\n");
List<String> names = new ArrayList<String>();
names.addAll(resource.getSearchParams().keySet());
Collections.sort(names);
for (String name : names) {
SearchParameterDefn p = resource.getSearchParams().get(name);
String pp = presentPaths(p.getPaths());
String sst = (p.getStandardsStatus() == null || p.getStandardsStatus() == st) ? "" : makeStandardsStatusRef(p.getStandardsStatus());
b.append("<tr><td><a name=\"sp-").append(p.getCode()).append("\"> </a>").append(p.getCode()).append(sst).append("</td><td><a href=\"search.html#").append(p.getType()).append("\">").append(p.getType()).append("</a></td><td>").append(Utilities.escapeXml(p.getDescription())).append("</td><td>").append(p.getType() == SearchType.composite ? getCompositeExpression(p) : Utilities.escapeXml(p.getExpression())).append(p.getType() == SearchType.reference ? p.getTargetTypesAsText() : "").append("</td><td>").append(presentOthers(p)).append("</td></tr>\r\n");
}
b.append(searchAdditions);
b.append("</table>\r\n");
return b.toString();
}
}
use of org.hl7.fhir.r4.model.Expression in project kindling by HL7.
the class ExampleInspector method testSearchParameters.
private void testSearchParameters(org.w3c.dom.Element xe, String rn, boolean inBundle) throws FHIRException {
ResourceDefn r = definitions.getResources().get(rn);
for (SearchParameterDefn sp : r.getSearchParams().values()) {
if (!sp.isXPathDone() && !Utilities.noString(sp.getXPath())) {
try {
sp.setXPathDone(true);
NamespaceContext context = new NamespaceContextMap("f", "http://hl7.org/fhir", "h", "http://www.w3.org/1999/xhtml");
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
xpath.setNamespaceContext(context);
XPathExpression expression;
expression = inBundle ? xpath.compile("/f:Bundle/f:entry/f:resource/" + sp.getXPath()) : xpath.compile("/" + sp.getXPath());
NodeList resultNodes = (NodeList) expression.evaluate(xe, XPathConstants.NODESET);
if (resultNodes.getLength() > 0)
sp.setWorks(true);
} catch (Exception e1) {
throw new FHIRException("Xpath \"" + sp.getXPath() + "\" execution failed: " + e1.getMessage(), e1);
}
}
}
}
Aggregations