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