use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator in project org.hl7.fhir.core by hapifhir.
the class ValueSetComparer method renderCompose.
public XhtmlNode renderCompose(ValueSetComparison csc, String id, String prefix) throws FHIRException, IOException {
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(Utilities.path("[tmp]", "comparison"), false);
TableModel model = gen.new TableModel(id, true);
model.setAlternating(true);
model.getTitles().add(gen.new Title(null, null, "Item", "The type of item being compared", null, 100));
model.getTitles().add(gen.new Title(null, null, "Property", "The system for the concept", null, 100, 2));
model.getTitles().add(gen.new Title(null, null, "Value", "The display for the concept", null, 200, 2));
model.getTitles().add(gen.new Title(null, null, "Comments", "Additional information about the comparison", null, 200));
for (StructuralMatch<Element> t : csc.getIncludes().getChildren()) {
addComposeRow(gen, model.getRows(), t, "include");
}
for (StructuralMatch<Element> t : csc.getExcludes().getChildren()) {
addComposeRow(gen, model.getRows(), t, "exclude");
}
return gen.generate(model, prefix, 0, null);
}
use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireRenderer method renderTreeItem.
private boolean renderTreeItem(HierarchicalTableGenerator gen, List<Row> rows, Questionnaire q, QuestionnaireItemComponent i, boolean hasFlags) throws IOException {
Row r = gen.new Row();
rows.add(r);
boolean hasExt = false;
r.setIcon("icon-q-" + i.getType().toCode().toLowerCase() + ".png", i.getType().getDisplay());
r.getCells().add(gen.new Cell(null, context.getDefinitionsTarget() == null ? "" : context.getDefinitionsTarget() + "#item." + i.getLinkId(), i.getLinkId(), null, null));
String txt = (i.hasPrefix() ? i.getPrefix() + ". " : "") + i.getText();
r.getCells().add(gen.new Cell(null, null, txt, null, null));
r.getCells().add(gen.new Cell(null, null, (i.getRequired() ? "1" : "0") + ".." + (i.getRepeats() ? "*" : "1"), null, null));
if (i.getTypeElement().hasExtension(EXT_QUESTIONNAIRE_ITEM_TYPE_ORIGINAL)) {
String t = i.getTypeElement().getExtensionString(EXT_QUESTIONNAIRE_ITEM_TYPE_ORIGINAL);
r.getCells().add(gen.new Cell(null, context.getSpecificationLink() + "codesystem-item-type.html#item-type-" + t, t, null, null));
} else {
r.getCells().add(gen.new Cell(null, context.getSpecificationLink() + "codesystem-item-type.html#item-type-" + i.getType().toCode(), i.getType().toCode(), null, null));
}
if (hasFlags) {
// flags:
Cell flags = gen.new Cell();
r.getCells().add(flags);
if (i.getReadOnly()) {
flags.addPiece(gen.new Piece(Utilities.pathURL(context.getSpecificationLink(), "questionnaire-definitions.html#Questionnaire.item.readOnly"), null, "Is Readonly").addHtml(new XhtmlNode(NodeType.Element, "img").attribute("src", Utilities.path(context.getLocalPrefix(), "icon-qi-readonly.png"))));
}
if (ToolingExtensions.readBoolExtension(i, "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-isSubject")) {
flags.addPiece(gen.new Piece(getSDCLink("StructureDefinition-sdc-questionnaire-isSubject.html"), null, "Can change the subject of the questionnaire").addHtml(new XhtmlNode(NodeType.Element, "img").attribute("src", Utilities.path(context.getLocalPrefix(), "icon-qi-subject.png"))));
}
if (ToolingExtensions.readBoolExtension(i, "http://hl7.org/fhir/StructureDefinition/questionnaire-hidden")) {
flags.addPiece(gen.new Piece(getSpecLink("extension-questionnaire-hidden.html"), null, "Is a hidden item").addHtml(new XhtmlNode(NodeType.Element, "img").attribute("src", Utilities.path(context.getLocalPrefix(), "icon-qi-hidden.png"))));
}
if (ToolingExtensions.readBoolExtension(i, "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-optionalDisplay")) {
flags.addPiece(gen.new Piece(getSDCLink("StructureDefinition-sdc-questionnaire-optionalDisplay.html"), null, "Is optional to display").addHtml(new XhtmlNode(NodeType.Element, "img").attribute("src", Utilities.path(context.getLocalPrefix(), "icon-qi-optional.png"))));
}
if (i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationLinkPeriod")) {
flags.addPiece(gen.new Piece(getSDCLink("StructureDefinition-sdc-questionnaire-observationLinkPeriod"), null, "Is linked to an observation").addHtml(new XhtmlNode(NodeType.Element, "img").attribute("src", Utilities.path(context.getLocalPrefix(), "icon-qi-observation.png"))));
}
if (i.hasExtension("http://hl7.org/fhir/StructureDefinition/questionnaire-choiceOrientation")) {
String code = ToolingExtensions.readStringExtension(i, "http://hl7.org/fhir/StructureDefinition/questionnaire-choiceOrientation");
flags.addPiece(gen.new Piece(getSpecLink("extension-questionnaire-choiceorientation.html"), null, "Orientation: " + code).addHtml(new XhtmlNode(NodeType.Element, "img").attribute("src", Utilities.path(context.getLocalPrefix(), "icon-qi-" + code + ".png"))));
}
if (i.hasExtension("http://hl7.org/fhir/StructureDefinition/questionnaire-displayCategory")) {
CodeableConcept cc = i.getExtensionByUrl("http://hl7.org/fhir/StructureDefinition/questionnaire-displayCategory").getValueCodeableConcept();
String code = cc.getCode("http://hl7.org/fhir/questionnaire-display-category");
flags.addPiece(gen.new Piece(getSDCLink("StructureDefinition-sdc-questionnaire-displayCategory"), null, "Category: " + code).addHtml(new XhtmlNode(NodeType.Element, "img").attribute("src", Utilities.path(context.getLocalPrefix(), "icon-qi-" + code + ".png"))));
}
}
Cell defn = gen.new Cell();
r.getCells().add(defn);
if (i.hasMaxLength()) {
defn.getPieces().add(gen.new Piece(null, "Max Length: ", null));
defn.getPieces().add(gen.new Piece(null, Integer.toString(i.getMaxLength()), null));
}
if (i.hasDefinition()) {
if (!defn.getPieces().isEmpty())
defn.addPiece(gen.new Piece("br"));
defn.getPieces().add(gen.new Piece(null, "Definition: ", null));
genDefinitionLink(gen, i, defn);
}
if (i.hasEnableWhen()) {
if (!defn.getPieces().isEmpty())
defn.addPiece(gen.new Piece("br"));
Piece p = gen.new Piece(null, "Enable When: ", null);
defn.getPieces().add(p);
if (i.getEnableWhen().size() == 0) {
XhtmlNode x = new XhtmlNode(NodeType.Element, "span");
p.getChildren().add(x);
renderEnableWhen(x, i.getEnableWhenFirstRep());
} else {
XhtmlNode x = new XhtmlNode(NodeType.Element, "ul");
p.getChildren().add(x);
for (QuestionnaireItemEnableWhenComponent qi : i.getEnableWhen()) {
renderEnableWhen(x.li(), qi);
}
}
}
if (i.hasAnswerValueSet()) {
if (!defn.getPieces().isEmpty())
defn.addPiece(gen.new Piece("br"));
defn.getPieces().add(gen.new Piece(null, "Value Set: ", null));
if (!Utilities.noString(i.getAnswerValueSet()) && i.getAnswerValueSet().startsWith("#")) {
ValueSet vs = (ValueSet) q.getContained(i.getAnswerValueSet().substring(1));
if (vs == null) {
defn.getPieces().add(gen.new Piece(null, i.getAnswerValueSet(), null));
} else {
defn.getPieces().add(gen.new Piece(vs.getUserString("path"), vs.present(), null));
}
} else {
ValueSet vs = context.getWorker().fetchResource(ValueSet.class, i.getAnswerValueSet());
if (vs == null || !vs.hasUserData("path")) {
defn.getPieces().add(gen.new Piece(null, i.getAnswerValueSet(), null));
} else {
defn.getPieces().add(gen.new Piece(vs.getUserString("path"), vs.present(), null));
}
}
}
if (i.hasAnswerOption()) {
if (!defn.getPieces().isEmpty())
defn.addPiece(gen.new Piece("br"));
defn.getPieces().add(gen.new Piece(null, "Options: ", null));
if (context.getDefinitionsTarget() == null) {
// if we don't have a definitions target, we'll add them below.
defn.getPieces().add(gen.new Piece("#opt-item." + i.getLinkId(), Integer.toString(i.getAnswerOption().size()) + " " + Utilities.pluralize("option", i.getAnswerOption().size()), null));
} else {
defn.getPieces().add(gen.new Piece(context.getDefinitionsTarget() + "#item." + i.getLinkId(), Integer.toString(i.getAnswerOption().size()) + " " + Utilities.pluralize("option", i.getAnswerOption().size()), null));
}
}
if (i.hasInitial()) {
for (QuestionnaireItemInitialComponent v : i.getInitial()) {
if (!defn.getPieces().isEmpty())
defn.addPiece(gen.new Piece("br"));
defn.getPieces().add(gen.new Piece(null, "Initial Value: ", null));
defn.getPieces().add(gen.new Piece(null, v.getValue().fhirType(), null));
defn.getPieces().add(gen.new Piece(null, " = ", null));
if (v.getValue().isPrimitive()) {
defn.getPieces().add(gen.new Piece(null, v.getValue().primitiveValue(), null));
} else {
renderCoding(gen, defn.getPieces(), v.getValueCoding());
}
}
}
if (i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemContext") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-contextExpression") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-candidateExpression") || i.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression")) {
if (!defn.getPieces().isEmpty())
defn.addPiece(gen.new Piece("br"));
defn.getPieces().add(gen.new Piece(null, "Expressions: ", null));
Piece p = gen.new Piece("ul");
defn.getPieces().add(p);
for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression")) {
addExpression(p, e.getValueExpression(), "Initial Value", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-initialExpression");
}
for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-contextExpression")) {
addExpression(p, e.getValueExpression(), "Context", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-contextExpression");
}
for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemContext")) {
addExpression(p, e.getValueExpression(), "Item Context", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-itemContext");
}
for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression")) {
addExpression(p, e.getValueExpression(), "Enable When", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression");
}
for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression")) {
addExpression(p, e.getValueExpression(), "Calculated Value", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression");
}
for (Extension e : i.getExtensionsByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-candidateExpression")) {
addExpression(p, e.getValueExpression(), "Candidates", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-candidateExpression");
}
}
for (QuestionnaireItemComponent c : i.getItem()) {
hasExt = renderTreeItem(gen, r.getSubRows(), q, c, hasFlags) || hasExt;
}
return hasExt;
}
use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator in project org.hl7.fhir.core by hapifhir.
the class DataRenderer method renderCoding.
protected void renderCoding(HierarchicalTableGenerator gen, List<Piece> pieces, Coding c) {
if (c.isEmpty()) {
return;
}
String url = getLinkForSystem(c.getSystem(), c.getVersion());
String name = displayCodeSource(c.getSystem(), c.getVersion());
if (!Utilities.noString(url)) {
pieces.add(gen.new Piece(url, name, c.getSystem() + (c.hasVersion() ? "#" + c.getVersion() : "")));
} else {
pieces.add(gen.new Piece(null, name, c.getSystem() + (c.hasVersion() ? "#" + c.getVersion() : "")));
}
pieces.add(gen.new Piece(null, "#" + c.getCode(), null));
String s = c.getDisplay();
if (Utilities.noString(s)) {
s = lookupCode(c.getSystem(), c.getVersion(), c.getCode());
}
if (!Utilities.noString(s)) {
pieces.add(gen.new Piece(null, " \"" + s + "\"", null));
}
}
use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireResponseRenderer method renderTree.
public boolean renderTree(XhtmlNode x, ResourceWrapper qr) throws UnsupportedEncodingException, IOException {
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(context.getDestDir(), context.isInlineGraphics(), true);
TableModel model = gen.new TableModel("qtree=" + qr.getId(), false);
model.setAlternating(true);
model.setDocoImg(context.getSpecificationLink() + "help16.png");
model.setDocoRef(context.getSpecificationLink() + "formats.html#table");
model.getTitles().add(gen.new Title(null, model.getDocoRef(), translate("sd.head", "LinkId"), translate("sd.hint", "The linkId for the item"), null, 0));
model.getTitles().add(gen.new Title(null, model.getDocoRef(), translate("sd.head", "Text"), translate("sd.hint", "Text for the item"), null, 0));
model.getTitles().add(gen.new Title(null, model.getDocoRef(), translate("sd.head", "Definition"), translate("sd.hint", "Minimum and Maximum # of times the the itemcan appear in the instance"), null, 0));
model.getTitles().add(gen.new Title(null, model.getDocoRef(), translate("sd.head", "Answer"), translate("sd.hint", "The type of the item"), null, 0));
boolean hasExt = false;
// first we add a root for the questionaire itself
Row row = addTreeRoot(gen, model.getRows(), qr);
List<BaseWrapper> items = qr.children("item");
for (BaseWrapper i : items) {
hasExt = renderTreeItem(gen, row.getSubRows(), qr, i) || hasExt;
}
XhtmlNode xn = gen.generate(model, context.getLocalPrefix(), 1, null);
x.getChildNodes().add(xn);
return hasExt;
}
use of org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireResponseRenderer method renderTreeItem.
private boolean renderTreeItem(HierarchicalTableGenerator gen, List<Row> rows, ResourceWrapper q, BaseWrapper i) throws IOException {
Row r = gen.new Row();
rows.add(r);
boolean hasExt = false;
List<BaseWrapper> items = i.children("item");
List<BaseWrapper> answers = i.children("answer");
boolean hasItem = items != null && !items.isEmpty();
if (answers != null) {
for (BaseWrapper a : answers) {
hasItem = a.has("item");
}
}
if (hasItem) {
r.setIcon("icon-q-group.png", "Group");
} else {
r.setIcon("icon-q-string.png", "Item");
}
String linkId = i.has("linkId") ? i.get("linkId").primitiveValue() : "??";
String text = i.has("text") ? i.get("text").primitiveValue() : "";
r.getCells().add(gen.new Cell(null, context.getDefinitionsTarget() == null ? "" : context.getDefinitionsTarget() + "#item." + linkId, linkId, null, null));
r.getCells().add(gen.new Cell(null, null, text, null, null));
r.getCells().add(gen.new Cell(null, null, null, null, null));
if (answers.size() == 0) {
r.getCells().add(gen.new Cell(null, null, null, null, null));
for (BaseWrapper si : items) {
renderTreeItem(gen, r.getSubRows(), q, si);
}
} else if (answers.size() == 1) {
BaseWrapper ans = answers.get(0);
renderAnswer(gen, q, r, ans);
} else {
r.getCells().add(gen.new Cell(null, null, null, null, null));
for (BaseWrapper ans : answers) {
Row ar = gen.new Row();
ar.setIcon("icon-q-string.png", "Item");
ar.getSubRows().add(ar);
ar.getCells().add(gen.new Cell(null, null, null, null, null));
ar.getCells().add(gen.new Cell(null, null, text, null, null));
ar.getCells().add(gen.new Cell(null, null, null, null, null));
renderAnswer(gen, q, ar, ans);
}
}
return hasExt;
}
Aggregations