use of uk.nhs.adaptors.oneoneone.cda.report.comparator.ResourceDateComparator in project integration-adaptor-111 by nhsconnect.
the class ListMapper method mapList.
public ListResource mapList(POCDMT000002UK01ClinicalDocument1 clinicalDocument, Encounter encounter, Collection<Resource> resourcesCreated, Reference deviceRef) {
ListResource listResource = new ListResource();
listResource.setIdElement(resourceUtil.newRandomUuid());
Identifier docIdentifier = new Identifier();
docIdentifier.setUse(USUAL);
docIdentifier.setValue(clinicalDocument.getSetId().getRoot());
listResource.setStatus(CURRENT).setTitle(LIST_TITLE).setMode(WORKING).setCode(createCodeConcept()).setSubject(encounter.getSubject()).setSourceTarget(encounter.getSubjectTarget()).setEncounter(resourceUtil.createReference(encounter)).setEncounterTarget(encounter).setDateElement(DateUtil.parse(clinicalDocument.getEffectiveTime().getValue())).setSource(deviceRef).setOrderedBy(createOrderByConcept());
resourcesCreated.stream().sorted(resourceDateComparator).filter(it -> TRIAGE_RESOURCES.contains(it.getResourceType()) && it.hasId()).map(resourceUtil::createReference).map(ListResource.ListEntryComponent::new).forEach(listResource::addEntry);
return listResource;
}
Aggregations