refill_gap: Determine Drug Persistence with Refill Gap Only

Description Usage Arguments Value Examples

View source: R/persistence.R

Description

This function determines periods of persistent use of the drug of interest based on the gaps between prescriptions. Gaps which exceed the selected allowable gap length result in discontinuation points, and the function returns patient ID's and periods of exposure that are over the selected minimum length.

Usage

1
2
3
refill_gap(df, drug, gap, threshold = 0, summary = FALSE,
  patient_id_col = "patient_id", drug_id_col = "drug_id",
  presc_date_col = "presc_date_x", date_format)

Arguments

df

a data frame containing prescribing records to be analysed - records must contain at least a paitent ID, drug ID and a prescription date

drug

a string containing a drug ID to be used to limit the prescribing data to the drug(s) of interest, accepts regular expressions

gap

a number, the length of the allowable gap in days between two prescriptions before the patient is considered to have discontinued use of the drug

threshold

a number, the minimum length of period of exposure, in days, to be included in the results

summary

a logical, if true the function will return a summary of all exposure periods instead of the individual periods

patient_id_col

a string, the name of the column in df containing the patient IDs

drug_id_col

a string, the name of the column in df containing the drug IDs

presc_date_col

a string, the name of the column in df containing the prescption date

date_format

a string, the format of the dates in df

Value

a data frame containing patient IDs and corresponding periods of exposure (consisting of first and last prescriptions, number of prescriptions and lengths of exposure) which match the chosen refill gap and minimum length

Examples

1
2
3
4
5
6
refill_gap(synth_presc, drug = "SIMVASTATIN", gap = 30,
drug_id_col = "approved_name", presc_date_col = "presc_date",
date_format = "%d/%m/%Y")
refill_gap(synth_presc, drug = "103050", gap = 30, threshold = 60, summary = TRUE,
drug_id_col = "bnf_paragraph", presc_date_col = "presc_date",
date_format = "%d/%m/%Y")

amarshall1/prescribeR documentation built on May 20, 2020, 2:34 p.m.