use of uk.nhs.adaptors.scr.exceptions.NonSuccessSpineProcessingResultException 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