def update_patient_target_dates(case):
    from custom.succeed.reports import VISIT_SCHEDULE

    for visit_key, visit in enumerate(VISIT_SCHEDULE):
        try:
            next_visit = VISIT_SCHEDULE[visit_key + 1]
        except __HOLE__:
            next_visit = 'last'
        if next_visit != 'last' and case.get_case_property("randomization_date") is not None:
            rand_date = dateutil.parser.parse(get_randomization_date(case))
            tg_date = rand_date.date() + timedelta(days=next_visit['days'])
            # technically updates to cases should only happen via form submissions
            # leaving as is for now since this is custom code
            # SK 2016-02-03
            setattr(case, visit['target_date_case_property'], tg_date.strftime("%m/%d/%Y"))
    case.save()
dataset/ETHPy150Open dimagi/commcare-hq/custom/succeed/utils.py/update_patient_target_dates