(requests, tei_id, case_trigger_info)
Fetch a tracked entity instance from a DHIS2 server by its TEI ID,
    and return it with its ETag.

    Raises BadTrackedEntityInstanceID if the ID does not belong to an
    instance.
Fetch a tracked entity instance from a DHIS2 server by its TEI ID,
    and return it with its ETag.
Fetch a tracked entity instance from a DHIS2 server by its TEI ID and return it with its ETag .
def get_tracked_entity_instance_and_etag_by_id(requests, tei_id, case_trigger_info):
    """
    Fetch a tracked entity instance from a DHIS2 server by its TEI ID,
    and return it with its ETag.

    Raises BadTrackedEntityInstanceID if the ID does not belong to an
    instance.
    """
    endpoint = f"/api/trackedEntityInstances/{tei_id}"
    params = {"fields": "*"}  # Tells DHIS2 to return everything
    response = requests.get(endpoint, params=params)
    if 200 <= response.status_code < 300:
        return response.json(), response.headers["ETag"]
    else:
        raise BadTrackedEntityInstanceID(_(
            'The tracked entity instance ID "{id}" of case {case} was not '
            'found on its DHIS2 server.'
        ).format(id=tei_id, case=case_trigger_info))
def get_tracked_entity_instance_and_etag_by_id ( requests , tei_id , case_trigger_info ) : endpoint = f"/api/trackedEntityInstances/{tei_id}" params = { "fields" : "*" } # Tells DHIS2 to return everything response = requests . get ( endpoint , params = params ) if 200 <= response . status_code < 300 : return response . json ( ) , response . headers [ "ETag" ] else : raise BadTrackedEntityInstanceID ( _ ( 'The tracked entity instance ID "{id}" of case {case} was not ' 'found on its DHIS2 server.' ) . format ( id = tei_id , case = case_trigger_info ) )