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;
}
Aggregations