use of uk.nhs.adaptors.scr.exceptions.UnexpectedSpineResponseException in project summary-care-record-api by NHSDigital.
the class SpineClient method sendGetScr.
@SneakyThrows
@Override
@LogExecutionTime
public Response<Document> sendGetScr(String requestBody, String nhsdAsid) {
var uri = spineConfiguration.getUrl() + spineConfiguration.getPsisQueriesEndpoint();
var request = new HttpPost(uri);
LOGGER.info("Sending GET SCR Spine request. URL: {}", uri);
LOGGER.debug("Body: {}", requestBody);
request.addHeader(SOAP_ACTION, PSIS_EVENT_QUERY_SOAP_ACTION);
request.addHeader(CONTENT_TYPE, TEXT_XML_VALUE);
request.addHeader(NHSD_ASID, nhsdAsid);
request.setEntity(new StringEntity(requestBody, UTF_8));
var response = spineHttpClient.sendRequest(request, xmlResponseHandler);
var statusCode = response.getStatusCode();
if (statusCode != OK.value()) {
LOGGER.error("Unexpected spine GET SCR response: {} {}", statusCode, serialize(response.getBody()));
throw new UnexpectedSpineResponseException("Unexpected spine send response " + statusCode);
}
LOGGER.info("Received Spine {} interaction response: HTTP status {}", PSIS_EVENT_QUERY_SOAP_ACTION, response.getStatusCode());
return response;
}
use of uk.nhs.adaptors.scr.exceptions.UnexpectedSpineResponseException in project summary-care-record-api by NHSDigital.
the class AlertService method sendAlert.
public void sendAlert(String body, String nhsdAsid, String nhsdIdentity, String nhsdSessionUrid) {
Response<String> response = spineClient.sendAlert(body, nhsdAsid, nhsdIdentity, nhsdSessionUrid);
HttpStatus status = HttpStatus.resolve(response.getStatusCode());
if (status == null || !status.is2xxSuccessful()) {
OperationOutcome error = fhirParser.parseResource(response.getBody(), OperationOutcome.class);
if (status != null && status.is4xxClientError()) {
LOGGER.error("Spine processing error: {}", status);
throw new BadRequestException(getErrorReason(error));
} else {
LOGGER.error("Spine processing error: {}", getErrorReason(error));
throw new UnexpectedSpineResponseException(getErrorReason(error));
}
}
}
use of uk.nhs.adaptors.scr.exceptions.UnexpectedSpineResponseException in project summary-care-record-api by NHSDigital.
the class UploadScrService method validateProcessingResult.
@SneakyThrows
private void validateProcessingResult(ProcessingResult processingResult) {
var hl7Document = parseDocument(processingResult.getHl7());
var acknowledgementXPath = XPathFactory.newInstance().newXPath().compile("/MCCI_IN010000UK13/acknowledgement");
var acknowledgementNode = ((NodeList) acknowledgementXPath.evaluate(hl7Document, XPathConstants.NODESET)).item(0);
String acknowledgementTypeCode;
try {
acknowledgementTypeCode = acknowledgementNode.getAttributes().getNamedItem("typeCode").getNodeValue();
} catch (Exception ex) {
LOGGER.error("Unable to extract acknowledgement code:\n{}", processingResult.getHl7());
throw new UnexpectedSpineResponseException("Unable to extract acknowledgement code");
}
if (!acknowledgementTypeCode.equals("AA")) {
var errors = getErrors(hl7Document);
LOGGER.error("Non success spine processing result:\n{}\n{}", processingResult.getSoapEnvelope(), processingResult.getHl7());
throw new NonSuccessSpineProcessingResultException(errors);
}
}
Aggregations