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 national primary care inequalities overview #119

Merged
merged 25 commits into from
Dec 10, 2024

Conversation

camappel
Copy link
Contributor

We present the latest NHS primary care data, using Index of Multiple Deprivation (IMD) to examine inequalities existing in primary care access, experience and outcomes, across the following categories:

-   **Resources (supply)**: Payments, Workforce
-   **Population (demand)**: Disease prevalence, Health-related behaviours
-   **Service quality**: QOF achievement
-   **Access**: Patient experience, Appointments
-   **Impact on secondary care**: Emergency admissions, A&E attendances

@camappel
Copy link
Contributor Author

@Lextuga007 Would it better for me to add the NHSRtheme to the Qmd?

@Lextuga007
Copy link
Member

@camappel - applying the brand would be a great idea but I think we should use the new _brand.yml file https://github.com/nhs-r-community/assets/tree/main/brand. There is an important issue on that repository though about accessibility following the code published to put the brand on Posit's Gallery https://posit-dev.github.io/brand-yml/inspiration/

england.qmd Outdated Show resolved Hide resolved
england.qmd Outdated Show resolved Hide resolved
@camappel camappel requested a review from Lextuga007 December 3, 2024 14:08
england.qmd Outdated
df[is.na(df$quin_4) & is.na(df$quin_5), ]
df %<>%
mutate(quin_5 = ifelse(is.na(quin_5), quin_4, quin_5))

Copy link
Member

@Lextuga007 Lextuga007 Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is line 36 filtering by nothing in quin_4 and quin_5 but then lines 37-38 are mutating quin_5 to populate from two columns that are NA. Is that right? I struggle with reading base R and the magrittr pipe %<>% is new to me! I only have ever used %>%!

Edit: Is line 50 not used in the later code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If quin_5 is NA (missing), it assigns the value from quin_4 to quin_5. If quin_5 is not NA, it retains its value.

This shouldn't be necessary for this national level analysis, so I can remove it (or comment it out).

I'm not sure what line 50 refers to (I think the line numbers have changed), but the line was only run once as it applied to all indicators across all ICBs. This is so that if there were no practices in the most deprived quintile in the ICB, there would still be a datapoint representing the most deprived practices in that ICB (not the country)

Copy link
Member

@Lextuga007 Lextuga007 Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry, you are right about the lines being out of synch - that was local to me! I think it's good to keep the ICB level code in but comment it out and leave a note about that because it's highly likely if anyone wishes to replicate this for their area they will need this logic.

I can add this code back in with the comments to explain. Thanks

england.qmd Outdated

Average payment per weighted patient is **£`r round(df_filter[df_filter$Indicator == "payment_per_patient_all", ]$quin_5, 2)`** in the most deprived 20% of practices, versus **£`r round(df_filter[df_filter$Indicator == "payment_per_patient_all", ]$quin_1, 2)`** in the least deprived 20%.

If there are no dispensing practices in the most deprived quintile, we use the second most deprived. If both are missing, we omit the data point from the figure.
Copy link
Member

@Lextuga007 Lextuga007 Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this relates to when the data is used for other areas as these charts are for England and so there is data at these quintiles. Could this be amended to advise this is guidance as the code doesn't include this logic? I'm assuming that readers of this may well be new to R and want to follow the same principles.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right - removed

england.qmd Outdated
labs(
x = NULL, y = NULL,
title = paste0("Life expectancy by practice, birth cohort 2016-20 (England)"),
subtitle = "Practices in most and least deprived IMD quintiles. Larger circles represent stronger socio-economic gradient.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there code that relates to changing circle sizes? These all render the at the same size.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an old feature that I removed as it wasn't very interpretable - thank you for spotting

@Lextuga007
Copy link
Member

Note for fixing - there are font issues which are suppressed with warning: false in global:

Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database

Font size is still quite small even with code removed in commit 2fe3385

england.qmd Outdated

- The work of the Health Equity Evidence Centre is made possible through seed funding from NHS East of England team.

- The views expressed in this publication are those of the Health Equity Evidence Centre and not necessarily those of NHS England.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been giving this line a bit of thought. NHS-R Community is not part of NHS England and, for this year at least, we aren't funded by NHSE so it might be these sentences are written more as a recognition of the contribution you have made to NHS-R Community:

This work has been provided by the Health Equity Evidence Centre which was made possible through seed funding from NHS East of England team. 

Before I accept this PR and with this in mind, are you aware and happy that all the code and text you have submitted is subject to our CC0 and MIT licences for reuse?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's much better.

Yes, happy with re-use and licenses etc!

@camappel
Copy link
Contributor Author

camappel commented Dec 9, 2024

Note for fixing - NHS logo not in repo

/nhsr-logo.svg (404: Not Found)

@camappel
Copy link
Contributor Author

camappel commented Dec 9, 2024

Note for fixing - there are font issues which are suppressed with warning: false in global:

Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database

Font size is still quite small even with code removed in commit 2fe3385

I've added 20 to the font size for all chart elements:

theme_set(
  theme_minimal() +
    theme(
      axis.title = element_text(size = 100),
      axis.text = element_text(size = 100),
      plot.caption = element_text(size = 80),
      plot.title = element_text(size = 120),
      plot.subtitle = element_text(size = 110),
      panel.grid = element_line(size = 5),
      legend.title = element_text(size = 80),
      legend.text = element_text(size = 80),
      legend.key.width = unit(3.5, "cm"),
      plot.title.position = "plot"
    )
)

@camappel
Copy link
Contributor Author

camappel commented Dec 9, 2024

Thanks very much for the code review! I've now submitted the changes

BTW I pushed new changes after submitting the review so it thinks there are more changes that need to be reviewed

@camappel camappel requested a review from Lextuga007 December 9, 2024 14:45
@Lextuga007 Lextuga007 merged commit b831c74 into nhs-r-community:main Dec 10, 2024
@Lextuga007
Copy link
Member

@all-contributors please add @camappel for content

Copy link
Contributor

@Lextuga007

I've put up a pull request to add @camappel! 🎉

@Lextuga007
Copy link
Member

@all-contributors please add @camappel for code

Copy link
Contributor

@Lextuga007

I've put up a pull request to add @camappel! 🎉

@Lextuga007 Lextuga007 linked an issue Dec 10, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[NEW CHAPTER]: ICB-level inequalities in General Practice
3 participants