Search in sources :

Example 1 with PatientTaskQueryFactory

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

the class PatientTaskService method read.

public PatientTaskDto read(String id) {
    Bundle taskBundle = new PatientTaskQueryFactory().query(ehrClient, SmartOnFhirContext.get().getPatient()).include(Task.INCLUDE_PART_OF).where(Task.RES_ID.exactly().code(id)).where(new TokenClientParam("owner:Patient").exactly().code(SmartOnFhirContext.get().getPatient())).returnBundle(Bundle.class).execute();
    addQuestionnairesToTaskBundle(taskBundle);
    addQuestionnaireResponsesToTaskBundle(taskBundle);
    return new PatientTaskBundleToDtoConverter().convert(taskBundle).stream().findFirst().orElseThrow(() -> new ResourceNotFoundException(new IdType(Task.class.getSimpleName(), id)));
}
Also used : Task(org.hl7.fhir.r4.model.Task) TokenClientParam(ca.uhn.fhir.rest.gclient.TokenClientParam) Bundle(org.hl7.fhir.r4.model.Bundle) PatientTaskBundleToDtoConverter(org.hl7.gravity.refimpl.sdohexchange.dto.converter.PatientTaskBundleToDtoConverter) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) PatientTaskQueryFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.query.PatientTaskQueryFactory) IdType(org.hl7.fhir.r4.model.IdType)

Example 2 with PatientTaskQueryFactory

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

the class PatientTaskService method listTasks.

public List<PatientTaskItemDto> listTasks() {
    Assert.notNull(SmartOnFhirContext.get().getPatient(), "Patient id cannot be null.");
    Bundle tasksBundle = new PatientTaskQueryFactory().query(ehrClient, SmartOnFhirContext.get().getPatient()).include(Task.INCLUDE_PART_OF).where(new TokenClientParam("owner:Patient").exactly().code(SmartOnFhirContext.get().getPatient())).returnBundle(Bundle.class).execute();
    addQuestionnairesToTaskBundle(tasksBundle);
    return new PatientTaskBundleToItemDtoConverter().convert(tasksBundle);
}
Also used : PatientTaskBundleToItemDtoConverter(org.hl7.gravity.refimpl.sdohexchange.dto.converter.PatientTaskBundleToItemDtoConverter) TokenClientParam(ca.uhn.fhir.rest.gclient.TokenClientParam) Bundle(org.hl7.fhir.r4.model.Bundle) PatientTaskQueryFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.query.PatientTaskQueryFactory)

Aggregations

TokenClientParam (ca.uhn.fhir.rest.gclient.TokenClientParam)2 Bundle (org.hl7.fhir.r4.model.Bundle)2 PatientTaskQueryFactory (org.hl7.gravity.refimpl.sdohexchange.fhir.query.PatientTaskQueryFactory)2 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)1 IdType (org.hl7.fhir.r4.model.IdType)1 Task (org.hl7.fhir.r4.model.Task)1 PatientTaskBundleToDtoConverter (org.hl7.gravity.refimpl.sdohexchange.dto.converter.PatientTaskBundleToDtoConverter)1 PatientTaskBundleToItemDtoConverter (org.hl7.gravity.refimpl.sdohexchange.dto.converter.PatientTaskBundleToItemDtoConverter)1