Skip to content

Commit d360dc2

Browse files
committed
Fix NAs for age band, and added new colours and gradients
1 parent 39102b5 commit d360dc2

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

analysis/measures_definition_pf_codes_conditions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,16 @@
6666
# Age bands for age breakdown
6767
age = patients.age_on(INTERVAL.start_date)
6868
age_band = case(
69+
when(age.is_null()).then("Missing"),
6970
when((age >= 0) & (age < 20)).then("0-19"),
7071
when((age >= 20) & (age < 40)).then("20-39"),
7172
when((age >= 40) & (age < 60)).then("40-59"),
7273
when((age >= 60) & (age < 80)).then("60-79"),
7374
when(age >= 80).then("80+"),
74-
when(age.is_null()).then("Missing"),
75+
otherwise="Missing"
7576
)
7677

78+
7779
# IMD groupings for IMD breakdown
7880
imd = addresses.for_patient_on(INTERVAL.start_date).imd_rounded
7981
max_imd = 32844

lib/functions/function_plot_measures.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ plot_measures <- function(
7373
plot.title = element_text(hjust = 0.5)
7474
) +
7575

76-
scale_colour_brewer(palette = "Set1")
76+
scale_colour_manual(values = c(
77+
"navy", "red", "#3cb44b", "#ff00ff",
78+
"#f58231",
79+
"#dcdc00", "#911eb4", "#469990", "#8000009d", "grey50"
80+
), na.value = "grey50")
7781

7882
# Automatically change y scale depending selected value
7983
if (rlang::as_label(enquo(select_value)) %in% c("numerator", "denominator")) {

reports/pharmacy_first_report.Rmd

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ df_measures$region <- factor(
107107
108108
df_measures <- df_measures %>%
109109
mutate(sex = factor(sex, levels = c("female", "male"), labels = c("Female", "Male")))
110+
111+
df_measures$age_band[is.na(df_measures$age_band)] <- "Missing"
110112
```
111113

112114
# Background
@@ -150,7 +152,7 @@ plot_measures(
150152
facet_var = NULL,
151153
title = "Number of consultations for each clinical service per month",
152154
y_label = "Number of codes for consultations",
153-
)
155+
)
154156
```
155157

156158
### Breakdown by age
@@ -172,7 +174,8 @@ plot_measures(
172174
facet_var = measure,
173175
title = "Number of consultations for each clinical service by age band per month",
174176
y_label = "Number of codes for consultations",
175-
)
177+
) + scale_color_manual(values = c("#FFCCCC", "#fa7070", "#fc0e0e", "#9c0000", "#4c0000", "grey"))
178+
176179
```
177180

178181
### Breakdown by sex
@@ -216,7 +219,7 @@ plot_measures(
216219
facet_var = measure,
217220
title = "Number of consultations for each clinical service by IMD per month",
218221
y_label = "Number of codes for consultations",
219-
)
222+
) + scale_color_manual(values = c("#001F4D", "#0056B3", "#007BFF", "#66B3E2", "#A4D8E1", "grey"))
220223
```
221224

222225
### Breakdown by region
@@ -308,7 +311,8 @@ plot_measures(
308311
facet_var = measure,
309312
title = "Number of consultations for each clinical condition by age band per month",
310313
y_label = "Number of codes for consultations",
311-
)
314+
) + scale_color_manual(values = c("#FFCCCC", "#fa7070", "#fc0e0e", "#9c0000", "#4c0000", "grey"))
315+
312316
```
313317

314318
### Breakdown by sex
@@ -352,7 +356,7 @@ plot_measures(
352356
facet_var = measure,
353357
title = "Number of consultations for each clinical condition by IMD per month",
354358
y_label = "Number of codes for consultations",
355-
)
359+
) + scale_color_manual(values = c("#001F4D", "#0056B3", "#007BFF", "#66B3E2", "#A4D8E1", "grey"))
356360
```
357361

358362
### Breakdown by region

0 commit comments

Comments
 (0)