(
    data_element_id: str,
    data_values: List[dict],
)
return found, value
A DHIS2 data element may be broken down by category options, and
    ``data_values`` can contain multiple entries for the same data
    element. This function returns whether ``data_element_id`` is found
    in ``data_values``, and its total.

    The following doctest shows an example value for ``data_values`` as
    might be returned by DHIS2:

    >>> data_values = [
    ...     {
    ...         "dataElement": "f7n9E0hX8qk",
    ...         "period": "2014Q1",
    ...         "orgUnit": "DiszpKrYNg8",
    ...         "categoryOption": "FNnj3jKGS7i",
    ...         "value": "12"
    ...     },
    ...     {
    ...         "dataElement": "f7n9E0hX8qk",
    ...         "period": "2014Q1",
    ...         "orgUnit": "DiszpKrYNg8",
    ...         "categoryOption": "Jkhdsf8sdf4",
    ...         "value": "16"
    ...     }
    ... ]
    >>> get_data_element_total('f7n9E0hX8qk', data_values)
    (True, 28)
A DHIS2 data element may be broken down by category options, and
    ``data_values`` can contain multiple entries for the same data
    element. This function returns whether ``data_element_id`` is found
    in ``data_values``, and its total.
A DHIS2 data element may be broken down by category options and data_values can contain multiple entries for the same data element . This function returns whether data_element_id is found in data_values and its total .
def get_data_element_total(
    data_element_id: str,
    data_values: List[dict],
) -> Tuple[bool, int]:
    """
    A DHIS2 data element may be broken down by category options, and
    ``data_values`` can contain multiple entries for the same data
    element. This function returns whether ``data_element_id`` is found
    in ``data_values``, and its total.

    The following doctest shows an example value for ``data_values`` as
    might be returned by DHIS2:

    >>> data_values = [
    ...     {
    ...         "dataElement": "f7n9E0hX8qk",
    ...         "period": "2014Q1",
    ...         "orgUnit": "DiszpKrYNg8",
    ...         "categoryOption": "FNnj3jKGS7i",
    ...         "value": "12"
    ...     },
    ...     {
    ...         "dataElement": "f7n9E0hX8qk",
    ...         "period": "2014Q1",
    ...         "orgUnit": "DiszpKrYNg8",
    ...         "categoryOption": "Jkhdsf8sdf4",
    ...         "value": "16"
    ...     }
    ... ]
    >>> get_data_element_total('f7n9E0hX8qk', data_values)
    (True, 28)

    """
    found = False
    value = 0
    for data_value in data_values:
        if data_value['dataElement'] == data_element_id:
            found = True
            value += int(data_value['value'])
    return found, value
def get_data_element_total ( data_element_id : str , data_values : List [ dict ] , ) -> Tuple [ bool , int ] : found = False value = 0 for data_value in data_values : if data_value [ 'dataElement' ] == data_element_id : found = True value += int ( data_value [ 'value' ] ) return found , value