Skip to content
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

Count monthly medications of pharmacy first events #54

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

milanwiedemann
Copy link
Member

@milanwiedemann milanwiedemann commented Nov 7, 2024

Closes #49

This code aims to count all medications prescribed during a Pharmacy First consultation. However, there are two main limitations: (1) only the first prescribed medication is selected per consultation, and (2) only one event per month per patient is captured – I think this is acceptable for this?

To test the measure definitions, I added some dummy data to help me verify that the code works as intended. However, I wish there were an easier way to test and extract this data?!

  • Patients 1 to 10: PF event (1577041000000109) and medication (10000000000000000) with same consultation ID
    • I expect these 10 patients to show up in my ouput
  • Patients 11 to 20: PF event (1577041000000109) and medication (11111111111111111) with same consultation ID
    • I expect these 10 patients to show up in my ouput
  • Patients 21 to 30: PF consultation (1577041000000109) and no medication with same consultation ID
    • I'm a bit confused why these patients also show up with a missing dmd_code, but I'm not too bothered about it
  • Patient 31: PF consultation (1577041000000109) and medication (22222222222222222) with same consultation ID
    • I expect this code to show up but replaced as 0 because of statistical disclosure control
  • Patient 32: No PF event and medication (99999999999999999) with same consultation ID
    • I dont expect to see this code in the output
opensafely exec ehrql:v1 generate-measures analysis/measures_definition_pf_medications.py --dummy-tables dummy_tables

Copy link
Contributor

@viv3ckj viv3ckj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice approach to this ticket, approved!

Comment on lines +36 to +38
first_pharmacy_first_medication = (
pharmacy_first_medications.sort_by(medications.date).first_for_patient().dmd_code
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also be helpful to look at last medication (last_for_patient()), to see if this approach is missing out on medication counts.

In addition, another idea could be to look at the first and last medication for the first consultation and first and last medication for the last consultation of every patient.

Copy link

@LFISHER7 LFISHER7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me! Nice to have the tests. Patients 21-30 show up in the measure because they are included in the measure denominator. If you don't care about the denominator or the ratio calculated here, you could just set the denominator to the same as the numerator and then that group wouldn't be included

@milanwiedemann milanwiedemann merged commit 0ec245f into main Nov 7, 2024
1 check passed
@milanwiedemann milanwiedemann deleted the milanwiedemann/count-pf-dmd-codes branch November 7, 2024 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create table with 10 most used medications in Pharmacy First
3 participants