def flatten_result(result):
    case_properties = result.pop('case_properties', None)
    for case_property in case_properties:
        key = case_property.get('key')
        value = case_property.get('value')
        if key and value:
            result[key] = value
    return result
Flattens a result from CaseSearchES into the format that Case serializers
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/es/case_search.py/flatten_result