public void setQuestionService(QuestionService questionService) {
this.questionService = questionService;
}
public FindAllQuestionsResponseType findAllQuestions(AttributedURIType address, FindAllQuestionsType parameters) {
FindAllQuestionsResponseType response = new FindAllQuestionsResponseType();
try {
String careUnit = parameters.getCareUnitId().getExtension();
log.debug("FindAllQuestions called for careunit:" + careUnit);
QuestionsValue questionValue = questionService.getQuestionsForCareUnit(careUnit);
response.setResult(new ResultOfCall());
response.getResult().setResultCode(ResultCodeEnum.OK);
response.setQuestionsLeft(questionValue.getQuestionsLeft());
response.setQuestions(new QuestionsType());
for (Question q : questionValue.getQuestions()) {
QuestionFromFkType questionFromFk = (QuestionFromFkType) q.getMessage();
QuestionType qt = new QuestionType();
qt.setId(q.getId().toString());
qt.setReceivedDate(q.getArrived());
qt.setQuestion(questionFromFk);
response.getQuestions().getQuestion().add(qt);
q.setStatusRetrieved();
}
log.debug("FindAllQuestions found " + questionValue.getQuestions().size() + " questions for careunit " + careUnit);
} catch (Exception e) {
log.warn("Failed to handle FindAllQuestions", e);
response.setResult(new ResultOfCall());
response.getResult().setResultCode(ResultCodeEnum.ERROR);
response.getResult().setErrorText(e.getMessage());
}
return response;
}