use of org.hl7.fhir.r4b.model.Extension in project kindling by HL7.
the class TurtleSpecGenerator method renderType.
private int renderType(int indent, int w, TypeRef t) throws IOException {
if (t.isXhtml())
write("fhir:value \"[escaped xhtml]\"^^xsd:string");
else if (t.getName().startsWith("@"))
write("<a href=\"#ttl-" + t.getName().substring(1) + "\"><span style=\"color: DarkViolet\">See " + t.getName().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++;
}
return w;
}
use of org.hl7.fhir.r4b.model.Extension 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.r4b.model.Extension in project kindling by HL7.
the class Regenerator method generateOperation.
private void generateOperation(String root, ResourceDefn r, Operation op) throws IOException {
OperationDefinition opd = op.getResource().copy();
opd.setId(r.getName() + "-" + op.getName());
opd.setUrl("http://hl7.org/fhir/build/OperationDefinition/" + opd.getId());
if (!Utilities.noString(op.getFooter())) {
opd.addExtension(BuildExtensions.EXT_FOOTER, new MarkdownType(op.getFooter()));
}
if (!Utilities.noString(op.getFooter2())) {
opd.addExtension(BuildExtensions.EXT_FOOTER2, new MarkdownType(op.getFooter2()));
}
for (OperationExample opex : op.getExamples()) {
Extension ex = new Extension(BuildExtensions.EXT_OP_EXAMPLE);
if (!Utilities.noString(opex.getContent())) {
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_CONTENT, new StringType(opex.getContent()));
}
if (!Utilities.noString(opex.getComment())) {
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_COMMENT, new StringType(opex.getComment()));
}
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_RESPONSE, new BooleanType(opex.isResponse()));
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_LIST, new IntegerType(1));
opd.addExtension(ex);
}
for (OperationExample opex : op.getExamples2()) {
Extension ex = new Extension(BuildExtensions.EXT_OP_EXAMPLE);
if (!Utilities.noString(opex.getContent())) {
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_CONTENT, new StringType(opex.getContent()));
}
if (!Utilities.noString(opex.getComment())) {
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_COMMENT, new StringType(opex.getComment()));
}
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_RESPONSE, new BooleanType(opex.isResponse()));
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_LIST, new IntegerType(2));
opd.addExtension(ex);
}
File fn = new File(Utilities.path(root, opd.fhirType().toLowerCase() + "-" + opd.getId() + ".gen.xml"));
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(fn), opd);
fn.setLastModified(r.getTimestamp());
}
use of org.hl7.fhir.r4b.model.Extension 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.r4b.model.Extension in project kindling by HL7.
the class XmlSpecGenerator method generateExtensionInner.
private void generateExtensionInner(StructureDefinition ed) throws IOException, Exception {
ElementDefinition root = ed.getSnapshot().getElement().get(0);
write("<!-- " + Utilities.escapeXml(ed.getName()) + " -->");
write("<span style=\"float: right\"><a title=\"Documentation for this format\" href=\"" + prefix + "xml.html\"><img src=\"" + prefix + "help.png\" alt=\"doco\"/></a></span>\r\n");
String rn = ed.getSnapshot().getElement().get(0).getIsModifier() ? "modifierExtension" : "extension";
write("\r\n<");
if (defPage == null)
write("<span title=\"" + Utilities.escapeXml(root.getDefinition()) + "\"><b>");
else
write("<a href=\"" + (defPage + "#" + root.getSliceName()) + "\" title=\"" + Utilities.escapeXml(root.getDefinition()) + "\" class=\"dict\"><b>");
write(rn);
if ((defPage == null))
write("</b></span>");
else
write("</b></a>");
write(" xmlns=\"http://hl7.org/fhir\"\r\n ");
generateExtensionAttribute(ed);
write(" >\r\n");
List<ElementDefinition> children = getChildren(ed.getSnapshot().getElement(), ed.getSnapshot().getElement().get(0));
boolean complex = isComplex(children);
if (!complex)
write(" <!-- from Element: <a href=\"" + prefix + "extensibility.html\">extension</a> -->\r\n");
for (ElementDefinition child : children) generateCoreElem(ed.getSnapshot().getElement(), child, 1, rn, false, complex);
write("</");
write(rn);
write(">\r\n");
}
Aggregations