Search in sources :

Example 6 with CodingDto

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

the class ServiceRequestToDtoConverter method convert.

@Override
public ServiceRequestDto convert(ServiceRequest serviceRequest) {
    String id = serviceRequest.getIdElement().getIdPart();
    ServiceRequestDto serviceRequestDto = new ServiceRequestDto(id);
    Coding categoryCode = serviceRequest.getCategoryFirstRep().getCodingFirstRep();
    serviceRequestDto.setCategory(new CodingDto(categoryCode.getCode(), categoryCode.getDisplay()));
    Coding requestCode = serviceRequest.getCode().getCodingFirstRep();
    serviceRequestDto.setCode(new CodingDto(requestCode.getCode(), requestCode.getDisplay()));
    serviceRequestDto.setOccurrence(convertOccurrence(serviceRequest.getOccurrence()));
    serviceRequestDto.setConditions(serviceRequest.getReasonReference().stream().map(typeToDtoConverter::convert).collect(Collectors.toList()));
    serviceRequestDto.setGoals(serviceRequest.getSupportingInfo().stream().filter(info -> info.getReferenceElement().getResourceType().equals(Goal.class.getSimpleName())).map(typeToDtoConverter::convert).collect(Collectors.toList()));
    // TODO: confirm display
    serviceRequestDto.setConsent(serviceRequest.getSupportingInfo().stream().filter(info -> info.getReferenceElement().getResourceType().equals(Consent.class.getSimpleName())).map(typeToDtoConverter::convert).findAny().orElse(null));
    return serviceRequestDto;
}
Also used : CodingDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.CodingDto) Converter(org.springframework.core.convert.converter.Converter) Type(org.hl7.fhir.r4.model.Type) Goal(org.hl7.fhir.r4.model.Goal) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Period(org.hl7.fhir.r4.model.Period) OccurrenceResponseDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.OccurrenceResponseDto) Consent(org.hl7.fhir.r4.model.Consent) Collectors(java.util.stream.Collectors) Slf4j(lombok.extern.slf4j.Slf4j) CodingDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.CodingDto) ServiceRequestDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.ServiceRequestDto) Coding(org.hl7.fhir.r4.model.Coding) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) FhirUtil(org.hl7.gravity.refimpl.sdohexchange.util.FhirUtil) Goal(org.hl7.fhir.r4.model.Goal) Coding(org.hl7.fhir.r4.model.Coding) ServiceRequestDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.ServiceRequestDto)

Example 7 with CodingDto

use of org.hl7.gravity.refimpl.sdohexchange.dto.response.CodingDto 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)

Aggregations

Coding (org.hl7.fhir.r4.model.Coding)7 CodingDto (org.hl7.gravity.refimpl.sdohexchange.dto.response.CodingDto)7 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)5 ReferenceDto (org.hl7.gravity.refimpl.sdohexchange.dto.response.ReferenceDto)4 ArrayList (java.util.ArrayList)3 Collectors (java.util.stream.Collectors)3 Observation (org.hl7.fhir.r4.model.Observation)3 Reference (org.hl7.fhir.r4.model.Reference)3 Converter (org.springframework.core.convert.converter.Converter)3 List (java.util.List)2 Condition (org.hl7.fhir.r4.model.Condition)2 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)2 Goal (org.hl7.fhir.r4.model.Goal)2 Questionnaire (org.hl7.fhir.r4.model.Questionnaire)2 QuestionnaireResponse (org.hl7.fhir.r4.model.QuestionnaireResponse)2 ServiceRequest (org.hl7.fhir.r4.model.ServiceRequest)2 Task (org.hl7.fhir.r4.model.Task)2 Type (org.hl7.fhir.r4.model.Type)2 DetailedEthnicityCode (org.hl7.gravity.refimpl.sdohexchange.codes.DetailedEthnicityCode)2 EthnicityCode (org.hl7.gravity.refimpl.sdohexchange.codes.EthnicityCode)2