this should be evaluated at the beginning, not inside the loop -- it will be executed once for each patient in the cohort, if left here.