| Title: | Assess Medication Adherence from Pharmaceutical Claims Data |
|---|---|
| Description: | A (mildly) opinionated set of functions to help assess medication adherence for researchers working with medication claims data. Medication adherence analyses have several complex steps that are often convoluted and can be time-intensive. The focus is to create a set of functions using "tidy principles" geared towards transparency, speed, and flexibility while working with adherence metrics. All functions perform exactly one task with an intuitive name so that a researcher can handle details (often achieved with vectorized solutions) while we handle non-vectorized tasks common to most adherence calculations such as adjusting fill dates and determining episodes of care. The methodologies in referenced in this package come from Canfield SL, et al (2019) "Navigating the Wild West of Medication Adherence Reporting in Specialty Pharmacy" <doi:10.18553/jmcp.2019.25.10.1073>. |
| Authors: | Brennan Beal [aut, cre] |
| Maintainer: | Brennan Beal <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 1.0.0.9000 |
| Built: | 2026-06-05 09:28:28 UTC |
| Source: | https://github.com/btbeal/adherencerx |
tibble for Performance DemonstrationA toy pharmaceutical claims data set meant to be used to benchmark other algorithms
big_data_toybig_data_toy
A tibble with 100,000 rows and 6 variables:
patient ID to be grouped by
date of claim
number of days supplied
Calculate the proportion of days covered (PDC) from a pharmaceutical claims database. This function is suggested only
after one has properly adjusted their dates (propagate_date()) and identified gaps in therapy
(identify_gaps()). This function calculates a length of total therapy as the first fill date to the last for a given grouping.
Finally, if you'd like to view adherence by episodes after you have used rank_episodes(), the function will re-adjust gaps for you so that the gap that defined the episode isn't included.
calculate_pdc(.data, .summarise = TRUE)calculate_pdc(.data, .summarise = TRUE)
.data |
data frame |
.summarise |
Logical value (defaulting to TRUE) indicating whether the output should be summarised or not |
a summarised tibble, by default, with proportion of days covered calculated
library(adheRenceRX) library(dplyr) toy_claims %>% group_by(ID) %>% propagate_date(.date = date, .days_supply = days_supply) %>% identify_gaps() %>% calculate_pdc() #OR, one could group by the ID and episode of care like... toy_claims %>% group_by(ID) %>% propagate_date(.date = date, .days_supply = days_supply) %>% identify_gaps() %>% rank_episodes(.permissible_gap = 30) %>% ungroup() %>% group_by(ID, episode) %>% calculate_pdc()library(adheRenceRX) library(dplyr) toy_claims %>% group_by(ID) %>% propagate_date(.date = date, .days_supply = days_supply) %>% identify_gaps() %>% calculate_pdc() #OR, one could group by the ID and episode of care like... toy_claims %>% group_by(ID) %>% propagate_date(.date = date, .days_supply = days_supply) %>% identify_gaps() %>% rank_episodes(.permissible_gap = 30) %>% ungroup() %>% group_by(ID, episode) %>% calculate_pdc()
This is a function meant to be utilized within propagate_date() in order to adjust pharmaceutical claims dates to prevent overlapping in adherence calculations, per 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.
date_check(df)date_check(df)
df |
a claims data frame with a date of a medication claim and the corresponding days supply |
A new claims data frame with an appended column, adjusted_date
This is a helper function to assist rank_episodes
episode_check(df)episode_check(df)
df |
a data frame with "gap", "initial_rank", and "permi_gap" columns appended from |
a data frame with an "episode" column appended, which ranks episodes of care in time
Compute gaps in a patient's therapy from the end of their prior fill to the beginning of the next. This function assumes that one has arranged the dates and grouped appropriately outside of the function. The length of any gap will be appended to the row after the gap has occurred.
identify_gaps(.data)identify_gaps(.data)
.data |
data frame |
A new claims tibble with an appended column, gap
This function relies an adjusted_date column to identify gaps in therapy. So, if you don't want to use propagate_date() beforehand,
you'll need to rename the date variable you wish to use to adjusted_date.
library(adheRenceRX) library(dplyr) toy_claims %>% filter(ID == "D") %>% propagate_date(.date_var = date, .days_supply_var = days_supply) %>% identify_gaps()library(adheRenceRX) library(dplyr) toy_claims %>% filter(ID == "D") %>% propagate_date(.date_var = date, .days_supply_var = days_supply) %>% identify_gaps()
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)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)library(adheRenceRX) library(dplyr) toy_claims %>% filter(ID == "D") %>% propagate_date(.date_var = date, .days_supply_var = days_supply)
This function identifies and labels all episodes of care for a given patient in chronological order. A new episode begins after a specified gap in therapy has occurred.
It is meant to be used after one has appropriately adjusted dates (propagate_date()) and identified gaps in therapy (identify_gaps()).
rank_episodes(.data, .permissible_gap = NULL, .initial_rank = 1)rank_episodes(.data, .permissible_gap = NULL, .initial_rank = 1)
.data |
Data frame with a "gap" column appended from |
.permissible_gap |
Integer value suggesting the maximum gap allowed before labeling a new episode of care |
.initial_rank |
Integer value to identify what the indexing rank should be (defaults to 1). |
The initial claims data frame with an episode column appended, which ranks episodes of care in time
This function assumes an adjusted_date column, which is produced by the propagate_date() function and a
gap column, which is produced by identify_gaps(). If you would like to rank episodes of care using other dates and a separate
column for gaps, you'll need to rename those columns before passing the frame to rank_episodes(). Notably, this is on purpose as this step should
almost always come after the former two.
library(adheRenceRX) library(dplyr) toy_claims %>% filter(ID == "D") %>% propagate_date() %>% identify_gaps() %>% rank_episodes(.permissible_gap = 20, .initial_rank = 1)library(adheRenceRX) library(dplyr) toy_claims %>% filter(ID == "D") %>% propagate_date() %>% identify_gaps() %>% rank_episodes(.permissible_gap = 20, .initial_rank = 1)
This function serves as a convenience wrapper of dplyr::summarise(), which takes the grouped variables and
summarises their gaps in therapy. This function is to be used after propagate_date().
summarise_gaps(.data)summarise_gaps(.data)
.data |
Data to be piped into the function |
A summary of gaps in therapy
This function relies an adjusted_date column to identify gaps in therapy. So, if you don't want to use propagate_date() beforehand,
you'll need to rename the date variable you wish to use to adjusted_date.
library(adheRenceRX) library(dplyr) toy_claims %>% filter(ID == "D") %>% propagate_date(.date_var = date, .days_supply_var = days_supply) %>% summarise_gaps()library(adheRenceRX) library(dplyr) toy_claims %>% filter(ID == "D") %>% propagate_date(.date_var = date, .days_supply_var = days_supply) %>% summarise_gaps()
tibble
This mock patient claims tibble is meant to test adheRenceRX with scenarios presented in Figure 1. of 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
toy_claimstoy_claims
A tibble with 22 rows and 3 variables:
patient ID to be grouped by
date of claim
number of days supplied