diff --git a/analysis/report_measures.py b/analysis/report_measures.py
index 1e50702..12b5cc8 100644
--- a/analysis/report_measures.py
+++ b/analysis/report_measures.py
@@ -15,6 +15,25 @@
# Pharmacy First service (qualifier value)
"pharmacy_first_service": ["983341000000102"],
}
+# The following codes come from codelists/user-chriswood-pharmacy-first-clinical-pathway-conditions.csv file.
+# Currently written as a hardcoded dictionary to allow for easy for looping (ln66-83), but will be imported from codelist csv in future commits.
+# Pharmacy First seven clinical conditions codelist
+pharmacy_first_conditions_codes = {
+ # Community Pharmacy (CP) Blood Pressure (BP) Check Service (procedure)
+ "acute_otitis_media": ["3110003"],
+ # Community Pharmacy (CP) Contraception Service (procedure)
+ "herpes_zoster": ["4740000"],
+ # Community Pharmacist (CP) Consultation Service for minor illness (procedure)
+ "acute_sinusitis": ["15805002"],
+ # Pharmacy First service (qualifier value)
+ "impetigo": ["48277006"],
+ # Community Pharmacy (CP) Contraception Service (procedure)
+ "infected_insect_bite": ["262550002"],
+ # Community Pharmacist (CP) Consultation Service for minor illness (procedure)
+ "acute_pharyngitis": ["363746003"],
+ # Pharmacy First service (qualifier value)
+ "uncomplicated_urinary_tract_infection": ["1090711000000102"],
+}
registration = practice_registrations.for_patient_on(INTERVAL.end_date)
@@ -24,7 +43,7 @@
)
# Loop through each condition to create a measure
-for condition_name, codelist in pharmacy_first_event_codes.items():
+for pharmacy_first_event, codelist in pharmacy_first_event_codes.items():
condition_events = selected_events.where(
clinical_events.snomedct_code.is_in(codelist)
)
@@ -36,33 +55,29 @@
# Define the denominator as the number of patients registered
denominator = registration.exists_for_patient()
- # Define the measure
measures.define_measure(
- name=f"count_{condition_name}",
+ name=f"count_{pharmacy_first_event}",
numerator=numerator,
denominator=denominator,
intervals=months(8).starting_on("2023-11-01")
)
-# # Count pharmacy first codes
-# pharmacy_first_code_counts = {}
+# Loop through each CLINICAL condition to create a measure
+for condition_name, condition_code in pharmacy_first_conditions_codes.items():
+ condition_events = selected_events.where(
+ clinical_events.snomedct_code.is_in(condition_code)
+ )
-# for code_desc, code in pharmacy_first_event_codes.items():
-# count_codes_query = selected_events.where(
-# selected_events.snomedct_code.is_in(code)
-# ).count_for_patient()
-# pharmacy_first_code_counts[f"count_{code_desc}"] = count_codes_query
+ # Define the numerator as the count of events for the condition
+ numerator = condition_events.count_for_patient()
-# for measures_name, code_counts in pharmacy_first_code_counts.items():
-# measures.define_measure(
-# name=measures_name,
-# numerator=code_counts,
-# group_by={
-# "practice_region": registration.practice_nuts1_region_name
-# },
-# denominator=patients.exists_for_patient(),
-# intervals=intervals,
-# )
+ # Define the denominator as the number of patients registered
+ denominator = registration.exists_for_patient()
-
\ No newline at end of file
+ measures.define_measure(
+ name=f"count_{condition_name}",
+ numerator=numerator,
+ denominator=denominator,
+ intervals=months(8).starting_on("2023-11-01")
+ )
\ No newline at end of file
diff --git a/analysis/reports/pf_report.Rmd b/analysis/reports/pf_report.Rmd
index 6f5c7d0..231319a 100644
--- a/analysis/reports/pf_report.Rmd
+++ b/analysis/reports/pf_report.Rmd
@@ -24,7 +24,6 @@ pre[class] {
-
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
@@ -34,13 +33,13 @@ library(readr)
```
-$~$
+
## Background
Add background here.
-$~$
+
## Methods
@@ -58,8 +57,7 @@ Links to the codelist for each analysis can be found beneath the relevant sectio
This report contains the following sections:
-
-
+* [Clinical Services](#services)
* [Clinical Pathways](#pathways)
* [Clinical condition](#condition)
* [Days of the week](#dotw)
@@ -82,9 +80,11 @@ This report contains the following sections:
* [Age](#contra_age)
* [Region](#contra_region)
-$~$
+
-## Clinical services
+## Clinical Services
+
+
```{r, message=FALSE, warning=FALSE}
# Load plotting function
@@ -94,12 +94,15 @@ df_measures <- readr::read_csv(
here::here("output", "report", "conditions_measures.csv")
)
-plot1_conditions <- plot_measures(df_measures,
+plot_services <- plot_measures(df_measures,
title = "Number of consultations for each clinical service per month",
-x_label = "Month",
-y_label = "Number of Consultations",
-color_label = "Clinical Service")
-print(plot1_conditions)
+measure_names = c("count_blood_pressure_service",
+ "count_contraception_service",
+ "count_consultation_service",
+ "count_pharmacy_first_service"),
+y_label = "Number of codes for consultations",
+)
+print(plot_services)
```
## Clinical Pathways
@@ -116,6 +119,22 @@ Here we show the number of consultations for each of the Pharmacy First Clinical
> LINE CHART WITH COUNT OF EACH CLINICAL CONDITION
+```{r, message=FALSE, warning=FALSE}
+
+plot_conditions <- plot_measures(df_measures,
+title = "Number of consultations for each clinical condition per month",
+measure_names = c("count_acute_otitis_media",
+ "count_herpes_zoster",
+ "count_acute_sinusitis",
+ "count_impetigo",
+ "count_infected_insect_bite",
+ "count_acute_pharyngitis",
+ "count_uncomplicated_urinary_tract_infection"),
+y_label = "Number of codes for consultations",
+)
+print(plot_conditions)
+```
+
### Counts by day of the week
Here we show the number of consultations for the Pharmacy First Clinical Pathways by day of the week the consultation was conducted. (Mainly of interest to show what happens at weekends etc e.g. when GP practices are closed).
diff --git a/analysis/reports/pf_report.html b/analysis/reports/pf_report.html
index f1a3584..9599104 100644
--- a/analysis/reports/pf_report.html
+++ b/analysis/reports/pf_report.html
@@ -286,7 +286,7 @@
+LINE CHART WITH COUNT OF EACH CLINICAL CONDITION