@@ -19,10 +19,18 @@ library(readr)
19
19
source(here::here("lib", "functions", "function_tidy_measures.R"))
20
20
source(here::here("lib", "functions", "function_plot_measures.R"))
21
21
22
- # Load data
23
- df_measures <- readr::read_csv(
24
- here::here("output", "measures", "pf_codes_conditions_measures.csv")
25
- )
22
+ # Load data based on environment
23
+ if (Sys.getenv("OPENSAFELY_BACKEND") != "") {
24
+ # Load data from generate_pf_measures action
25
+ df_measures <- readr::read_csv(
26
+ here::here("output", "measures", "pf_codes_conditions_measures.csv")
27
+ )
28
+ } else {
29
+ # Load data from released_output directory
30
+ df_measures <- readr::read_csv(
31
+ here::here("released_output", "measures", "pf_codes_conditions_measures.csv")
32
+ )
33
+ }
26
34
27
35
# Define dictionaries with tidy names and mappings for measures
28
36
pf_measures_name_dict <- list(
@@ -72,26 +80,32 @@ df_measures <- tidy_measures(
72
80
73
81
df_measures$ethnicity <- factor(
74
82
df_measures$ethnicity,
75
- levels = c("White", "Mixed", "Asian or Asian British",
76
- "Black or Black British", "Chinese or Other Ethnic Groups",
77
- "Missing"),
83
+ levels = c(
84
+ "White", "Mixed", "Asian or Asian British",
85
+ "Black or Black British", "Chinese or Other Ethnic Groups",
86
+ "Missing"
87
+ ),
78
88
ordered = TRUE
79
89
)
80
90
81
91
df_measures$age_band <- factor(
82
92
df_measures$age_band,
83
- levels = c("0-19", "20-39", "40-59",
84
- "60-79", "80+",
85
- "Missing"),
93
+ levels = c(
94
+ "0-19", "20-39", "40-59",
95
+ "60-79", "80+",
96
+ "Missing"
97
+ ),
86
98
ordered = TRUE
87
99
)
88
100
89
101
df_measures$region <- factor(
90
102
df_measures$region,
91
- levels = c("East", "East Midlands", "London",
92
- "North East", "North West", "South East",
93
- "South West", "West Midlands", "Yorkshire and The Humber",
94
- "Missing"),
103
+ levels = c(
104
+ "East", "East Midlands", "London",
105
+ "North East", "North West", "South East",
106
+ "South West", "West Midlands", "Yorkshire and The Humber",
107
+ "Missing"
108
+ ),
95
109
ordered = TRUE
96
110
)
97
111
@@ -234,8 +248,6 @@ plot_measures(
234
248
### Clinical Services by ethnicity
235
249
236
250
``` {r, message=FALSE, warning=FALSE}
237
-
238
-
239
251
# Select measures and breakdown
240
252
df_measures_selected <- df_measures %>%
241
253
filter(measure_desc == "pharmacy_first_services") %>%
@@ -372,7 +384,6 @@ plot_measures(
372
384
### Clinical Conditions by ethnicity
373
385
374
386
``` {r, message=FALSE, warning=FALSE, fig.height=15, fig.width=8}
375
-
376
387
# Select measures and breakdown
377
388
df_measures_selected <- df_measures %>%
378
389
filter(measure_desc == "clinical_condition") %>%
0 commit comments