use of gov.cms.ab2d.fhir.FhirVersion in project ab2d by CMSgov.
the class ErrorHandler method generateFHIRError.
private ResponseEntity<JsonNode> generateFHIRError(Exception e, HttpHeaders httpHeaders, HttpServletRequest request) throws IOException {
String msg = getRootCause(e);
HttpStatus httpStatus = getErrorResponse(e.getClass());
FhirVersion version = FhirVersion.fromAB2DUrl(request.getRequestURI());
IBaseResource operationOutcome = version.getErrorOutcome(msg);
String encoded = version.outcomePrettyToJSON(operationOutcome);
// Log so that Splunk can pick this up and alert
log.warn("{} {}", ExceptionUtils.getRootCause(e).getClass(), msg);
eventLogger.log(new ApiResponseEvent(MDC.get(ORGANIZATION), null, ErrorHandler.getErrorResponse(e.getClass()), "FHIR Error", msg, (String) request.getAttribute(REQUEST_ID)));
return new ResponseEntity<>(new ObjectMapper().readTree(encoded), httpHeaders, httpStatus);
}
use of gov.cms.ab2d.fhir.FhirVersion in project ab2d by CMSgov.
the class PatientClaimsProcessorImpl method process.
/**
* Process the retrieval of patient explanation of benefit objects and return the result
* for further post-processing
*/
@Async("patientProcessorThreadPool")
public Future<ProgressTrackerUpdate> process(PatientClaimsRequest request) {
ProgressTrackerUpdate update = new ProgressTrackerUpdate();
final Token token = request.getToken();
token.link();
FhirVersion fhirVersion = request.getVersion();
try {
String anyErrors = writeOutData(request, fhirVersion, update);
if (anyErrors != null && anyErrors.length() > 0) {
writeOutErrors(anyErrors, request);
}
} catch (Exception ex) {
return AsyncResult.forExecutionException(ex);
} finally {
token.expire();
}
return AsyncResult.forValue(update);
}
Aggregations