Search in sources :

Example 1 with QuestionnaireItemOptionComponent

use of org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemOptionComponent 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)

Aggregations

ArrayList (java.util.ArrayList)1 QuestionnaireItemComponent (org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemComponent)1 QuestionnaireItemOptionComponent (org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemOptionComponent)1 StringType (org.hl7.fhir.dstu3.model.StringType)1 Answer (org.nhspathways.webservices.pathways.pathwayscase.PathwaysCaseDocument.PathwaysCase.PathwayDetails.PathwayTriageDetails.PathwayTriage.TriageLineDetails.TriageLine.Question.Answers.Answer)1