Search in sources :

Example 1 with QuestionnaireResponseItemComponent

use of org.hl7.fhir.r4.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;
}
Also used : QuestionnaireResponseItemAnswerComponent(org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent) Answer(org.nhspathways.webservices.pathways.pathwayscase.PathwaysCaseDocument.PathwaysCase.PathwayDetails.PathwayTriageDetails.PathwayTriage.TriageLineDetails.TriageLine.Question.Answers.Answer) StringType(org.hl7.fhir.dstu3.model.StringType) QuestionnaireResponseItemComponent(org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemComponent)

Example 2 with QuestionnaireResponseItemComponent

use of org.hl7.fhir.r4.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;
}
Also used : QuestionnaireResponseItemComponent(org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemComponent) HierarchicalTableGenerator(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator) Row(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row) TableModel(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 3 with QuestionnaireResponseItemComponent

use of org.hl7.fhir.r4.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;
}
Also used : QuestionnaireResponseItemAnswerComponent(org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent) Row(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row) Cell(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)

Example 4 with QuestionnaireResponseItemComponent

use of org.hl7.fhir.r4.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;
}
Also used : QuestionnaireResponseItemAnswerComponent(org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent) QuestionnaireResponseItemComponent(org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent)

Example 5 with QuestionnaireResponseItemComponent

use of org.hl7.fhir.r4.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;
}
Also used : QuestionnaireResponseItemComponent(org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent)

Aggregations

Row (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row)4 QuestionnaireResponseItemComponent (org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent)3 QuestionnaireResponseItemAnswerComponent (org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent)2 StructureDefinition (org.hl7.fhir.r4b.model.StructureDefinition)2 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)2 HierarchicalTableGenerator (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator)2 Cell (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)2 Piece (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece)2 TableModel (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel)2 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)2 FhirContext (ca.uhn.fhir.context.FhirContext)1 DataFormatException (ca.uhn.fhir.parser.DataFormatException)1 IParser (ca.uhn.fhir.parser.IParser)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1