Skip to main content

A package to facilitate efficient and accurate calculation of the medication adherence metric "Proportion of Days Covered" or "PDC".

Project description

The objective of this package is to offer a Python-based solution for computing the Proportion of Days Covered (PDC), a widely used metric in the healthcare industry to evaluate medication adherence. As the healthcare analytics sector shifts away from SAS, there is a growing need to recreate key metrics in alternative platforms. This package aims to simplify the process and reduce the workload for business analysts in the healthcare ecosystem by providing a readily available PDC calculation tool, thereby eliminating the need to build it from scratch.

I followed the original implementation logic of PDC in SAS, this can be found at https://support.sas.com/resources/papers/proceedings13/167-2013.pdf

This paper offers a gentle, yet detailed introduction to the topic, and will serve as a reference to anyone new to the subject.

Current update is optimized for multiprocessing large datasets.

Please use as described below:

PARAMETERS:

dataframe - A pandas dataframe containing the required columns described below.

patient_id_col - A unique patient identifier. Format = STRING or INTEGER

drugname_col - The name of the drug being filled or drug class or Generic name, per usual PDC requirements. Format = STRING

filldate_col - The date of the fill being dispensed. Format = DATE

supply_days_col - Days of supply being dispensed at fill. Format = INTEGER

mbr_elig_start_dt_col - First date of coverage eligiblity for patient or a reference START DATE. Format = DATE

MBRELIGEND - Last date of coverage eligiblity for patient or a reference END DATE. Format = DATE

Returns - A Pandas dataframe containing the following columns

patient_id_col - This will return a column name representing a unique patient identifier as provided in original input dataframe. FORMAT = STRING

drugname_col - The name of the drug being filled or drug class or Generic name, as provided in original input dataframe.

DAYSCOVERED- The number of unique days of drug coverage, after shifting coverage to accommodate early refills. FORMAT = INTEGER

TOTALDAYS - The total number of days in patient analysis window. Set to 0 if days of coverage is 0. FORMAT = INTEGER

PDC_SCORE - The patient's PDC score, calculated as DAYSCOVERED / TOTALDAYS. Set to 0 if days of coverage is 0. FORMAT = FLOAT

Usage Example

#  Import required libraries
import pandas as pd
import numpy as np
from pdcscore import pdccalc

# Create a sample dataframe
df = pd.DataFrame({
    'MCID': ['A', 'A', 'A', 'B', 'B', 'B'],
    'DRUGNAME': ['X', 'X', 'X', 'Y', 'Y', 'Y'],
    'RX_FILLED_DT': pd.to_datetime(['2022-01-01', '2022-01-21', '2022-03-20',
                                '2022-01-01', '2022-02-01', '2022-03-01']),
    'DAYS_SPLY_NBR': [30, 30, 30, 30, 30, 30],
    'START_DT': pd.to_datetime(['2022-01-01', '2022-01-01', '2022-01-01',
                                         '2022-02-01', '2022-02-01', '2022-02-01']),
    'END_DT': pd.to_datetime(['2022-03-31', '2022-03-31', '2022-03-31',
                                       '2022-03-31', '2022-03-31', '2022-03-31'])
})

# Inspect sample data
df.head(n=len(df))

# calculate PDC scores on the input DataFrame
calcfunc= pdccalc(dataframe=df, patient_id_col='MCID', drugname_col='DRUGNAME'
                                         , filldate_col='RX_FILLED_DT', supply_days_col='DAYS_SPLY_NBR'
                                         , mbr_elig_start_dt_col='START_DT', mbr_elig_end_dt_col='END_DT')
pdc_scores_df = calcfunc.calculate_pdc()

# Inspect output
pdc_scores_df.head()


<button class="btn" data-clipboard-target="#usage-example">Copy</button>

<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.8/clipboard.min.js"></script>
<script>
  var clipboard = new ClipboardJS('.btn');

  clipboard.on('success', function(e) {
    console.log('Copied!');
  });

  clipboard.on('error', function(e) {
    console.log('Error copying: ' + e);
  });
</script>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdcscore-1.0.5.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

pdcscore-1.0.5-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file pdcscore-1.0.5.tar.gz.

File metadata

  • Download URL: pdcscore-1.0.5.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for pdcscore-1.0.5.tar.gz
Algorithm Hash digest
SHA256 6df427ebb3feab9279ce830ee7b1061a193281f2dd3610149baf40c60cf84549
MD5 5d75267c8e6699a5f33434d6aca4345b
BLAKE2b-256 b28b520124cff9bc2c47e6797abca13206850d43d9ec2a35d44c91e879841f98

See more details on using hashes here.

File details

Details for the file pdcscore-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: pdcscore-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for pdcscore-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1316c3f22e71fb6197fc44df7d3bdc44e8864dffcb10c3041b2ee27e18357f62
MD5 71ee06d3ea7b6da112fbfcf44d013ff8
BLAKE2b-256 4ea1f7e402109d53f0a7e0f20d0e539adefc71a11fcc71e371f60fbf5466b131

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page