Search in sources :

Example 1 with OurTaskBundleToDtoConverter

use of org.hl7.gravity.refimpl.sdohexchange.dto.converter.OurTaskBundleToDtoConverter in project Gravity-SDOH-Exchange-RI by FHIR.

the class OurTaskService method read.

public TaskDto read(String id) {
    Bundle taskBundle = taskRepository.find(id, Lists.newArrayList(Task.INCLUDE_FOCUS, Task.INCLUDE_BASED_ON, Task.INCLUDE_OWNER.asNonRecursive()));
    Task ourTask = FhirUtil.getFirstFromBundle(taskBundle, Task.class);
    if (Objects.isNull(ourTask)) {
        throw new ResourceNotFoundException(new IdType(Task.class.getSimpleName(), id));
    }
    if (!ourTask.getIntent().equals(Task.TaskIntent.FILLERORDER)) {
        throw new TaskReadException("The intent of Task/" + id + " is not filler-order.");
    }
    return new OurTaskBundleToDtoConverter().convert(taskBundle).stream().findFirst().get();
}
Also used : Task(org.hl7.fhir.r4.model.Task) OurTaskBundleToDtoConverter(org.hl7.gravity.refimpl.sdohexchange.dto.converter.OurTaskBundleToDtoConverter) Bundle(org.hl7.fhir.r4.model.Bundle) TaskReadException(org.hl7.gravity.refimpl.sdohexchange.exception.TaskReadException) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) IdType(org.hl7.fhir.r4.model.IdType)

Aggregations

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 OurTaskBundleToDtoConverter (org.hl7.gravity.refimpl.sdohexchange.dto.converter.OurTaskBundleToDtoConverter)1 TaskReadException (org.hl7.gravity.refimpl.sdohexchange.exception.TaskReadException)1