Search in sources :

Example 6 with QuestionnaireResponseItemAnswerComponent

use of org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent 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 7 with QuestionnaireResponseItemAnswerComponent

use of org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent in project pathling by aehrc.

the class TestData method newNestedResponseAnswer.

private static QuestionnaireResponseItemAnswerComponent newNestedResponseAnswer(final int nestingLevel) {
    final QuestionnaireResponseItemAnswerComponent answer = new QuestionnaireResponseItemAnswerComponent();
    answer.setId("AnswerLevel/" + nestingLevel);
    answer.setItem(Collections.singletonList(newNestedResponseItem(nestingLevel - 1)));
    return answer;
}
Also used : QuestionnaireResponseItemAnswerComponent(org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent)

Example 8 with QuestionnaireResponseItemAnswerComponent

use of org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent in project org.hl7.fhir.core by hapifhir.

the class QuestionnaireBuilder method selectTypes.

private void selectTypes(StructureDefinition profile, QuestionnaireItemComponent sub, TypeRefComponent t, List<QuestionnaireResponse.QuestionnaireResponseItemComponent> source, List<QuestionnaireResponse.QuestionnaireResponseItemComponent> dest) throws FHIRFormatError {
    List<QuestionnaireResponse.QuestionnaireResponseItemComponent> temp = new ArrayList<QuestionnaireResponse.QuestionnaireResponseItemComponent>();
    for (QuestionnaireResponse.QuestionnaireResponseItemComponent g : source) if (instanceOf(t, (Element) g.getUserData("object")))
        temp.add(g);
    for (QuestionnaireResponse.QuestionnaireResponseItemComponent g : temp) source.remove(g);
    for (QuestionnaireResponse.QuestionnaireResponseItemComponent g : temp) {
        // it should be empty
        assert (g.getItem().size() == 0);
        QuestionnaireResponse.QuestionnaireResponseItemComponent q = g.addItem();
        q.setLinkId(g.getLinkId() + "._type");
        q.setText("type");
        QuestionnaireResponseItemAnswerComponent a = q.addAnswer();
        if (t.hasTarget()) {
            for (UriType u : t.getTargetProfile()) {
                if (u.getValue().startsWith("http://hl7.org/fhir/StructureDefinition/")) {
                    Coding cc = new Coding();
                    a.setValue(cc);
                    cc.setCode(u.getValue().substring(40));
                    cc.setSystem("http://hl7.org/fhir/resource-types");
                }
            }
        } else {
            Coding cc = new Coding();
            a.setValue(cc);
            ProfileUtilities pu = new ProfileUtilities(context, null, null);
            StructureDefinition ps = null;
            if (t.hasProfile())
                ps = pu.getProfile(profile, t.getProfile().get(0).getValue());
            if (ps != null) {
                cc.setCode(t.getProfile().get(0).getValue());
                cc.setSystem("http://hl7.org/fhir/resource-types");
            } else {
                cc.setCode(t.getWorkingCode());
                cc.setSystem("http://hl7.org/fhir/data-types");
            }
        }
        // 1st: create the subgroup
        QuestionnaireResponse.QuestionnaireResponseItemComponent subg = a.addItem();
        dest.add(subg);
        subg.setLinkId(sub.getLinkId());
        subg.setText(sub.getText());
        subg.setUserData("object", g.getUserData("object"));
    }
}
Also used : QuestionnaireResponseItemAnswerComponent(org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) Coding(org.hl7.fhir.r5.model.Coding) ProfileUtilities(org.hl7.fhir.r5.conformance.ProfileUtilities) Element(org.hl7.fhir.r5.model.Element) ArrayList(java.util.ArrayList) QuestionnaireResponse(org.hl7.fhir.r5.model.QuestionnaireResponse) UriType(org.hl7.fhir.r5.model.UriType)

Example 9 with QuestionnaireResponseItemAnswerComponent

use of org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent in project org.hl7.fhir.core by hapifhir.

the class QuestionnaireBuilder method selectTypes.

private void selectTypes(StructureDefinition profile, QuestionnaireItemComponent sub, TypeRefComponent t, List<QuestionnaireResponse.QuestionnaireResponseItemComponent> source, List<QuestionnaireResponse.QuestionnaireResponseItemComponent> dest) {
    List<QuestionnaireResponse.QuestionnaireResponseItemComponent> temp = new ArrayList<QuestionnaireResponse.QuestionnaireResponseItemComponent>();
    for (QuestionnaireResponse.QuestionnaireResponseItemComponent g : source) if (instanceOf(t, (Element) g.getUserData("object")))
        temp.add(g);
    for (QuestionnaireResponse.QuestionnaireResponseItemComponent g : temp) source.remove(g);
    for (QuestionnaireResponse.QuestionnaireResponseItemComponent g : temp) {
        // it should be empty
        assert (g.getItem().size() == 0);
        QuestionnaireResponse.QuestionnaireResponseItemComponent q = g.addItem();
        q.setLinkId(g.getLinkId() + "._type");
        q.setText("type");
        Coding cc = new Coding();
        QuestionnaireResponseItemAnswerComponent a = q.addAnswer();
        a.setValue(cc);
        if (t.getCode().equals("Reference") && t.hasProfile() && t.getProfile().get(0).getValue().startsWith("http://hl7.org/fhir/StructureDefinition/")) {
            cc.setCode(t.getProfile().get(0).getValue().substring(40));
            cc.setSystem("http://hl7.org/fhir/resource-types");
        } else {
            ProfileUtilities pu = new ProfileUtilities(context, null, null);
            StructureDefinition ps = null;
            if (t.hasProfile())
                ps = pu.getProfile(profile, t.getProfile().get(0).getValue());
            if (ps != null) {
                cc.setCode(t.getProfile().get(0).getValue());
                cc.setSystem("http://hl7.org/fhir/resource-types");
            } else {
                cc.setCode(t.getCode());
                cc.setSystem("http://hl7.org/fhir/data-types");
            }
        }
        // 1st: create the subgroup
        QuestionnaireResponse.QuestionnaireResponseItemComponent subg = a.addItem();
        dest.add(subg);
        subg.setLinkId(sub.getLinkId());
        subg.setText(sub.getText());
        subg.setUserData("object", g.getUserData("object"));
    }
}
Also used : QuestionnaireResponseItemAnswerComponent(org.hl7.fhir.dstu2016may.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent) StructureDefinition(org.hl7.fhir.dstu2016may.model.StructureDefinition) Coding(org.hl7.fhir.dstu2016may.model.Coding) Element(org.hl7.fhir.dstu2016may.model.Element) ArrayList(java.util.ArrayList) QuestionnaireResponse(org.hl7.fhir.dstu2016may.model.QuestionnaireResponse)

Example 10 with QuestionnaireResponseItemAnswerComponent

use of org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent 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.r4b.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent) Row(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row) Cell(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)

Aggregations

ArrayList (java.util.ArrayList)5 QuestionnaireResponseItemAnswerComponent (org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent)3 QuestionnaireResponseItemAnswerComponent (org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent)2 QuestionnaireResponseItemAnswerComponent (org.hl7.fhir.r4b.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent)2 QuestionnaireResponseItemAnswerComponent (org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent)2 Cell (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)2 Row (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row)2 Coding (org.hl7.fhir.dstu2016may.model.Coding)1 Element (org.hl7.fhir.dstu2016may.model.Element)1 QuestionnaireResponse (org.hl7.fhir.dstu2016may.model.QuestionnaireResponse)1 QuestionnaireResponseItemAnswerComponent (org.hl7.fhir.dstu2016may.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent)1 StructureDefinition (org.hl7.fhir.dstu2016may.model.StructureDefinition)1 ProfileUtilities (org.hl7.fhir.dstu3.conformance.ProfileUtilities)1 Coding (org.hl7.fhir.dstu3.model.Coding)1 Element (org.hl7.fhir.dstu3.model.Element)1 QuestionnaireResponse (org.hl7.fhir.dstu3.model.QuestionnaireResponse)1 QuestionnaireResponseItemComponent (org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemComponent)1 StringType (org.hl7.fhir.dstu3.model.StringType)1 StructureDefinition (org.hl7.fhir.dstu3.model.StructureDefinition)1 ProfileUtilities (org.hl7.fhir.r4.conformance.ProfileUtilities)1