Search in sources :

Example 1 with ProcedureDto

use of org.hl7.gravity.refimpl.sdohexchange.dto.response.ProcedureDto 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;
}
Also used : ProcedureDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.ProcedureDto) Type(org.hl7.fhir.r4.model.Type) Reference(org.hl7.fhir.r4.model.Reference) TaskOutputComponent(org.hl7.fhir.r4.model.Task.TaskOutputComponent) TaskDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.TaskDto) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Aggregations

CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)1 Reference (org.hl7.fhir.r4.model.Reference)1 TaskOutputComponent (org.hl7.fhir.r4.model.Task.TaskOutputComponent)1 Type (org.hl7.fhir.r4.model.Type)1 ProcedureDto (org.hl7.gravity.refimpl.sdohexchange.dto.response.ProcedureDto)1 TaskDto (org.hl7.gravity.refimpl.sdohexchange.dto.response.TaskDto)1