This might be handled by standard recurrent-event analysis allowing for time-dependent covariates (in this case, in particular whether the drug was being provided during each time interval). The general principles and illustrations for analysis in SAS, Stata and R are nicely presented in a recent paper by Amorim and Cai.
In R, the simplest approach would be to format the data with columns for (patientID, startTime, stopTime, event, drugStatus, otherCovariateValues...) with a separate row starting with each change of drug (or of other time-dependent covariates) or ending with each event. See this vignette for ways to format data this way. Including an ID for each patient allows correction for the correlations of results within individuals, e.g. by including a term of
cluster(patientID) as a predictor in the model. This approach would be appropriate if the occurrence of an event is simply a function of the covariates and drug status at the time of the event, and if subsequent recurrent events were independent of prior events (given the present values of drug/covariates).
There isn't a problem here with events happening absent the drug. Presumably your interest is in whether the drug affects the probability/timing of an event occurring, and this analysis would address this issue directly provided that the above assumptions hold.
It is possible to model more complicated situations in which prior events themselves influence the probability of subsequent events, cumulative exposure to drug rather than instantaneous exposure is related to events, and so on. The references linked above are useful starting points for exploring these possibilities.