public void setAnswerService(AnswerService questionService) {
this.answerService = questionService;
}
public FindAllAnswersResponseType findAllAnswers(AttributedURIType address, FindAllAnswersType parameters) {
FindAllAnswersResponseType response = new FindAllAnswersResponseType();
try {
String careUnit = parameters.getCareUnitId().getExtension();
log.debug("FindAllAnswers called for careunit:" + careUnit);
AnswersValue answerValue = answerService.getAnswersForCareUnit(careUnit);
response.setResult(new ResultOfCall());
response.getResult().setResultCode(ResultCodeEnum.OK);
response.setAnswersLeft(answerValue.getAnswersLeft());
response.setAnswers(new AnswersType());
for (Answer a : answerValue.getAnswers()) {
AnswerFromFkType answerFromFk = (AnswerFromFkType) a.getMessage();
AnswerType qt = new AnswerType();
qt.setId(a.getId().toString());
qt.setReceivedDate(a.getArrived());
qt.setAnswer(answerFromFk);
response.getAnswers().getAnswer().add(qt);
a.setStatusRetrieved();
}
log.debug("FindAllAnswers found " + answerValue.getAnswers().size() + " answers for careunit " + careUnit);
} catch (Exception e) {
// FIXME: Add better error handling
response.setResult(new ResultOfCall());
response.getResult().setResultCode(ResultCodeEnum.ERROR);
response.getResult().setErrorText(e.getMessage());
}
return response;
}