use of org.hl7.gravity.refimpl.sdohexchange.dto.response.TaskDto in project Gravity-SDOH-Exchange-RI by FHIR.
the class TaskService method read.
public TaskDto read(String id) {
Bundle taskBundle = taskRepository.find(id, Lists.newArrayList(Task.INCLUDE_FOCUS, Task.INCLUDE_OWNER.asNonRecursive()), Lists.newArrayList(Task.INCLUDE_BASED_ON));
Task task = FhirUtil.getFirstFromBundle(taskBundle, Task.class);
if (Objects.isNull(task)) {
throw new ResourceNotFoundException(new IdType(Task.class.getSimpleName(), id));
}
if (!task.getIntent().equals(Task.TaskIntent.ORDER)) {
throw new TaskReadException("The intent of Task/" + id + " is not order.");
}
return new TaskBundleToDtoConverter().convert(taskBundle).stream().findFirst().get();
}
use of org.hl7.gravity.refimpl.sdohexchange.dto.response.TaskDto in project Gravity-SDOH-Exchange-RI by FHIR.
the class TaskService method read.
public TaskDto read(Integer serverId, String taskId) {
Server server = serverRepository.findById(serverId).orElseThrow(() -> new ServerNotFoundException(String.format("No server was found by id '%s'", serverId)));
IGenericClient fhirClient = fhirContext.newRestfulGenericClient(server.getFhirServerUrl());
// Doesn't support now
// fhirClient.registerInterceptor(new BearerTokenAuthInterceptor(
// authorizationClient.getTokenResponse(URI.create(server.getAuthServerUrl()), server.getClientId(),
// server.getClientSecret(), SCOPE)
// .getAccessToken()));
TaskRepository taskRepository = new TaskRepository(fhirClient, applicationUrl);
Bundle taskBundle = taskRepository.find(taskId, Lists.newArrayList(Task.INCLUDE_FOCUS));
Task task = FhirUtil.getFirstFromBundle(taskBundle, Task.class);
if (Objects.isNull(task)) {
throw new ResourceNotFoundException(new IdType(Task.class.getSimpleName(), taskId));
}
if (!task.getIntent().equals(Task.TaskIntent.FILLERORDER)) {
throw new TaskReadException("The intent of Task/" + taskId + " is not filler-order.");
}
return new TaskBundleToDtoConverter(serverId).convert(taskBundle).stream().findFirst().get();
}
use of org.hl7.gravity.refimpl.sdohexchange.dto.response.TaskDto 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);
}
Aggregations