Search in sources :

Example 1 with QuestionnaireItemComponent

use of org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent in project integration-adaptor-111 by nhsconnect.

the class QuestionnaireMapper method getItem.

private QuestionnaireItemComponent getItem(Question question, String caseId) {
    if (question != null) {
        List<QuestionnaireItemOptionComponent> questionnaireItemOptionComponentList = new ArrayList<>();
        QuestionnaireItemComponent item = new QuestionnaireItemComponent();
        item.setLinkId(caseId);
        item.setPrefix(getPrefix(question));
        item.setType(Questionnaire.QuestionnaireItemType.CHOICE);
        item.setRequired(true);
        item.setRepeats(false);
        if (question.getQuestionText() != null) {
            item.setText(question.getQuestionText());
        } else {
            item.setText(NOT_APPLICABLE);
        }
        if (question.getAnswers() != null) {
            if (question.getAnswers().sizeOfAnswerArray() > 0) {
                for (Answer answer : question.getAnswers().getAnswerArray()) {
                    QuestionnaireItemOptionComponent optionComponent = new QuestionnaireItemOptionComponent();
                    StringType answerStringType = new StringType();
                    answerStringType.setValueAsString(String.format("%s, Selected: %s", answer.getText(), answer.getSelected()));
                    optionComponent.setValue(answerStringType);
                    questionnaireItemOptionComponentList.add(optionComponent);
                }
            }
        }
        item.setOption(questionnaireItemOptionComponentList);
        return item;
    }
    return null;
}
Also used : Answer(org.nhspathways.webservices.pathways.pathwayscase.PathwaysCaseDocument.PathwaysCase.PathwayDetails.PathwayTriageDetails.PathwayTriage.TriageLineDetails.TriageLine.Question.Answers.Answer) QuestionnaireItemComponent(org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemComponent) StringType(org.hl7.fhir.dstu3.model.StringType) ArrayList(java.util.ArrayList) QuestionnaireItemOptionComponent(org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemOptionComponent)

Example 2 with QuestionnaireItemComponent

use of org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent in project org.hl7.fhir.core by hapifhir.

the class QuestionnaireBuilder method addTimingQuestions.

private void addTimingQuestions(QuestionnaireItemComponent group, ElementDefinition element, String path, List<QuestionnaireResponse.QuestionnaireResponseItemComponent> answerGroups) throws FHIRException {
    ToolingExtensions.addFhirType(group, "Schedule");
    addQuestion(group, QuestionnaireItemType.STRING, path, "text", "text:", answerGroups);
    addQuestion(group, QuestionnaireItemType.DATETIME, path, "date", "date:", answerGroups);
    QuestionnaireItemComponent q = addQuestion(group, QuestionnaireItemType.REFERENCE, path, "author", "author:", answerGroups);
    ToolingExtensions.addAllowedResource(q, "Patient");
    ToolingExtensions.addAllowedResource(q, "Practitioner");
    ToolingExtensions.addAllowedResource(q, "RelatedPerson");
}
Also used : QuestionnaireItemComponent(org.hl7.fhir.dstu2016may.model.Questionnaire.QuestionnaireItemComponent)

Example 3 with QuestionnaireItemComponent

use of org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent in project org.hl7.fhir.core by hapifhir.

the class QuestionnaireBuilder method buildQuestion.

private void buildQuestion(QuestionnaireItemComponent group, StructureDefinition profile, ElementDefinition element, String path, List<QuestionnaireResponse.QuestionnaireResponseItemComponent> answerGroups) throws FHIRException {
    group.setLinkId(path);
    // in this context, we don't have any concepts to mark...
    // prefix with name?
    group.setText(element.getShort());
    group.setRequired(element.getMin() > 0);
    if (element.getMin() > 0)
        ToolingExtensions.addMin(group, element.getMin());
    group.setRepeats(!element.getMax().equals('1'));
    if (!element.getMax().equals("*"))
        ToolingExtensions.addMax(group, Integer.parseInt(element.getMax()));
    for (QuestionnaireResponse.QuestionnaireResponseItemComponent ag : answerGroups) {
        ag.setLinkId(group.getLinkId());
        ag.setText(group.getText());
    }
    if (!Utilities.noString(element.getComments()))
        ToolingExtensions.addFlyOver(group, element.getDefinition() + " " + element.getComments());
    else
        ToolingExtensions.addFlyOver(group, element.getDefinition());
    if (element.getType().size() > 1 || element.getType().get(0).getCode().equals("*")) {
        List<TypeRefComponent> types = expandTypeList(element.getType());
        Questionnaire.QuestionnaireItemComponent q = addQuestion(group, QuestionnaireItemType.CHOICE, element.getPath(), "_type", "type", null, makeTypeList(profile, types, element.getPath()));
        for (TypeRefComponent t : types) {
            Questionnaire.QuestionnaireItemComponent sub = q.addItem();
            sub.setType(QuestionnaireItemType.GROUP);
            sub.setLinkId(element.getPath() + "._" + t.getUserData("text"));
            sub.setText((String) t.getUserData("text"));
            // always optional, never repeats
            List<QuestionnaireResponse.QuestionnaireResponseItemComponent> selected = new ArrayList<QuestionnaireResponse.QuestionnaireResponseItemComponent>();
            selectTypes(profile, sub, t, answerGroups, selected);
            processDataType(profile, sub, element, element.getPath() + "._" + t.getUserData("text"), t, selected);
        }
    } else
        // now we have to build the question panel for each different data type
        processDataType(profile, group, element, element.getPath(), element.getType().get(0), answerGroups);
}
Also used : Questionnaire(org.hl7.fhir.dstu2016may.model.Questionnaire) TypeRefComponent(org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent) ArrayList(java.util.ArrayList) QuestionnaireResponse(org.hl7.fhir.dstu2016may.model.QuestionnaireResponse) QuestionnaireItemComponent(org.hl7.fhir.dstu2016may.model.Questionnaire.QuestionnaireItemComponent)

Example 4 with QuestionnaireItemComponent

use of org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent in project org.hl7.fhir.core by hapifhir.

the class ToolingExtensions method addFlyOver.

public static void addFlyOver(QuestionnaireItemComponent item, String text) {
    if (!StringUtils.isBlank(text)) {
        QuestionnaireItemComponent display = item.addItem();
        display.setType(QuestionnaireItemType.DISPLAY);
        display.setText(text);
        display.getExtension().add(Factory.newExtension(EXT_CONTROL, Factory.newCodeableConcept("flyover", "http://hl7.org/fhir/questionnaire-item-control", "Fly-over"), true));
    }
}
Also used : QuestionnaireItemComponent(org.hl7.fhir.dstu2016may.model.Questionnaire.QuestionnaireItemComponent)

Example 5 with QuestionnaireItemComponent

use of org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent in project org.hl7.fhir.core by hapifhir.

the class QuestionnaireBuilder method addReferenceQuestions.

// Special Types ---------------------------------------------------------------
private void addReferenceQuestions(QuestionnaireItemComponent group, ElementDefinition element, String path, String profileURL, List<QuestionnaireResponse.QuestionnaireResponseItemComponent> answerGroups) throws FHIRException {
    // var
    // rn : String;
    // i : integer;
    // q : TFhirQuestionnaireGroupQuestion;
    ToolingExtensions.addFhirType(group, "Reference");
    QuestionnaireItemComponent q = addQuestion(group, QuestionnaireItemType.REFERENCE, path, "value", group.getText(), answerGroups);
    group.setText(null);
    String rn = null;
    if (profileURL != null && profileURL.startsWith("http://hl7.org/fhir/StructureDefinition/"))
        rn = profileURL.substring(40);
    else
        rn = "Any";
    if (rn.equals("Any"))
        ToolingExtensions.addReferenceFilter(q, "subject=$subj&patient=$subj&encounter=$encounter");
    else {
        ToolingExtensions.addAllowedResource(q, rn);
        ToolingExtensions.addReferenceFilter(q, "subject=$subj&patient=$subj&encounter=$encounter");
    }
    for (QuestionnaireResponse.QuestionnaireResponseItemComponent ag : answerGroups) ag.setText(null);
}
Also used : QuestionnaireItemComponent(org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemComponent) QuestionnaireResponse(org.hl7.fhir.dstu3.model.QuestionnaireResponse)

Aggregations

ArrayList (java.util.ArrayList)32 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)20 QuestionnaireItemComponent (org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent)16 QuestionnaireItemComponent (org.hl7.fhir.r4b.model.Questionnaire.QuestionnaireItemComponent)15 QuestionnaireItemComponent (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent)11 Element (org.hl7.fhir.r5.elementmodel.Element)9 NodeStack (org.hl7.fhir.validation.instance.utils.NodeStack)9 QuestionnaireItemComponent (org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemComponent)7 QuestionnaireResponse (org.hl7.fhir.r4.model.QuestionnaireResponse)7 QuestionnaireResponse (org.hl7.fhir.r4b.model.QuestionnaireResponse)7 QuestionnaireItemAnswerOptionComponent (org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemAnswerOptionComponent)7 QuestionnaireResponse (org.hl7.fhir.r5.model.QuestionnaireResponse)7 QuestionnaireItemComponent (org.hl7.fhir.dstu2016may.model.Questionnaire.QuestionnaireItemComponent)6 ValueSet (org.hl7.fhir.r4b.model.ValueSet)6 ValueSet (org.hl7.fhir.r5.model.ValueSet)6 Piece (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece)6 Row (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row)6 QuestionnaireResponse (org.hl7.fhir.dstu2016may.model.QuestionnaireResponse)5 QuestionnaireResponse (org.hl7.fhir.dstu3.model.QuestionnaireResponse)5 FHIRException (org.hl7.fhir.exceptions.FHIRException)5