use of uk.nhs.adaptors.scr.models.EventListQueryResponse 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.models.EventListQueryResponse in project summary-care-record-api by NHSDigital.
the class GetScrService method getScrId.
@LogExecutionTime
public Bundle getScrId(String nhsNumber, String nhsdAsid, String clientIp) {
Document scrIdXml = getScrIdRawXml(nhsNumber, nhsdAsid, clientIp);
checkDetectedIssues(scrIdXml);
EventListQueryResponse response = eventListQueryResponseParser.parseXml(scrIdXml);
Bundle bundle = buildBundle();
if (StringUtils.isNotEmpty(response.getLatestScrId())) {
bundle.setTotal(1);
Patient patient = buildPatientResource(nhsNumber);
DocumentReference documentReference = buildDocumentReference(nhsNumber, response, patient);
bundle.addEntry(new BundleEntryComponent().setFullUrl(getScrUrl() + "/DocumentReference/" + documentReference.getId()).setResource(documentReference).setSearch(new Bundle.BundleEntrySearchComponent().setMode(MATCH)));
bundle.addEntry(new BundleEntryComponent().setFullUrl(patient.getId()).setResource(patient));
} else {
bundle.setTotal(0);
}
return bundle;
}
Aggregations