use of org.hl7.fhir.r5.model.BackboneElement in project kindling by HL7.
the class ProfileGenerator method generate.
public StructureDefinition generate(Profile pack, ResourceDefn r, String usage, boolean logical) throws Exception {
StructureDefinition p = new StructureDefinition();
p.setId(r.getRoot().getName());
p.setUrl("http://hl7.org/fhir/StructureDefinition/" + r.getRoot().getName());
if (logical)
p.setKind(StructureDefinitionKind.LOGICAL);
else
p.setKind(StructureDefinitionKind.RESOURCE);
if (r.isInterface()) {
ToolingExtensions.addBooleanExtension(p, ToolingExtensions.EXT_RESOURCE_INTERFACE, true);
}
IniFile cini = new IniFile(Utilities.path(rootFolder, "temp", "categories.ini"));
String cat = cini.getStringProperty("category", r.getName());
if (!Utilities.noString(cat))
ToolingExtensions.setStringExtension(p, ToolingExtensions.EXT_RESOURCE_CATEGORY, cat);
p.setAbstract(r.isAbstract());
assert !Utilities.noString(r.getRoot().typeCode());
if (!Utilities.noString(r.getRoot().typeCode())) {
p.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/" + r.getRoot().typeCode());
p.setDerivation(TypeDerivationRule.SPECIALIZATION);
// if (r.getTemplate() != null)
// ToolingExtensions.addStringExtension(p.getBaseDefinitionElement(), ToolingExtensions.EXT_CODE_GENERATION_PARENT, r.getTemplate().getName());
}
p.setType(r.getRoot().getName());
p.setUserData("filename", r.getName().toLowerCase());
p.setUserData("path", r.getName().toLowerCase() + ".html");
p.setTitle(pack.metadata("display"));
p.setFhirVersion(version);
p.setVersion(version.toCode());
ToolingExtensions.setStandardsStatus(p, r.getStatus(), r.getNormativeVersion());
if (r.getFmmLevel() != null)
ToolingExtensions.addIntegerExtension(p, ToolingExtensions.EXT_FMM_LEVEL, Integer.parseInt(r.getFmmLevel()));
if (r.getSecurityCategorization() != null)
ToolingExtensions.addCodeExtension(p, ToolingExtensions.EXT_SEC_CAT, r.getSecurityCategorization().toCode());
ToolResourceUtilities.updateUsage(p, usage);
p.setName(r.getRoot().getName());
p.setPublisher("Health Level Seven International" + (r.getWg() == null ? "" : " (" + r.getWg().getName() + ")"));
p.addContact().getTelecom().add(Factory.newContactPoint(ContactPointSystem.URL, "http://hl7.org/fhir"));
if (r.getWg() != null)
p.addContact().getTelecom().add(Factory.newContactPoint(ContactPointSystem.URL, r.getWg().getUrl()));
ToolingExtensions.setCodeExtension(p, ToolingExtensions.EXT_WORKGROUP, r.getWg().getCode());
p.setDescription(r.getDefinition());
p.setPurpose(r.getRoot().getRequirements());
if (!p.hasPurpose())
p.setPurpose(r.getRoot().getRequirements());
p.setDate(genDate.getTime());
// DSTU
p.setStatus(r.getStatus() == StandardsStatus.NORMATIVE ? PublicationStatus.fromCode("active") : PublicationStatus.fromCode("draft"));
Set<String> containedSlices = new HashSet<String>();
// first, the differential
p.setDifferential(new StructureDefinitionDifferentialComponent());
defineElement(null, p, p.getDifferential().getElement(), r.getRoot(), r.getRoot().getName(), containedSlices, new ArrayList<ProfileGenerator.SliceHandle>(), SnapShotMode.None, true, "BackboneElement", r.getRoot().typeCode(), false);
reset();
// now. the snapshot'
p.setSnapshot(new StructureDefinitionSnapshotComponent());
defineElement(null, p, p.getSnapshot().getElement(), r.getRoot(), r.getRoot().getName(), containedSlices, new ArrayList<ProfileGenerator.SliceHandle>(), SnapShotMode.Resource, true, "BackboneElement", r.getRoot().typeCode(), true);
for (ElementDefinition ed : p.getSnapshot().getElement()) if (!ed.hasBase() && !logical)
generateElementDefinition(p, ed, getParent(ed, p.getSnapshot().getElement()));
if (!logical && !r.isInterface()) {
List<String> names = new ArrayList<String>();
names.addAll(r.getSearchParams().keySet());
Collections.sort(names);
// 1st, non composites
for (String pn : names) {
SearchParameterDefn sp = r.getSearchParams().get(pn);
if (sp.getType() != SearchType.composite)
pack.getSearchParameters().add(makeSearchParam(p, r.getName() + "-" + pn.replace("_", ""), r.getName(), sp, r));
}
for (String pn : names) {
SearchParameterDefn sp = r.getSearchParams().get(pn);
if (sp.getType() == SearchType.composite)
pack.getSearchParameters().add(makeSearchParam(p, r.getName() + "-" + pn.replace("_", ""), r.getName(), sp, r));
}
}
containedSlices.clear();
addElementConstraintToSnapshot(p);
p.getDifferential().getElement().get(0).getType().clear();
p.getSnapshot().getElement().get(0).getType().clear();
XhtmlNode div = new XhtmlNode(NodeType.Element, "div");
div.addText("to do");
p.setText(new Narrative());
p.getText().setStatus(NarrativeStatus.GENERATED);
p.getText().setDiv(div);
checkHasTypes(p);
return p;
}
use of org.hl7.fhir.r5.model.BackboneElement in project kindling by HL7.
the class ResourceDependencyGenerator method genElement.
protected Row genElement(ElementDefn e, HierarchicalTableGenerator gen, boolean resource, String path, boolean isProfile, String prefix, RenderMode mode, boolean isRoot) throws Exception {
Row row = gen.new Row();
row.setAnchor(path);
// 1. Name
Cell gc = gen.new Cell(null, dictLinks() ? pageName + "#" + path.replace("[", "_").replace("]", "_") : null, e.getName(), path + " : " + e.getDefinition(), null);
row.getCells().add(gc);
if (e.getStandardsStatus() != null) {
gc.addPiece(gen.new Piece(null, " ", null));
gc.addStyledText("Publication Status = " + e.getStandardsStatus().toDisplay(), e.getStandardsStatus().getAbbrev(), "black", e.getStandardsStatus().getColor(), prefix + "versions.html#std-process", true);
}
Cell dc;
if (resource) {
// card.
row.getCells().add(gen.new Cell());
row.setIcon("icon_resource.png", HierarchicalTableGenerator.TEXT_ICON_RESOURCE);
if (Utilities.noString(e.typeCode())) {
row.getCells().add(gen.new Cell(null, null, "n/a", null, null));
// analysis
row.getCells().add(dc = gen.new Cell());
} else {
// type
row.getCells().add(gen.new Cell(null, prefix + definitions.getSrcFile(e.typeCode()) + ".html#" + e.typeCode(), e.typeCode(), null, null));
// analysis
row.getCells().add(dc = gen.new Cell(null, null, path.contains(".") ? e.describeCardinality() : "", null, null));
}
} else {
if (!e.getElements().isEmpty()) {
// card.
row.getCells().add(gen.new Cell(null, null, path.contains(".") ? e.describeCardinality() : "", null, null));
row.setIcon("icon_element.gif", HierarchicalTableGenerator.TEXT_ICON_ELEMENT);
if (mode == RenderMode.RESOURCE)
row.getCells().add(gen.new Cell(null, prefix + definitions.getBackboneLink(), "BackboneElement", null, null));
else if (e.getName().equals("Element"))
row.getCells().add(gen.new Cell(null, null, "n/a", null, null));
else
row.getCells().add(gen.new Cell(null, prefix + definitions.getBackboneLink(), "Element", null, null));
// analysis
row.getCells().add(dc = gen.new Cell());
} else if (e.getTypes().size() == 1) {
// card.
row.getCells().add(gen.new Cell(null, null, path.contains(".") ? e.describeCardinality() : "", null, null));
String t = e.getTypes().get(0).getName();
Cell c;
if (t.startsWith("@")) {
row.setIcon("icon_reuse.png", HierarchicalTableGenerator.TEXT_ICON_REUSE);
row.getCells().add(c = gen.new Cell("see ", "#" + t.substring(1), t.substring(t.lastIndexOf(".") + 1), t.substring(1), null));
// analysis
row.getCells().add(dc = gen.new Cell());
} else if (t.equals("Reference") || t.equals("canonical")) {
row.setIcon("icon_reference.png", HierarchicalTableGenerator.TEXT_ICON_REFERENCE);
row.getCells().add(c = gen.new Cell());
c.getPieces().add(gen.new Piece(prefix + "references.html", t, null));
c.getPieces().add(gen.new Piece(null, "(", null));
boolean first = true;
for (String rt : e.getTypes().get(0).getParams()) {
if (definitions.hasLogicalModel(rt)) {
for (String rtn : definitions.getLogicalModel(rt).getImplementations()) {
if (!first)
c.getPieces().add(gen.new Piece(null, " | ", null));
c.getPieces().add(gen.new Piece(prefix + findPage(rtn) + ".html", rtn, null));
first = false;
}
} else {
if (!first)
c.getPieces().add(gen.new Piece(null, " | ", null));
if (first && isProfile && e.getTypes().get(0).getProfile() != null)
c.getPieces().add(gen.new Piece(null, e.getTypes().get(0).getProfile(), null));
else
c.getPieces().add(gen.new Piece(prefix + findPage(rt) + ".html", rt, null));
first = false;
}
}
c.getPieces().add(gen.new Piece(null, ")", null));
// analysis
row.getCells().add(dc = gen.new Cell());
for (String rt : e.getTypes().get(0).getParams()) if (definitions.hasLogicalModel(rt)) {
for (String rtn : definitions.getLogicalModel(rt).getImplementations()) {
addTypeToAnalysis(gen, row, dc, true, e.getStandardsStatus(), rtn);
}
} else
addTypeToAnalysis(gen, row, dc, true, e.getStandardsStatus(), rt);
} else if (definitions.getPrimitives().containsKey(t)) {
row.setIcon("icon_primitive.png", HierarchicalTableGenerator.TEXT_ICON_PRIMITIVE);
row.getCells().add(c = gen.new Cell(null, prefix + "datatypes.html#" + t, t, null, null));
// analysis
row.getCells().add(dc = gen.new Cell());
addTypeToAnalysis(gen, row, dc, false, e.getStandardsStatus(), e.typeCode());
} else {
if (t.equals("Extension"))
row.setIcon("icon_extension_simple.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION);
else
row.setIcon("icon_datatype.gif", HierarchicalTableGenerator.TEXT_ICON_DATATYPE);
row.getCells().add(c = gen.new Cell(null, prefix + definitions.getSrcFile(t) + ".html#" + t.replace("*", "open"), t, null, null));
// analysis
row.getCells().add(dc = gen.new Cell());
addTypeToAnalysis(gen, row, dc, false, e.getStandardsStatus(), t);
}
} else {
row.getCells().add(gen.new Cell(null, null, e.describeCardinality(), null, null));
row.setIcon("icon_choice.gif", HierarchicalTableGenerator.TEXT_ICON_CHOICE);
row.getCells().add(gen.new Cell(null, null, "", null, null));
// analysis
row.getCells().add(dc = gen.new Cell());
}
}
if (e.hasBinding() && e.getBinding() != null && e.getBinding().getBinding() != BindingMethod.Unbound && (e.getBinding().getStrength() == BindingStrength.REQUIRED || e.getBinding().getStrength() == BindingStrength.EXTENSIBLE)) {
addBindingToAnalysis(gen, row, dc, e.getBinding().getStrength() == BindingStrength.REQUIRED, e.getStandardsStatus(), e.getBinding());
// if (cc.getPieces().size() == 1)
// cc.addPiece(gen.new Piece("br"));
// cc.getPieces().add(gen.new Piece(getBindingLink(prefix, e), e.getBinding().getValueSet() != null ? e.getBinding().getValueSet().getName() : e.getBinding().getName(),
// e.getBinding().getDefinition()));
// cc.getPieces().add(gen.new Piece(null, " (", null));
// BindingSpecification b = e.getBinding();
// if (b.hasMax() ) {
// cc.getPieces().add(gen.new Piece(prefix+"terminologies.html#"+b.getStrength().toCode(), b.getStrength().getDisplay(), b.getStrength().getDefinition()));
// cc.getPieces().add(gen.new Piece(null, " but limited to ", null));
// ValueSet vs = b.getMaxValueSet();
// cc.getPieces().add(gen.new Piece(vs.getUserString("path"), vs.getName(), null));
// } else
// cc.getPieces().add(gen.new Piece(prefix+"terminologies.html#"+b.getStrength().toCode(), b.getStrength().getDisplay(), b.getStrength().getDefinition()));
// cc.getPieces().add(gen.new Piece(null, ")", null));
}
if (e.getTypes().size() > 1) {
// create a child for each choice
for (TypeRef tr : e.getTypes()) {
Row choicerow = gen.new Row();
String t = tr.getName();
if (t.equals("Reference")) {
choicerow.getCells().add(gen.new Cell(null, null, e.getName().replace("[x]", "Reference"), null, null));
choicerow.getCells().add(gen.new Cell(null, null, "", null, null));
choicerow.setIcon("icon_reference.png", HierarchicalTableGenerator.TEXT_ICON_REFERENCE);
Cell c = gen.new Cell();
choicerow.getCells().add(c);
c.getPieces().add(gen.new Piece(prefix + "references.html", "Reference", null));
c.getPieces().add(gen.new Piece(null, "(", null));
boolean first = true;
List<String> tt = new ArrayList<>();
for (String rt : tr.getParams()) {
if (definitions.hasLogicalModel(rt))
tt.addAll(definitions.getLogicalModel(rt).getImplementations());
else
tt.add(rt);
}
Collections.sort(tt);
for (String rt : tt) {
if (!first)
c.getPieces().add(gen.new Piece(null, " | ", null));
c.getPieces().add(gen.new Piece(prefix + findPage(rt) + ".html", rt, null));
first = false;
}
// analysis
choicerow.getCells().add(dc = gen.new Cell());
for (String rt : tt) addTypeToAnalysis(gen, choicerow, dc, true, e.getStandardsStatus(), rt);
} else if (definitions.getPrimitives().containsKey(t)) {
choicerow.getCells().add(gen.new Cell(null, null, e.getName().replace("[x]", Utilities.capitalize(t)), definitions.getPrimitives().get(t).getDefinition(), null));
choicerow.getCells().add(gen.new Cell(null, null, "", null, null));
choicerow.setIcon("icon_primitive.png", HierarchicalTableGenerator.TEXT_ICON_PRIMITIVE);
choicerow.getCells().add(gen.new Cell(null, prefix + "datatypes.html#" + t, t, null, null));
// analysis
choicerow.getCells().add(dc = gen.new Cell());
addTypeToAnalysis(gen, choicerow, dc, false, e.getStandardsStatus(), t);
} else if (definitions.getConstraints().containsKey(t)) {
ProfiledType pt = definitions.getConstraints().get(t);
choicerow.getCells().add(gen.new Cell(null, null, e.getName().replace("[x]", Utilities.capitalize(pt.getBaseType())), definitions.getTypes().containsKey(t) ? definitions.getTypes().get(t).getDefinition() : null, null));
choicerow.getCells().add(gen.new Cell(null, null, "", null, null));
choicerow.setIcon("icon_datatype.gif", HierarchicalTableGenerator.TEXT_ICON_DATATYPE);
choicerow.getCells().add(gen.new Cell(null, definitions.getSrcFile(t) + ".html#" + t.replace("*", "open"), t, null, null));
// analysis
choicerow.getCells().add(dc = gen.new Cell());
addTypeToAnalysis(gen, choicerow, dc, false, e.getStandardsStatus(), t);
} else {
choicerow.getCells().add(gen.new Cell(null, null, e.getName().replace("[x]", Utilities.capitalize(t)), definitions.getTypes().containsKey(t) ? definitions.getTypes().get(t).getDefinition() : null, null));
choicerow.getCells().add(gen.new Cell(null, null, "", null, null));
choicerow.setIcon("icon_datatype.gif", HierarchicalTableGenerator.TEXT_ICON_DATATYPE);
choicerow.getCells().add(gen.new Cell(null, definitions.getSrcFile(t) + ".html#" + t.replace("*", "open"), t, null, null));
// analysis
choicerow.getCells().add(dc = gen.new Cell());
addTypeToAnalysis(gen, choicerow, dc, false, e.getStandardsStatus(), t);
}
row.getSubRows().add(choicerow);
}
} else
for (ElementDefn c : e.getElements()) row.getSubRows().add(genElement(c, gen, false, path + '.' + c.getName(), isProfile, prefix, mode, false));
return row;
}
use of org.hl7.fhir.r5.model.BackboneElement in project kindling by HL7.
the class XmlSpecGenerator 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("<");
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>");
boolean hasXmlLang = false;
for (ElementDefn elem : root.getElements()) {
hasXmlLang = hasXmlLang || elem.typeCode().equals("xml:lang");
}
if (hasXmlLang)
write(" xml:lang?");
if (resource)
write(" xmlns=\"http://hl7.org/fhir\"");
else
write(" xmlns=\"http://hl7.org/fhir\"");
for (ElementDefn elem : root.getElements()) {
if (elem.isXmlAttribute()) {
generateAttribute(elem);
}
}
if (resource) {
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");
} else
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\">extension</a>, <a href=\"" + prefix + "extensibility.html\">modifierExtension</a> -->\r\n");
} else {
write(" <!-- from Element: <a href=\"" + prefix + "extensibility.html\">extension</a> -->\r\n");
}
for (ElementDefn elem : root.getElements()) {
if (!elem.typeCode().equals("xml:lang") && !elem.isXmlAttribute())
generateCoreElem(elem, 1, rn, root.getName(), rn.equals(root.getName()) && resource);
}
write("</");
write(rn);
write(">\r\n");
}
use of org.hl7.fhir.r5.model.BackboneElement in project kindling by HL7.
the class JsonGenerator method generateType.
private JsonObject generateType(ElementDefn root, String name, ElementDefn struc, boolean isResource, JsonObject base, boolean relative) throws IOException, Exception {
String parent = isResource ? struc.typeCode() : "BackboneElement";
JsonObject r = new JsonObject();
name = name.replace(".", "_");
base.add(name, r);
r.addProperty("description", root.getDefinition());
Set<String> required = new HashSet<String>();
JsonObject props = new JsonObject();
r.add("properties", props);
if (isResource && definitions.hasResource(root.getName()) || "Parameters".equals(struc.getName())) {
JsonObject rt = new JsonObject();
props.add("resourceType", rt);
rt.addProperty("description", "This is a " + root.getName() + " resource");
rt.addProperty("const", root.getName());
required.add("resourceType");
}
r.addProperty("additionalProperties", false);
addInheritedProperties(root, parent, required, props, relative);
for (ElementDefn e : struc.getElements()) {
if (e.getName().equals("[type]"))
generateAny(root, e, "", props, relative);
else
generateElement(root, e, required, props, relative);
}
if (required.size() > 0) {
JsonArray req = new JsonArray();
r.add("required", req);
for (String s : required) {
req.add(new JsonPrimitive(s));
}
}
return props;
}
use of org.hl7.fhir.r5.model.BackboneElement in project kindling by HL7.
the class TableGenerator method genElement.
protected Row genElement(ElementDefn e, HierarchicalTableGenerator gen, boolean resource, String path, boolean isProfile, String prefix, RenderMode mode, boolean isRoot, StandardsStatus rootStatus, boolean isAbstract, boolean isInterface) throws Exception {
Row row = gen.new Row();
row.setAnchor(path);
boolean isProfiledExtension = isProfile && (e.getName().equals("extension") || e.getName().equals("modifierExtension"));
row.getCells().add(gen.new Cell(null, dictLinks() ? pageName + "#" + path.replace("[", "_").replace("]", "_") : null, e.getName(), path + " : " + e.getDefinition(), null));
Cell gc = gen.new Cell();
row.getCells().add(gc);
if (e.hasMustSupport() && e.isMustSupport()) {
gc.addStyledText("This element must be supported", "S", "white", "red", prefix + "conformance-rules.html#mustSupport", false);
}
if (e.isModifier()) {
gc.addStyledText("This element is a modifier element", "?!", null, null, prefix + "conformance-rules.html#isModifier", false);
}
if (e.isSummary()) {
gc.addStyledText("This element is included in summaries", "\u03A3", null, null, prefix + "elementdefinition-definitions.html#ElementDefinition.isSummary", false);
}
if (!isRoot && (!e.getInvariants().isEmpty() || !e.getStatedInvariants().isEmpty())) {
gc.addStyledText("This element has or is affected by some invariants", "I", null, null, prefix + "conformance-rules.html#constraints", false);
}
if (isInterface) {
gc.addStyledText("This is an abstract type", "«A»", null, null, prefix + "uml.html#abstract", false);
} else if (isAbstract) {
gc.addStyledText("This is an interface resource", "«I»", null, null, prefix + "uml.html#interface", false);
}
if (rootStatus != null)
gc.addStyledText("Standards Status = " + rootStatus.toDisplay(), rootStatus.getAbbrev(), "black", rootStatus.getColor(), prefix + "versions.html#std-process", true);
else if (e.getStandardsStatus() != null)
gc.addStyledText("Standards Status = " + e.getStandardsStatus().toDisplay(), e.getStandardsStatus().getAbbrev(), "black", e.getStandardsStatus().getColor(), prefix + "versions.html#std-process", true);
if (resource) {
row.getCells().add(gen.new Cell());
row.setIcon("icon_resource.png", HierarchicalTableGenerator.TEXT_ICON_RESOURCE);
if (Utilities.noString(e.typeCode()))
row.getCells().add(gen.new Cell(null, null, "n/a", null, null));
else if ("Logical".equals(e.typeCode()))
row.getCells().add(gen.new Cell(null, prefix + "structuredefinition.html#logical", e.typeCode(), null, null));
else if ("Base".equals(e.typeCode()))
row.getCells().add(gen.new Cell(null, prefix + definitions.getSrcFile("Base") + ".html#" + e.typeCode(), e.typeCode(), null, null));
else
row.getCells().add(gen.new Cell(null, prefix + e.typeCode().toLowerCase() + ".html", e.typeCode(), null, null));
// todo: base elements
} else {
if (!e.getElements().isEmpty()) {
row.getCells().add(gen.new Cell(null, null, path.contains(".") ? e.describeCardinality() : "", null, null));
row.setIcon("icon_element.gif", HierarchicalTableGenerator.TEXT_ICON_ELEMENT);
if (mode == RenderMode.RESOURCE)
row.getCells().add(gen.new Cell(null, prefix + definitions.getBackboneLink(), "BackboneElement", null, null));
else if (e.getName().equals("Type"))
row.getCells().add(gen.new Cell(null, null, "", null, null));
else if (e.getName().equals("Element")) {
if (version.isR4B()) {
row.getCells().add(gen.new Cell(null, prefix + definitions.getElementLink(), "Element", null, null));
} else {
row.getCells().add(gen.new Cell(null, prefix + definitions.getBaseLink(), "Base", null, null));
}
} else if (e.typeCode().equals("BackboneElement"))
row.getCells().add(gen.new Cell(null, prefix + definitions.getBackboneLink(), "BackBoneElement", null, null));
else
row.getCells().add(gen.new Cell(null, prefix + definitions.getElementLink(), "Element", null, null));
} else if (e.getTypes().size() == 1) {
row.getCells().add(gen.new Cell(null, null, path.contains(".") ? e.describeCardinality() : "", null, null));
String t = e.getTypes().get(0).getName();
Cell c;
if (t.startsWith("@")) {
row.setIcon("icon_reuse.png", HierarchicalTableGenerator.TEXT_ICON_REUSE);
c = gen.new Cell("see ", "#" + t.substring(1), t.substring(t.lastIndexOf(".") + 1), t.substring(1), null);
} else if (isReference(t)) {
row.setIcon("icon_reference.png", HierarchicalTableGenerator.TEXT_ICON_REFERENCE);
c = gen.new Cell();
if (ADD_REFERENCE_TO_TABLE) {
c.getPieces().add(gen.new Piece(prefix + definitions.getSrcFile(t) + ".html#" + t, t, null));
c.getPieces().add(gen.new Piece(null, "(", null));
}
boolean first = true;
for (String rt : e.getTypes().get(0).getParams()) {
if (!first)
c.getPieces().add(gen.new Piece(null, " | ", null));
if (first && isProfile && e.getTypes().get(0).getProfile() != null)
c.getPieces().add(gen.new Piece(null, e.getTypes().get(0).getProfile(), null));
else
c.getPieces().add(gen.new Piece(prefix + findPage(rt) + ".html", rt, null));
first = false;
}
if (ADD_REFERENCE_TO_TABLE)
c.getPieces().add(gen.new Piece(null, ")", null));
} else if (definitions.getPrimitives().containsKey(t)) {
row.setIcon("icon_primitive.png", HierarchicalTableGenerator.TEXT_ICON_PRIMITIVE);
c = gen.new Cell(null, prefix + "datatypes.html#" + t, t, null, null);
} else {
if (t.equals("Extension"))
row.setIcon("icon_extension_simple.png", HierarchicalTableGenerator.TEXT_ICON_EXTENSION);
else
row.setIcon("icon_datatype.gif", HierarchicalTableGenerator.TEXT_ICON_DATATYPE);
c = gen.new Cell(null, prefix + definitions.getSrcFile(t) + ".html#" + t.replace("*", "open"), t, null, null);
}
row.getCells().add(c);
} else {
row.getCells().add(gen.new Cell(null, null, isRoot ? "" : e.describeCardinality(), null, null));
row.setIcon("icon_choice.gif", HierarchicalTableGenerator.TEXT_ICON_CHOICE);
row.getCells().add(gen.new Cell(null, null, "", null, null));
}
}
Cell cc = gen.new Cell(null, e.getShortDefn() != null && Utilities.isURL(e.getShortDefn()) ? e.getShortDefn() : null, e.getShortDefn(), null, null);
row.getCells().add(cc);
// constraints
if (isProfiledExtension) {
cc.addPiece(gen.new Piece("br"));
cc.getPieces().add(gen.new Piece(null, e.getTypes().get(0).getProfile(), null));
}
if (e.hasBinding() && e.getBinding() != null && e.getBinding().getBinding() != BindingMethod.Unbound) {
if (cc.getPieces().size() == 1)
cc.addPiece(gen.new Piece("br"));
cc.getPieces().add(gen.new Piece(getBindingLink(prefix, e), e.getBinding().getValueSet() != null ? e.getBinding().getValueSet().present() : e.getBinding().getName(), e.getBinding().getDefinition()));
cc.getPieces().add(gen.new Piece(null, " (", null));
BindingSpecification b = e.getBinding();
if (b.hasMax()) {
cc.getPieces().add(gen.new Piece(prefix + "terminologies.html#" + b.getStrength().toCode(), b.getStrength().getDisplay(), b.getStrength().getDefinition()));
cc.getPieces().add(gen.new Piece(null, " but limited to ", null));
ValueSet vs = b.getMaxValueSet();
if (vs == null)
cc.getPieces().add(gen.new Piece(b.getMaxReference(), b.getMaxReference(), null));
else
cc.getPieces().add(gen.new Piece(vs.hasUserData("external.url") ? vs.getUserString("external.url") : vs.getUserString("path"), vs.getName(), null));
} else
cc.getPieces().add(gen.new Piece(prefix + "terminologies.html#" + b.getStrength().toCode(), b.getStrength().getDisplay(), b.getStrength().getDefinition()));
cc.getPieces().add(gen.new Piece(null, ")", null));
}
List<String> invs = new ArrayList<String>(e.getInvariants().keySet());
Collections.sort(invs, new ConstraintsSorter());
for (String name : invs) {
Invariant inv = e.getInvariants().get(name);
cc.addPiece(gen.new Piece("br"));
cc.getPieces().add(gen.new Piece(null, "+ " + presentLevel(inv) + ": " + inv.getEnglish(), inv.getId()).setStyle("font-style: italic"));
}
if (e.unbounded() && !isRoot) {
if (cc.getPieces().size() > 0)
cc.addPiece(gen.new Piece("br"));
if (Utilities.noString(e.getOrderMeaning())) {
// don't show this, this it's important: cc.getPieces().add(gen.new Piece(null, "This repeating element has no defined order", null));
} else {
cc.getPieces().add(gen.new Piece(null, "This repeating element order: " + e.getOrderMeaning(), null));
}
}
if (isRoot && !Utilities.noString(e.typeCode()) && !"Logical".equals(e.typeCode())) {
List<ElementDefn> ancestors = new ArrayList<ElementDefn>();
ElementDefn f = definitions.getElementDefn(e.typeCode());
while (f != null) {
ancestors.add(0, f);
f = Utilities.noString(f.typeCode()) || "Logical".equals(f.typeCode()) ? null : definitions.getElementDefn(f.typeCode());
}
cc.getPieces().add(gen.new Piece("br"));
cc.getPieces().add(gen.new Piece(null, "Elements defined in Ancestors: ", null));
boolean first = true;
for (ElementDefn fi : ancestors) {
for (ElementDefn fc : fi.getElements()) {
if (first)
first = false;
else
cc.getPieces().add(gen.new Piece(null, ", ", null));
cc.getPieces().add(gen.new Piece(definitions.getSrcFile(fi.getName()) + ".html#" + fi.getName(), fc.getName(), fc.getDefinition()));
}
}
}
if (mode == RenderMode.LOGICAL) {
String logical = e.getMappings().get("http://hl7.org/fhir/logical");
Cell c = gen.new Cell();
row.getCells().add(c);
if (logical != null)
presentLogicalMapping(gen, c, logical, prefix);
}
if (e.getTypes().size() > 1) {
// create a child for each choice
for (TypeRef tr : e.getTypes()) {
Row choicerow = gen.new Row();
String t = tr.getName();
if (isReference(t)) {
choicerow.getCells().add(gen.new Cell(null, null, e.getName().replace("[x]", Utilities.capitalize(t)), null, null));
choicerow.getCells().add(gen.new Cell());
choicerow.getCells().add(gen.new Cell(null, null, "", null, null));
choicerow.setIcon("icon_reference.png", HierarchicalTableGenerator.TEXT_ICON_REFERENCE);
Cell c = gen.new Cell();
choicerow.getCells().add(c);
if (ADD_REFERENCE_TO_TABLE) {
if (tr.getName().equals("canonical"))
c.getPieces().add(gen.new Piece(prefix + "datatypes.html#canonical", "canonical", null));
else
c.getPieces().add(gen.new Piece(prefix + "references.html#Reference", "Reference", null));
c.getPieces().add(gen.new Piece(null, "(", null));
}
boolean first = true;
for (String rt : tr.getParams()) {
if (!first)
c.getPieces().add(gen.new Piece(null, " | ", null));
c.getPieces().add(gen.new Piece(prefix + findPage(rt) + ".html", rt, null));
first = false;
}
if (ADD_REFERENCE_TO_TABLE)
c.getPieces().add(gen.new Piece(null, ")", null));
} else if (definitions.getPrimitives().containsKey(t)) {
choicerow.getCells().add(gen.new Cell(null, null, e.getName().replace("[x]", Utilities.capitalize(t)), definitions.getPrimitives().get(t).getDefinition(), null));
choicerow.getCells().add(gen.new Cell());
choicerow.getCells().add(gen.new Cell(null, null, "", null, null));
choicerow.setIcon("icon_primitive.png", HierarchicalTableGenerator.TEXT_ICON_PRIMITIVE);
choicerow.getCells().add(gen.new Cell(null, prefix + "datatypes.html#" + t, t, null, null));
} else if (definitions.getConstraints().containsKey(t)) {
ProfiledType pt = definitions.getConstraints().get(t);
choicerow.getCells().add(gen.new Cell(null, null, e.getName().replace("[x]", Utilities.capitalize(pt.getBaseType())), definitions.getTypes().containsKey(t) ? definitions.getTypes().get(t).getDefinition() : null, null));
choicerow.getCells().add(gen.new Cell());
choicerow.getCells().add(gen.new Cell(null, null, "", null, null));
choicerow.setIcon("icon_datatype.gif", HierarchicalTableGenerator.TEXT_ICON_DATATYPE);
choicerow.getCells().add(gen.new Cell(null, definitions.getSrcFile(t) + ".html#" + t.replace("*", "open"), t, null, null));
} else {
choicerow.getCells().add(gen.new Cell(null, null, e.getName().replace("[x]", Utilities.capitalize(t)), definitions.getTypes().containsKey(t) ? definitions.getTypes().get(t).getDefinition() : null, null));
choicerow.getCells().add(gen.new Cell());
choicerow.getCells().add(gen.new Cell(null, null, "", null, null));
choicerow.setIcon("icon_datatype.gif", HierarchicalTableGenerator.TEXT_ICON_DATATYPE);
choicerow.getCells().add(gen.new Cell(null, definitions.getSrcFile(t) + ".html#" + t.replace("*", "open"), t, null, null));
}
choicerow.getCells().add(gen.new Cell());
// choicerow.getCells().add(gen.new Cell());
row.getSubRows().add(choicerow);
}
} else
for (ElementDefn c : e.getElements()) {
row.getSubRows().add(genElement(c, gen, false, path + '.' + c.getName(), isProfile, prefix, mode, false, null, false, false));
}
return row;
}
Aggregations