I'm finding it difficult to settle on a method in the literature on how to deal with exposure time of being on a drug(s) (or not) on a future outcome. Let's say my outcome is death and I have longitudinal drug data:
person_id | first_prescription_date | duration_drug_months | drug_type | study_start_date | study_end_date | status
----------+-------------------------+----------------------+-----------+------------------+----------------+-------
1 | 2012-01-06 | 6 | Drug C | 2010-01-01 | 2020-12-31 | 0
2 | 2011-08-27 | 10 | Drug C | 2010-01-01 | 2019-09-01 | 1
2 | 2012-03-01 | 8 | Drug B | 2010-01-01 | 2019-09-01 | 1
3 | NA | 0 | No Drug | 2010-01-01 | 2020-12-31 | 0
4 | 2010-08-10 | 2 | Drug A | 2010-01-01 | 2016-10-23 | 1
4 | 2014-11-30 | 12 | Drug C | 2010-01-01 | 2016-10-23 | 1
5 | 2011-05-29 | 24 | Drug B | 2010-01-01 | 2020-12-31 | 0
5 | 2014-03-27 | 4 | Drug A | 2010-01-01 | 2020-12-31 | 0
6 | NA | 0 | No Drug | 2010-01-01 | 2013-12-12 | 1
There is only 1 row of data where the participant has never been given a drug, and there is a row for each drug a person has been given that includes which drug, when they were first prescribed and the duration. the status column indicates survival.
I know that I could just record a binary outcome of whether a drug was taken, or even a proportion of time spent exposed to drug over the study period, but even the second method does not take into account when they were exposed.
This paper discusses the many approaches and pitfalls https://onlinelibrary.wiley.com/doi/full/10.1002/pds.4372 of using this kind of data - but I'm still not left with a conclusive path. Does anyone have any suggestions? I am using R so any packages that could help would be great. I have used the survival package often but never but sequential data.