Functions & Formulae

Each applied formula has its own function page, with a signature, implementations, and tests.

Medication possession ratio from summed days' supply function

MPR_fixed = sum_(i=1)^n [S_i] / D; MPR_refill = sum_(i=1)^n [S_i] / (f_n - f_1 + S_n); MPR_m = (sum_(i=1)^n [S_i] - S_n) / (f_n - f_1); MPR_capped = min(MPR, 1)

Maps a patient's dispensing records for one medicine, each a fill date and a days' supply, to the medication possession ratio (MPR): the days' supply dispensed divided by a count of days. The variants differ in which fills enter the numerator and which days form the denominator: a fixed interval from the first dispensing to the end of the observation period, or a refill interval between the first and last dispensing, with or without the last fill. Because supply is summed without regard to overlap, an uncapped MPR can exceed 1, and it is often capped at 1. The records follow the notation of the Medication Possession Ratio article. The proportion of days covered, which counts unique covered days instead, is HE-FM-PDC-001.

  • Fixed-interval medication possession ratio

    MPR_fixed = sum_(i=1)^n [S_i] / D

    Divides the total days' supply of the fills dispensed in the observation period by the number of days from the first dispensing to the end of the period, the most common variant in the review by Raebel and colleagues. Time after the last refill counts in the denominator, so stopping treatment lowers the ratio. Supply that runs past the end of the period still counts unless the analyst truncates it, so the ratio can exceed 1.

  • Refill-interval medication possession ratio including the last fill

    MPR_refill = sum_(i=1)^n [S_i] / (f_n - f_1 + S_n)

    Divides the total days' supply from the first to the last dispensing by the days between the first and last dispensing plus the days' supply of the last fill. Sikka and colleagues describe it as an often-used definition; Raebel and colleagues list it as less common and note that it has also been called MPRm. The clock stops when the last fill's supply ends, so the ratio does not account for discontinuation, and early refilling takes it above 1.

  • Modified medication possession ratio excluding the last fill (MPRm)

    MPR_m = (sum_(i=1)^n [S_i] - S_n) / (f_n - f_1)

    Divides the days' supply of every fill except the last by the days between the first and last dispensing. Raebel and colleagues list it as MPR modified (MPRm). Because the last fill's supply and the time it would cover are both left out, the ratio describes refilling between the first and last dispensing and ignores any stop after the last refill.

  • Medication possession ratio capped at 1

    MPR_capped = min(MPR, 1)

    Truncates any of the MPR variants at 1, so supply beyond the days in the denominator no longer raises the ratio. Sikka and colleagues note that early refilling takes the MPR above 1.0 and that it is often truncated there; Vollmer and colleagues define their capped measures as the minimum of the uncapped ratio and 1. Capping limits the upward skew of averages but still credits surplus supply against days without medicine.