public ReceiveMedicalCertificateQuestionResponseType receiveMedicalCertificateQuestion(
AttributedURIType logicalAddress, ReceiveMedicalCertificateQuestionType parameters) {
// TODO: Should we have a default error response here?
ReceiveMedicalCertificateQuestionResponseType response = null;
try {
// The adress consist of an address in the format XX#caregiver#careunit or caregiver#careunit or only careunit
String careGiverAndCareUnit = logicalAddress.getValue();
String careUnit = "";
if (careGiverAndCareUnit.indexOf("#") < 0) {
careUnit = careGiverAndCareUnit;
} else {
careUnit = careGiverAndCareUnit.substring(careGiverAndCareUnit.lastIndexOf("#")+1, careGiverAndCareUnit.length());
}
log.debug("Received MedicalCertificateQuestion for care unit={}", careUnit);
Question question = new Question(careUnit, parameters.getQuestion());
questionService.saveQuestion(question);
response = new ReceiveMedicalCertificateQuestionResponseType();
response.setResult(new ResultOfCall());
response.getResult().setResultCode(ResultCodeEnum.OK);
} catch (Exception e) {
log.warn("Error handling MedicalCertificateQuestion" ,e);
// TODO: Fix this error handling
response = new ReceiveMedicalCertificateQuestionResponseType();
response.setResult(new ResultOfCall());
response.getResult().setResultCode(ResultCodeEnum.ERROR);
response.getResult().setErrorId(ErrorIdEnum.APPLICATION_ERROR);
response.getResult().setErrorText(e.getMessage());
}
return response;
}