use of org.hl7.gravity.refimpl.sdohexchange.codes.EthnicityCode in project Gravity-SDOH-Exchange-RI by FHIR.
the class PersonalCharacteristicsInfoHolderToDtoConverter method convertEthnicity.
private void convertEthnicity(Observation obs, PersonalCharacteristicDto dto) {
List<CodeableConcept> detailedValues = new ArrayList<>();
obs.getComponent().stream().filter(c -> CharacteristicCode.SYSTEM.equals(c.getCode().getCodingFirstRep().getSystem()) && c.hasValueCodeableConcept()).map(Observation.ObservationComponentComponent::getValueCodeableConcept).forEach(cc -> {
if (DetailedEthnicityCode.CODES.containsKey(cc.getCodingFirstRep().getCode())) {
detailedValues.add(cc);
} else {
Validated.withError(dto, () -> {
EthnicityCode ethnicityCode = EthnicityCode.fromCode(cc.getCodingFirstRep().getCode());
dto.setValue(new CodingDto(ethnicityCode.getCode(), ethnicityCode.getDisplay()));
});
}
});
dto.setDetailedValues(detailedValues.stream().map(v -> {
Coding coding = v.getCodingFirstRep();
return new CodingDto(coding.getCode(), coding.getDisplay());
}).collect(Collectors.toList()));
}
Aggregations