Search in sources :

Example 1 with TaskQueryFactory

use of org.hl7.gravity.refimpl.sdohexchange.fhir.query.TaskQueryFactory in project Gravity-SDOH-Exchange-RI by FHIR.

the class GoalService method addTasksAndSRsToGoalBundle.

// TODO refactor. this fragmet ins used in a ProblemService as well.
private Bundle addTasksAndSRsToGoalBundle(Bundle responseBundle) {
    Bundle tasksWithServiceRequests = new TaskQueryFactory().query(ehrClient, SmartOnFhirContext.get().getPatient()).include(Task.INCLUDE_FOCUS).returnBundle(Bundle.class).execute();
    if (tasksWithServiceRequests.getLink(IBaseBundle.LINK_NEXT) != null) {
        throw new RuntimeException("Multi-page Task results returned for the List Problems operation. Pagination not supported yet. Make sure " + "there is a small amount of tasks in your FHIR store.");
    }
    Bundle merged = FhirUtil.mergeBundles(ehrClient.getFhirContext(), responseBundle, tasksWithServiceRequests);
    return merged;
}
Also used : TaskQueryFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.query.TaskQueryFactory) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) Bundle(org.hl7.fhir.r4.model.Bundle)

Example 2 with TaskQueryFactory

use of org.hl7.gravity.refimpl.sdohexchange.fhir.query.TaskQueryFactory in project Gravity-SDOH-Exchange-RI by FHIR.

the class ProblemService method addTasksAndSRsToConditionBundle.

private Bundle addTasksAndSRsToConditionBundle(Bundle responseBundle) {
    Bundle tasksWithServiceRequests = new TaskQueryFactory().query(ehrClient, SmartOnFhirContext.get().getPatient()).include(Task.INCLUDE_FOCUS).returnBundle(Bundle.class).execute();
    if (tasksWithServiceRequests.getLink(IBaseBundle.LINK_NEXT) != null) {
        throw new RuntimeException("Multi-page Task results returned for the List Problems operation. Pagination not supported yet. Make sure " + "there is a small amount of tasks in your FHIR store.");
    }
    Bundle merged = FhirUtil.mergeBundles(ehrClient.getFhirContext(), responseBundle, tasksWithServiceRequests);
    return merged;
}
Also used : TaskQueryFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.query.TaskQueryFactory) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) Bundle(org.hl7.fhir.r4.model.Bundle)

Example 3 with TaskQueryFactory

use of org.hl7.gravity.refimpl.sdohexchange.fhir.query.TaskQueryFactory in project Gravity-SDOH-Exchange-RI by FHIR.

the class SupportService method getActiveResources.

// TODO do this in parallel.
public ActiveResourcesDto getActiveResources() {
    SmartOnFhirContext smartOnFhirContext = SmartOnFhirContext.get();
    IQuery hcQuery = new HealthConcernQueryFactory().query(ehrClient, smartOnFhirContext.getPatient()).where(Condition.CLINICAL_STATUS.exactly().code(ConditionClinicalStatusCodes.ACTIVE.toCode()));
    IQuery problemQuery = new ProblemQueryFactory().query(ehrClient, smartOnFhirContext.getPatient()).where(Condition.CLINICAL_STATUS.exactly().code(ConditionClinicalStatusCodes.ACTIVE.toCode()));
    IQuery goalQuery = new GoalQueryFactory().query(ehrClient, smartOnFhirContext.getPatient()).where(Goal.LIFECYCLE_STATUS.exactly().code(Goal.GoalLifecycleStatus.ACTIVE.toCode()));
    IQuery taskQuery = new TaskQueryFactory().query(ehrClient, smartOnFhirContext.getPatient()).where(Task.STATUS.exactly().codes(Task.TaskStatus.ACCEPTED.toCode(), Task.TaskStatus.DRAFT.toCode(), Task.TaskStatus.INPROGRESS.toCode(), Task.TaskStatus.ONHOLD.toCode(), Task.TaskStatus.READY.toCode(), Task.TaskStatus.RECEIVED.toCode(), Task.TaskStatus.REQUESTED.toCode()));
    return new ActiveResourcesDto(getTotal(hcQuery), getTotal(problemQuery), getTotal(goalQuery), getTotal(taskQuery));
}
Also used : HealthConcernQueryFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.query.HealthConcernQueryFactory) IQuery(ca.uhn.fhir.rest.gclient.IQuery) GoalQueryFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.query.GoalQueryFactory) TaskQueryFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.query.TaskQueryFactory) ActiveResourcesDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.ActiveResourcesDto) SmartOnFhirContext(com.healthlx.smartonfhir.core.SmartOnFhirContext) ProblemQueryFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.query.ProblemQueryFactory)

Example 4 with TaskQueryFactory

use of org.hl7.gravity.refimpl.sdohexchange.fhir.query.TaskQueryFactory in project Gravity-SDOH-Exchange-RI by FHIR.

the class TaskService method listTasks.

public List<TaskDto> listTasks() {
    Assert.notNull(SmartOnFhirContext.get().getPatient(), "Patient id cannot be null.");
    Bundle tasksBundle = new TaskQueryFactory().query(ehrClient, SmartOnFhirContext.get().getPatient()).include(Task.INCLUDE_FOCUS).where(new TokenClientParam("owner:Organization.type").hasSystemWithAnyCode(OrganizationTypeCode.SYSTEM)).returnBundle(Bundle.class).execute();
    return new TaskBundleToDtoConverter().convert(tasksBundle);
}
Also used : TaskQueryFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.query.TaskQueryFactory) TokenClientParam(ca.uhn.fhir.rest.gclient.TokenClientParam) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) Bundle(org.hl7.fhir.r4.model.Bundle) TaskBundleToDtoConverter(org.hl7.gravity.refimpl.sdohexchange.dto.converter.TaskBundleToDtoConverter)

Aggregations

TaskQueryFactory (org.hl7.gravity.refimpl.sdohexchange.fhir.query.TaskQueryFactory)4 IBaseBundle (org.hl7.fhir.instance.model.api.IBaseBundle)3 Bundle (org.hl7.fhir.r4.model.Bundle)3 IQuery (ca.uhn.fhir.rest.gclient.IQuery)1 TokenClientParam (ca.uhn.fhir.rest.gclient.TokenClientParam)1 SmartOnFhirContext (com.healthlx.smartonfhir.core.SmartOnFhirContext)1 TaskBundleToDtoConverter (org.hl7.gravity.refimpl.sdohexchange.dto.converter.TaskBundleToDtoConverter)1 ActiveResourcesDto (org.hl7.gravity.refimpl.sdohexchange.dto.response.ActiveResourcesDto)1 GoalQueryFactory (org.hl7.gravity.refimpl.sdohexchange.fhir.query.GoalQueryFactory)1 HealthConcernQueryFactory (org.hl7.gravity.refimpl.sdohexchange.fhir.query.HealthConcernQueryFactory)1 ProblemQueryFactory (org.hl7.gravity.refimpl.sdohexchange.fhir.query.ProblemQueryFactory)1