Title

rrc -- Calculate adherence statistics

Syntax

rrc using filename , timespan(begin/interval/end)
[ optional options ]

timespan() the period over (and periodicity with which) to measure adherence

ptid(varname) patient ids

ixdate(varname) index date; ie, the dates from which begin and end are measured

drugid(varname) drug ids; must be numeric

prdate(varname) prescription dates

prdays(varname) prescription durations (ie, days supply)

using specifies the name of the output file, which will replace the dataset in memory when the command is finished. Note that the specified file will be over-written without warning...

Description

rrc calculates adherence, measured as the percent of days during which a patient has all the drug they're supposed to have. It requires (in the data file):

o- a set of cases, defined as a patient ID combined with an index date

o- a set of drugs

o- for each case/drug, a list of prescription dates & durations (in days)

The command also specifies the relevant timeperiods as timespan(begin/interval/end), where:

o- begin is the offset from index date, in days, at which to begin calculations.

o- interval is the number of days over which to calcuate each adherence statistic.

o- end is the offset from index date, in days, at which to end calculations.

For example, timespan(-90/30/180) would calculate adherence for each 30-day period from 90 days before the index date, till 180 days after the index date.
(Note that the 180th day post-index would not actually be included, since it would not be part of a complete 30-day period.)

Remarks

The 5 optional varnames should be treated as a group: either all specified or none. If the variables are the first 5 in the dataset, and ordered as above, they don't need to be explicitly specified.

The output dataset will have one variable for each value of drugid() found in the input data. These variables will contain the adherence outcomes, numbers between 0 and 1.
There will also be 3 "header" fields: patient ID and index date (from the input file), and period, an offset relative to the index date.
The period containing the index date will be 0; the one just before the index date would be numbered -1; three periods prior would be -3; just after would be 1, etc.

To get the (case specific) start- and end- dates for each period, if begin is an exact multiple of interval, use the following calculations:

start-date = index date + period *interval

end-date = index date + (period +1)*interval -1

If begin is not an exact multiple of interval, append the following to each calcultion:

+sign(begin)*mod(begin,interval)

To reiterate the description above, a set of prescription dates & durations must be present for each case; that is, for each combination of patient ID and index date.
In particular, if adherence must be calculated for a single patient relative to two or more index dates, some prescription records might have to be repeated in the input file.
In general, this should be a natural result of merging the required index dates with the prescription data.