use of uk.nhs.adaptors.scr.clients.spine.SpineHttpClient.Response in project summary-care-record-api by NHSDigital.
the class SandboxSpineClient method sendScrData.
@SneakyThrows
@Override
public Response<String> sendScrData(String requestBody, String nhsdAsid, String nhsdIdentity, String nhsdSessionUrid) {
Header[] headers = { new BasicHeader(CONTENT_LOCATION, ""), new BasicHeader(RETRY_AFTER, "100") };
sleep(scrConfiguration.getSandboxDelay());
return new Response(ACCEPTED.value(), headers, null);
}
use of uk.nhs.adaptors.scr.clients.spine.SpineHttpClient.Response in project summary-care-record-api by NHSDigital.
the class GetScrService method getScr.
@LogExecutionTime
public Bundle getScr(String nhsNumber, String compositionId, String nhsdAsid, String clientIp) {
Document scrIdXml = getScrIdRawXml(nhsNumber, nhsdAsid, clientIp);
checkDetectedIssues(scrIdXml);
EventListQueryResponse response = eventListQueryResponseParser.parseXml(scrIdXml);
if (StringUtils.equals(response.getLatestScrId(), compositionId)) {
Document document = getScrRawXml(response.getLatestScrId(), nhsNumber, nhsdAsid, clientIp);
logXml("Received SCR XML: {}", document);
checkDetectedIssues(document);
var bundle = interactionMapper.map(document);
Patient patient = recordTargetMapper.mapPatient(document);
Stream.of(gpSummaryMapper, diagnosisMapper, findingMapper).map(mapper -> mapper.map(document)).flatMap(resources -> resources.stream()).peek(it -> setPatientReferences(it, patient)).map(resource -> getBundleEntryComponent(resource)).forEach(bundle::addEntry);
bundle.addEntry(getBundleEntryComponent(patient));
bundle.setTotal(bundle.getEntry().size());
return bundle;
} else {
return interactionMapper.mapToEmpty();
}
}
use of uk.nhs.adaptors.scr.clients.spine.SpineHttpClient.Response in project summary-care-record-api by NHSDigital.
the class SandboxSpineClient method sendAcsData.
@SneakyThrows
@Override
public Response<Document> sendAcsData(String requestBody, String nhsdAsid) {
Document document = parseXml(requestBody);
String nhsNumber = xmlUtils.getValueByXPath(document, SET_ACS_NHS_NUMBER_XPATH);
if (EXISTING_NHS_NUMBER.equals(nhsNumber)) {
return new Response(OK.value(), null, getResourceAsXmlDocument(setAcsSuccess));
} else {
return new Response(OK.value(), null, getResourceAsXmlDocument(setAcsIncorrectNhsNumber));
}
}
use of uk.nhs.adaptors.scr.clients.spine.SpineHttpClient.Response in project summary-care-record-api by NHSDigital.
the class SandboxSpineClient method sendGetScrId.
@SneakyThrows
@Override
public Response<Document> sendGetScrId(String requestBody, String nhsdAsid) {
sleep(scrConfiguration.getSandboxDelay());
Document document = parseXml(requestBody);
String nhsNumber = xmlUtils.getValueByXPath(document, GET_SCR_ID_NHS_NUMBER_XPATH);
switch(nhsNumber) {
case EXISTING_NHS_NUMBER:
return new Response(OK.value(), null, getResourceAsXmlDocument(getScrIdSuccess));
default:
return new Response(OK.value(), null, getResourceAsXmlDocument(getScrIdNoConsent));
}
}
Aggregations