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

Add has_pf_consultation constraint to denominators of scripts #110

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion analysis/measures_definition_pf_breakdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@
"ethnicity": ethnicity_combined,
}

pf_consultation_events = select_events(selected_events, codelist=pf_consultation_events_dict["pf_consultation_services_combined"])
has_pf_consultation = pf_consultation_events.exists_for_patient()

# Define the denominator as the number of patients registered
denominator = registration.exists_for_patient() & patients.sex.is_in(["male", "female"])
denominator = registration.exists_for_patient() & patients.sex.is_in(["male", "female"]) & has_pf_consultation

# Create measures for pharmacy first services
for pharmacy_first_event, codelist in pf_consultation_events_dict.items():
Expand Down
4 changes: 2 additions & 2 deletions analysis/measures_definition_pf_consultation_med_counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
)

pharmacy_first_ids = pharmacy_first_events.consultation_id
has_pharmacy_first_consultation = pharmacy_first_events.exists_for_patient()
has_pf_consultation = pharmacy_first_events.exists_for_patient()

# Select Pharmacy First consultations during interval date range
selected_medications = select_events(
Expand All @@ -57,7 +57,7 @@
denominator = (
registration.exists_for_patient()
& patients.sex.is_in(["male", "female"])
& has_pharmacy_first_consultation
& has_pf_consultation
)

measures.define_measure(
Expand Down
3 changes: 2 additions & 1 deletion analysis/measures_definition_pf_medications.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
)

pharmacy_first_ids = pharmacy_first_events.consultation_id
has_pharmacy_first_consultation = pharmacy_first_events.exists_for_patient()
has_pf_consultation = pharmacy_first_events.exists_for_patient()

# Select medications prescribed with PF consultation ID
selected_medications = select_events(medications, start_date=INTERVAL.start_date, end_date=INTERVAL.end_date).where(
Expand All @@ -51,6 +51,7 @@
registration.exists_for_patient()
& patients.sex.is_in(["male", "female"])
& has_pharmacy_first_medication
& has_pf_consultation
)

measures.define_measure(
Expand Down
Loading