When assessing pharmaceutical adherence, one should adjust overlapping dates forward for a specified group (e.g. patient ids or medication classes) so that there is no overlap in days supply. For example, if a patient receives a 30 days supply on January 1st, and another 15 days later, the next fill date should be moved up 15 days. This function is modeled after recommendations from Canfield SL, Zuckerman A, Anguiano RH, Jolly JA, DeClercq J. Navigating the wild west of medication adherence reporting in specialty pharmacy. J Manag Care Spec Pharm. 2019;25(10):1073-77.
propagate_date(.data, .date_var = NULL, .days_supply_var = NULL)
.data | Data to be piped into the function |
---|---|
.date_var | Date, column indicating the date of a given fill |
.days_supply_var | Integer, column indicating the days supply of a given fill |
The initial claims data frame with an appended column, adjusted_date
This function relies on anydate to parse the users date variable into a date class. So, for most columns passed to .date_var, this function will run without warning or error.
For example, anydate(30)
will return "1970-01-31" even though 30 is most likely a days supply. If strange results are produced, double check that the
date variable being specified is indeed a fill date.
library(adheRenceRX) library(dplyr) toy_claims %>% filter(ID == "D") %>% propagate_date(.date_var = date, .days_supply_var = days_supply)#> # A tibble: 6 x 4 #> ID date days_supply adjusted_date #> <chr> <date> <dbl> <date> #> 1 D 2020-01-01 60 2020-01-01 #> 2 D 2020-01-31 60 2020-03-01 #> 3 D 2020-03-01 60 2020-04-30 #> 4 D 2020-05-30 30 2020-06-29 #> 5 D 2020-08-28 60 2020-08-28 #> 6 D 2020-09-27 30 2020-10-27