survival analysis with time dependent variable

Hello Guys,
I am still a beginner with R.
I am trying to do cox proportional hazard model for female patients with non obstructive coronary artery disease. Events reported include death and MI.
I am trying to adjust this to statin use. to show that statin use can decrease events even in non obstructive plaques
the question is, if patient had multiple visits and with each visit medication use was reported and statin use varied from visit to visit. how would you adjust for statin use knowing that it statin status varies in each visit?