use of org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemComponent in project integration-adaptor-111 by nhsconnect.
the class QuestionnaireResponseMapper method getItem.
private QuestionnaireResponseItemComponent getItem(Question question) {
QuestionnaireResponseItemComponent item = new QuestionnaireResponseItemComponent();
QuestionnaireResponseItemAnswerComponent answer = new QuestionnaireResponseItemAnswerComponent();
StringType correctAnswerText = new StringType();
if (StringUtils.isBlank(question.getQuestionId())) {
item.setLinkId(NOT_APPLICABLE);
} else {
item.setLinkId(question.getQuestionId());
}
item.setText(question.getQuestionText());
for (Answer singleAnswer : question.getAnswers().getAnswerArray()) {
if (singleAnswer.getSelected() && !singleAnswer.getText().isBlank()) {
correctAnswerText.setValueAsString(singleAnswer.getText());
}
}
answer.setValue(correctAnswerText);
item.addAnswer(answer);
return item;
}
use of org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemComponent in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireResponseRenderer method renderTree.
public boolean renderTree(XhtmlNode x, QuestionnaireResponse q) throws UnsupportedEncodingException, 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", "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(), q);
for (QuestionnaireResponseItemComponent i : q.getItem()) {
hasExt = renderTreeItem(gen, row.getSubRows(), 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.QuestionnaireResponse.QuestionnaireResponseItemComponent in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireResponseRenderer method renderTreeItem.
private boolean renderTreeItem(HierarchicalTableGenerator gen, List<Row> rows, QuestionnaireResponse q, QuestionnaireResponseItemComponent i) throws IOException {
Row r = gen.new Row();
rows.add(r);
boolean hasExt = false;
boolean hasItem = i.hasItem();
for (QuestionnaireResponseItemAnswerComponent a : i.getAnswer()) {
hasItem = a.hasItem();
}
if (hasItem) {
r.setIcon("icon-q-group.png", "Group");
} else {
r.setIcon("icon-q-string.png", "Item");
}
r.getCells().add(gen.new Cell(null, context.getDefinitionsTarget() == null ? "" : context.getDefinitionsTarget() + "#item." + i.getLinkId(), i.getLinkId(), null, null));
r.getCells().add(gen.new Cell(null, null, i.getText(), null, null));
r.getCells().add(gen.new Cell(null, null, null, null, null));
r.getCells().add(gen.new Cell(null, null, null, null, null));
return hasExt;
}
use of org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemComponent in project pathling by aehrc.
the class TestData method newQuestionnaireResponse.
/**
* Returns a FHIR QuestionnaireResponse resource for testing purposes.
*/
public static QuestionnaireResponse newQuestionnaireResponse() {
final QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
questionnaireResponse.setId("QuestionnaireResponse/1");
final QuestionnaireResponseItemComponent item = questionnaireResponse.addItem();
final QuestionnaireResponseItemAnswerComponent answer1 = new QuestionnaireResponseItemAnswerComponent();
answer1.setValue(new DecimalType(TEST_VERY_SMALL_DECIMAL_SCALE_6));
final QuestionnaireResponseItemAnswerComponent answer2 = new QuestionnaireResponseItemAnswerComponent();
answer2.setValue(new DecimalType(TEST_VERY_BIG_DECIMAL));
item.addAnswer(answer1);
item.addAnswer(answer2);
return questionnaireResponse;
}
use of org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemComponent in project pathling by aehrc.
the class TestData method newNestedResponseItem.
private static QuestionnaireResponseItemComponent newNestedResponseItem(final int nestingLevel) {
final QuestionnaireResponseItemComponent item = new QuestionnaireResponseItemComponent();
item.setLinkId("ItemLevel/" + nestingLevel);
if (nestingLevel > 0) {
item.setAnswer(Collections.singletonList(newNestedResponseAnswer(nestingLevel)));
item.setItem(Collections.singletonList(newNestedResponseItem(nestingLevel - 1)));
}
return item;
}
Aggregations