use of org.hl7.fhir.r4.utils.formats.Turtle.Complex 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");
}
use of org.hl7.fhir.r4.utils.formats.Turtle.Complex in project kindling by HL7.
the class XmlSpecGenerator method generateInner.
private void generateInner(StructureDefinition sd) throws IOException, Exception {
ElementDefinition root = sd.getSnapshot().getElement().get(0);
write("<!-- " + Utilities.escapeXml(sd.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 = sd.getSnapshot().getElement().get(0).getPath();
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>\r\n");
List<ElementDefinition> children = getChildren(sd.getSnapshot().getElement(), sd.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(sd.getSnapshot().getElement(), child, 1, rn, false, complex);
write("</");
write(rn);
write(">\r\n");
}
use of org.hl7.fhir.r4.utils.formats.Turtle.Complex in project kindling by HL7.
the class JsonSpecGenerator method generateCoreElem.
@SuppressWarnings("rawtypes")
private void generateCoreElem(List<ElementDefinition> elements, ElementDefinition elem, int indent, String pathName, boolean asValue, TypeRefComponent type, boolean last, boolean complex) throws Exception {
if (elem.getPath().endsWith(".id"))
return;
if (!complex && elem.getPath().endsWith(".extension"))
return;
if (elem.getMax().equals("0"))
return;
String indentS = "";
for (int i = 0; i < indent; i++) {
indentS += " ";
}
write(indentS);
List<ElementDefinition> children = getChildren(elements, elem);
String name = tail(elem.getPath());
String en = asValue ? "value[x]" : name;
String tc = type.getWorkingCode();
if (en.contains("[x]"))
en = en.replace("[x]", upFirst(tc));
boolean unbounded = elem.hasMax() && elem.getMax().equals("*");
// 1. name
write("\"<a href=\"" + (defPage + "#" + pathName + "." + en) + "\" title=\"" + Utilities.escapeXml(getEnhancedDefinition(elem)) + "\" class=\"dict\"><span style=\"text-decoration: underline\">" + en + "</span></a>\" : ");
// 2. value
boolean delayedCloseArray = false;
if (unbounded)
write("[");
if (type == null) {
// inline definition
assert (children.size() > 0);
write("{");
delayedCloseArray = true;
} else if (definitions.getPrimitives().containsKey(tc)) {
if (!(tc.equals("integer") || tc.equals("boolean") || tc.equals("decimal")))
write("\"");
if (elem.hasFixed())
write(Utilities.escapeJson(((PrimitiveType) elem.getFixed()).asStringValue()));
else
write("<<span style=\"color: darkgreen\"><a href=\"" + prefix + (dtRoot + definitions.getSrcFile(tc) + ".html#" + tc) + "\">" + tc + "</a></span>>");
if (!(tc.equals("integer") || tc.equals("boolean") || tc.equals("decimal")))
write("\"");
} else {
write("{ ");
write("<span style=\"color: darkgreen\"><a href=\"" + prefix + (dtRoot + definitions.getSrcFile(tc) + ".html#" + tc) + "\">" + tc + "</a></span>");
if (type.hasProfile()) {
if (type.getProfile().get(0).getValue().startsWith("http://hl7.org/fhir/StructureDefinition/")) {
String t = type.getProfile().get(0).getValue().substring(40);
if (definitions.hasType(t))
write("(<span style=\"color: darkgreen\"><a href=\"" + prefix + (dtRoot + definitions.getSrcFile(t) + ".html#" + t) + "\">" + t + "</a></span>)");
else if (definitions.hasResource(t))
write("(<span style=\"color: darkgreen\"><a href=\"" + prefix + dtRoot + t.toLowerCase() + ".html\">" + t + "</a></span>)");
else
write("(" + t + ")");
} else
write("(" + type.getProfile() + ")");
}
if (type.hasTargetProfile()) {
if (type.getTargetProfile().get(0).getValue().startsWith("http://hl7.org/fhir/StructureDefinition/")) {
String t = type.getTargetProfile().get(0).getValue().substring(40);
if (definitions.hasType(t))
write("(<span style=\"color: darkgreen\"><a href=\"" + prefix + (dtRoot + definitions.getSrcFile(t) + ".html#" + t) + "\">" + t + "</a></span>)");
else if (definitions.hasResource(t))
write("(<span style=\"color: darkgreen\"><a href=\"" + prefix + dtRoot + t.toLowerCase() + ".html\">" + t + "</a></span>)");
else
write("(" + t + ")");
} else
write("(" + type.getTargetProfile() + ")");
}
write(" }");
}
if (!delayedCloseArray) {
if (unbounded)
write("]");
if (!last)
write(",");
}
write(" <span style=\"color: Gray\">//</span>");
// 3. optionality
writeCardinality(elem);
// 4. doco
if (!elem.hasFixed()) {
if (elem.hasBinding() && elem.getBinding().hasValueSet()) {
ValueSet vs = resolveValueSet(elem.getBinding().getValueSet());
if (vs != null)
write("<span style=\"color: navy; opacity: 0.8\"><a href=\"" + (Utilities.isAbsoluteUrl(vs.getUserString("path")) ? "" : prefix) + vs.getUserData("path") + "\" style=\"color: navy\">" + Utilities.escapeXml(elem.getShort()) + "</a></span>");
else
write("<span style=\"color: navy; opacity: 0.8\"><a href=\"" + elem.getBinding().getValueSet() + ".html\" style=\"color: navy\">" + Utilities.escapeXml(elem.getShort()) + "</a></span>");
} else
write("<span style=\"color: navy; opacity: 0.8\">" + Utilities.escapeXml(elem.getShort()) + "</span>");
}
write("\r\n");
if (delayedCloseArray) {
int c = 0;
for (ElementDefinition child : children) {
if (child.getType().size() == 1)
generateCoreElem(elements, child, indent + 1, pathName + "." + name, false, child.getType().get(0), ++c == children.size(), false);
else {
write("<span style=\"color: Gray\">// value[x]: <span style=\"color: navy; opacity: 0.8\">" + Utilities.escapeXml(child.getShort()) + "</span>. One of these " + Integer.toString(child.getType().size()) + ":</span>\r\n");
for (TypeRefComponent t : child.getType()) generateCoreElem(elements, child, indent + 1, pathName + "." + name, false, t, ++c == children.size(), false);
}
}
write("}]");
if (!last)
write(",");
}
}
use of org.hl7.fhir.r4.utils.formats.Turtle.Complex in project kindling by HL7.
the class JsonSpecGenerator method generateCoreElemSliced.
private void generateCoreElemSliced(List<ElementDefinition> elements, ElementDefinition elem, List<ElementDefinition> children, int indent, String pathName, boolean asValue, TypeRefComponent type, boolean last, boolean complex) throws Exception {
String name = tail(elem.getPath());
String en = asValue ? "value[x]" : name;
if (en.contains("[x]"))
en = en.replace("[x]", upFirst(type.getWorkingCode()));
boolean unbounded = elem.hasMax() && elem.getMax().equals("*");
String indentS = "";
for (int i = 0; i < indent; i++) {
indentS += " ";
}
write(indentS);
List<ElementDefinition> slices = getSlices(elem, children);
boolean hasContent = slices.size() > 0;
write("\"<a href=\"" + (defPage + "#" + pathName + "." + en) + "\" title=\"" + Utilities.escapeXml(getEnhancedDefinition(elem)) + "\" class=\"dict\"><span style=\"text-decoration: underline\">" + en + "</span></a>\" : ");
write("[ // <span style=\"color: navy\">" + describeSlicing(elem.getSlicing()) + "</span> " + (hasContent ? "" : "]"));
// write(" <span style=\"color: Gray\">//</span>");
// writeCardinality(elem);
write("\r\n");
int c = 0;
for (ElementDefinition slice : slices) {
write(indentS + " ");
write("{ // <span style=\"color: navy; opacity: 0.8\">" + Utilities.escapeXml(slice.getShort()) + "</span>");
write(" <span style=\"color: Gray\">//</span>");
writeCardinality(slice);
write("\r\n");
List<ElementDefinition> extchildren = getChildren(elements, slice);
boolean extcomplex = isComplex(extchildren) && complex;
if (!extcomplex) {
write(indentS + " ");
write(" // from Element: <a href=\"" + prefix + "extensibility.html\">extension</a>\r\n");
}
int cc = 0;
int l = lastChild(extchildren);
for (ElementDefinition child : extchildren) if (child.hasSlicing())
generateCoreElemSliced(elements, child, children, indent + 2, pathName + "." + en, false, child.getType().get(0), ++cc == l, extcomplex);
else if (wasSliced(child, children))
// nothing
;
else if (child.getType().size() == 1)
generateCoreElem(elements, child, indent + 2, pathName + "." + en, false, child.getType().get(0), ++cc == l, extcomplex);
else {
write("<span style=\"color: Gray\">// value[x]: <span style=\"color: navy; opacity: 0.8\">" + Utilities.escapeXml(child.getShort()) + "</span>. One of these " + Integer.toString(child.getType().size()) + ":</span>\r\n");
for (TypeRefComponent t : child.getType()) generateCoreElem(elements, child, indent + 2, pathName + "." + en, false, t, ++cc == l, false);
}
c++;
write(indentS);
if (c == slices.size())
write(" }\r\n");
else
write(" },\r\n");
}
if (hasContent) {
write(indentS);
if (last)
write("]\r\n");
else
write("],\r\n");
}
}
use of org.hl7.fhir.r4.utils.formats.Turtle.Complex in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeValueSet.
protected void composeValueSet(Complex parent, String parentType, String name, ValueSet element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "ValueSet", name, element, index);
if (element.hasUrlElement())
composeUri(t, "ValueSet", "url", element.getUrlElement(), -1);
if (element.hasIdentifier())
composeIdentifier(t, "ValueSet", "identifier", element.getIdentifier(), -1);
if (element.hasVersionElement())
composeString(t, "ValueSet", "version", element.getVersionElement(), -1);
if (element.hasNameElement())
composeString(t, "ValueSet", "name", element.getNameElement(), -1);
if (element.hasStatusElement())
composeEnum(t, "ValueSet", "status", element.getStatusElement(), -1);
if (element.hasExperimentalElement())
composeBoolean(t, "ValueSet", "experimental", element.getExperimentalElement(), -1);
if (element.hasPublisherElement())
composeString(t, "ValueSet", "publisher", element.getPublisherElement(), -1);
for (int i = 0; i < element.getContact().size(); i++) composeValueSetValueSetContactComponent(t, "ValueSet", "contact", element.getContact().get(i), i);
if (element.hasDateElement())
composeDateTime(t, "ValueSet", "date", element.getDateElement(), -1);
if (element.hasLockedDateElement())
composeDate(t, "ValueSet", "lockedDate", element.getLockedDateElement(), -1);
if (element.hasDescriptionElement())
composeString(t, "ValueSet", "description", element.getDescriptionElement(), -1);
for (int i = 0; i < element.getUseContext().size(); i++) composeCodeableConcept(t, "ValueSet", "useContext", element.getUseContext().get(i), i);
if (element.hasImmutableElement())
composeBoolean(t, "ValueSet", "immutable", element.getImmutableElement(), -1);
if (element.hasRequirementsElement())
composeString(t, "ValueSet", "requirements", element.getRequirementsElement(), -1);
if (element.hasCopyrightElement())
composeString(t, "ValueSet", "copyright", element.getCopyrightElement(), -1);
if (element.hasExtensibleElement())
composeBoolean(t, "ValueSet", "extensible", element.getExtensibleElement(), -1);
if (element.hasCompose())
composeValueSetValueSetComposeComponent(t, "ValueSet", "compose", element.getCompose(), -1);
if (element.hasExpansion())
composeValueSetValueSetExpansionComponent(t, "ValueSet", "expansion", element.getExpansion(), -1);
}
Aggregations