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;
}
Aggregations