Search in sources :

Example 1 with Answer

use of org.nhspathways.webservices.pathways.pathwayscase.PathwaysCaseDocument.PathwaysCase.PathwayDetails.PathwayTriageDetails.PathwayTriage.TriageLineDetails.TriageLine.Question.Answers.Answer 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 Answer

use of org.nhspathways.webservices.pathways.pathwayscase.PathwaysCaseDocument.PathwaysCase.PathwayDetails.PathwayTriageDetails.PathwayTriage.TriageLineDetails.TriageLine.Question.Answers.Answer 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)

Aggregations

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