use of org.hl7.fhir.definitions.model.ElementDefn in project kindling by HL7.
the class PageProcessor method generateConstraintsTable.
private void generateConstraintsTable(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 = "<tr><td><b title=\"Formal Invariant Identifier\">" + inv.getId() + "</b></td><td>" + presentLevel(inv) + "</td><td>(base)</td><td>" + Utilities.escapeXml(inv.getEnglish()) + "</td><td><span style=\"font-family: Courier New, monospace\">" + Utilities.escapeXml(inv.getExpression()) + "</span>";
else
s = "<tr><td><b title=\"Formal Invariant Identifier\">" + inv.getId() + "</b></td><td>" + presentLevel(inv) + "</td><td>" + path + "</td><td>" + Utilities.escapeXml(inv.getEnglish()) + "</td><td><span style=\"font-family: Courier New, monospace\">" + Utilities.escapeXml(inv.getExpression()) + "</span>";
if (!Utilities.noString(inv.getExplanation()))
s = s + "<br/>This is (only) a best practice guideline because: <blockquote>" + processMarkdown("best practice guideline", inv.getExplanation(), prefix) + "</blockquote>";
s = s + "</td></tr>";
invs.put(inv.getId(), s);
}
for (ElementDefn c : e.getElements()) {
generateConstraintsTable(path + "." + c.getName(), c, invs, false, prefix);
}
}
use of org.hl7.fhir.definitions.model.ElementDefn 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.definitions.model.ElementDefn in project kindling by HL7.
the class PageProcessor method generateValueSetUsage.
private String generateValueSetUsage(ValueSet vs, String prefix, boolean addTitle) throws Exception {
List<String> items = new ArrayList<>();
if (vs.hasUrl()) {
for (CodeSystem cs : getCodeSystems().getList()) {
if (cs != null) {
if (vs.getUrl().equals(cs.getValueSet())) {
String p = cs.getUserString("path");
addItem(items, "<li>CodeSystem: This value set is the designated 'entire code system' value set for <a href=\"" + (Utilities.isAbsoluteUrl(p) ? "" : prefix) + p + "\">" + cs.getName() + "</a> " + "</li>\r\n");
}
}
}
}
for (ConceptMap cm : getConceptMaps().getList()) {
String p = cm.getUserString("path");
if (cm.hasSourceUriType() && cm.getSourceUriType().equals(vs.getUrl())) {
addItem(items, "<li>ConceptMap: Translation source in <a href=\"" + (Utilities.isAbsoluteUrl(p) ? "" : prefix) + p + "\">" + cm.present() + "</a> " + "</li>\r\n");
} else if (cm.hasSourceCanonicalType() && (cm.getSourceCanonicalType().getValue().equals(vs.getUrl()) || vs.getUrl().endsWith("/" + cm.getSourceCanonicalType().getValue()))) {
addItem(items, "<li>ConceptMap: Translation source in <a href=\"" + (Utilities.isAbsoluteUrl(p) ? "" : prefix) + p + "\">" + cm.getName() + "</a> " + "</li>\r\n");
}
}
for (ConceptMap cm : getConceptMaps().getList()) {
String p = cm.getUserString("path");
if (cm.hasTargetUriType() && cm.getTargetUriType().equals(vs.getUrl())) {
addItem(items, "<li>ConceptMap: Translation target in <a href=\"" + (Utilities.isAbsoluteUrl(p) ? "" : prefix) + p + "\">" + cm.present() + "</a> " + "</li>\r\n");
} else if (cm.hasTargetCanonicalType() && (cm.getTargetCanonicalType().getValue().equals(vs.getUrl()) || vs.getUrl().endsWith("/" + cm.getTargetCanonicalType().getValue()))) {
addItem(items, "<li>ConceptMap: Translation target ConceptMap <a href=\"" + (Utilities.isAbsoluteUrl(p) ? "" : prefix) + p + "\">" + cm.getName() + "</a> " + "</li>\r\n");
}
}
for (ResourceDefn r : definitions.getBaseResources().values()) {
scanForUsage(items, vs, r.getRoot(), r.getName().toLowerCase() + "-definitions.html", prefix);
scanForOperationUsage(items, vs, r, r.getName().toLowerCase() + "-operation-", prefix);
scanForProfileUsage(items, vs, r, prefix);
}
for (ResourceDefn r : definitions.getResources().values()) {
scanForUsage(items, vs, r.getRoot(), r.getName().toLowerCase() + "-definitions.html", prefix);
scanForOperationUsage(items, vs, r, r.getName().toLowerCase() + "-operation-", prefix);
scanForProfileUsage(items, vs, r, prefix);
}
for (ElementDefn e : definitions.getInfrastructure().values()) {
scanForUsage(items, vs, e, definitions.getSrcFile(e.getName()) + "-definitions.html", prefix);
}
for (ElementDefn e : definitions.getTypes().values()) {
if (!definitions.dataTypeIsSharedInfo(e.getName())) {
scanForUsage(items, vs, e, definitions.getSrcFile(e.getName()) + "-definitions.html", prefix);
}
}
for (StructureDefinition sd : workerContext.getExtensionDefinitions()) {
scanForUsage(items, vs, sd, sd.getUserString("path"), prefix);
}
for (ValueSet vsi : definitions.getValuesets().getList()) {
String path = (String) vsi.getUserData("path");
if (vs.hasCompose()) {
for (ConceptSetComponent t : vs.getCompose().getInclude()) {
for (UriType uri : t.getValueSet()) {
if (uri.getValue().equals(vs.getUrl())) {
addItem(items, "<li>ValueSet: Included in <a href=\"" + prefix + path + "\">" + Utilities.escapeXml(vs.present()) + "</a></li>\r\n");
}
}
}
for (ConceptSetComponent t : vs.getCompose().getExclude()) {
for (UriType uri : t.getValueSet()) {
if (uri.getValue().equals(vs.getUrl())) {
addItem(items, "<li>ValueSet: Excluded from <a href=\"" + prefix + path + "\">" + Utilities.escapeXml(vs.present()) + "</a></li>\r\n");
}
}
}
// for (ConceptSetComponent t : vsi.getCompose().getInclude()) {
// if (vs.hasCodeSystem() && t.getSystem().equals(vs.getCodeSystem().getSystem()))
// b.append(" <li>Included in Valueset <a href=\""+prefix+path+"\">"+Utilities.escapeXml(vs.getName())+"</a></li>\r\n");
// }
// for (ConceptSetComponent t : vsi.getCompose().getExclude()) {
// if (vs.hasCodeSystem() && t.getSystem().equals(vs.getCodeSystem().getSystem()))
// b.append(" <li>Excluded in Valueset <a href=\""+prefix+path+"\">"+Utilities.escapeXml(vs.getName())+"</a></li>\r\n");
// }
}
}
if (ini.getPropertyNames(vs.getUrl()) != null) {
for (String n : ini.getPropertyNames(vs.getUrl())) {
addItem(items, "<li>" + ini.getStringProperty(vs.getUrl(), n) + "</li>\r\n");
}
}
if (items.size() == 0)
return "<p>\r\nThis value set is not currently used\r\n</p>\r\n";
else {
StringBuilder b = new StringBuilder();
for (String s : items) {
b.append(" " + s);
}
return (addTitle ? "<p>\r\nThis value set is used in the following places:\r\n</p>\r\n" : "") + "<ul>\r\n" + b.toString() + "</ul>\r\n";
}
}
use of org.hl7.fhir.definitions.model.ElementDefn in project kindling by HL7.
the class DefinitionsUsageTracker method usage.
private void usage(org.hl7.fhir.r5.elementmodel.Element instance, ElementDefn definition, String path) throws Exception {
definition.setCoveredByExample(true);
for (Element c : instance.getChildren()) {
String p = c.getProperty().getDefinition().getPath();
ElementDefn ed = definitions.getElementByPath(p.split("\\."), "example usage", true);
if (ed != null)
usage(c, ed, path + "." + c.getName());
// else if (!c.getName().equals("extension"))
// System.out.println("error finding "+c.getName()+" at "+path);
}
}
use of org.hl7.fhir.definitions.model.ElementDefn in project kindling by HL7.
the class ExampleAdorner method getLink.
@Override
public String getLink(XhtmlGenerator ref, XhtmlGeneratorAdornerState state, Element node) throws Exception {
if (state == null) {
if (node == null || !definitions.hasResource(node.getLocalName()))
return null;
else {
definitions.getResourceByName(node.getLocalName()).getRoot().setCoveredByExample(true);
return prefix + node.getLocalName().toLowerCase() + "-definitions.html";
}
} else {
ExampleAdornerState s = (ExampleAdornerState) state;
if (s.definition == null)
if (node.getNamespaceURI().equals("http://www.w3.org/1999/xhtml"))
return prefix + "narrative.html";
else
return null;
ElementDefn t = s.definition;
if (t.typeCode().equals("Resource") && (s.getPath().endsWith(".entry.resource") || s.getPath().endsWith(".contained")) && definitions.isResource(node.getNodeName()))
return null;
ElementDefn child = t.getElementByName(node.getNodeName(), true, definitions, "adorn example", false);
String p = child == null ? null : s.getPath() + "." + child.getName();
while (child == null && t != null && definitions.hasElementDefn(t.typeCodeNoParams())) {
t = definitions.getElementDefn(t.typeCodeNoParams());
child = t.getElementByName(node.getNodeName(), true, definitions, "adorn example", false);
if (child != null) {
p = t.getName() + "." + child.getName();
}
}
if (child == null) {
if (node.getNamespaceURI().equals("http://www.w3.org/1999/xhtml"))
return prefix + "narrative.html";
else
return null;
} else {
child.setCoveredByExample(true);
String r = p.contains(".") ? p.substring(0, p.indexOf(".")) : p;
return prefix + definitions.getSrcFile(r) + "-definitions.html#" + p;
}
}
}
Aggregations