use of org.hl7.fhir.definitions.model.ElementDefn in project kindling by HL7.
the class TerminologyNotesGenerator method scan.
private void scan(ElementDefn e, String path) throws Exception {
if (e.hasBinding()) {
BindingSpecification cd = e.getBinding();
if (!txusages.containsKey(cd)) {
txusages.put(cd, new ArrayList<CDUsage>());
c++;
txusages.get(cd).add(new CDUsage(String.valueOf(c), null));
}
txusages.get(cd).add(new CDUsage(path, e));
}
for (ElementDefn c : e.getElements()) {
scan(c, path + "." + c.getName());
}
}
use of org.hl7.fhir.definitions.model.ElementDefn in project kindling by HL7.
the class TurtleSpecGenerator method generateInner.
private void generateInner(ElementDefn root, boolean resource, boolean isAbstract) throws IOException, Exception {
String rn;
if (root.getName().equals("Extension"))
rn = "extension|modifierExtension";
else if (root.getName().equals("Meta"))
rn = "meta";
else if (root.getTypes().size() > 0 && (root.getTypes().get(0).getName().equals("Type") || (root.getTypes().get(0).getName().equals("Structure"))) || isAbstract)
rn = "[name]";
else
rn = root.getName();
write("@prefix fhir: <http://hl7.org/fhir/> .");
if (resource)
write("<span style=\"float: right\"><a title=\"Documentation for this format\" href=\"" + prefix + "rdf.html\"><img src=\"" + prefix + "help.png\" alt=\"doco\"/></a></span>\r\n");
write("\r\n");
write("\r\n");
if (resource) {
write("[ a fhir:");
if (defPage == null)
write("<span title=\"" + Utilities.escapeXml(root.getDefinition()) + "\"><b>");
else
write("<a href=\"" + (defPage + "#" + root.getName()) + "\" title=\"" + Utilities.escapeXml(root.getDefinition()) + "\" class=\"dict\"><b>");
write(rn);
if ((defPage == null))
write("</b></span>;");
else
write("</b></a>;");
write("\r\n fhir:nodeRole fhir:treeRoot; # if this is the parser root\r\n");
} else
write("[");
write("\r\n");
if (rn.equals(root.getName()) && resource) {
if (!Utilities.noString(root.typeCode())) {
write(" # from <a href=\"" + prefix + "resource.html\">Resource</a>: <a href=\"" + prefix + "resource.html#id\">.id</a>, <a href=\"" + prefix + "resource.html#meta\">.meta</a>, <a href=\"" + prefix + "resource.html#implicitRules\">.implicitRules</a>, and <a href=\"" + prefix + "resource.html#language\">.language</a>\r\n");
if (root.typeCode().equals("DomainResource"))
write(" # from <a href=\"" + prefix + "domainresource.html\">DomainResource</a>: <a href=\"" + prefix + "narrative.html#Narrative\">.text</a>, <a href=\"" + prefix + "references.html#contained\">.contained</a>, <a href=\"" + prefix + "extensibility.html\">.extension</a>, and <a href=\"" + prefix + "extensibility.html#modifierExtension\">.modifierExtension</a>\r\n");
}
} else {
if (root.typeCode().equals("BackboneElement"))
write(" # from BackboneElement: <a href=\"" + prefix + "extensibility.html\">Element.extension</a>, <a href=\"" + prefix + "extensibility.html\">BackboneElement.modifierextension</a>\r\n");
else
write(" # from Element: <a href=\"" + prefix + "extensibility.html\">Element.extension</a>\r\n");
}
for (ElementDefn elem : root.getElements()) {
generateCoreElem(elem, 1, root.getName(), rn.equals(root.getName()) && resource);
}
write("]\r\n");
}
use of org.hl7.fhir.definitions.model.ElementDefn in project kindling by HL7.
the class TurtleSpecGenerator method generateCoreElem.
private void generateCoreElem(ElementDefn elem, int indent, String path, boolean backbone) throws Exception {
String left = Utilities.padLeft("", ' ', indent * 2);
if (isChoice(elem)) {
write(left + "# ");
String en = elem.getName();
writeElementName(elem, path, en);
write(": ");
write(elem.describeCardinality());
write(" <span style=\"color: navy\">");
write(Utilities.escapeXml(elem.getShortDefn()));
write("</span>");
List<TypeRef> tl = getTypes(elem);
write(". One of these ");
write(Integer.toString(tl.size()));
write("\r\n");
for (TypeRef t : tl) {
generateElementType(elem, path, left + " ", t, elem.getName().replace("[x]", Utilities.capitalize(t.getName())));
write("\r\n");
}
} else if (elem.getTypes().size() == 1) {
TypeRef t = elem.getTypes().get(0);
String en = elem.getName();
generateElementType(elem, path, left, t, en);
if (elem.getMaxCardinality() > 1)
write(", ... ; # ");
else
write("; # ");
write(elem.describeCardinality());
write(" <span style=\"color: navy\">");
write(Utilities.escapeXml(elem.getShortDefn()));
write("</span>\r\n");
} else {
// children elements
write(left + "fhir:");
String en = elem.getName();
writeElementName(elem, path, en);
write("[ # ");
write(elem.describeCardinality());
write(" <span style=\"color: navy\">");
write(Utilities.escapeXml(elem.getShortDefn()));
write("</span>\r\n");
for (ElementDefn child : elem.getElements()) {
generateCoreElem(child, indent + 1, path + "." + en, backbone);
}
if (elem.getMaxCardinality() > 1)
write(left + "], ...;\r\n");
else
write(left + "];\r\n");
}
}
use of org.hl7.fhir.definitions.model.ElementDefn in project kindling by HL7.
the class XmlSpecGenerator method writeTypeLinks.
private int writeTypeLinks(ElementDefn elem, int indent) throws Exception {
write(" <span style=\"color: darkgreen\">");
int i = 0;
// this is wrong if the type is an attribute, but the wrapping concern shouldn't apply in this case, so this is ok
int w = indent + 12 + elem.getName().length();
for (TypeRef t : elem.getTypes()) {
if (i > 0) {
write("|");
w++;
}
if (w + t.getName().length() > 80) {
write("\r\n ");
for (int j = 0; j < indent; j++) write(" ");
w = indent + 2;
}
// again, could be wrong if this is an extension, but then it won't wrap
w = w + t.getName().length();
if (t.isXhtml() || t.getName().equals("list"))
write(t.getName());
else if (t.getName().equals("Extension") && t.getParams().size() == 0 && !Utilities.noString(t.getProfile()))
write("<a href=\"" + prefix + t.getProfile() + "\"><span style=\"color: DarkViolet\">@" + t.getProfile().substring(1) + "</span></a>");
else if (definitions.getConstraints().containsKey(t.getName())) {
ProfiledType pt = definitions.getConstraints().get(t.getName());
write("<a href=\"" + (dtRoot + definitions.getSrcFile(pt.getBaseType()) + ".html#" + pt.getBaseType() + "\">" + pt.getBaseType()) + "</a>");
w = w + pt.getBaseType().length() + 2;
write("(<a style=\"color:navy\" href=\"" + (dtRoot + definitions.getSrcFile(t.getName()) + ".html#" + t.getName() + "\">" + t.getName()) + "</a>)");
} else
write("<a href=\"" + (dtRoot + definitions.getSrcFile(t.getName()) + ".html#" + t.getName() + "\">" + t.getName()) + "</a>");
if (t.hasParams()) {
write("(");
boolean firstp = true;
List<String> ap = new ArrayList<>();
for (String p : t.getParams()) {
if (definitions.hasLogicalModel(p))
ap.addAll(definitions.getLogicalModel(p).getImplementations());
else
ap.add(p);
}
Collections.sort(ap);
for (String p : ap) {
if (!firstp) {
write("|");
w++;
}
// again, p.length() could be wrong if this is an extension, but then it won't wrap
if (w + p.length() > 80) {
write("\r\n ");
for (int j = 0; j < indent; j++) write(" ");
w = indent + 2;
}
w = w + p.length();
// TODO: Display action and/or profile information
if (p.equals("Any")) {
write("<a href=\"" + prefix + "resourcelist.html" + "\">" + p + "</a>");
} else if (t.getName().equals("Reference") && t.getParams().size() == 1 && !Utilities.noString(t.getProfile()))
write("<a href=\"" + prefix + t.getProfile() + "\"><span style=\"color: DarkViolet\">@" + t.getProfile().substring(1) + "</span></a>");
else
write("<a href=\"" + (dtRoot + definitions.getSrcFile(p) + ".html#" + p) + "\">" + p + "</a>");
firstp = false;
}
write(")");
w++;
}
i++;
}
write("</span>");
return w;
}
use of org.hl7.fhir.definitions.model.ElementDefn in project kindling by HL7.
the class XmlSpecGenerator method getInvariants.
private String getInvariants(ElementDefn elem) {
StringBuilder b = new StringBuilder();
boolean first = true;
for (Invariant i : elem.getStatedInvariants()) {
if (!first)
b.append("; ");
first = false;
b.append(i.getId() + ": " + i.getEnglish());
}
return b.toString();
}
Aggregations