use of org.hl7.fhir.r5.model.Questionnaire in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireRenderer method listOptions.
private void listOptions(Questionnaire q, QuestionnaireItemComponent i, XhtmlNode select) {
if (i.hasAnswerValueSet()) {
ValueSet vs = null;
if (!Utilities.noString(i.getAnswerValueSet()) && i.getAnswerValueSet().startsWith("#")) {
vs = (ValueSet) q.getContained(i.getAnswerValueSet().substring(1));
if (vs != null && !vs.hasUrl()) {
vs = vs.copy();
vs.setUrl(q.getUrl() + "--" + q.getContained(i.getAnswerValueSet().substring(1)));
}
} else {
vs = context.getContext().fetchResource(ValueSet.class, i.getAnswerValueSet());
}
if (vs != null) {
ValueSetExpansionOutcome exp = context.getContext().expandVS(vs, true, false);
if (exp.getValueset() != null) {
for (ValueSetExpansionContainsComponent cc : exp.getValueset().getExpansion().getContains()) {
select.option(cc.getCode(), cc.hasDisplay() ? cc.getDisplay() : cc.getCode(), false);
}
return;
}
}
} else if (i.hasAnswerOption()) {
renderItemOptions(select, i);
}
select.option("a", "??", false);
}
use of org.hl7.fhir.r5.model.Questionnaire in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireRenderer method renderLogic.
private boolean renderLogic(XhtmlNode x, Questionnaire q) throws FHIRException, IOException {
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(context.getDestDir(), context.isInlineGraphics(), true);
TableModel model = gen.new TableModel("qtree=" + q.getId(), true);
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", "Description & Constraints"), translate("sd.hint", "Additional information about the item"), null, 0));
boolean hasExt = false;
if (!q.hasItem()) {
gen.emptyRow(model, 2);
} else {
for (QuestionnaireItemComponent i : q.getItem()) {
hasExt = renderLogicItem(gen, model.getRows(), q, i) || hasExt;
}
}
XhtmlNode xn = gen.generate(model, context.getLocalPrefix(), 1, null);
x.getChildNodes().add(xn);
return hasExt;
}
use of org.hl7.fhir.r5.model.Questionnaire in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireRenderer method addTreeRoot.
private Row addTreeRoot(HierarchicalTableGenerator gen, List<Row> rows, Questionnaire q, boolean hasFlags) throws IOException {
Row r = gen.new Row();
rows.add(r);
r.setIcon("icon_q_root.gif", "QuestionnaireRoot");
r.getCells().add(gen.new Cell(null, null, q.getName(), null, null));
r.getCells().add(gen.new Cell(null, null, q.getDescription(), null, null));
r.getCells().add(gen.new Cell(null, null, "", null, null));
r.getCells().add(gen.new Cell(null, null, "Questionnaire", null, null));
if (hasFlags) {
r.getCells().add(gen.new Cell(null, null, "", null, null));
}
r.getCells().add(gen.new Cell(null, null, q.hasUrl() ? q.hasVersion() ? q.getUrl() + "#" + q.getVersion() : q.getUrl() : "", null, null));
return r;
}
use of org.hl7.fhir.r5.model.Questionnaire in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireRenderer method renderLinks.
private boolean renderLinks(XhtmlNode x, Questionnaire q) {
x.para().tx("Try this questionnaire out:");
XhtmlNode ul = x.ul();
ul.li().ah("http://todo.nlm.gov/path?mode=ig&src=" + Utilities.pathURL(context.getSelfLink(), "package.tgz") + "&q=" + q.getId() + ".json").tx("NLM Forms Library");
return false;
}
use of org.hl7.fhir.r5.model.Questionnaire in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireRenderer method renderLogicItem.
private boolean renderLogicItem(HierarchicalTableGenerator gen, List<Row> rows, Questionnaire q, QuestionnaireItemComponent i) 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));
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"));
defn.getPieces().add(gen.new Piece(null, "Enable When: ", null));
defn.getPieces().add(gen.new Piece(null, "todo", null));
}
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));
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 = renderLogicItem(gen, r.getSubRows(), q, c) || hasExt;
}
return hasExt;
}
Aggregations