Search in sources :

Example 1 with EthnicityCode

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()));
}
Also used : CodingDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.CodingDto) Coding(org.hl7.fhir.r4.model.Coding) ArrayList(java.util.ArrayList) Observation(org.hl7.fhir.r4.model.Observation) EthnicityCode(org.hl7.gravity.refimpl.sdohexchange.codes.EthnicityCode) DetailedEthnicityCode(org.hl7.gravity.refimpl.sdohexchange.codes.DetailedEthnicityCode) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Aggregations

ArrayList (java.util.ArrayList)1 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)1 Coding (org.hl7.fhir.r4.model.Coding)1 Observation (org.hl7.fhir.r4.model.Observation)1 DetailedEthnicityCode (org.hl7.gravity.refimpl.sdohexchange.codes.DetailedEthnicityCode)1 EthnicityCode (org.hl7.gravity.refimpl.sdohexchange.codes.EthnicityCode)1 CodingDto (org.hl7.gravity.refimpl.sdohexchange.dto.response.CodingDto)1