(requests, repeater, case_trigger_infos)
return RepeaterResponse(200, "OK")
Send request to register / update tracked entities
Send request to register / update tracked entities
Send request to register / update tracked entities
def send_dhis2_entities(requests, repeater, case_trigger_infos):
    """
    Send request to register / update tracked entities
    """
    errors = []
    info_config_pairs = _get_info_config_pairs(repeater, case_trigger_infos)
    for info, case_config in info_config_pairs:
        try:
            tracked_entity, etag = get_tracked_entity_and_etag(requests, info, case_config)
            if tracked_entity:
                update_tracked_entity_instance(requests, tracked_entity, etag, info, case_config)
            else:
                register_tracked_entity_instance(requests, info, case_config)
        except (Dhis2Exception, HTTPError) as err:
            errors.append(str(err))

    # Create relationships after handling tracked entity instances, to
    # ensure that both the instances in the relationship have been created.
    for info, case_config in info_config_pairs:
        if not case_config.relationships_to_export:
            continue
        try:
            create_relationships(
                requests,
                info,
                case_config,
                repeater.dhis2_entity_config,
            )
        except (Dhis2Exception, HTTPError) as err:
            errors.append(str(err))

    if errors:
        errors_str = f"Errors sending to {repeater}: " + pformat_json([str(e) for e in errors])
        requests.notify_error(errors_str)
        return RepeaterResponse(400, 'Bad Request', errors_str)
    return RepeaterResponse(200, "OK")
def send_dhis2_entities ( requests , repeater , case_trigger_infos ) : errors = [ ] info_config_pairs = _get_info_config_pairs ( repeater , case_trigger_infos ) for info , case_config in info_config_pairs : try : tracked_entity , etag = get_tracked_entity_and_etag ( requests , info , case_config ) if tracked_entity : update_tracked_entity_instance ( requests , tracked_entity , etag , info , case_config ) else : register_tracked_entity_instance ( requests , info , case_config ) except ( Dhis2Exception , HTTPError ) as err : errors . append ( str ( err ) ) # Create relationships after handling tracked entity instances, to # ensure that both the instances in the relationship have been created. for info , case_config in info_config_pairs : if not case_config . relationships_to_export : continue try : create_relationships ( requests , info , case_config , repeater . dhis2_entity_config , ) except ( Dhis2Exception , HTTPError ) as err : errors . append ( str ( err ) ) if errors : errors_str = f"Errors sending to {repeater}: " + pformat_json ( [ str ( e ) for e in errors ] ) requests . notify_error ( errors_str ) return RepeaterResponse ( 400 , 'Bad Request' , errors_str ) return RepeaterResponse ( 200 , "OK" )