# Survival model for longitudinal data with overlapping exposures

I have a dataset with info on patient exposures (drug 1 / drug 2) and outcomes (hospitalisation / death) over ten years. All patients were prescribed drug 1 on and off over the period (inclusion criteria for the study), and some patients were prescribed drug 2.

I am interested in modelling patient survival in R, including time to hospitalisation and time to death. My hypothesis is that being prescribed drug 2 (alone or in combination with drug 1) increases the risk of these outcomes. I had intended to develop a joint frailty model using the frailtypack library as this would account for the longitudinal nature of the data, repeat drug 1 treatment episodes, and include individual factors associated with risk of outcome.

Although drug 2 is my main exposure of interest, I would like to explore drug 1 as a contributory factor, but am not sure if this is appropriate / feasible in a frailty model.

Should I create a 4-state dummy variable {no drugs, drug 1 alone, drug 2 alone, drug 1 + drug 2} and use this as my exposure variable? Would a different modelling approach be more suitable for these data?

Your 4-state dummy variable (with a baseline level subsumed in the baseline hazard so that you only code 3 dummies) is what you would get if you included a term drug 1 * drug 2 in your R formula. That's certainly a way to proceed, although I prefer to let R expand my formulas for me. The presence of the drugs would be coded as time-varying covariates.
The question is just what you intend to model. With that type of term in a proportional hazards model you are evaluating how much the presence of either or both of the drugs affects the risks of events instantaneously. If you think that any prior exposure to drug 1 or the cumulative exposure to drug 1 is what really matters with respect to event probability directly or to affecting responses to drug 2, you need to provide corresponding time-varying covariate values associated with drug 1.