Search in sources :

Example 1 with ServiceRequestDto

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

Aggregations

Collectors (java.util.stream.Collectors)1 Slf4j (lombok.extern.slf4j.Slf4j)1 Coding (org.hl7.fhir.r4.model.Coding)1 Consent (org.hl7.fhir.r4.model.Consent)1 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)1 Goal (org.hl7.fhir.r4.model.Goal)1 Period (org.hl7.fhir.r4.model.Period)1 ServiceRequest (org.hl7.fhir.r4.model.ServiceRequest)1 Type (org.hl7.fhir.r4.model.Type)1 CodingDto (org.hl7.gravity.refimpl.sdohexchange.dto.response.CodingDto)1 OccurrenceResponseDto (org.hl7.gravity.refimpl.sdohexchange.dto.response.OccurrenceResponseDto)1 ServiceRequestDto (org.hl7.gravity.refimpl.sdohexchange.dto.response.ServiceRequestDto)1 FhirUtil (org.hl7.gravity.refimpl.sdohexchange.util.FhirUtil)1 Converter (org.springframework.core.convert.converter.Converter)1