Search in sources :

Example 1 with FhirVersion

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);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) HttpStatus(org.springframework.http.HttpStatus) FhirVersion(gov.cms.ab2d.fhir.FhirVersion) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ApiResponseEvent(gov.cms.ab2d.eventlogger.events.ApiResponseEvent) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with FhirVersion

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);
}
Also used : FhirVersion(gov.cms.ab2d.fhir.FhirVersion) Token(com.newrelic.api.agent.Token) ParseException(java.text.ParseException) IOException(java.io.IOException) Async(org.springframework.scheduling.annotation.Async)

Aggregations

FhirVersion (gov.cms.ab2d.fhir.FhirVersion)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Token (com.newrelic.api.agent.Token)1 ApiResponseEvent (gov.cms.ab2d.eventlogger.events.ApiResponseEvent)1 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)1 HttpStatus (org.springframework.http.HttpStatus)1 ResponseEntity (org.springframework.http.ResponseEntity)1 Async (org.springframework.scheduling.annotation.Async)1