Search in sources :

Example 1 with OrganizationTypeCode

use of org.hl7.gravity.refimpl.sdohexchange.codes.OrganizationTypeCode in project Gravity-SDOH-Exchange-RI by FHIR.

the class OrganizationToDtoConverter method convert.

@Override
public OrganizationDto convert(Organization org) {
    String orgId = org.getIdElement().getIdPart();
    OrganizationDto orgDto = new OrganizationDto(orgId);
    orgDto.setName(org.getName());
    // We are interested only in CBO/CP types. Other are ignored.
    Coding coding = FhirUtil.findCoding(org.getType(), OrganizationTypeCode.SYSTEM);
    if (coding == null) {
        orgDto.getErrors().add(String.format("Organization with id '%s' has no coding with system '%s' within a 'type' property. Such organizations " + "are " + "not expected in this context.", orgId, OrganizationTypeCode.SYSTEM));
    } else {
        try {
            orgDto.setType(OrganizationTypeCode.fromCode(coding.getCode()));
        } catch (FHIRException exc) {
            orgDto.getErrors().add(String.format("OrganizationTypeCode code '%s' cannot be resolved for Organization with id '%s'.", coding.getCode(), orgId));
        }
    }
    return orgDto;
}
Also used : Coding(org.hl7.fhir.r4.model.Coding) FHIRException(org.hl7.fhir.exceptions.FHIRException) OrganizationDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.OrganizationDto)

Aggregations

FHIRException (org.hl7.fhir.exceptions.FHIRException)1 Coding (org.hl7.fhir.r4.model.Coding)1 OrganizationDto (org.hl7.gravity.refimpl.sdohexchange.dto.response.OrganizationDto)1