public ReceiveMedicalCertificateAnswerResponseType receiveMedicalCertificateAnswer(
org.w3.wsaddressing10.AttributedURIType logicalAddress,
ReceiveMedicalCertificateAnswerType parameters) {
ReceiveMedicalCertificateAnswerResponseType response = new ReceiveMedicalCertificateAnswerResponseType();
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 MedicalCertificateAnswer for care unit={}", careUnit);
Answer answer = new Answer(careUnit, parameters.getAnswer());
answerService.saveAnswer(answer);
ResultOfCall value = new ResultOfCall();
value.setResultCode(ResultCodeEnum.OK);
response.setResult(value );
} catch (Exception e) {
log.warn("Error handling MedicalCertificateAnswer" ,e);
// TODO: Fix this error handling
response = new ReceiveMedicalCertificateAnswerResponseType();
response.setResult(new ResultOfCall());
response.getResult().setResultCode(ResultCodeEnum.ERROR);
response.getResult().setErrorId(ErrorIdEnum.APPLICATION_ERROR);
response.getResult().setErrorText(e.getMessage());
}
return response;
}