A package to facilitate efficient and accurate calculation of the medication adherence metric "Proportion of Days Covered" or "PDC".
Project description
README.md
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 accounts for 6 months washout period and is optimized for multiprocessing large datasets.
Please use as described below:
INPUT 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
msr_start_dt_col - start date of measurement period for the patient or a reference START DATE. Format = DATE
msr_end_dt_col - end date of measurement period for the patient or a reference END DATE. Format = DATE
OUTPUT DATAFRAME - 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 datetime import datetime
from pdcscore import pdcCalc
# Create a sample dataframe
df = pd.DataFrame({
'patient_id': ['A001', 'A001', 'A001', 'B001', 'B001', 'B001', 'C001', 'C001', 'C001','C001', 'C001', 'C001'],
'drugname': ['DRUG_X', 'DRUG_X', 'DRUG_X', 'DRUG_Y', 'DRUG_Y', 'DRUG_Y', 'DRUG_Y', 'DRUG_Y', 'DRUG_Y',
'DRUG_Z', 'DRUG_Z', 'DRUG_Z'],
'filldate': pd.to_datetime(['2021-10-21', '2022-01-21', '2022-03-20',
'2022-01-01', '2022-02-01', '2022-03-01',
'2022-02-18', '2022-03-01', '2022-03-22',
'2021-06-18', '2022-02-11', '2022-03-05']),
'supply_days': [90, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
'msr_start_dt': pd.to_datetime(['2022-01-01', '2022-01-01', '2022-01-01',
'2022-01-01', '2022-01-01', '2022-01-01',
'2022-01-01', '2022-01-01', '2022-01-01',
'2022-01-01', '2022-01-01', '2022-01-01']),
'msr_end_dt': pd.to_datetime(['2022-03-31', '2022-03-31', '2022-03-31',
'2022-03-31', '2022-03-31', '2022-03-31',
'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='patient_id', drugname_col='drugname', filldate_col='filldate'
, supply_days_col='supply_days', msr_start_dt_col='msr_start_dt', msr_end_dt_col='msr_end_dt')
pdc_scores_df = calcfunc.calculate_pdc()
# Inspect output
pdc_scores_df.head()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pdcscore-1.1.4.tar.gz
.
File metadata
- Download URL: pdcscore-1.1.4.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f50ddcdb3b6a6a0547496e8b5884b54261a16e2a050053e4db112418a6c2bd54 |
|
MD5 | 8b653060ede6cd5da4c7fc217616f578 |
|
BLAKE2b-256 | 53b44ad7f1a75bf73af41a6f4fcb41a10549a20a12991c9537db80458aca3c15 |
File details
Details for the file pdcscore-1.1.4-py3-none-any.whl
.
File metadata
- Download URL: pdcscore-1.1.4-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65ffa44fa8f445c7b7ff35fe38f96625e2c6ef5990be4f56e48eaf2884601fae |
|
MD5 | c0e0db9be09c1afbaa641878faf9ba2e |
|
BLAKE2b-256 | 39a1759e793ba5682b6b74fe24df6b509c815700d7be817ecd7669e254c6e5a5 |