I am trying to do a Cox regression with a time dependent variable. Time zero is time of diagnosis and follow up ends when patient has admission or is censored. I am interested in seeing whether a particular intervention reduces risk of hospital admission. Patients receive interventions at different times after diagnosis and to avoid immortal time bias I want to differentiate between time before and after patient had intervention. I can calculate the time from diagnosis to intervention (lag time?) for each patient but how do I use this data to construct a time dependent variable. The examples I have seen for time segmented covariates do not seem to address such a situation.