forked from NHSDigital/rap-package-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
report_template.qmd
190 lines (163 loc) · 7.18 KB
/
report_template.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
---
title: "A&E Attendance Report"
date: "`r Sys.Date()`"
author: Craig R Shenton
date-format: "D MMMM YYYY"
format:
html:
# Table of Contents options
toc: true
toc-depth: 3
toc-location: left
toc-title: Contents
number-sections: false
number-depth: 3
# Render options
theme: cosmo
css: report_styles.css
anchor-sections: false
html-math-method: katex
# Code options
code-tools:
source: false
toggle: false
caption: none
# code-fold: false
# code-summary: "Show code"
embed-resources: true
standalone: true
# URL options
link-external-icon: true
link-external-newwindow: true
# References
citations-hover: true
footnotes-hover: true
callout-appearance: simple
callout-collapse: true
cap-location: bottom
title-block-banner: '#005EB8'
backgroundcolor: '#f0f4f5'
mainfont: 'Open Sans'
execute:
echo: false
crossref:
fig-title: '**Figure**'
fig-labels: arabic
#execute:
# echo: false
---
```{r load library}
#| include: false
# Load libs and global vars
# -------------------------------------------------------------------------
install_and_load_packages <- function(packages, github_packages) {
for (package in packages) {
if (!require(package, character.only = TRUE)) {
install.packages(package,
repos = "https://cran.r-project.org",
dependencies = TRUE
)
library(package, character.only = TRUE)
}
}
if (!requireNamespace("remotes", quietly = TRUE)) {
install.packages("remotes",
repos = "https://cran.r-project.org",
dependencies = TRUE
)
}
for (github_path in github_packages) {
package <- strsplit(github_path, "/")[[1]][2]
if (!require(package, character.only = TRUE)) {
remotes::install_github(github_path)
library(package, character.only = TRUE)
}
}
}
packages <- c("dplyr", "readr",
"here", "DT", "scales",
"lubridate", "plotly",
"targets", "quarto",
"stringr", "stringi", "purrr"
)
github_packages <- c("nhs-r-community/NHSRdatasets",
"ropensci/tarchetypes")
suppressPackageStartupMessages(
install_and_load_packages(packages, github_packages)
)
source(here("utilities/plotly_line_chart_minmax_dropdown.R"))
```
# A&E (Type 1) 4-Hour Performance
The four-hour A&E waiting time target is a pledge set out in the [Handbook to the NHS Constitution][nhs_const]. The operational standard is that at least 95% of patients attending A&E should be admitted, transferred or discharged within four hours.
:::: panel-tabset
## Time-Series
```{r}
#| warning: false
data <- targets::tar_read(ae_attendance_type1_data)
```
```{r}
plotly_line_chart_minmax_dropdown(data = data,
x = "period",
y = "performance",
min = "performance_min",
max = "performance_max",
mean = "performance_average",
target = 0.95,
dropdown = "org_name",
plot_title = " ",
x_lab = "Month of attendance",
y_lab = "Met 4-hour standard",
y_min = 0, y_max = 1.09,
percent = TRUE) %>%
layout(annotations = text_annotate(x = "2016-06-01",
y = 0.99,
color = '#30BCAD',
text = "95% Target"))
```
::: {.callout-note}
## Data source
- [NHS England Statistical Work Areas][nhs_swa]
- Available under the [Open Government Licence v3.0][ogl_v3]
:::
## Data Table
```{r}
df_table <- targets::tar_read(ae_attendance_type1_table)
DT::datatable(df_table,
extensions = 'Buttons',
rownames = FALSE,
options = list(dom = 'Brtip', pageLength = 10, autoWidth = TRUE,
buttons = c('copy', 'csv', 'pdf', 'print')
#lengthMenu = list(c(10,25,50,-1), c(10,25,50,"All")),
#columnDefs = list(list(visible=FALSE, targets=c(0, 3, 4)))
)) %>%
DT::formatStyle(columns = colnames(.$x$data), `font-size` = "14px")
```
## Metadata
This report uses the `ae_attendances` dataset from the [{NHSRdatasets}](https://nhs-r-community.github.io/NHSRdatasets/) package, developed by the [NHS-R Community](https://nhsrcommunity.com/). The dataset contains all reported A&E attendances for the period April 2016 through March 2019.
| Column | Description |
|---|---|
| `period` | The month that this activity relates to, stored as a date (1st of each month) |
| `org_code` | The [ODS code][ods] for the organisation that this activity relates to |
| `type` | The [Department Type][ae_types] for this activity, either 1, 2, or other |
| `attendances` | The number of attendances for this department type at this organisation for this month |
| `breaches` | The number of attendances that breached the 4 hour target |
| `admissions` | The number of attendances that resulted in an admission to the hospital |
### Department Types
According to the [NHS Data Dictonary][ae_types] the type of Accident and Emergency Department is determined according to the activity performed as follows:
| Type | Definition |
|---|---|
| `01` | Emergency departments are a Consulatant led 24 hour service with full resuscitation facilities and designated accommodation for the reception of accident and emergency Patients |
| `02` | Consultant led mono specialty accident and emergency service (e.g. ophthalmology, dental) with designated accommodation for the reception of Patients |
| `03` | Other type of A&E/minor injury activity with designated accommodation for the reception of accident and emergency Patients. The department may be doctor led or NURSE led and treats at least minor injuries and illnesses and can be routinely accessed without appointment. A service mainly or entirely appointment based (for example a GP Practice or Out-Patient Clinic) is excluded even though it may treat a number of Patients with minor illness or injury. Excludes NHS walk-in centres |
| `04` | NHS walk in centres |
::::
The length of time patients spend in A&E before admission, transfer or discharge depends on the type of A&E unit they visit. In the past, minor A&Es (types 2 and 3, such as single specialty departments or minor injury units) nearly always admit, transfer, or discharge in less than four hours, whereas major A&Es (type 1) deal with a higher number of attendees and more serious cases, and consistently perform worse at the four-hour target[^1].
</br>
[tj_email]: mailto:thomas.jemmett@nhs.net
[su_web]: https://www.strategyunitwm.nhs.uk/
[nhs_swa]: https://www.england.nhs.uk/statistics/statistical-work-areas/ae-waiting-times-and-activity/
[ogl_v3]: https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/
[ods]: https://digital.nhs.uk/services/organisation-data-service
[ae_types]: https://web.archive.org/web/20200128111444/https://www.datadictionary.nhs.uk/data_dictionary/attributes/a/acc/accident_and_emergency_department_type_de.asp
[nhs_const]: https://www.gov.uk/government/publications/supplements-to-the-nhs-constitution-for-england/the-handbook-to-the-nhs-constitution-for-england
[^1]: [Nuffield Trust: A&E waiting times](https://www.nuffieldtrust.org.uk/resource/a-e-waiting-times)