ever_use: Determine Ever Use of Drug(s) of Interest

Description Usage Arguments Value Examples

View source: R/ever_use.R

Description

Determines which patients within a data frame have been exposed to the drug of interest, based on having at least the desired number of prescriptions matching the drug identifier of interest, with option to also provide counts and dates of the first matching prescription.

Usage

1
2
3
4
ever_use(df, drug, flatten = FALSE, threshold = 1, summary = FALSE,
  return_all = 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

flatten

logical, if TRUE the function will only count one record/ prescription per drug ID per date

threshold

a number representing the minimum number of prescriptions that must be present for the patient to be considered exposed

summary

logical, if TRUE the corresponding prescription counts and first prescription dates will be returned alongside patient IDs

return_all

logical, if TRUE the output will contain all patients with a flag indicating if they were exposed or not, and if FALSE will only return data for patients who meet the exposure threshold

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 who match the selected criteria, and if summary is TRUE the corresponding prescription counts and dates

Examples

1
2
3
4
5
ever_use(synth_presc, drug = "CITALOPRAM", drug_id_col = "approved_name",
presc_date_col = "presc_date")
ever_use(synth_presc, drug = "212000", summary = TRUE, threshold = 10,
flatten = TRUE, drug_id_col = "bnf_paragraph",
presc_date_col = "presc_date", date_format = "%Y-%m-%d")

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