Search in sources :

Example 1 with PatientTaskBundleToDtoConverter

use of org.hl7.gravity.refimpl.sdohexchange.dto.converter.PatientTaskBundleToDtoConverter 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)

Aggregations

TokenClientParam (ca.uhn.fhir.rest.gclient.TokenClientParam)1 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)1 Bundle (org.hl7.fhir.r4.model.Bundle)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 PatientTaskQueryFactory (org.hl7.gravity.refimpl.sdohexchange.fhir.query.PatientTaskQueryFactory)1