Search in sources :

Example 31 with Organization

use of org.hl7.fhir.r4.model.Organization in project summary-care-record-api by NHSDigital.

the class GpSummaryMapper method addAuthorOrganisation.

private void addAuthorOrganisation(Node document, List<Resource> resources, Composition composition) {
    xmlUtils.detachOptionalNodeByXPath(document, GP_SUMMARY_AUTHOR_AGENT_ORG_SDS_XPATH).ifPresent(agentOrganisationSds -> {
        Organization organisation = organisationSdsMapper.mapOrganizationSds(agentOrganisationSds);
        resources.add(organisation);
        composition.addAuthor(new Reference(organisation));
    });
    xmlUtils.detachOptionalNodeByXPath(document, GP_SUMMARY_AUTHOR_AGENT_ORG_XPATH).ifPresent(agentOrganisation -> {
        List<? extends Resource> organisationResources = agentOrganisationMapper.map(agentOrganisation);
        resources.addAll(organisationResources);
        composition.addAuthor(findPractitionerRole(organisationResources));
    });
}
Also used : Organization(org.hl7.fhir.r4.model.Organization) Reference(org.hl7.fhir.r4.model.Reference)

Example 32 with Organization

use of org.hl7.fhir.r4.model.Organization in project summary-care-record-api by NHSDigital.

the class OrganisationMapper method mapOrganization.

public Organization mapOrganization(Node organisation) {
    var org = new Organization();
    org.setId(randomUUID());
    xmlUtils.getOptionalValueByXPath(organisation, ORG_CODE_XPATH).ifPresent(it -> org.addType(new CodeableConcept(new Coding().setCode(it))));
    xmlUtils.detachOptionalNodeByXPath(organisation, ORG_NAME_XPATH).ifPresent(name -> org.setName(name.getTextContent()));
    xmlUtils.detachOptionalNodeByXPath(organisation, ADDRESS_XPATH).ifPresent(node -> org.addAddress(new Address().setText(node.getTextContent())));
    xmlUtils.detachOptionalNodeByXPath(organisation, TELECOM_XPATH).ifPresent(telecom -> org.addTelecom(telecomMapper.mapTelecom(telecom)));
    return org;
}
Also used : Organization(org.hl7.fhir.r4.model.Organization) Address(org.hl7.fhir.r4.model.Address) Coding(org.hl7.fhir.r4.model.Coding) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 33 with Organization

use of org.hl7.fhir.r4.model.Organization in project summary-care-record-api by NHSDigital.

the class OrganisationSdsMapper method mapOrganizationSds.

public Organization mapOrganizationSds(Node organisationSds) {
    var org = new Organization();
    org.setId(randomUUID());
    var orgIdentifier = new Identifier().setValue(xmlUtils.getValueByXPath(organisationSds, ORG_SDS_ID_XPATH));
    var rootId = xmlUtils.getValueByXPath(organisationSds, ORG_SDS_ID_ROOT_XPATH);
    if (HL7_ORG_OID.equals(rootId)) {
        orgIdentifier.setSystem(ORG_SDS_SYSTEM);
    }
    org.addIdentifier(orgIdentifier);
    xmlUtils.detachOptionalNodeByXPath(organisationSds, ORG_NAME_XPATH).ifPresent(nameNode -> org.setName(nameNode.getTextContent()));
    return org;
}
Also used : Organization(org.hl7.fhir.r4.model.Organization) Identifier(org.hl7.fhir.r4.model.Identifier)

Example 34 with Organization

use of org.hl7.fhir.r4.model.Organization in project Gravity-SDOH-Exchange-RI by FHIR.

the class TaskPollingService method updateTasks.

public void updateTasks() {
    log.info("Updating tasks from CP Organizations...");
    Bundle tasksBundle = openEhrClient.search().forResource(Task.class).include(Task.INCLUDE_FOCUS).include(Task.INCLUDE_OWNER).include(Organization.INCLUDE_ENDPOINT.setRecurse(true)).where(new TokenClientParam("owner:Organization.type").exactly().systemAndCode(OrganizationTypeCode.CP.getSystem(), OrganizationTypeCode.CP.toCode())).where(new TokenClientParam(Task.SP_STATUS + ":" + SearchModifierCode.NOT.toCode()).exactly().code(Task.TaskStatus.FAILED.toCode())).where(new TokenClientParam(Task.SP_STATUS + ":" + SearchModifierCode.NOT.toCode()).exactly().code(Task.TaskStatus.REJECTED.toCode())).where(new TokenClientParam(Task.SP_STATUS + ":" + SearchModifierCode.NOT.toCode()).exactly().code(Task.TaskStatus.COMPLETED.toCode())).where(new TokenClientParam(Task.SP_STATUS + ":" + SearchModifierCode.NOT.toCode()).exactly().code(Task.TaskStatus.CANCELLED.toCode())).where(Task.AUTHORED_ON.before().millis(Date.from(LocalDateTime.now().minusSeconds(10).atZone(ZoneId.systemDefault()).toInstant()))).returnBundle(Bundle.class).execute();
    TasksPollingInfo tasksPollingInfo = new TasksPollingBundleExtractor().extract(tasksBundle);
    // Collect all entries from every Task bundle for performance considerations.
    Bundle updateBundle = new Bundle();
    updateBundle.setType(Bundle.BundleType.TRANSACTION);
    for (Task task : tasksPollingInfo.getTasks()) {
        ServiceRequest serviceRequest = tasksPollingInfo.getServiceRequest(task);
        Organization organization = tasksPollingInfo.getOrganization(task);
        try {
            Endpoint endpoint = tasksPollingInfo.getEndpoint(organization);
            combineResult(updateBundle, getUpdateBundle(task, serviceRequest, endpoint));
        } catch (TaskPollingUpdateException | CpClientException exc) {
            combineResult(updateBundle, failTask(task, serviceRequest, exc.getMessage()));
        }
    }
    // If there is at least one bundle entry - execute a transaction request.
    if (updateBundle.getEntry().size() != 0) {
        log.info("One or more tasks were changed. Storing updates to EHR...");
        openEhrClient.transaction().withBundle(updateBundle).execute();
    }
    log.info("Task update process finished.");
}
Also used : Task(org.hl7.fhir.r4.model.Task) TasksPollingInfo(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.TasksPollingBundleExtractor.TasksPollingInfo) TasksPollingBundleExtractor(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.TasksPollingBundleExtractor) CpClientException(org.hl7.gravity.refimpl.sdohexchange.service.CpService.CpClientException) Organization(org.hl7.fhir.r4.model.Organization) TokenClientParam(ca.uhn.fhir.rest.gclient.TokenClientParam) Endpoint(org.hl7.fhir.r4.model.Endpoint) Bundle(org.hl7.fhir.r4.model.Bundle) TaskPollingUpdateException(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.TasksPollingBundleExtractor.TaskPollingUpdateException) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest)

Example 35 with Organization

use of org.hl7.fhir.r4.model.Organization in project Gravity-SDOH-Exchange-RI by FHIR.

the class TaskReferenceResolver method getRequester.

public Organization getRequester() {
    if (localRequester == null) {
        Organization requester = externalRequester.copy();
        // Remove SDOH profile, Logica does not support this.
        // TODO Use SDOH Profiles.
        requester.setMeta(null);
        requester.addIdentifier().setSystem(identifierSystem).setValue(requester.getIdElement().getIdPart());
        requester.setId(IdType.newRandomUuid());
        return requester;
    }
    return localRequester;
}
Also used : Organization(org.hl7.fhir.r4.model.Organization)

Aggregations

Test (org.junit.jupiter.api.Test)101 Organization (org.hl7.fhir.dstu3.model.Organization)90 Organization (org.hl7.fhir.r4.model.Organization)69 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)41 Resource (org.hl7.fhir.r4.model.Resource)38 ArrayList (java.util.ArrayList)34 List (java.util.List)33 Reference (org.hl7.fhir.r4.model.Reference)33 Identifier (org.hl7.fhir.r4.model.Identifier)30 Bundle (org.hl7.fhir.dstu3.model.Bundle)27 UUID (java.util.UUID)26 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)25 Patient (org.hl7.fhir.r4.model.Patient)25 IdType (org.hl7.fhir.dstu3.model.IdType)24 Bundle (org.hl7.fhir.r4.model.Bundle)24 Coding (org.hl7.fhir.r4.model.Coding)24 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)19 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)17 Reference (org.hl7.fhir.dstu3.model.Reference)16 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)16