diff --git a/Master RMarkdown Document & Render Code/Locality_Profiles_Master_Markdown.Rmd b/Master RMarkdown Document & Render Code/Locality_Profiles_Master_Markdown.Rmd index 5667355..8837394 100755 --- a/Master RMarkdown Document & Render Code/Locality_Profiles_Master_Markdown.Rmd +++ b/Master RMarkdown Document & Render Code/Locality_Profiles_Master_Markdown.Rmd @@ -642,26 +642,30 @@ x <- x + 1 **Summary** -This section includes acute hospital data, delayed discharge bed days and A&E attendances. For the most recent time period available, `r LOCALITY` had: - -- **`r latest_emergency_adm_loc`** emergency hospital admissions per 100,000 population, compared to `r scot_emergency_adm` in Scotland. - -- **`r latest_bed_days_loc`** unscheduled acute specialty bed days per 100,000 population, compared to `r scot_bed_days` in Scotland. - -- **`r latest_ae_att_loc`** A&E attendances per 100,000 population, compared to `r scot_ae_att` in Scotland. - -- **`r latest_dd_loc`** delayed discharge bed days per 100,000 population aged over 65, compared to `r scot_dd` in Scotland. - -- **`r latest_falls_loc`** emergency hospital admissions from falls per 100,000 population aged over 65, compared to `r scot_falls` in Scotland. - -- **`r latest_read_loc`** emergency readmissions (28 days) per 1,000 discharges, compared to `r scot_read` in Scotland. - -- **`r latest_ppa_loc`** potentially preventable hospital admissions per 100,000 population, compared to `r scot_ppa` in Scotland. +**For the most recent time periods available, `r LOCALITY` had:** + +- **`r latest_emergency_adm_loc1`** emergency hospital admissions per 100,000 population, compared to `r scot_emergency_adm1` in Scotland. + +- **`r latest_bed_days_loc1`** unscheduled acute specialty bed days per 100,000 population, compared to `r scot_bed_days1` in Scotland. + +- **`r latest_ae_att_loc1`** A&E attendances per 100,000 population, compared to `r scot_ae_att1` in Scotland. + +- **`r latest_dd_loc1`** delayed discharge bed days per 100,000 population aged over 65, compared to `r scot_dd1` in Scotland. + +- **`r latest_falls_loc1`** emergency hospital admissions from falls per 100,000 population aged over 65, compared to `r scot_falls1` in Scotland. + +- **`r latest_read_loc1`** emergency readmissions (28 day) per 1,000 discharges, compared to `r scot_read` in Scotland. + +- **`r latest_ppa_loc$formatted_data[2]`** potentially preventable hospital admissions per 100,000 population, compared to `r scot_ppa$formatted_data[2]` in Scotland. ##### Page break ### Emergency Admissions +Figure `r x` presents the emergency admissions rate per 100,000 population in the `r LOCALITY` locality from `r min_year_ea` to `r max_year_ea`. + +As presented in Figure `r x`, the emergency admissions rate in the `r LOCALITY` locality for `r max_year_ea` is `r latest_emergency_adm_loc1`, `r get_article(percent_rate_change)` `r percent_rate_change`% `r word_change_rate` since `r min_year_ea`. The `r HSCP` HSCP rate is `r hscp_emergency_adm1`, `r get_article(hscp_rate_change)` `r hscp_rate_change`% `r word_change_hscp` since `r min_year_ea`. The `r HB` health board rate is `r hscp_emergency_adm1` in `r max_year_ea`, `r get_article(hb_rate_change)` `r hb_rate_change`% `r word_change_hb` since `r min_year_ea` and the Scotland rate is `r scot_emergency_adm1`, `r get_article(scot_rate_change)` `r scot_rate_change`% `r word_change_scot` since `r min_year_ea`. + #### Figure `r x`: Emergency admissions by geographical area \newline @@ -672,6 +676,10 @@ EAs_loc_ts x <- x + 1 ``` +Figure `r x` presents the emergency admissions rate per 100,000 population in the `r LOCALITY` locality from `r min_ea_age` to `r max_ea_age` by age group. + +As presented in Figure `r x`, the highest emergency admissions rate for the `r LOCALITY` locality in `r max_ea_age` is `r latest_ea_max_age1` per 100,000 population for the `r age_group_max_ea` age group with a percentage `r max_word_change_ea` of `r max_rate_change_ea`% since `r min_ea_age`. The lowest emergency admissions rate for `r LOCALITY` in `r max_ea_age` is `r latest_ea_min_age1` per 100,000 population for the `r age_group_min_ea` age group with a percentage `r min_word_change_ea` of `r min_rate_change_ea`% since `r min_ea_age`. + #### Figure `r x`: Emergency admissions by age group \newline @@ -686,6 +694,10 @@ x <- x + 1 ### Unscheduled Acute Bed Days +Figure `r x` presents the unscheduled bed days rate per 100,000 population in the `r LOCALITY` locality from `r min_year_ubd` to `r max_year_ubd`. + +As presented in Figure `r x`, the unscheduled bed days rate in the `r LOCALITY` locality for `r max_year_ubd` is `r latest_bed_days_loc1`, `r get_article(rate_change_ubd)` `r rate_change_ubd`% `r word_change_ubd` since `r min_year_ubd` and the `r HSCP` HSCP rate is `r hscp_bed_days1`, `r get_article(hscp_rate_ubd)` `r hscp_rate_ubd`% `r hscp_change_ubd` since `r min_year_ubd`. The `r HB` health board rate for `r max_year_ubd` is `r hb_bed_days1`, `r get_article(hb_rate_change_ubd)` `r hb_rate_change_ubd`% `r word_change_hb_ubd` since `r min_year_ubd` and the Scotland rate is `r scot_bed_days1`, `r get_article(scot_rate_ubd)` `r scot_rate_ubd`% `r scot_change_ubd` since `r min_year_ubd`. + #### Figure `r x`: Unscheduled acute bed days by geographical area \newline @@ -696,6 +708,10 @@ BDs_loc_ts x <- x + 1 ``` +Figure `r x` presents the unscheduled bed days rate per 100,000 population in the `r LOCALITY` locality from `r min_ubd_age` to `r max_ubd_age` by age group. + +As presented in Figure `r x`, the highest unscheduled bed days rate for the `r LOCALITY` locality in `r max_ubd_age` is `r latest_ubd_max_age1` bed days per 100,000 population for the `r age_group_max_ubd` age group with a percentage `r max_word_change_ubd` of `r max_rate_change_ubd`% since `r min_ubd_age`. The lowest unscheduled bed days rate for `r LOCALITY` in `r max_ubd_age` is `r latest_ubd_min_age1` bed days per 100,000 population for the `r age_group_min_ubd` age group with a percentage `r min_word_change_ubd` of `r min_rate_change_ubd`% since `r min_ubd_age`. + #### Figure `r x`: Unscheduled acute bed days by age group \newline @@ -710,6 +726,10 @@ x <- x + 1 ### A&E Attendances +Figure `r x` presents the A&E attendance rate per 100,000 population in the `r LOCALITY` locality from `r min_year_ae_area` to `r max_year_ae_area`. + +As presented in Figure `r x`, the A&E attendance rate per 100,000 in the `r LOCALITY` locality for `r max_year_ae_area` is `r latest_ae_att_loc1`, `r get_article(percent_rate_change_ae_areas)` `r percent_rate_change_ae_areas`% `r word_change_rate_ae_areas` since `r min_year_ae_area` and the `r HSCP` HSCP rate is `r hscp_ae_att1`, `r get_article(percent_rate_change_ae_areas_hscp)` `r percent_rate_change_ae_areas_hscp`% `r word_change_rate_ae_areas_hscp` since `r min_year_ae_area`. The `r HB` health board rate for `r max_year_ae_area` is `r hb_ae1`, `r get_article(hb_rate_change_ae)` `r hb_rate_change_ae`% `r word_change_hb_ae` since `r min_year_ae_area` and the Scotland rate is `r scot_ae_att1`, `r get_article(percent_rate_change_ae_areas_scot)` `r percent_rate_change_ae_areas_scot`% `r word_change_rate_ae_areas_scot` since `r min_year_ae_area`. + #### Figure `r x`: A&E attendances by geographical area \newline @@ -720,6 +740,10 @@ AandE_loc_ts x <- x + 1 ``` +Figure `r x` presents the A&E attendance rate per 100,000 population in the `r LOCALITY` locality from `r min_year_ae_area` to `r max_year_ae_area` by age group. + +As presented in Figure `r x`, the highest A&E attendance rate for the `r LOCALITY` locality in `r max_year_ae_age` is `r latest_ae_att_loc1_age` per 100,000 population for the `r age_group_max` age group with a percentage `r word_change_rate_ae_age` of `r percent_rate_change_ae_age`% since `r min_year_ae_age`. The lowest A&E attendance rate for `r LOCALITY` in `r max_year_ae_age` is `r latest_ae_att_loc1_age_min` per 100,000 population for the `r age_group_min` age group with a percentage `r word_change_rate_ae_age2` of `r percent_rate_change_ae_age2`% since `r min_year_ae_age`. + #### Figure `r x`: A&E attendances by age group \newline @@ -734,22 +758,30 @@ x <- x + 1 ### Emergency Readmissions (28 days) +Figure `r x` presents the emergency readmission (28 days) rate per 1,000 discharges in the `r LOCALITY` locality from `r min_year_re_area` to `r max_year_re_area`. + +As presented in Figure `r x`, the emergency readmission (28 days) rate per 1,000 discharges in the `r LOCALITY` locality for `r max_year_re_area` is `r latest_read_loc1`, `r get_article(percent_rate_change_re_area)` `r percent_rate_change_re_area`% `r word_change_rate_re_area` since `r min_year_re_area` and the `r HSCP` HSCP rate is `r hscp_read`, `r get_article(percent_rate_change_re_area_hscp)` `r percent_rate_change_re_area_hscp`% `r word_change_rate_re_area_hscp` since `r min_year_re_area`. The `r HB` health board rate for `r max_year_re_area` is `r hb_read1`, `r get_article(hb_rate_change_read)` `r hb_rate_change_read`% `r word_change_hb_read` since `r min_year_re_area` and the Scotland rate is `r scot_read`, `r get_article(percent_rate_change_re_area_scot)` `r percent_rate_change_re_area_scot`% `r word_change_rate_re_area_scot` since `r min_year_re_area`. + #### Figure `r x`: Emergency readmissions (28 days) by geographical area \newline ```{r echo = FALSE, fig.width = 8.5, fig.height = 4, warning = FALSE, fig.cap = "A line graph showing seven-year time trends for emergency readmissions per 1,000 discharges split by geographical area."} -Read_loc_ts +read_loc_ts x <- x + 1 ``` +Figure `r x` presents the emergency readmission (28 days) rate per 1,000 discharges in the `r LOCALITY` locality from `r min_year_re_age` to `r max_year_re_age` by age group. + +As presented in Figure `r x`, the highest emergency readmission (28 days) rate for the `r LOCALITY` locality in `r max_year_re_age` is `r latest_re_max_age_data` per 1,000 discharges for the `r latest_re_max_age_group` age group with a percentage `r word_change_rate_re_age` of `r percent_rate_change_re_age`% since `r min_year_re_age`. The lowest emergency readmission (28 days) rate for the `r LOCALITY` locality in `r max_year_re_age` is `r latest_re_min_age_data` per 1,000 discharges for the `r latest_re_min_age_group` age group with a percentage `r word_change_rate_re_age_min` of `r percent_rate_change_re_age_min`% since `r min_year_re_age`. + #### Figure `r x`: Emergency readmissions (28 days) by age group \newline ```{r echo = FALSE, fig.width = 8.5, fig.height = 4, warning = FALSE, fig.cap = "A line graph showing seven-year time trends for emergency readmissions per 1,000 discharges split by age group."} -Read_age_ts +read_age_ts x <- x + 1 ``` @@ -758,6 +790,10 @@ x <- x + 1 ### Delayed Discharge Bed Days +Figure `r x` presents the number of delayed discharge bed days per 100,000 population aged over 65+ in the `r LOCALITY` locality from `r min_year_dd` to `r max_year_dd`. + +As presented in Figure `r x`, the number of delayed discharge bed days per 100,000 population aged over 65+ in the `r LOCALITY` locality for `r max_year_dd` is `r latest_dd_loc1`, `r get_article(percent_rate_change_dd_loc)` `r percent_rate_change_dd_loc`% `r word_change_rate_dd_loc` since `r min_year_dd` and the `r HSCP` HSCP rate is `r hscp_dd1`, `r get_article(percent_rate_change_dd_hscp)` `r percent_rate_change_dd_hscp`% `r word_change_rate_dd_hscp` since `r min_year_dd`. The `r HB` health board rate for `r max_year_dd` is `r hb_dd1`, `r get_article(hb_rate_change_dd)` `r hb_rate_change_dd`% `r word_change_hb_dd` since `r min_year_dd` and the Scotland rate is `r scot_dd1`, `r get_article(percent_rate_change_dd_scot)` `r percent_rate_change_dd_scot`% `r word_change_rate_dd_scot` since `r min_year_dd`. + #### Figure `r x`: Delayed discharge bed days in the population aged 65+ by geographical area \newline @@ -770,6 +806,10 @@ x <- x + 1 ### Emergency admissions from a fall +Figure `r x` presents the emergency admissions from falls rate per 100,000 population aged 65 and over in the `r LOCALITY` locality from `r min_year_falls` to `r max_year_falls`. + +As presented in Figure `r x`, the emergency admissions from falls rate per 100,000 population aged over 65+ in the `r LOCALITY` locality for `r max_year_falls` is `r latest_falls_loc1`, `r get_article(percent_rate_change_falls_loc)` `r percent_rate_change_falls_loc`% `r word_change_rate_falls_loc` since `r min_year_falls` and the `r HSCP` HSCP rate is `r hscp_falls1`, `r get_article(percent_rate_change_falls_hscp)` `r percent_rate_change_falls_hscp`% `r word_change_rate_falls_hscp` since `r min_year_falls`. The `r HB` health board rate for `r max_year_falls` is `r hb_falls1`, `r get_article(hb_rate_change_falls)` `r hb_rate_change_falls`% `r word_change_hb_falls` since `r min_year_falls` and the Scotland rate is `r scot_falls1`, `r get_article(percent_rate_change_falls_scot)` `r percent_rate_change_falls_scot`% `r word_change_rate_falls_scot` since `r min_year_falls`. + #### Figure `r x`: Falls in the population aged 65+ by geographical area \newline @@ -784,14 +824,16 @@ x <- x + 1 ### Potentially Preventable Admissions (PPAs) -Information on the conditions included in PPAs is available in Appendix 3. In `r max_fy`, **`r latest_ppa_65plus`%** of PPAs in `r LOCALITY` were amongst those aged 65 and over, and **`r latest_ppa_under65`%** were amongst those aged under 65. +Information on the conditions included in Potentially Preventable Admissions (PPA)s is available in Appendix 3. In `r max_fy`, **`r latest_ppa_65plus`%** of PPAs in `r LOCALITY` were amongst those aged 65 and over, and **`r latest_ppa_under65`%** were amongst those aged under 65. + +Figure `r x` presents the PPA rate per 100,000 population in the `r LOCALITY` locality from `r min_year_ppa_areas` to `r max_year_ppa_areas`. The rate per 100,000 population for PPAs in the `r LOCALITY` locality for `r max_year_ppa_areas` is `r latest_ppa_loc$formatted_data[2]`, `r get_article(ppa_diff)` `r ppa_diff`% `r ppa_word_change` since `r latest_ppa_loc$financial_year[1]` and the `r HSCP` HSCP rate is `r hscp_ppa$data[2]`, `r get_article(ppa_diff_hscp)` `r ppa_diff_hscp`% `r ppa_word_change_hscp` since `r latest_ppa_loc$financial_year[1]`. The `r HB` health board rate for `r hb_ppa$financial_year[2]` is `r hb_ppa$formatted_data[2]`, `r get_article(diff_hb_ppa)` `r diff_hb_ppa`% `r word_change_hb_ppa` since `r hb_ppa$financial_year[]` and the Scotland rate is `r scot_ppa$formatted_data[2]`, `r get_article(diff_scot_ppa)` `r diff_scot_ppa`% `r word_change_scot_ppa` since `r hb_ppa$financial_year[1]`. #### Figure `r x`: Potentially Preventable Admissions (PPAs) by geographical area \newline ```{r echo = FALSE, fig.width = 8.5, fig.height = 4, warning = FALSE, fig.cap = "A line graph showing seven-year time trends for potentially preventable admissions per 100,000 population split by geographical area."} -PPA_loc_ts +ppa_loc_ts x <- x + 1 ``` @@ -808,13 +850,17 @@ x <- x + 1 This section looks at mental health-related unscheduled care indicators. For the most recent time period available, `r LOCALITY` had: -- **`r psych_hosp_latest`** psychiatric patient hospitalisations per 100,000, compared to `r scot_psych_hosp` in Scotland^4^. -- **`r latest_bed_days_mh_loc`** unscheduled mental health specialty bed days per 100,000, compared to `r scot_bed_days_mh` in Scotland. +- **`r psych_hosp_latest`** psychiatric patient hospitalisations per 100,000, compared to `r scot_psych_hosp$measure[2]` in Scotland^4^. +- **`r latest_bed_days_mh_loc1`** unscheduled mental health specialty bed days per 100,000, compared to `r scot_bed_days_mh1` in Scotland. \newline ### Psychiatric patient hospitalisations +Figure `r x` presents the psychiatric patient hospitalisation 3-year aggregate rate per 100,000 population in the `r LOCALITY` locality from `r loc_psych_hosp$period_short[1]` to `r loc_psych_hosp$period_short[2]`. + +As presented in Figure `r x`, the 3-year aggregate psychiatric patient hospitalisation rate per 100,000 population in the `r LOCALITY` locality for `r loc_psych_hosp$period_short[2]` is `r loc_psych_hosp$measure[2]`, `r get_article(diff_loc_psych)` `r diff_loc_psych`% `r word_change_loc_psych` since `r loc_psych_hosp$period_short[1]` and the `r HSCP` HSCP rate is `r hscp_psych_hosp$measure[2]`, `r get_article(diff_hscp_psych)` `r diff_hscp_psych`% `r word_change_hscp_psych` since `r loc_psych_hosp$period_short[1]`. The `r HB` health board the 3-year aggregate rate for `r loc_psych_hosp$period_short[2]` is `r hb_psych_hosp$measure[2]`, `r get_article(diff_hb_psych)` `r diff_hb_psych`% `r word_change_hb_psych` since `r loc_psych_hosp$period_short[1]` and the Scotland the 3-year aggregate rate is `r scot_psych_hosp$measure[2]`, `r get_article(diff_scot_psych)` `r diff_scot_psych`% `r word_change_scot_psych` since `r loc_psych_hosp$period_short[1]`. + #### Figure `r x`: Psychiatric patient hospitalisations by geographical area \newline @@ -829,6 +875,10 @@ x <- x + 1 ### Unscheduled Mental Health Specialty Bed Days +Figure `r x` presents the unscheduled mental health bed days rate per 100,000 population in the `r LOCALITY` locality from `r min_year_bd_mh_areas` to `r max_year_bd_mh_areas`. + +As presented in Figure `r x`, the unscheduled mental health bed days rate per 100,000 population in the `r LOCALITY` locality for `r max_year_bd_mh_areas` is `r latest_bed_days_mh_loc1`, `r get_article(loc_rate_change_beds_mh)` `r loc_rate_change_beds_mh`% `r loc_word_change_beds_mh` since `r min_year_bd_mh_areas` and the `r HSCP` HSCP rate is `r hscp_bed_days_mh1`, `r get_article(hscp_rate_change_beds_mh)` `r hscp_rate_change_beds_mh`% `r hscp_word_change_beds_mh` since `r min_year_bd_mh_areas`. The `r HB` health board rate for `r max_year_bd_mh_areas` is `r hb_mh_beddays1`, `r get_article(hb_rate_change_mh)` `r hb_rate_change_mh`% `r word_change_hb_mh` since `r min_year_bd_mh_areas` and the Scotland rate is `r scot_bed_days_mh1`, `r get_article(scot_rate_change_beds_mh)` `r scot_rate_change_beds_mh`% `r scot_word_change_beds_mh` since `r min_year_bd_mh_areas`. + #### Figure `r x`: Unscheduled mental health specialty bed days by geographical area \newline @@ -839,6 +889,10 @@ BDMH_loc_ts x <- x + 1 ``` +Figure `r x` presents the unscheduled mental health bed days rate per 100,000 in the `r LOCALITY` locality from `r min_year_bd_mh_age` to `r max_year_bd_mh_age` by age group. + +As presented in Figure `r x`, the highest unscheduled mental health bed days rate for the `r LOCALITY` locality in `r max_year_bd_mh_age` is `r latest_bd_mh_max_age1` per 100,000 population for the `r age_group_max_mh` age group with a percentage `r max_word_change_beds_mh` of `r max_rate_change_beds_mh`% since `r min_year_bd_mh_age`. The lowest unscheduled mental health bed days rate for the `r LOCALITY` locality in `r max_year_bd_mh_age` is `r latest_bd_mh_min_age1` per 100,000 population for the `r age_group_min_mh` age group with a percentage `r min_word_change_beds_mh` of `r min_rate_change_beds_mh`% since `r min_year_bd_mh_age1`. + #### Figure `r x`: Unscheduled mental health specialty bed days by age group \newline @@ -853,13 +907,13 @@ x <- x + 1 ### Footnotes -1. Population projections are not currently provided by NRS at the locality level. To explore how the population in `r LOCALITY` is expected to change in the future, the percent changes in population projection to 2025 for `r HSCP` by age group and gender were calculated from the NRS Local Authority Population Projections. These percent changes were then applied to the `r LOCALITY` 2018 mid-year population estimates (also split by age group and gender) to obtain population projection estimates for `r LOCALITY`, based on the projections for the HSCP and the current population structure of the locality. +1. Population projections are not currently provided by the National Records Scotland (NRS) at the locality level. To explore how the population in `r LOCALITY` is expected to change in the future, the percent changes in population projection to 2025 for `r HSCP` by age group and gender were calculated using the NRS Local Authority Population Projections. These percent changes were then applied to the `r LOCALITY` 2018 mid-year population estimates (also split by age group and gender) to obtain population projection estimates for `r LOCALITY`, based on the projections for the HSCP and the current population structure of the locality. -2. Care Home Data included in the Services Map and Table was sourced from the [Care Inspectorate](https://www.careinspectorate.com/images/documents/5713/MDSF_data_31%20May%202020.csv). [GP Practice](https://www.opendata.nhs.scot/dataset/gp-practice-contact-details-and-list-sizes) data from October 2021, and [Hospital](https://www.opendata.nhs.scot/dataset/hospital-codes) and [A&E](https://www.opendata.nhs.scot/dataset/nhs-scotland-accident-emergency-sites) data was sourced from Public Health Scotland Open Data. Only services that are within the physical boundary of the HSCP or Locality are included in the map and table, so there may be services outside `r HSCP` that people may use but are not shown. Information on access deprivation was taken from [ScotPHO](https://scotland.shinyapps.io/ScotPHO_profiles_tool/). +2. Care Home data included in the Services Map and Table was sourced from the [Care Inspectorate](https://www.careinspectorate.com/images/documents/5713/MDSF_data_31%20May%202020.csv). [GP Practice](https://www.opendata.nhs.scot/dataset/gp-practice-contact-details-and-list-sizes) data from October 2021, and [Hospital](https://www.opendata.nhs.scot/dataset/hospital-codes) and [A&E](https://www.opendata.nhs.scot/dataset/nhs-scotland-accident-emergency-sites) data was sourced from Public Health Scotland Open Data platform. Only services that are within the physical boundary of the HSCP or Locality are included in the map and table, so there may be services outside `r HSCP` that people may use but are not shown. Information on access deprivation was taken from [ScotPHO](https://scotland.shinyapps.io/ScotPHO_profiles_tool/). -3. Sourced from [ScotPHO](https://scotland.shinyapps.io/ScotPHO_profiles_tool/). There may be more recent data available for the indicators elsewhere. +3. Sourced from [ScotPHO](https://scotland.shinyapps.io/ScotPHO_profiles_tool/). More recent data may be available for the indicators elsewhere. -4. Data taken from ScotPHO is often reported using the European Age-Sex Standardised Rate per 100,000. This allows for comparisons across different areas to be made. For more information on how these rates are calculated, please refer to [www.isdscotland.org/Products-and-Services/GPD-Support/Population/Standard-Populations/](https://www.isdscotland.org/Products-and-Services/GPD-Support/Population/Standard-Populations/) +4. Data taken from ScotPHO is often reported using the European Age-Sex Standardised Rate per 100,000. This allows for comparisons across different areas to be made. For more information on how these rates are calculated, please refer to 5. Physical long-term conditions data comes from the Source Linkage Files, and the conditions are identified using ICD-9 and ICD-10 codes in the diagnosis fields. Please note that the Source Linkage Files data only contains information on people who have had contact with the NHS through either inpatient admissions, outpatient attendances, daycase attendances, A&E attendances or through prescribed items, the data does not show all service users in Scotland who have been diagnosed with an LTC as not all of these individuals will have used these services. Also, note that LTC rates are based on an adjusted population indicator in the Source Linkage Files so that population sizes are closer to the official estimates. diff --git a/Unscheduled Care/2. Unscheduled Care outputs.R b/Unscheduled Care/2. Unscheduled Care outputs.R index 4fe8eec..5f11672 100755 --- a/Unscheduled Care/2. Unscheduled Care outputs.R +++ b/Unscheduled Care/2. Unscheduled Care outputs.R @@ -26,7 +26,7 @@ library(reshape2) ### for testing run global script and locality placeholder below ## Functions -# source("./Master RMarkdown Document & Render Code/Global Script.R") +# source("../Master RMarkdown Document & Render Code/Global Script.R") ## Define locality # LOCALITY <- "Stirling City with the Eastern Villages Bridge of Allan and Dunblane" @@ -75,8 +75,6 @@ populations22 <- read_in_dz_pops22() populations <- rbind(populations, populations22) -# pop_max_year <- max(populations$year) - # compute age bands populations$"Pop0_17" <- rowSums(subset(populations, select = age0:age17)) populations$"Pop18_44" <- rowSums(subset(populations, select = age18:age44)) @@ -288,6 +286,22 @@ area_trend_usc <- function(data_for_plot, plot_title, yaxis_title, source) { ) } +# Functions for text variables + +percent_change_calc <- function(numerator, denominator, digits = 1) { + janitor::round_half_up( + abs(numerator - denominator) / denominator * 100, + digits = digits + ) +} + +word_change_calc <- function(latest, first) { + dplyr::case_when( + dplyr::near(latest, first) ~ "same", + latest > first ~ "increase", + latest < first ~ "decrease" + ) +} ####################### SECTION 4: Data manipulation & outputs ######################### @@ -305,7 +319,8 @@ emergency_adm_age <- emergency_adm %>% summarise(adm = sum(admissions)) %>% ungroup() %>% left_join(loc_pop_age1) %>% - mutate(data = round_half_up(adm / pop * 100000)) + mutate(data = round_half_up(adm / pop * 100000)) %>% + drop_na(year) EAs_age_ts <- age_group_trend_usc( @@ -320,7 +335,8 @@ emergency_adm_areas <- emergency_adm %>% rename(n = admissions) %>% aggregate_usc_area_data() %>% left_join(pop_areas_all_ages) %>% - mutate(data = round_half_up(n / pop * 100000)) + mutate(data = round_half_up(n / pop * 100000)) %>% + drop_na(year) EAs_loc_ts <- area_trend_usc( data_for_plot = emergency_adm_areas, @@ -330,31 +346,91 @@ EAs_loc_ts <- area_trend_usc( ) -# Objects for text and summary table +# Objects for text for Figures and Summary (Emergency Admissions) +min_year_ea <- min(emergency_adm_areas$financial_year) +max_year_ea <- max(emergency_adm_areas$financial_year) + +first_fy_rate <- filter( + emergency_adm_areas, + financial_year == min(financial_year), + location == LOCALITY, + area_type == "Locality" +)$data + latest_emergency_adm_loc <- emergency_adm_areas %>% filter( location == LOCALITY, - year == max(year) + year == max(year, na.rm = TRUE) ) %>% - mutate(data = format(data, big.mark = ",")) %>% - pull(data) + mutate(formatted_data = format(data, big.mark = ",")) + +latest_emergency_adm_loc1 <- latest_emergency_adm_loc %>% pull(formatted_data) +latest_emergency_adm_loc2 <- latest_emergency_adm_loc %>% pull(data) +percent_rate_change <- percent_change_calc(latest_emergency_adm_loc2, first_fy_rate) +word_change_rate <- word_change_calc(latest_emergency_adm_loc2, first_fy_rate) + +# HSCP hscp_emergency_adm <- emergency_adm_areas %>% filter( location == HSCP, year == max(year) ) %>% - mutate(data = format(data, big.mark = ",")) %>% - pull(data) + mutate(formatted_data = format(data, big.mark = ",")) +hscp_emergency_adm1 <- hscp_emergency_adm %>% pull(formatted_data) +hscp_emergency_adm2 <- hscp_emergency_adm %>% pull(data) + +first_fy_hscp <- filter( + emergency_adm_areas, + financial_year == min(financial_year), + area_type == "HSCP" +)$data + +hscp_rate_change <- percent_change_calc(hscp_emergency_adm2, first_fy_hscp) +word_change_hscp <- word_change_calc(hscp_emergency_adm2, first_fy_hscp) + +# Scotland scot_emergency_adm <- emergency_adm_areas %>% filter( location == "Scotland", year == max(year) ) %>% - mutate(data = format(data, big.mark = ",")) %>% - pull(data) + mutate(formatted_data = format(data, big.mark = ",")) + +scot_emergency_adm1 <- scot_emergency_adm %>% pull(formatted_data) +scot_emergency_adm2 <- scot_emergency_adm %>% pull(data) +first_fy_scot <- filter( + emergency_adm_areas, + financial_year == min(financial_year), + location == "Scotland" +)$data + +scot_rate_change <- percent_change_calc(scot_emergency_adm2, first_fy_scot) +word_change_scot <- word_change_calc(scot_emergency_adm2, first_fy_scot) + +# NHS health board +hb_emergency_adm <- emergency_adm_areas %>% + filter( + location == HB, + year == max(year) + ) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +hb_emergency_adm1 <- hb_emergency_adm %>% pull(formatted_data) +hb_emergency_adm2 <- hb_emergency_adm %>% pull(data) + +first_fy_hb <- filter( + emergency_adm_areas, + financial_year == min(financial_year), + location == HB +)$data + +hb_rate_change <- percent_change_calc(hb_emergency_adm2, first_fy_hb) +word_change_hb <- word_change_calc(hb_emergency_adm2, first_fy_hb) + +# other locations other_loc_emergency_adm <- emergency_adm %>% group_by(financial_year, hscp_locality) %>% summarise(adm = sum(admissions)) %>% @@ -366,7 +442,58 @@ other_loc_emergency_adm <- emergency_adm %>% select(hscp_locality, data) %>% pivot_wider(names_from = hscp_locality, values_from = data) +# Create objects for text emergency admissions by age group +max_ea_age <- max(emergency_adm_age$financial_year) +min_ea_age <- min(emergency_adm_age$financial_year) + +latest_ea_max_age <- emergency_adm_age %>% + filter( + year == max(year) + ) %>% + filter( + data == max(data) + ) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +latest_ea_max_age1 <- latest_ea_max_age %>% pull(formatted_data) +latest_ea_max_age2 <- latest_ea_max_age %>% pull(data) +age_group_max_ea <- latest_ea_max_age %>% pull(age_group) + +first_ea_max_age <- emergency_adm_age %>% + filter( + year == min(year), + age_group == age_group_max_ea + ) %>% + pull(data) +max_rate_change_ea <- percent_change_calc(latest_ea_max_age2, first_ea_max_age) +max_word_change_ea <- word_change_calc(latest_ea_max_age2, first_ea_max_age) + +latest_ea_min_age <- emergency_adm_age %>% + filter( + year == max(year) + ) %>% + filter( + data == min(data) + ) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +latest_ea_min_age1 <- latest_ea_min_age %>% pull(formatted_data) +latest_ea_min_age2 <- latest_ea_min_age %>% pull(data) +age_group_min_ea <- latest_ea_min_age %>% pull(age_group) + +first_ea_min_age <- emergency_adm_age %>% + filter( + age_group == age_group_min_ea + ) %>% + filter(year == min(year)) + +first_ea_min_age1 <- first_ea_min_age %>% pull(data) +min_year_ea_age1 <- first_ea_min_age %>% pull(year) + + +min_rate_change_ea <- percent_change_calc(latest_ea_min_age2, first_ea_min_age1) +min_word_change_ea <- word_change_calc(latest_ea_min_age2, first_ea_min_age1) # 2a. Unscheduled bed days ---- # _________________________________________________________________________ @@ -382,7 +509,8 @@ bed_days_age <- bed_days %>% summarise(bed_days = sum(bed_days)) %>% ungroup() %>% left_join(loc_pop_age1) %>% - mutate(data = round_half_up(bed_days / pop * 100000)) + mutate(data = round_half_up(bed_days / pop * 100000)) %>% + drop_na(year) BDs_age_ts <- age_group_trend_usc( @@ -398,7 +526,8 @@ bed_days_areas <- bed_days %>% rename(n = bed_days) %>% aggregate_usc_area_data() %>% left_join(pop_areas_all_ages) %>% - mutate(data = round_half_up(n / pop * 100000)) + mutate(data = round_half_up(n / pop * 100000)) %>% + drop_na(year) BDs_loc_ts <- area_trend_usc( data_for_plot = bed_days_areas, @@ -407,31 +536,74 @@ BDs_loc_ts <- area_trend_usc( source = "Source: PHS SMR01" ) +# Objects for text for Figures and Summary (Unscheduled Bed Days) +min_year_ubd <- min(bed_days_areas$financial_year) +max_year_ubd <- max(bed_days_areas$financial_year) + +# LOCALITY +first_fy_rate_ubd <- filter( + bed_days_areas, + financial_year == min(financial_year), + location == LOCALITY & area_type == "Locality" +)$data -# Objects for text and summary table latest_bed_days_loc <- bed_days_areas %>% - filter( - location == LOCALITY, - year == max(year) - ) %>% - mutate(data = format(data, big.mark = ",")) %>% - pull(data) + filter(location == LOCALITY, year == max(year)) %>% + mutate(formatted_data = format(data, big.mark = ",")) +latest_bed_days_loc1 <- latest_bed_days_loc %>% pull(formatted_data) +latest_bed_days_loc2 <- latest_bed_days_loc %>% pull(data) + +rate_change_ubd <- percent_change_calc(latest_bed_days_loc2, first_fy_rate_ubd) +word_change_ubd <- word_change_calc(latest_bed_days_loc2, first_fy_rate_ubd) +# HSCP +first_fy_hscp_ubd <- filter( + bed_days_areas, (financial_year == min(bed_days_areas$financial_year)) & (area_type == "HSCP") +)$data hscp_bed_days <- bed_days_areas %>% - filter( - location == HSCP, - year == max(year) - ) %>% - mutate(data = format(data, big.mark = ",")) %>% - pull(data) + filter(location == HSCP, year == max(year)) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +hscp_bed_days1 <- hscp_bed_days %>% pull(formatted_data) +hscp_bed_days2 <- hscp_bed_days %>% pull(data) + +hscp_rate_ubd <- percent_change_calc(hscp_bed_days2, first_fy_hscp_ubd) +hscp_change_ubd <- word_change_calc(hscp_bed_days2, first_fy_hscp_ubd) + +# Scotland +first_fy_scot_ubd <- filter( + bed_days_areas, (financial_year == min(bed_days_areas$financial_year)) & (area_type == "Scotland") +)$data scot_bed_days <- bed_days_areas %>% + filter(location == "Scotland", year == max(year)) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +scot_bed_days1 <- scot_bed_days %>% pull(formatted_data) +scot_bed_days2 <- scot_bed_days %>% pull(data) + +scot_rate_ubd <- percent_change_calc(scot_bed_days2, first_fy_scot_ubd) +scot_change_ubd <- word_change_calc(scot_bed_days2, first_fy_scot_ubd) + +# NHS health board +hb_bed_days <- bed_days_areas %>% filter( - location == "Scotland", + location == HB, year == max(year) ) %>% - mutate(data = format(data, big.mark = ",")) %>% - pull(data) + mutate(formatted_data = format(data, big.mark = ",")) + +hb_bed_days1 <- hb_bed_days %>% pull(formatted_data) +hb_bed_days2 <- hb_bed_days %>% pull(data) +first_fy_hb_ubd <- filter( + bed_days_areas, + financial_year == min(financial_year), + location == HB +)$data + +hb_rate_change_ubd <- percent_change_calc(hb_bed_days2, first_fy_hb_ubd) +word_change_hb_ubd <- word_change_calc(hb_bed_days2, first_fy_hb_ubd) + other_loc_bed_days <- bed_days %>% group_by(financial_year, hscp_locality) %>% @@ -444,6 +616,58 @@ other_loc_bed_days <- bed_days %>% select(hscp_locality, data) %>% pivot_wider(names_from = hscp_locality, values_from = data) +# Create objects for text emergency admissions by age group +max_ubd_age <- max(bed_days_age$financial_year) +min_ubd_age <- min(bed_days_age$financial_year) + +latest_ubd_max_age <- bed_days_age %>% + filter( + year == max(year) + ) %>% + filter( + data == max(data) + ) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +latest_ubd_max_age1 <- latest_ubd_max_age %>% pull(formatted_data) +latest_ubd_max_age2 <- latest_ubd_max_age %>% pull(data) +age_group_max_ubd <- latest_ubd_max_age %>% pull(age_group) + +first_ubd_max_age <- bed_days_age %>% + filter( + year == min(year), + age_group == age_group_max_ubd + ) %>% + pull(data) + +max_rate_change_ubd <- percent_change_calc(latest_ubd_max_age2, first_ubd_max_age) +max_word_change_ubd <- word_change_calc(latest_ubd_max_age2, first_ubd_max_age) + +latest_ubd_min_age <- bed_days_age %>% + filter( + year == max(year) + ) %>% + filter( + data == min(data) + ) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +latest_ubd_min_age1 <- latest_ubd_min_age %>% pull(formatted_data) +latest_ubd_min_age2 <- latest_ubd_min_age %>% pull(data) +age_group_min_ubd <- latest_ubd_min_age %>% pull(age_group) + +first_ubd_min_age <- bed_days_age %>% + filter( + age_group == age_group_min_ubd + ) %>% + filter(year == min(year)) + +first_ubd_min_age1 <- first_ubd_min_age %>% pull(data) +min_year_ubd_age1 <- first_ubd_min_age %>% pull(year) + + +min_rate_change_ubd <- percent_change_calc(latest_ubd_min_age2, first_ubd_min_age1) +min_word_change_ubd <- word_change_calc(latest_ubd_min_age2, first_ubd_min_age1) # 2b. Unscheduled bed days - Mental Health ---- # _________________________________________________________________________ @@ -459,7 +683,8 @@ bed_days_mh_age <- bed_days_mh %>% summarise(bed_days = sum(bed_days)) %>% ungroup() %>% left_join(loc_pop_age1) %>% - mutate(data = round_half_up(bed_days / pop * 100000)) + mutate(data = round_half_up(bed_days / pop * 100000)) %>% + drop_na(year) BDMH_age_ts <- age_group_trend_usc( @@ -475,7 +700,8 @@ bed_days_mh_areas <- bed_days_mh %>% rename(n = bed_days) %>% aggregate_usc_area_data() %>% left_join(pop_areas_all_ages) %>% - mutate(data = round_half_up(n / pop * 100000)) + mutate(data = round_half_up(n / pop * 100000)) %>% + drop_na(year) BDMH_loc_ts <- area_trend_usc( data_for_plot = bed_days_mh_areas, @@ -485,33 +711,144 @@ BDMH_loc_ts <- area_trend_usc( ) -# Objects for text and summary table +# Objects for text and summary table- age +max_year_bd_mh_age <- max(bed_days_mh_age$financial_year) +min_year_bd_mh_age <- min(bed_days_mh_age$financial_year) + +latest_bd_mh_max_age <- bed_days_mh_age %>% + filter( + year == max(year) + ) %>% + filter( + data == max(data) + ) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +latest_bd_mh_max_age1 <- latest_bd_mh_max_age %>% pull(formatted_data) +latest_bd_mh_max_age2 <- latest_bd_mh_max_age %>% pull(data) +age_group_max_mh <- latest_bd_mh_max_age %>% pull(age_group) + +first_bd_mh_max_age <- bed_days_mh_age %>% + filter( + year == min(year), + age_group == age_group_max_mh + ) %>% + pull(data) + +max_rate_change_beds_mh <- percent_change_calc(latest_bd_mh_max_age2, first_bd_mh_max_age) +max_word_change_beds_mh <- word_change_calc(latest_bd_mh_max_age2, first_bd_mh_max_age) + +latest_bd_mh_min_age <- bed_days_mh_age %>% + filter( + year == max(year) + ) %>% + filter( + data == min(data) + ) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +latest_bd_mh_min_age1 <- latest_bd_mh_min_age %>% pull(formatted_data) +latest_bd_mh_min_age2 <- latest_bd_mh_min_age %>% pull(data) +age_group_min_mh <- latest_bd_mh_min_age %>% pull(age_group) + +first_bd_mh_min_age <- bed_days_mh_age %>% + filter( + age_group == age_group_min_mh + ) %>% + filter(year == min(year)) + +first_bd_mh_min_age1 <- first_bd_mh_min_age %>% pull(data) +min_year_bd_mh_age1 <- first_bd_mh_min_age %>% pull(year) + + +min_rate_change_beds_mh <- percent_change_calc(latest_bd_mh_min_age2, first_bd_mh_min_age1) +min_word_change_beds_mh <- word_change_calc(latest_bd_mh_min_age2, first_bd_mh_min_age1) + +# Objects for text and summary table- area +max_year_bd_mh_areas <- max(bed_days_mh_areas$financial_year) +min_year_bd_mh_areas <- min(bed_days_mh_areas$financial_year) + latest_bed_days_mh_loc <- bed_days_mh_areas %>% filter( location == LOCALITY, year == max(year) ) %>% - mutate(data = format(data, big.mark = ",")) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +latest_bed_days_mh_loc1 <- latest_bed_days_mh_loc %>% pull(formatted_data) +latest_bed_days_mh_loc2 <- latest_bed_days_mh_loc %>% pull(data) +latest_bed_days_mh_loc1 <- ifelse(is_empty(latest_bed_days_mh_loc1), "NA", latest_bed_days_mh_loc1) + +first_bed_days_mh_loc <- bed_days_mh_areas %>% + filter( + location == LOCALITY, + year == min(year) + ) %>% pull(data) -latest_bed_days_mh_loc <- ifelse(is_empty(latest_bed_days_mh_loc), "NA", latest_bed_days_mh_loc) +loc_rate_change_beds_mh <- percent_change_calc(latest_bed_days_mh_loc2, first_bed_days_mh_loc) +loc_word_change_beds_mh <- word_change_calc(latest_bed_days_mh_loc2, first_bed_days_mh_loc) hscp_bed_days_mh <- bed_days_mh_areas %>% filter( location == HSCP, year == max(year) ) %>% - mutate(data = format(data, big.mark = ",")) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +hscp_bed_days_mh1 <- hscp_bed_days_mh %>% pull(formatted_data) +hscp_bed_days_mh2 <- hscp_bed_days_mh %>% pull(data) + +first_hscp_bed_days_mh <- bed_days_mh_areas %>% + filter( + location == HSCP, + year == min(year) + ) %>% pull(data) +hscp_rate_change_beds_mh <- percent_change_calc(hscp_bed_days_mh2, first_hscp_bed_days_mh) +hscp_word_change_beds_mh <- word_change_calc(hscp_bed_days_mh2, first_hscp_bed_days_mh) + scot_bed_days_mh <- bed_days_mh_areas %>% filter( location == "Scotland", year == max(year) ) %>% - mutate(data = format(data, big.mark = ",")) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +scot_bed_days_mh1 <- scot_bed_days_mh %>% pull(formatted_data) +scot_bed_days_mh2 <- scot_bed_days_mh %>% pull(data) + +first_scot_bed_days_mh <- bed_days_mh_areas %>% + filter( + location == "Scotland", + year == min(year) + ) %>% pull(data) +scot_rate_change_beds_mh <- percent_change_calc(scot_bed_days_mh2, first_scot_bed_days_mh) +scot_word_change_beds_mh <- word_change_calc(scot_bed_days_mh2, first_scot_bed_days_mh) + +# NHS health board +hb_mh_beddays <- bed_days_mh_areas %>% + filter( + location == HB, + year == max(year) + ) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +hb_mh_beddays1 <- hb_mh_beddays %>% pull(formatted_data) +hb_mh_beddays2 <- hb_mh_beddays %>% pull(data) + +first_fy_hb_mh <- filter( + bed_days_mh_areas, + financial_year == min(financial_year), + location == HB +)$data + +hb_rate_change_mh <- round(abs(hb_mh_beddays2 - first_fy_hb_mh) / first_fy_hb_mh * 100, digits = 1) +word_change_hb_mh <- word_change_calc(hb_mh_beddays2, first_fy_hb_mh) + other_loc_bed_days_mh <- bed_days_mh %>% group_by(financial_year, hscp_locality) %>% summarise(bed_days = sum(bed_days)) %>% @@ -540,7 +877,9 @@ ae_att_age <- ae_attendances %>% summarise(attendances = sum(attendances)) %>% ungroup() %>% left_join(loc_pop_age1) %>% - mutate(data = round_half_up(attendances / pop * 100000)) + mutate(data = round_half_up(attendances / pop * 100000)) %>% + drop_na(year) + AandE_age_ts <- age_group_trend_usc( data_for_plot = ae_att_age, @@ -555,7 +894,9 @@ ae_att_areas <- ae_attendances %>% rename(n = attendances) %>% aggregate_usc_area_data() %>% left_join(pop_areas_all_ages) %>% - mutate(data = round_half_up(n / pop * 100000)) + mutate(data = round_half_up(n / pop * 100000)) %>% + drop_na(year) + AandE_loc_ts <- area_trend_usc( data_for_plot = ae_att_areas, @@ -564,31 +905,143 @@ AandE_loc_ts <- area_trend_usc( source = "Source: PHS A&E Datamart" ) +# Objects for text and summary table- age + +min_year_ae_age <- min(ae_att_age$financial_year) +max_year_ae_age <- max(ae_att_age$financial_year) + + +latest_ae_att_max_age <- ae_att_age %>% + filter( + year == max(year) + ) %>% + filter( + data == max(data) + ) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +latest_ae_att_loc1_age <- latest_ae_att_max_age %>% pull(formatted_data) +latest_ae_att_loc2_age <- latest_ae_att_max_age %>% pull(data) + +age_group_max <- latest_ae_att_max_age %>% pull(age_group) + +first_ae_att_max_age <- ae_att_age %>% + filter( + year == min(year), + age_group == age_group_max + ) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +first_ae_att_max_age_data <- first_ae_att_max_age %>% pull(data) + +percent_rate_change_ae_age <- percent_change_calc(latest_ae_att_loc2_age, first_ae_att_max_age_data) +word_change_rate_ae_age <- word_change_calc(latest_ae_att_loc2_age, first_ae_att_max_age_data) + +latest_ae_att_min_age <- ae_att_age %>% + filter( + year == max(year) + ) %>% + filter( + data == min(data) + ) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +latest_ae_att_loc1_age_min <- latest_ae_att_min_age %>% pull(formatted_data) +latest_ae_att_loc2_age_min <- latest_ae_att_min_age %>% pull(data) +age_group_min <- latest_ae_att_min_age %>% pull(age_group) + +first_ae_att_min_age <- ae_att_age %>% + filter( + year == min(year), + age_group == age_group_min + ) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +first_ae_att_min_data <- first_ae_att_min_age %>% pull(data) + +percent_rate_change_ae_age2 <- percent_change_calc(latest_ae_att_loc2_age_min, first_ae_att_min_data) +word_change_rate_ae_age2 <- word_change_calc(latest_ae_att_loc2_age_min, first_ae_att_min_data) + + +# Objects for text and summary table- area + +min_year_ae_area <- min(ae_att_areas$financial_year) +max_year_ae_area <- max(ae_att_areas$financial_year) + +first_fy_rate_ae_areas <- filter( + ae_att_areas, + financial_year == min(financial_year), + location == LOCALITY & area_type == "Locality", +)$data -# Objects for text and summary table latest_ae_att_loc <- ae_att_areas %>% filter( location == LOCALITY, year == max(year) ) %>% - mutate(data = format(data, big.mark = ",")) %>% - pull(data) + mutate(formatted_data = format(data, big.mark = ",")) + +latest_ae_att_loc1 <- latest_ae_att_loc %>% pull(formatted_data) +latest_ae_att_loc2 <- latest_ae_att_loc %>% pull(data) + +percent_rate_change_ae_areas <- percent_change_calc(latest_ae_att_loc2, first_fy_rate_ae_areas) +word_change_rate_ae_areas <- word_change_calc(latest_ae_att_loc2, first_fy_rate_ae_areas) hscp_ae_att <- ae_att_areas %>% filter( location == HSCP, year == max(year) ) %>% - mutate(data = format(data, big.mark = ",")) %>% - pull(data) + mutate(formatted_data = format(data, big.mark = ",")) + +hscp_ae_att1 <- hscp_ae_att %>% pull(formatted_data) +hscp_ae_att2 <- hscp_ae_att %>% pull(data) + +first_fy_hscp_ae <- filter( + ae_att_areas, + financial_year == min(financial_year), + area_type == "HSCP" +)$data + +percent_rate_change_ae_areas_hscp <- percent_change_calc(hscp_ae_att2, first_fy_hscp_ae) +word_change_rate_ae_areas_hscp <- word_change_calc(hscp_ae_att2, first_fy_hscp_ae) scot_ae_att <- ae_att_areas %>% filter( location == "Scotland", year == max(year) ) %>% - mutate(data = format(data, big.mark = ",")) %>% - pull(data) + mutate(formatted_data = format(data, big.mark = ",")) +scot_ae_att1 <- scot_ae_att %>% pull(formatted_data) +scot_ae_att2 <- scot_ae_att %>% pull(data) + +first_fy_scot_ae <- filter( + ae_att_areas, + financial_year == min(financial_year), + location == "Scotland" +)$data + +percent_rate_change_ae_areas_scot <- percent_change_calc(scot_ae_att2, first_fy_scot_ae) +word_change_rate_ae_areas_scot <- word_change_calc(scot_ae_att2, first_fy_scot_ae) + +# NHS health board +hb_ae_att <- ae_att_areas %>% + filter( + location == HB, + year == max(year) + ) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +hb_ae1 <- hb_ae_att %>% pull(formatted_data) +hb_ae2 <- hb_ae_att %>% pull(data) +first_fy_hb_ae <- filter( + ae_att_areas, + financial_year == min(financial_year), + location == HB +)$data + +hb_rate_change_ae <- percent_change_calc(hb_ae2, first_fy_hb_ae) +word_change_hb_ae <- word_change_calc(hb_ae2, first_fy_hb_ae) other_loc_ae_att <- ae_attendances %>% group_by(financial_year, hscp_locality) %>% @@ -621,7 +1074,8 @@ delayed_disch_areas <- delayed_disch %>% rename(n = dd_bed_days) %>% aggregate_usc_area_data() %>% left_join(pop_areas_65plus) %>% - mutate(data = round_half_up(n / pop * 100000)) + mutate(data = round_half_up(n / pop * 100000)) %>% + drop_na(year) DD_loc_ts <- area_trend_usc( data_for_plot = delayed_disch_areas, @@ -635,30 +1089,91 @@ DD_loc_ts <- area_trend_usc( # Objects for text and summary table +min_year_dd <- min(delayed_disch_areas$financial_year) +max_year_dd <- max(delayed_disch_areas$financial_year) + latest_dd_loc <- delayed_disch_areas %>% filter( location == LOCALITY, year == max(year) ) %>% - mutate(data = format(data, big.mark = ",")) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +latest_dd_loc1 <- latest_dd_loc %>% pull(formatted_data) +latest_dd_loc2 <- latest_dd_loc %>% pull(data) + +first_dd_loc <- delayed_disch_areas %>% + filter( + location == LOCALITY, + year == min(year) + ) %>% pull(data) +percent_rate_change_dd_loc <- percent_change_calc(latest_dd_loc2, first_dd_loc) +word_change_rate_dd_loc <- word_change_calc(latest_dd_loc2, first_dd_loc) + + hscp_dd <- delayed_disch_areas %>% filter( location == HSCP, year == max(year) ) %>% - mutate(data = format(data, big.mark = ",")) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +hscp_dd1 <- hscp_dd %>% pull(formatted_data) +hscp_dd2 <- hscp_dd %>% pull(data) + +first_hscp_dd <- delayed_disch_areas %>% + filter( + location == HSCP, + year == min(year) + ) %>% pull(data) +percent_rate_change_dd_hscp <- percent_change_calc(hscp_dd2, first_hscp_dd) +word_change_rate_dd_hscp <- word_change_calc(hscp_dd2, first_hscp_dd) + + scot_dd <- delayed_disch_areas %>% filter( location == "Scotland", year == max(year) ) %>% - mutate(data = format(data, big.mark = ",")) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +scot_dd1 <- scot_dd %>% pull(formatted_data) +scot_dd2 <- scot_dd %>% pull(data) + +first_scot_dd <- delayed_disch_areas %>% + filter( + location == "Scotland", + year == min(year) + ) %>% pull(data) +percent_rate_change_dd_scot <- percent_change_calc(scot_dd2, first_scot_dd) +word_change_rate_dd_scot <- word_change_calc(scot_dd2, first_scot_dd) + +# NHS health board +hb_dd <- delayed_disch_areas %>% + filter( + location == HB, + year == max(year) + ) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +hb_dd1 <- hb_dd %>% pull(formatted_data) +hb_dd2 <- hb_dd %>% pull(data) +first_fy_hb_dd <- filter( + delayed_disch_areas, + financial_year == min(financial_year), + location == HB +)$data + +hb_rate_change_dd <- percent_change_calc(hb_dd2, first_fy_hb_dd) +word_change_hb_dd <- word_change_calc(hb_dd2, first_fy_hb_dd) + + other_loc_dd <- delayed_disch %>% group_by(financial_year, hscp_locality) %>% summarise(dd_bed_days = sum(dd_bed_days)) %>% @@ -684,7 +1199,8 @@ falls_areas <- falls %>% rename(n = admissions) %>% aggregate_usc_area_data() %>% left_join(pop_areas_65plus) %>% - mutate(data = round_half_up(n / pop * 100000)) + mutate(data = round_half_up(n / pop * 100000)) %>% + drop_na(year) Falls_loc_ts <- area_trend_usc( data_for_plot = falls_areas, @@ -698,22 +1214,88 @@ Falls_loc_ts <- area_trend_usc( # Objects for text and summary table +min_year_falls <- min(falls_areas$financial_year) +max_year_falls <- max(falls_areas$financial_year) + latest_falls_loc <- falls_areas %>% filter( location == LOCALITY, year == max(year) ) %>% - mutate(data = format(data, big.mark = ",")) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +latest_falls_loc1 <- latest_falls_loc %>% pull(formatted_data) +latest_falls_loc2 <- latest_falls_loc %>% pull(data) + +first_falls_loc <- falls_areas %>% + filter( + location == LOCALITY, + year == min(year) + ) %>% + pull(data) + +percent_rate_change_falls_loc <- percent_change_calc(latest_falls_loc2, first_falls_loc) +word_change_rate_falls_loc <- word_change_calc(latest_falls_loc2, first_falls_loc) + +hscp_falls <- falls_areas %>% + filter( + location == HSCP, + year == max(year) + ) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +hscp_falls1 <- hscp_falls %>% pull(formatted_data) +hscp_falls2 <- hscp_falls %>% pull(data) + +first_falls_hscp <- falls_areas %>% + filter( + location == HSCP, + year == min(year) + ) %>% pull(data) +percent_rate_change_falls_hscp <- percent_change_calc(hscp_falls2, first_falls_hscp) +word_change_rate_falls_hscp <- word_change_calc(hscp_falls2, first_falls_hscp) + scot_falls <- falls_areas %>% filter( location == "Scotland", year == max(year) ) %>% - mutate(data = format(data, big.mark = ",")) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +scot_falls1 <- scot_falls %>% pull(formatted_data) +scot_falls2 <- scot_falls %>% pull(data) + +first_falls_scot <- falls_areas %>% + filter( + location == "Scotland", + year == min(year) + ) %>% pull(data) +percent_rate_change_falls_scot <- percent_change_calc(scot_falls2, first_falls_scot) +word_change_rate_falls_scot <- word_change_calc(scot_falls2, first_falls_scot) + +# NHS health board +hb_falls <- falls_areas %>% + filter( + location == HB, + year == max(year) + ) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +hb_falls1 <- hb_falls %>% pull(formatted_data) +hb_falls2 <- hb_falls %>% pull(data) + +first_fy_hb_falls <- filter( + falls_areas, + financial_year == min(financial_year), + location == HB +)$data + +hb_rate_change_falls <- round(abs(hb_falls2 - first_fy_hb_falls) / first_fy_hb_falls * 100, digits = 1) +word_change_hb_falls <- word_change_calc(hb_falls2, first_fy_hb_falls) # 6. Readmissions (28 days) ---- # _________________________________________________________________________ @@ -722,6 +1304,7 @@ readmissions <- arrow::read_parquet(paste0(import_folder, "readmissions_smr.parq filter(financial_year <= max_fy) # Plotting by age + readmissions_age <- readmissions %>% filter(hscp_locality == LOCALITY) %>% drop_na(age_group) %>% @@ -733,7 +1316,7 @@ readmissions_age <- readmissions %>% ungroup() %>% mutate(data = round_half_up(read_28 / discharges * 1000, 1)) -Read_age_ts <- age_group_trend_usc( +read_age_ts <- age_group_trend_usc( data_for_plot = readmissions_age, plot_title = paste("Readmission rate (28 days) per 1,000 discharges by age group\n for", LOCALITY), yaxis_title = "Readmission rate (28 days)\n per 1,000 discharges", @@ -759,25 +1342,110 @@ read2 <- readmissions %>% readmissions_areas <- left_join(read1, read2) %>% left_join(pop_areas_all_ages) %>% - mutate(data = round_half_up(read_28 / discharges * 1000, 1)) + mutate(data = round_half_up(read_28 / discharges * 1000, 1)) %>% + drop_na(year) rm(read1, read2) -Read_loc_ts <- area_trend_usc( +read_loc_ts <- area_trend_usc( data_for_plot = readmissions_areas, plot_title = paste("Readmission rate (28 days) per 1,000 discharges over time by residence"), yaxis_title = "Readmission rate (28 days)\n per 1,000 discharges", source = "Source: PHS SMR01" ) -# Objects for text and summary table +# Objects for text and summary table-age +min_year_re_age <- min(readmissions_age$financial_year) +max_year_re_age <- max(readmissions_age$financial_year) + +latest_re_max_age <- readmissions_age %>% + filter( + financial_year == max(financial_year)) %>% + filter( + data == max(data) + ) + +latest_re_max_age_data <- latest_re_max_age %>% pull(data) +latest_re_max_age_group <- latest_re_max_age %>% pull(age_group) + +first_re_max_age <- readmissions_age %>% + filter( + financial_year == min(financial_year), + age_group == latest_re_max_age_group + ) %>% + pull(data) + + +percent_rate_change_re_age <- percent_change_calc(latest_re_max_age_data, first_re_max_age) +word_change_rate_re_age <- word_change_calc(latest_re_max_age_data, first_re_max_age) + +latest_re_min_age <- readmissions_age %>% + filter( + financial_year == max(financial_year) + ) %>% + filter(data == min(data)) + +latest_re_min_age_data <- latest_re_min_age %>% pull(data) +latest_re_min_age_group <- latest_re_min_age %>% pull(age_group) + +first_re_min_age <- readmissions_age %>% + filter( + financial_year == min(financial_year), + age_group == latest_re_min_age_group + ) %>% + pull(data) + +percent_rate_change_re_age_min <- percent_change_calc(latest_re_min_age_data, first_re_min_age) +word_change_rate_re_age_min <- word_change_calc(latest_re_min_age_data, first_re_min_age) + +# Objects for text and summary table-area +min_year_re_area <- min(readmissions_areas$financial_year) +max_year_re_area <- max(readmissions_areas$financial_year) + +first_read_loc <- readmissions_areas %>% + filter( + location == LOCALITY, + year == min(year) + ) + +first_read_loc1 <- first_read_loc %>% pull(data) + latest_read_loc <- readmissions_areas %>% filter( location == LOCALITY, year == max(year) + ) + +latest_read_loc1 <- latest_read_loc %>% pull(data) + +percent_rate_change_re_area <- percent_change_calc(latest_read_loc1, first_read_loc1) +word_change_rate_re_area <- word_change_calc(latest_read_loc1, first_read_loc1) + +first_hscp_read <- readmissions_areas %>% + filter( + location == HSCP, + year == min(year) + ) %>% + pull(data) + +hscp_read <- readmissions_areas %>% + filter( + location == HSCP, + year == max(year) + ) %>% + pull(data) + +percent_rate_change_re_area_hscp <- percent_change_calc(hscp_read, first_hscp_read) +word_change_rate_re_area_hscp <- word_change_calc(hscp_read, first_hscp_read) + +first_scot_read <- readmissions_areas %>% + filter( + location == "Scotland", + year == min(year) ) %>% pull(data) + scot_read <- readmissions_areas %>% filter( location == "Scotland", @@ -785,6 +1453,28 @@ scot_read <- readmissions_areas %>% ) %>% pull(data) +percent_rate_change_re_area_scot <- percent_change_calc(scot_read, first_scot_read) +word_change_rate_re_area_scot <- word_change_calc(scot_read, first_scot_read) + +# NHS health board +hb_read <- readmissions_areas %>% + filter( + location == HB, + year == max(year) + ) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +hb_read1 <- hb_read %>% pull(formatted_data) +hb_read2 <- hb_read %>% pull(data) + +first_fy_hb_read <- filter( + readmissions_areas, + financial_year == min(financial_year), + location == HB +)$data + +hb_rate_change_read <- percent_change_calc(hb_read2, first_fy_hb_read) +word_change_hb_read <- word_change_calc(hb_read2, first_fy_hb_read) # 7. Comm 6 months ---- # _________________________________________________________________________________ @@ -894,7 +1584,8 @@ ppa_65plus <- ppa %>% rename(plus65tot = n) %>% left_join(ppa_total, by = c("financial_year", "location")) %>% left_join(pop_areas_all_ages) %>% - mutate(data = round_half_up(plus65tot / n * 100, 1)) + mutate(data = round_half_up(plus65tot / n * 100, 1)) %>% + drop_na(year) latest_ppa_65plus <- ppa_65plus %>% filter( @@ -910,7 +1601,8 @@ ppa_under65 <- ppa %>% rename(under65tot = n) %>% left_join(ppa_total, by = c("financial_year", "location")) %>% left_join(pop_areas_all_ages) %>% - mutate(data = round_half_up(under65tot / n * 100, 1)) + mutate(data = round_half_up(under65tot / n * 100, 1)) %>% + drop_na(year) latest_ppa_under65 <- ppa_under65 %>% filter( @@ -927,10 +1619,11 @@ ppa_areas <- ppa %>% left_join(pop_areas_all_ages) %>% mutate(data = round_half_up(n / pop * 100000)) %>% mutate(location = factor(location, levels = c(LOCALITY, HSCP, HB, "Scotland"))) %>% - arrange(location) + arrange(location) %>% + drop_na(year) -PPA_loc_ts <- area_trend_usc( +ppa_loc_ts <- area_trend_usc( data_for_plot = ppa_areas, plot_title = paste("Potentially Preventable Emergency Admissions per 100,000 by residence"), yaxis_title = "PPA rate\nper 100,000 population", @@ -939,29 +1632,50 @@ PPA_loc_ts <- area_trend_usc( # Objects for text and summary table +max_year_ppa_areas <- max(ppa_areas$financial_year) +min_year_ppa_areas <- min(ppa_areas$financial_year) + + latest_ppa_loc <- ppa_areas %>% filter( location == LOCALITY, - year == max(year) + year == max(year) | year == min(year) ) %>% - mutate(data = format(data, big.mark = ",")) %>% - pull(data) + mutate(formatted_data = format(data, big.mark = ",")) + +ppa_diff <- percent_change_calc(latest_ppa_loc$data[2], latest_ppa_loc$data[1]) +ppa_word_change <- word_change_calc(latest_ppa_loc$data[2], latest_ppa_loc$data[1]) hscp_ppa <- ppa_areas %>% filter( location == HSCP, - year == max(year) + year == max(year) | year == min(year) ) %>% - mutate(data = format(data, big.mark = ",")) %>% - pull(data) + mutate(formatted_data = format(data, big.mark = ",")) + +ppa_diff_hscp <- percent_change_calc(hscp_ppa$data[2], hscp_ppa$data[1]) +ppa_word_change_hscp <- word_change_calc(hscp_ppa$data[2], hscp_ppa$data[1]) scot_ppa <- ppa_areas %>% filter( location == "Scotland", - year == max(year) + year == max(year) | year == min(year) ) %>% - mutate(data = format(data, big.mark = ",")) %>% - pull(data) + mutate(formatted_data = format(data, big.mark = ",")) + +diff_scot_ppa <- percent_change_calc(scot_ppa$data[2], scot_ppa$data[1]) +word_change_scot_ppa <- word_change_calc(scot_ppa$data[2], scot_ppa$data[1]) + +# NHS health board +hb_ppa <- ppa_areas %>% + filter( + location == HB, + year == max(year) | year == min(year) + ) %>% + mutate(formatted_data = format(data, big.mark = ",")) + +diff_hb_ppa <- percent_change_calc(hb_ppa$data[2], hb_ppa$data[1]) +word_change_hb_ppa <- word_change_calc(hb_ppa$data[2], hb_ppa$data[1]) other_loc_ppa <- ppa %>% group_by(financial_year, hscp_locality) %>% @@ -1019,10 +1733,72 @@ other_locs_psych_hosp <- psych_hosp %>% mutate(measure = as.character(round_half_up(measure, 1))) %>% pivot_wider(names_from = hscp_locality, values_from = measure) -hscp_psych_hosp <- round_half_up(filter(psych_hosp, year == max(year) & - (area_name == HSCP & area_type == "HSCP"))$measure, 1) +hscp_psych_hosp <- round_half_up( + filter(psych_hosp, year == max(year) & (area_name == HSCP & area_type == "HSCP"))$measure, + 1 +) + +scot_psych_hosp <- round_half_up( + filter(psych_hosp, year == max(year) & area_name == "Scotland")$measure, + 1 +) + + +list_years <- unique(psych_hosp_time_trend$data[6]) +list_years_latest <- list_years$period + + +# Locality +loc_psych_hosp <- psych_hosp %>% + filter(period %in% list_years_latest) %>% + filter( + area_name == LOCALITY & + area_type == "Locality", + year == min(year) | year == max(year) + ) %>% + mutate(measure2 = format(measure, big.mark = ",")) + +diff_loc_psych <- percent_change_calc(loc_psych_hosp$measure[2], loc_psych_hosp$measure[1]) +word_change_loc_psych <- word_change_calc(loc_psych_hosp$measure[2], loc_psych_hosp$measure[1]) -scot_psych_hosp <- round_half_up(filter(psych_hosp, year == max(year) & area_name == "Scotland")$measure, 1) +# HSCP +hscp_psych_hosp <- psych_hosp %>% + filter(period %in% list_years_latest) %>% + filter( + area_name == HSCP & + area_type == "HSCP", + year == min(year) | year == max(year) + ) %>% + mutate(measure2 = format(measure, big.mark = ",")) + +diff_hscp_psych <- percent_change_calc(hscp_psych_hosp$measure[2], hscp_psych_hosp$measure[1]) +word_change_hscp_psych <- word_change_calc(hscp_psych_hosp$measure[2], hscp_psych_hosp$measure[1]) + +# NHS health board +hb_psych_hosp <- psych_hosp %>% + filter(period %in% list_years_latest) %>% + filter( + area_name == HB & + area_type == "Health board", + year == min(year) | year == max(year) + ) %>% + mutate(measure2 = format(measure, big.mark = ",")) + +diff_hb_psych <- percent_change_calc(hb_psych_hosp$measure[2], hb_psych_hosp$measure[1]) +word_change_hb_psych <- word_change_calc(hb_psych_hosp$measure[2], hb_psych_hosp$measure[1]) + +# Scotland +scot_psych_hosp <- psych_hosp %>% + filter(period %in% list_years_latest) %>% + filter( + area_name == "Scotland" & + area_type == "Scotland", + year == min(year) | year == max(year) + ) %>% + mutate(measure2 = format(measure, big.mark = ",")) + +diff_scot_psych <- percent_change_calc(scot_psych_hosp$measure[2], scot_psych_hosp$measure[1]) +word_change_scot_psych <- word_change_calc(scot_psych_hosp$measure[2], scot_psych_hosp$measure[1]) @@ -1044,3 +1820,4 @@ scot_psych_hosp <- round_half_up(filter(psych_hosp, year == max(year) & area_nam # "Readmissions 28" = readmissions, # "PPA" = ppa), # path = paste0(lp_path, "Publishing/SMR Data.xlsx")) + diff --git a/Unscheduled Care/Unscheduled-Care-Testing-Markdown.Rmd b/Unscheduled Care/Unscheduled-Care-Testing-Markdown.Rmd index 4611010..d508e89 100755 --- a/Unscheduled Care/Unscheduled-Care-Testing-Markdown.Rmd +++ b/Unscheduled Care/Unscheduled-Care-Testing-Markdown.Rmd @@ -8,7 +8,6 @@ output: df_print: paged --- - ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) options(kableExtra.auto_format = FALSE) @@ -23,15 +22,14 @@ options(kableExtra.auto_format = FALSE) LOCALITY <- "Inverness" # LOCALITY <- "East Dunbartonshire West" -source("~/localities/Master RMarkdown Document & Render Code/Global Script.R") +source("../Master RMarkdown Document & Render Code/Global Script.R") -source("~/localities/Unscheduled Care/2. Unscheduled Care outputs.R") +source("./2. Unscheduled Care outputs.R") x <- 1 # object for figure numbers y <- 1 # object for table numbers ``` - ## Hospital and Community Care ###Summary @@ -40,27 +38,29 @@ This section includes acute hospital data, delayed discharge bed days and A&E at **For the most recent time periods available, `r LOCALITY` had:** - - **`r latest_emergency_adm_loc`** emergency hospital admissions per 100,000 population, compared to `r scot_emergency_adm` in Scotland. - - - **`r latest_bed_days_loc`** unscheduled acute specialty bed days per 100,000 population, compared to `r scot_bed_days` in Scotland. - - - **`r latest_ae_att_loc`** A&E attendances per 100,000 population, compared to `r scot_ae_att` in Scotland. - - - **`r latest_dd_loc`** delayed discharge bed days per 100,000 population aged over 65, compared to `r scot_dd` in Scotland. - - - **`r latest_falls_loc`** emergency hospital admissions from falls per 100,000 population aged over 65, compared to `r scot_falls` in Scotland. - - - **`r latest_read_loc`** emergency readmissions (28 day) per 1,000 discharges, compared to `r scot_read` in Scotland. - - - **`r latest_ppa_loc`** potentially preventable hospital admissions per 100,000 population, compared to `r scot_ppa` in Scotland. +- **`r latest_emergency_adm_loc1`** emergency hospital admissions per 100,000 population, compared to `r scot_emergency_adm1` in Scotland. + +- **`r latest_bed_days_loc1`** unscheduled acute specialty bed days per 100,000 population, compared to `r scot_bed_days1` in Scotland. + +- **`r latest_ae_att_loc1`** A&E attendances per 100,000 population, compared to `r scot_ae_att1` in Scotland. +- **`r latest_dd_loc1`** delayed discharge bed days per 100,000 population aged over 65, compared to `r scot_dd1` in Scotland. + +- **`r latest_falls_loc1`** emergency hospital admissions from falls per 100,000 population aged over 65, compared to `r scot_falls1` in Scotland. + +- **`r latest_read_loc1`** emergency readmissions (28 day) per 1,000 discharges, compared to `r scot_read` in Scotland. + +- **`r latest_ppa_loc$formatted_data[2]`** potentially preventable hospital admissions per 100,000 population, compared to `r scot_ppa$formatted_data[2]` in Scotland. #####Pagebreak ### Emergency Admissions -####Figure `r x`: Emergency admissions by geographical area -\newline +Figure `r x` presents the emergency admissions rate per 100,000 population in the `r LOCALITY` locality from `r min_year_ea` to `r max_year_ea`. + +As presented Figure `r x`, the emergency admissions rate in the `r LOCALITY` locality for `r max_year_ea` is `r latest_emergency_adm_loc1`, `r get_article(percent_rate_change)` `r percent_rate_change`% `r word_change_rate` since `r min_year_ea`. The `r HSCP` HSCP rate is `r hscp_emergency_adm1`, `r get_article(hscp_rate_change)` `r hscp_rate_change`% `r word_change_hscp` since `r min_year_ea`. The `r HB` health board rate is `r hscp_emergency_adm1` in `r max_year_ea`, `r get_article(hb_rate_change)` `r hb_rate_change`% `r word_change_hb` since `r min_year_ea` and the Scotland rate is `r scot_emergency_adm1`, `r get_article(scot_rate_change)` `r scot_rate_change`% `r word_change_scot` since `r min_year_ea`. + +####Figure `r x`: Emergency admissions by geographical area \newline ```{r echo = FALSE, fig.width= 7.6, fig.height= 4, warning = F} EAs_loc_ts @@ -68,8 +68,11 @@ EAs_loc_ts x <- x + 1 ``` -####Figure `r x`: Emergency admissions by age group -\newline +Figure `r x` presents the emergency admissions rate per 100,000 population in the `r LOCALITY` locality from `r min_ea_age` to `r max_ea_age` by age group. + +As presented in Figure `r x`, the highest emergency admissions rate for the `r LOCALITY` locality in `r max_ea_age` is `r latest_ea_max_age1` per 100,000 population for the `r age_group_max_ea` age group with a percentage `r max_word_change_ea` of `r max_rate_change_ea`% since `r min_ea_age`. The lowest emergency admissions rate for `r LOCALITY` in `r max_ea_age` is `r latest_ea_min_age1` per 100,000 population for the `r age_group_min_ea` age group with a percentage `r min_word_change_ea` of `r min_rate_change_ea`% since `r min_ea_age`. + +####Figure `r x`: Emergency admissions by age group \newline ```{r echo = FALSE, fig.width= 7.6, fig.height= 4, warning = F} EAs_age_ts @@ -81,8 +84,11 @@ x <- x + 1 ### Unscheduled Acute Bed Days -####Figure `r x`: Unscheduled acute bed days by geographical area -\newline +Figure `r x` presents the unscheduled bed days rate per 100,000 population in the `r LOCALITY` locality from `r min_year_ubd` to `r max_year_ubd`. + +As presented in Figure `r x`, the unscheduled bed days rate in the `r LOCALITY` locality for `r max_year_ubd` is `r latest_bed_days_loc1`, `r get_article(rate_change_ubd)` `r rate_change_ubd`% `r word_change_ubd` since `r min_year_ubd` and the `r HSCP` HSCP rate is `r hscp_bed_days1`, `r get_article(hscp_rate_ubd)` `r hscp_rate_ubd`% `r hscp_change_ubd` since `r min_year_ubd`. The `r HB` health board rate for `r max_year_ubd` is `r hb_bed_days1`, `r get_article(hb_rate_change_ubd)` `r hb_rate_change_ubd`% `r word_change_hb_ubd` since `r min_year_ubd` and the Scotland rate is `r scot_bed_days1`, `r get_article(scot_rate_ubd)` `r scot_rate_ubd`% `r scot_change_ubd` since `r min_year_ubd`. + +####Figure `r x`: Unscheduled acute bed days by geographical area \newline ```{r echo = FALSE, fig.width= 7.6, fig.height= 4, warning = F} BDs_loc_ts @@ -90,8 +96,11 @@ BDs_loc_ts x <- x + 1 ``` -####Figure `r x`: Unscheduled acute bed days by age group -\newline +Figure `r x` presents the unscheduled bed days rate per 100,000 population in the `r LOCALITY` locality from `r min_ubd_age` to `r max_ubd_age` by age group. + +As presented in Figure `r x`, the highest unscheduled bed days rate for the `r LOCALITY` locality in `r max_ubd_age` is `r latest_ubd_max_age1` bed days per 100,000 population for the `r age_group_max_ubd` age group with a percentage `r max_word_change_ubd` of `r max_rate_change_ubd`% since `r min_ubd_age`. The lowest unscheduled bed days rate for `r LOCALITY` in `r max_ubd_age` is `r latest_ubd_min_age1` bed days per 100,000 population for the `r age_group_min_ubd` age group with a percentage `r min_word_change_ubd` of `r min_rate_change_ubd`% since `r min_ubd_age`. + +####Figure `r x`: Unscheduled acute bed days by age group \newline ```{r echo = FALSE, fig.width= 7.6, fig.height= 4, warning = F} BDs_age_ts @@ -99,13 +108,15 @@ BDs_age_ts x <- x + 1 ``` - ##### Page break ### A&E Attendances -####Figure `r x`: A&E attendances by geographical area -\newline +Figure `r x` presents the A&E attendance rate per 100,000 population in the `r LOCALITY` locality from `r min_year_ae_area` to `r max_year_ae_area`. + +As presented in Figure `r x`, the A&E attendance rate per 100,000 in the `r LOCALITY` locality for `r max_year_ae_area` is `r latest_ae_att_loc1`, `r get_article(percent_rate_change_ae_areas)` `r percent_rate_change_ae_areas`% `r word_change_rate_ae_areas` since `r min_year_ae_area` and the `r HSCP` HSCP rate is `r hscp_ae_att1`, `r get_article(percent_rate_change_ae_areas_hscp)` `r percent_rate_change_ae_areas_hscp`% `r word_change_rate_ae_areas_hscp` since `r min_year_ae_area`. The `r HB` health board rate for `r max_year_ae_area` is `r hb_ae1`, `r get_article(hb_rate_change_ae)` `r hb_rate_change_ae`% `r word_change_hb_ae` since `r min_year_ae_area` and the Scotland rate is `r scot_ae_att1`, `r get_article(percent_rate_change_ae_areas_scot)` `r percent_rate_change_ae_areas_scot`% `r word_change_rate_ae_areas_scot` since `r min_year_ae_area`. + +####Figure `r x`: A&E attendances by geographical area \newline ```{r echo = FALSE, fig.width= 7.6, fig.height= 4, warning = F} AandE_loc_ts @@ -113,8 +124,11 @@ AandE_loc_ts x <- x + 1 ``` -####Figure `r x`: A&E attendances by age group -\newline +Figure `r x` presents the A&E attendance rate per 100,000 population in the `r LOCALITY` locality from `r min_year_ae_area` to `r max_year_ae_area` by age group. + +As presented in Figure `r x`, the highest A&E attendance rate for the `r LOCALITY` locality in `r max_year_ae_age` is `r latest_ae_att_loc1_age` per 100,000 population for the `r age_group_max` age group with a percentage `r word_change_rate_ae_age` of `r percent_rate_change_ae_age`% since `r min_year_ae_age`. The lowest A&E attendance rate for `r LOCALITY` in `r max_year_ae_age` is `r latest_ae_att_loc1_age_min` per 100,000 population for the `r age_group_min` age group with a percentage `r word_change_rate_ae_age2` of `r percent_rate_change_ae_age2`% since `r min_year_ae_age`. + +####Figure `r x`: A&E attendances by age group \newline ```{r echo = FALSE, fig.width= 7.6, fig.height= 4, warning = F} AandE_age_ts @@ -122,36 +136,43 @@ AandE_age_ts x <- x + 1 ``` - ##### Page break ### Emergency Readmissions (28 days) -####Figure `r x`: Emergency readmissions (28 days) by geographical area -\newline +Figure `r x` presents the emergency readmission (28 days) rate per 1,000 discharges in the `r LOCALITY` locality from `r min_year_re_area` to `r max_year_re_area`. + +As presented in Figure `r x`, the emergency readmission (28 days) rate per 1,000 discharges in the `r LOCALITY` locality for `r max_year_re_area` is `r latest_read_loc1`, `r get_article(percent_rate_change_re_area)` `r percent_rate_change_re_area`% `r word_change_rate_re_area` since `r min_year_re_area` and the `r HSCP` HSCP rate is `r hscp_read`, `r get_article(percent_rate_change_re_area_hscp)` `r percent_rate_change_re_area_hscp`% `r word_change_rate_re_area_hscp` since `r min_year_re_area`. The `r HB` health board rate for `r max_year_re_area` is `r hb_read1`, `r get_article(hb_rate_change_read)` `r hb_rate_change_read`% `r word_change_hb_read` since `r min_year_re_area` and the Scotland rate is `r scot_read`, `r get_article(percent_rate_change_re_area_scot)` `r percent_rate_change_re_area_scot`% `r word_change_rate_re_area_scot` since `r min_year_re_area`. + +####Figure `r x`: Emergency readmissions (28 days) by geographical area \newline ```{r echo = FALSE, fig.width= 7.6, fig.height= 4, warning = F} -Read_loc_ts +read_loc_ts x <- x + 1 ``` -####Figure `r x`: Emergency readmissions (28 days) by age group -\newline +Figure `r x` presents the emergency readmission (28 days) rate per 1,000 discharges in the `r LOCALITY` locality from `r min_year_re_age` to `r max_year_re_age` by age group. + +As presented in Figure `r x`, the highest emergency readmission (28 days) rate for the `r LOCALITY` locality in `r max_year_re_age` is `r latest_re_max_age_data` per 1,000 discharges for the `r latest_re_max_age_group` age group with a percentage `r word_change_rate_re_age` of `r percent_rate_change_re_age`% since `r min_year_re_age`. The lowest emergency readmission (28 days) rate for the `r LOCALITY` locality in `r max_year_re_age` is `r latest_re_min_age_data` per 1,000 discharges for the `r latest_re_min_age_group` age group with a percentage `r word_change_rate_re_age_min` of `r percent_rate_change_re_age_min`% since `r min_year_re_age`. + +####Figure `r x`: Emergency readmissions (28 days) by age group \newline ```{r echo = FALSE, fig.width= 7.6, fig.height= 4, warning = F} -Read_age_ts +read_age_ts x <- x + 1 ``` - ##### Page break ### Delayed Discharge Bed Days -####Figure `r x`: Delayed discharge bed days in population aged 65+ by geographical area -\newline +Figure `r x` presents the number of delayed discharge bed days per 100,000 population aged over 65+ in the `r LOCALITY` locality from `r min_year_dd` to `r max_year_dd`. + +As presented in Figure `r x`, the number of delayed discharge bed days per 100,000 population aged over 65+ in the `r LOCALITY` locality for `r max_year_dd` is `r latest_dd_loc1`, `r get_article(percent_rate_change_dd_loc)` `r percent_rate_change_dd_loc`% `r word_change_rate_dd_loc` since `r min_year_dd` and the `r HSCP` HSCP rate is `r hscp_dd1`, `r get_article(percent_rate_change_dd_hscp)` `r percent_rate_change_dd_hscp`% `r word_change_rate_dd_hscp` since `r min_year_dd`. The `r HB` health board rate for `r max_year_dd` is `r hb_dd1`, `r get_article(hb_rate_change_dd)` `r hb_rate_change_dd`% `r word_change_hb_dd` since `r min_year_dd` and the Scotland rate is `r scot_dd1`, `r get_article(percent_rate_change_dd_scot)` `r percent_rate_change_dd_scot`% `r word_change_rate_dd_scot` since `r min_year_dd`. + +####Figure `r x`: Delayed discharge bed days in population aged 65+ by geographical area \newline ```{r echo = FALSE, fig.width= 7.6, fig.height= 4, warning = F} DD_loc_ts @@ -161,8 +182,11 @@ x <- x + 1 ### Emergency admissions from a fall -####Figure `r x`: Falls in population aged 65+ by geographical area -\newline +Figure `r x` presents the emergency admissions from falls rate per 100,000 population aged over 65+ in the `r LOCALITY` locality from `r min_year_falls` to `r max_year_falls`. + +As presented in Figure `r x`, the emergency admissions from falls rate per 100,000 population aged over 65+ in the `r LOCALITY` locality for `r max_year_falls` is `r latest_falls_loc1`, `r get_article(percent_rate_change_falls_loc)` `r percent_rate_change_falls_loc`% `r word_change_rate_falls_loc` since `r min_year_falls` and the `r HSCP` HSCP rate is `r hscp_falls1`, `r get_article(percent_rate_change_falls_hscp)` `r percent_rate_change_falls_hscp`% `r word_change_rate_falls_hscp` since `r min_year_falls`. The `r HB` health board rate for `r max_year_falls` is `r hb_falls1`, `r get_article(hb_rate_change_falls)` `r hb_rate_change_falls`% `r word_change_hb_falls` since `r min_year_falls` and the Scotland rate is `r scot_falls1`, `r get_article(percent_rate_change_falls_scot)` `r percent_rate_change_falls_scot`% `r word_change_rate_falls_scot` since `r min_year_falls`. + +####Figure `r x`: Falls in population aged 65+ by geographical area \newline ```{r echo = FALSE, fig.width= 7.6, fig.height= 4, warning = F} Falls_loc_ts @@ -170,43 +194,44 @@ Falls_loc_ts x <- x + 1 ``` - ##### Page break ### Potentially Preventable Admissions (PPAs) -Information conditions included in PPAs is available in Appendix 3. In `r max_fy`, **`r latest_ppa_65plus`%** of PPAs in `r LOCALITY` were amongst those aged 65 and over, and **`r latest_ppa_under65`%** were amongst those aged under 65. +Information conditions included in PPAs is available in Appendix 3. In `r max_year_ppa_areas`, **`r latest_ppa_65plus`%** of PPAs in `r LOCALITY` were amongst those aged 65 and over, and **`r latest_ppa_under65`%** were amongst those aged under 65. -####Figure `r x`: PPAs by geographical area -\newline +Figure `r x` presents the potentially preventable admissions rate per 100,000 population in the `r LOCALITY` locality from `r min_year_ppa_areas` to `r max_year_ppa_areas`. The rate per 100,000 population for potentially preventable admissions in the `r LOCALITY` locality for `r max_year_ppa_areas` is `r latest_ppa_loc$formatted_data[2]`, `r get_article(ppa_diff)` `r ppa_diff`% `r ppa_word_change` since `r latest_ppa_loc$financial_year[1]` and the `r HSCP` HSCP rate is `r hscp_ppa$data[2]`, `r get_article(ppa_diff_hscp)` `r ppa_diff_hscp`% `r ppa_word_change_hscp` since `r latest_ppa_loc$financial_year[1]`. The `r HB` health board rate for `r hb_ppa$financial_year[2]` is `r hb_ppa$formatted_data[2]`, `r get_article(diff_hb_ppa)` `r diff_hb_ppa`% `r word_change_hb_ppa` since `r hb_ppa$financial_year[]` and the Scotland rate is `r scot_ppa$formatted_data[2]`, `r get_article(diff_scot_ppa)` `r diff_scot_ppa`% `r word_change_scot_ppa` since `r hb_ppa$financial_year[1]`. + +####Figure `r x`: PPAs by geographical area \newline ```{r echo = FALSE, fig.width= 7.6, fig.height= 4, warning = F} -PPA_loc_ts +ppa_loc_ts x <- x + 1 ``` -\newline - +\newline ##### Page break ## Hospital Care (Mental Health Speciality) -###Summary -This section looks at mental health related unscheduled care indicators. +###Summary This section looks at mental health related unscheduled care indicators. **For the most recent time periods available, `r LOCALITY` had:** - - **`r psych_hosp_latest`** psychiatric patient hospitalisations per 100,000, compared to `r scot_psych_hosp` in Scotland^4^. - - **`r latest_bed_days_mh_loc`** unscheduled mental health specialty bed days per 100,000, compared to `r scot_bed_days_mh` in Scotland. +- **`r psych_hosp_latest`** psychiatric patient hospitalisations per 100,000, compared to `r scot_psych_hosp$measure[2]` in Scotland^4^. +- **`r latest_bed_days_mh_loc1`** unscheduled mental health specialty bed days per 100,000, compared to `r scot_bed_days_mh1` in Scotland. \newline ### Psychiatric patient hospitalisations -####Figure `r x`: Psychiatric patient hospitalisations by geographical area -\newline +Figure `r x` presents the psychiatric patient hospitalisation 3-year aggregate rate per 100,000 population in the `r LOCALITY` locality from `r loc_psych_hosp$period_short[1]` to `r loc_psych_hosp$period_short[2]`. + +As presented in Figure `r x`, the 3-year aggregate psychiatric patient hospitalisation rate per 100,000 population in the `r LOCALITY` locality for `r loc_psych_hosp$period_short[2]` is `r loc_psych_hosp$measure[2]`, `r get_article(diff_loc_psych)` `r diff_loc_psych`% `r word_change_loc_psych` since `r loc_psych_hosp$period_short[1]` and the `r HSCP` HSCP rate is `r hscp_psych_hosp$measure[2]`, `r get_article(diff_hscp_psych)` `r diff_hscp_psych`% `r word_change_hscp_psych` since `r loc_psych_hosp$period_short[1]`. The `r HB` health board the 3-year aggregate rate for `r loc_psych_hosp$period_short[2]` is `r hb_psych_hosp$measure[2]`, `r get_article(diff_hb_psych)` `r diff_hb_psych`% `r word_change_hb_psych` since `r loc_psych_hosp$period_short[1]` and the Scotland the 3-year aggregate rate is `r scot_psych_hosp$measure[2]`, `r get_article(diff_scot_psych)` `r diff_scot_psych`% `r word_change_scot_psych` since `r loc_psych_hosp$period_short[1]`. + +####Figure `r x`: Psychiatric patient hospitalisations by geographical area \newline ```{r echo = FALSE, fig.width= 7.6, fig.height= 4, warning = F} psych_hosp_time_trend @@ -214,13 +239,15 @@ psych_hosp_time_trend x <- x + 1 ``` - ##### Page break ### Unscheduled Mental Health Specialty Bed Days -####Figure `r x`: Unscheduled mental health specialty bed days by geographical area -\newline +Figure `r x` presents the unscheduled mental health bed days rate per 100,000 population in the `r LOCALITY` locality from `r min_year_bd_mh_areas` to `r max_year_bd_mh_areas`. + +As presented in Figure `r x`, the unscheduled mental health bed days rate per 100,000 population in the `r LOCALITY` locality for `r max_year_bd_mh_areas` is `r latest_bed_days_mh_loc1`, `r get_article(loc_rate_change_beds_mh)` `r loc_rate_change_beds_mh`% `r loc_word_change_beds_mh` since `r min_year_bd_mh_areas` and the `r HSCP` HSCP rate is `r hscp_bed_days_mh1`, `r get_article(hscp_rate_change_beds_mh)` `r hscp_rate_change_beds_mh`% `r hscp_word_change_beds_mh` since `r min_year_bd_mh_areas`. The `r HB` health board rate for `r max_year_bd_mh_areas` is `r hb_mh_beddays1`, `r get_article(hb_rate_change_mh)` `r hb_rate_change_mh`% `r word_change_hb_mh` since `r min_year_bd_mh_areas` and the Scotland rate is `r scot_bed_days_mh1`, `r get_article(scot_rate_change_beds_mh)` `r scot_rate_change_beds_mh`% `r scot_word_change_beds_mh` since `r min_year_bd_mh_areas`. + +####Figure `r x`: Unscheduled mental health specialty bed days by geographical area \newline ```{r echo = FALSE, fig.width= 7.6, fig.height= 4, warning = F} BDMH_loc_ts @@ -228,8 +255,11 @@ BDMH_loc_ts x <- x + 1 ``` -####Figure `r x`: Unscheduled mental health specialty bed days by age group -\newline +Figure `r x` presents the unscheduled mental health bed days rate per 100,000 in the `r LOCALITY` locality from `r min_year_bd_mh_age` to `r max_year_bd_mh_age` by age group. + +As presented in Figure `r x`, the highest unscheduled mental health bed days rate for the `r LOCALITY` locality in `r max_year_bd_mh_age` is `r latest_bd_mh_max_age1` per 100,000 population for the `r age_group_max_mh` age group with a percentage `r max_word_change_beds_mh` of `r max_rate_change_beds_mh`% since `r min_year_bd_mh_age`. The lowest unscheduled mental health bed days rate for the `r LOCALITY` locality in `r max_year_bd_mh_age` is `r latest_bd_mh_min_age1` per 100,000 population for the `r age_group_min_mh` age group with a percentage `r min_word_change_beds_mh` of `r min_rate_change_beds_mh`% since `r min_year_bd_mh_age1`. + +####Figure `r x`: Unscheduled mental health specialty bed days by age group \newline ```{r echo = FALSE, fig.width= 7.6, fig.height= 4, warning = F} BDMH_age_ts