use of uk.nhs.adaptors.scr.mappings.from.hl7.DiagnosisMapper 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();
}
}
Aggregations