Search in sources :

Example 1 with HealthcareServiceDto

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;
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) ArrayList(java.util.ArrayList) HealthcareService(org.hl7.fhir.r4.model.HealthcareService) HealthcareServiceDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.HealthcareServiceDto) Location(org.hl7.fhir.r4.model.Location)

Aggregations

ArrayList (java.util.ArrayList)1 HealthcareService (org.hl7.fhir.r4.model.HealthcareService)1 Location (org.hl7.fhir.r4.model.Location)1 Reference (org.hl7.fhir.r4.model.Reference)1 HealthcareServiceDto (org.hl7.gravity.refimpl.sdohexchange.dto.response.HealthcareServiceDto)1