def get_next_visit(case):
    actions = list(case['actions'])
    next_visit = VISIT_SCHEDULE[0]
    for visit_key, visit in enumerate(VISIT_SCHEDULE):
        is_ignored = case.get_case_property(visit['ignored_field'])
        completed = case.get_case_property(visit['completion_field'])
        if completed != '' and is_ignored is not None and is_ignored.lower() == 'yes':
            try:
                next_visit = VISIT_SCHEDULE[visit_key + 1]
            except IndexError:
                next_visit = LAST_VISIT
        else:
            for key, action in enumerate(actions):
                if visit['xmlns'] == action['xform_xmlns']:
                    try:
                        next_visit = VISIT_SCHEDULE[visit_key + 1]
                        del actions[key]
                        break
                    except __HOLE__:
                        next_visit = LAST_VISIT
    return next_visit
dataset/ETHPy150Open dimagi/commcare-hq/custom/succeed/models.py/get_next_visit