Skip to content

Commit

Permalink
Add has_pf_consultation constraint to denominators of scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
viv3ckj committed Jan 27, 2025
1 parent 57375ec commit 58eee3d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
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

0 comments on commit 58eee3d

Please sign in to comment.