Search in sources :

Example 1 with PatientTaskItemDto

use of org.hl7.gravity.refimpl.sdohexchange.dto.response.patienttask.PatientTaskItemDto 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;
}
Also used : Task(org.hl7.fhir.r4.model.Task) ReferenceDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.ReferenceDto) Questionnaire(org.hl7.fhir.r4.model.Questionnaire) Reference(org.hl7.fhir.r4.model.Reference) QuestionnaireResponse(org.hl7.fhir.r4.model.QuestionnaireResponse) PatientTaskItemDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.patienttask.PatientTaskItemDto) CodingDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.CodingDto) Type(org.hl7.fhir.r4.model.Type) PatientTaskType(org.hl7.gravity.refimpl.sdohexchange.dto.request.patienttask.PatientTaskType) Coding(org.hl7.fhir.r4.model.Coding) PatientTaskCode(org.hl7.gravity.refimpl.sdohexchange.codes.PatientTaskCode) TaskOutputComponent(org.hl7.fhir.r4.model.Task.TaskOutputComponent) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 2 with PatientTaskItemDto

use of org.hl7.gravity.refimpl.sdohexchange.dto.response.patienttask.PatientTaskItemDto in project Gravity-SDOH-Exchange-RI by FHIR.

the class PatientTaskService method listTasks.

public List<PatientTaskItemDto> listTasks() {
    Assert.notNull(SmartOnFhirContext.get().getPatient(), "Patient id cannot be null.");
    Bundle tasksBundle = new PatientTaskQueryFactory().query(ehrClient, SmartOnFhirContext.get().getPatient()).include(Task.INCLUDE_PART_OF).where(new TokenClientParam("owner:Patient").exactly().code(SmartOnFhirContext.get().getPatient())).returnBundle(Bundle.class).execute();
    addQuestionnairesToTaskBundle(tasksBundle);
    return new PatientTaskBundleToItemDtoConverter().convert(tasksBundle);
}
Also used : PatientTaskBundleToItemDtoConverter(org.hl7.gravity.refimpl.sdohexchange.dto.converter.PatientTaskBundleToItemDtoConverter) TokenClientParam(ca.uhn.fhir.rest.gclient.TokenClientParam) Bundle(org.hl7.fhir.r4.model.Bundle) PatientTaskQueryFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.query.PatientTaskQueryFactory)

Aggregations

TokenClientParam (ca.uhn.fhir.rest.gclient.TokenClientParam)1 Bundle (org.hl7.fhir.r4.model.Bundle)1 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)1 Coding (org.hl7.fhir.r4.model.Coding)1 Questionnaire (org.hl7.fhir.r4.model.Questionnaire)1 QuestionnaireResponse (org.hl7.fhir.r4.model.QuestionnaireResponse)1 Reference (org.hl7.fhir.r4.model.Reference)1 Task (org.hl7.fhir.r4.model.Task)1 TaskOutputComponent (org.hl7.fhir.r4.model.Task.TaskOutputComponent)1 Type (org.hl7.fhir.r4.model.Type)1 PatientTaskCode (org.hl7.gravity.refimpl.sdohexchange.codes.PatientTaskCode)1 PatientTaskBundleToItemDtoConverter (org.hl7.gravity.refimpl.sdohexchange.dto.converter.PatientTaskBundleToItemDtoConverter)1 PatientTaskType (org.hl7.gravity.refimpl.sdohexchange.dto.request.patienttask.PatientTaskType)1 CodingDto (org.hl7.gravity.refimpl.sdohexchange.dto.response.CodingDto)1 ReferenceDto (org.hl7.gravity.refimpl.sdohexchange.dto.response.ReferenceDto)1 PatientTaskItemDto (org.hl7.gravity.refimpl.sdohexchange.dto.response.patienttask.PatientTaskItemDto)1 PatientTaskQueryFactory (org.hl7.gravity.refimpl.sdohexchange.fhir.query.PatientTaskQueryFactory)1