Skip to content

Add pdc calculation to pharmacy models #770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

saywurdson
Copy link

@saywurdson saywurdson commented Apr 18, 2025

Describe your changes

This PR adds new capabilities to the Tuva healthcare data framework for calculating medication adherence metrics, specifically the Proportion of Days Covered (PDC).

To do this, I have created 3 pharmacy models that ultimately calculate pdc and associated metrics:

  1. pharmacy__stg_add_ingredient_concepts - Maps pharmacy claims to active ingredients via RxCUI
  2. pharmacy__int_calculate_sub_exposures - Groups overlapping prescriptions for the same ingredient into continuous sub-exposures, and applies a 30-day persistence window to combine sub-exposures that are part of the same treatment period
  3. pharmacy__pdc - Calculates final adherence metrics including total days covered and PDC percentages

This PR also adds a value set to pharmacy to facilitate the creation of pharmacy__stg_add_ingredient_concepts

I added some comments to explain the logic behind some of the choices. Feel free to remove if it is too messy.

How has this been tested?

I created the models in my local tuva instance using duckdb as a database. Code ran with no errors

Reviewer focus

I would like to validate that the logic used to calculate the drug eras/treatment periods makes sense. I think my logic is solid but there may be others who have done this calculation that have better insight.

Checklist before requesting a review

  • I have added at least one Github label to this PR (bug, enhancement, breaking change,...) -- This is an enhancement, not sure how to add the Label
  • My code follows style guidelines
  • (New models) YAML files are categorized by sub folder and models listed in alphabetical order
  • (New models) I have added a config to each new model to enable it for claims and/or clinical data
  • (New models) I have added the variable tuva_last_run to the final output -- added to the final pdc model table
  • (Optional) I have recorded a Loom to explain this PR

Package release checklist

  • I have updated dbt docs
  • I have updated the version number in the dbt_project.yml

(Optional) Gif of how this PR makes you feel

Loom link

@davidshimamoto davidshimamoto added community Issues created by community members enhancement New feature or request labels May 8, 2025
@davidshimamoto
Copy link
Collaborator

@saywurdson do you have any published documentation on the process or logic that you followed to develop this? This would help me validate the work as well as provide instruction for future maintenance of this algorithm.

@github-project-automation github-project-automation bot moved this to 👀 Ready for Review in The Tuva Project May 8, 2025
@saywurdson
Copy link
Author

saywurdson commented May 9, 2025

Hi @davidshimamoto
I've attached a paper about how the Pharmacy Quality Alliance defines the PDC calculation. There is also an example of SAS code that they used as their logic.
PDC_as_a_Preferred_Method_of_Measuring_Medication_Adherence.pdf. I am attempting to provide a dbt version that achieves the same logical outcome of their SAS example.

I also used some of the logic from the OHDSI drug era table implementation to understand how to consolidate medication records into continuous medicaiton treatment periods while factoring in some real-life medication refill scenarios like gap periods between fills and overlapping fills where a patient gets a refill but still has some medication from the previous fill left. Here is a link to their code: https://github.com/OHDSI/ETL-CMS/blob/master/SQL/create_CDMv5_drug_era_non_stockpile.sql

Please let me know if you need anything else!

P.S. I also have the python code I used to create the seed file for map NDCs/product-level RXCUIs to the active ingredient level RXCUIs to consolidate different medications that have the same active ingredient. I didn't think it fit into this PR but I'm happy to share it with you if it will help with ongoing maintenance

@sarah-tuva sarah-tuva moved this from 👀 Ready for Review to 🚧 Needs Scope in The Tuva Project May 20, 2025
@jansenpa jansenpa moved this from 🚧 Needs Scope to 👍 Ready to Pull in The Tuva Project Jun 12, 2025
@jansenpa jansenpa removed the status in The Tuva Project Jun 12, 2025
@jansenpa jansenpa moved this to 👍 Ready to Pull in The Tuva Project Jun 12, 2025
@kristinashikhrakarmaitri kristinashikhrakarmaitri moved this from 👍 Ready to Pull to 🏗 In Progress in The Tuva Project Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Issues created by community members enhancement New feature or request
Projects
Status: 🏗 In Progress
Development

Successfully merging this pull request may close these issues.

6 participants