use of org.hl7.gravity.refimpl.sdohexchange.dto.response.HealthcareServiceDto in project Gravity-SDOH-Exchange-RI by FHIR.
the class HealthcareServiceBundleToDtoConverter method convert.
@Override
public List<HealthcareServiceDto> convert(Bundle bundle) {
List<HealthcareService> services = FhirUtil.getFromBundle(bundle, HealthcareService.class);
List<HealthcareServiceDto> serviceDtos = new ArrayList<>(services.size());
for (HealthcareService s : services) {
HealthcareServiceDto dto = new HealthcareServiceDto(s.getIdElement().getIdPart());
dto.setLocations(new ArrayList<>());
dto.setName(s.getName());
for (Reference ref : s.getLocation()) {
if (!(ref.getResource() instanceof Location)) {
dto.getErrors().add(String.format("No Location resource was returned for reference %s", ref.getReference()));
} else {
dto.getLocations().add(locationToDtoConverter.convert((Location) ref.getResource()));
}
}
if (s.getLocation().isEmpty()) {
dto.getErrors().add(String.format("No Location resources are present for HealthcareService %s", s.getId()));
}
serviceDtos.add(dto);
}
return serviceDtos;
}
Aggregations