use of org.hl7.gravity.refimpl.sdohexchange.dto.response.TaskDto 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();
}
use of org.hl7.gravity.refimpl.sdohexchange.dto.response.TaskDto in project Gravity-SDOH-Exchange-RI by FHIR.
the class TaskService method readAll.
public List<TaskDto> readAll() throws AuthClientException {
List<Server> serverList = serverRepository.findAll();
List<TaskDto> taskDtoList = new ArrayList<>();
for (Server server : serverList) {
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);
taskDtoList.addAll(new TaskBundleToDtoConverter(server.getId()).convert(taskRepository.findAllTasks()));
}
return taskDtoList;
}
use of org.hl7.gravity.refimpl.sdohexchange.dto.response.TaskDto in project Gravity-SDOH-Exchange-RI by FHIR.
the class TaskToDtoConverter method convert.
@Override
public TaskDto convert(Task task) {
TaskDto taskDto = new TaskDto();
taskDto.setId(task.getIdElement().getIdPart());
taskDto.setName(task.getDescription());
taskDto.setCreatedAt(FhirUtil.toLocalDateTime(task.getAuthoredOnElement()));
taskDto.setLastModified(FhirUtil.toLocalDateTime(task.getLastModifiedElement()));
taskDto.setPriority(task.getPriority().getDisplay());
taskDto.setStatus(task.getStatus().getDisplay());
taskDto.setComments(task.getNote().stream().map(annotationToDtoConverter::convert).collect(Collectors.toList()));
taskDto.setStatusReason(task.getStatusReason().getText());
taskDto.setOrganization(typeToDtoConverter.convert(task.getOwner()));
for (TaskOutputComponent outputComponent : task.getOutput()) {
Type componentValue = outputComponent.getValue();
if (componentValue instanceof Reference) {
Reference procedureReference = (Reference) componentValue;
taskDto.getProcedures().add(new ProcedureDto(procedureReference.getReferenceElement().getIdPart(), procedureReference.getDisplay()));
} else if (componentValue instanceof CodeableConcept) {
CodeableConcept outcome = (CodeableConcept) componentValue;
taskDto.setOutcome(outcome.getText());
}
}
return taskDto;
}
use of org.hl7.gravity.refimpl.sdohexchange.dto.response.TaskDto in project Gravity-SDOH-Exchange-RI by FHIR.
the class PatientTaskInfoHolderToDtoConverter method convert.
@Override
public PatientTaskDto convert(PatientTaskInfoHolder taskInfoHolder) {
Task task = taskInfoHolder.getTask();
PatientTaskDto taskDto = (PatientTaskDto) super.convert(taskInfoHolder);
taskDto.setCreatedAt(FhirUtil.toLocalDateTime(task.getAuthoredOnElement()));
taskDto.setComments(task.getNote().stream().map(annotationToDtoConverter::convert).collect(Collectors.toList()));
taskDto.setOccurrence(new OccurrenceResponseDto(FhirUtil.toLocalDateTime(task.getExecutionPeriod().getStartElement()), FhirUtil.toLocalDateTime(task.getExecutionPeriod().getEndElement())));
if (taskInfoHolder.getQuestionnaireResponse() != null) {
taskDto.setAnswers(taskInfoHolder.getQuestionnaireResponse().getItem().stream().collect(Collectors.toMap(qr -> qr.getText(), qr -> {
Type itemAnswer = qr.getAnswerFirstRep().getValue();
if (itemAnswer instanceof StringType) {
return ((StringType) itemAnswer).getValue();
} else if (itemAnswer instanceof Coding) {
return ((Coding) itemAnswer).getDisplay();
} else {
taskDto.getErrors().add(String.format("Answer cannot be resolved. %s type is not expected.", itemAnswer.getClass().getSimpleName()));
return "Answer cannot be parsed.";
}
}, (existing, replacement) -> {
taskDto.getErrors().add(String.format("Duplicating questions detected. Value '%s' overwrites the value '%s'", replacement, existing));
return replacement;
}, LinkedHashMap::new)));
}
return taskDto;
}
use of org.hl7.gravity.refimpl.sdohexchange.dto.response.TaskDto in project Gravity-SDOH-Exchange-RI by FHIR.
the class PatientTaskItemInfoHolderToItemDtoConverter method convert.
@Override
public PatientTaskItemDto convert(T taskInfoHolder) {
Task task = taskInfoHolder.getTask();
Questionnaire questionnaire = taskInfoHolder.getQuestionnaire();
PatientTaskItemDto taskDto = createDto();
taskDto.setId(task.getIdElement().getIdPart());
taskDto.setName(task.getDescription());
taskDto.setPriority(task.getPriority().getDisplay());
taskDto.setLastModified(FhirUtil.toLocalDateTime(task.getLastModifiedElement()));
taskDto.setStatus(task.getStatus().getDisplay());
taskDto.setStatusReason(task.getStatusReason().getText());
setReferralTask(task, taskDto);
List<Coding> codings = task.getCode().getCoding();
PatientTaskCode code = getCode(taskDto, codings);
if (code != null) {
Coding coding = code.toCoding();
taskDto.setCode(new CodingDto(coding.getCode(), coding.getDisplay()));
}
setTaskType(task, taskDto, code);
if (questionnaire != null) {
taskDto.setAssessment(new ReferenceDto(questionnaire.getIdElement().getIdPart(), questionnaire.getTitle()));
}
for (TaskOutputComponent outputComponent : task.getOutput()) {
Type componentValue = outputComponent.getValue();
Coding coding = FhirUtil.findCoding(Lists.newArrayList(outputComponent.getType()), SDCTemporaryCode.SYSTEM, SDCTemporaryCode.QUESTIONNAIRE_RESPONSE.getCode());
if (coding != null) {
Reference qrRef = (Reference) componentValue;
if (QuestionnaireResponse.class.getSimpleName().equals(qrRef.getReferenceElement().getResourceType())) {
taskDto.setAssessmentResponse(new ReferenceDto(qrRef.getReferenceElement().getIdPart(), coding.getDisplay()));
}
}
if (componentValue instanceof CodeableConcept) {
CodeableConcept outcome = (CodeableConcept) componentValue;
taskDto.setOutcome(outcome.getText());
}
}
return taskDto;
}
Aggregations