Search in sources :

Example 1 with ResourceDateComparator

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;
}
Also used : USUAL(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.USUAL) Reference(org.hl7.fhir.dstu3.model.Reference) Identifier(org.hl7.fhir.dstu3.model.Identifier) Resource(org.hl7.fhir.dstu3.model.Resource) Collection(java.util.Collection) Coding(org.hl7.fhir.dstu3.model.Coding) RequiredArgsConstructor(lombok.RequiredArgsConstructor) DateUtil(uk.nhs.adaptors.oneoneone.cda.report.util.DateUtil) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) ListResource(org.hl7.fhir.dstu3.model.ListResource) Encounter(org.hl7.fhir.dstu3.model.Encounter) List(java.util.List) Component(org.springframework.stereotype.Component) ResourceType(org.hl7.fhir.dstu3.model.ResourceType) ResourceDateComparator(uk.nhs.adaptors.oneoneone.cda.report.comparator.ResourceDateComparator) ResourceUtil(uk.nhs.adaptors.oneoneone.cda.report.util.ResourceUtil) POCDMT000002UK01ClinicalDocument1(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01ClinicalDocument1) WORKING(org.hl7.fhir.dstu3.model.ListResource.ListMode.WORKING) CURRENT(org.hl7.fhir.dstu3.model.ListResource.ListStatus.CURRENT) Identifier(org.hl7.fhir.dstu3.model.Identifier) ListResource(org.hl7.fhir.dstu3.model.ListResource)

Aggregations

Collection (java.util.Collection)1 List (java.util.List)1 RequiredArgsConstructor (lombok.RequiredArgsConstructor)1 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)1 Coding (org.hl7.fhir.dstu3.model.Coding)1 Encounter (org.hl7.fhir.dstu3.model.Encounter)1 Identifier (org.hl7.fhir.dstu3.model.Identifier)1 USUAL (org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.USUAL)1 ListResource (org.hl7.fhir.dstu3.model.ListResource)1 WORKING (org.hl7.fhir.dstu3.model.ListResource.ListMode.WORKING)1 CURRENT (org.hl7.fhir.dstu3.model.ListResource.ListStatus.CURRENT)1 Reference (org.hl7.fhir.dstu3.model.Reference)1 Resource (org.hl7.fhir.dstu3.model.Resource)1 ResourceType (org.hl7.fhir.dstu3.model.ResourceType)1 Component (org.springframework.stereotype.Component)1 ResourceDateComparator (uk.nhs.adaptors.oneoneone.cda.report.comparator.ResourceDateComparator)1 DateUtil (uk.nhs.adaptors.oneoneone.cda.report.util.DateUtil)1 ResourceUtil (uk.nhs.adaptors.oneoneone.cda.report.util.ResourceUtil)1 POCDMT000002UK01ClinicalDocument1 (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01ClinicalDocument1)1