-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathREADME.Rmd
More file actions
executable file
·184 lines (136 loc) · 11.5 KB
/
Copy pathREADME.Rmd
File metadata and controls
executable file
·184 lines (136 loc) · 11.5 KB
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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
# set a seed so that the waiting list example is consistent
set.seed(2)
```
# NHSRwaitinglist
<a alt="NHS-R Community's logo" href='https://nhsrcommunity.com/'><img src='https://nhs-r-community.github.io/assets/logo/nhsr-logo.png' align="right" height="80" /></a>
<!-- badges: start -->
[](#contributors-)
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[](https://github.com/nhs-r-community/NHSRwaitinglist/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/nhs-r-community/NHSRwaitinglist?branch=main)
[](https://cran.r-project.org/package=NHSRwaitinglist)
<!-- badges: end -->
{NHSRwaitinglist} is an R package implementing the waiting list management approach described in the paper [Understanding Waiting Lists Pressures](https://www.medrxiv.org/content/10.1101/2022.08.23.22279117v1) by Fong et al (2022). The methodology is presented by Neil Walton, Professor in Operations Management at Durham University Business School. The package is being contributed to by members of the [NHS-R Community](https://nhsrcommunity.com/), with the aim of making it simpler for NHS analysts to adopt these methods for the analysis of their own waiting lists.
## Explanatory Videos
These videos explain more about the Operations Management methodologies which are encapsulated by the package. Click through to view them on YouTube.
Detailed presentation of method | Recap of method, and presentation of this package
:---:|:---:
[](https://www.youtube.com/watch?v=NWthhW5Fgls) | [](https://www.youtube.com/watch?v=3peqTEl_ZAQ)
Midlands Analyst Network Huddle, Nov 2023 | Health and Care Analytics Conference e-lab, Jul 2024
## Installation
You can install the current version of {NHSRwaitinglist} from GitHub as below.
If you have not installed from GitHub before, you may first need to create and store a "Personal Access Token" (PAT) to grant access to your account, for example by following the [{usethis} guide](https://usethis.r-lib.org/articles/git-credentials.html#get-a-personal-access-token-pat).
```r
# Install from CRAN
install.packages("NHSRwaitinglist")
# install.packages("remotes")
remotes::install_github("nhs-r-community/NHSRwaitinglist", build_vignettes = TRUE)
```
## Getting Started
There is a minimal example below. To look in more detail at the functions within the package and some more ways of using them, it is a good idea to review the vignettes:
1. The [example walkthrough](https://nhs-r-community.github.io/NHSRwaitinglist/articles/example_walkthrough.html) vignette takes a step-by-step walk through the white paper, using the six core functions in this package.
2. The [three example waiting lists](https://nhs-r-community.github.io/NHSRwaitinglist/articles/three_example_waiting_lists.html) vignette simulates three closely related waiting lists, and uses package functions to explore some of their characteristics.
3. The [histogram analysis](https://nhs-r-community.github.io/NHSRwaitinglist/articles/histogram_analysis.html) vignette shows how to work with aggregated/binned waiting list data, ideal for analysing NHS national statistics.
At its most basic, the package can be used to simulate a waiting list (a dataframe of waiting list addition dates and removal dates), and then compute some important statistics. Of course, if you already have waiting list data ready to analyse, you can skip the simulation step in the code below.
```{r}
# load the package
library(NHSRwaitinglist)
# simulate a waiting list
waiting_list <- wl_simulator(
start_date = "2020-01-01",
end_date = "2024-03-31",
demand = 10, # simulating 10 patient arrivals per week
capacity = 10.2 # simulating 10.2 patients being treated per week
)
# compute some waiting list statistics
overall_stats <- wl_stats(
waiting_list = waiting_list,
target_wait = 18 # standard NHS 18wk target
)
# review the minimal dataset needed to define a waiting list (first 5 rows only)
knitr::kable(head(waiting_list, 5))
# review the waiting list statistics
knitr::kable(overall_stats)
```
## Reporting functions
In addition to the underlying method functions above, there are some convenience functions designed to quickly product plots for RTT improvement discussions with clinical specialties. `plot_rtt_journey()` produces plots as demonstrated below, while `rep_rtt_improvement()` is a quarto report generating function that makes
it easy to produce a discussion document covering multiple referral rates.
```{r plot_rtt_journey, fig.height=5, fig.width=8}
# produce a single plot showing waiting list and RTT size for a specialty
# with a referral rate of 300 patients per week
plot_rtt_journey(300)
```
## Working with Aggregated Data (Histograms)
The package also supports analysis of aggregated or binned waiting list data (histogram format), which is particularly useful for:
- Analysing publicly available NHS national statistics
- Privacy-preserving analysis (no individual patient records)
- Working with time-bucketed summary data
```{r histogram-example}
# Example: Histogram format with 2 time points (needed for removal statistics)
wl_hist <- data.frame(
arrival_since = as.Date(c(
"2024-01-24", "2024-01-17", "2024-01-10",
"2024-02-21", "2024-02-14", "2024-02-07"
)),
arrival_before = as.Date(c(
"2024-01-30", "2024-01-23", "2024-01-16",
"2024-02-27", "2024-02-20", "2024-02-13"
)),
n = c(45, 38, 52, 42, 35, 48), # Patient counts in each week
report_date = as.Date(c(rep("2024-01-31", 3), rep("2024-02-29", 3)))
)
# Compute statistics from histogram data
hist_stats <- wl_stats_hist(
wl_hist = wl_hist,
target_wait = 18
)
knitr::kable(hist_stats)
```
See the [histogram analysis vignette](https://nhs-r-community.github.io/NHSRwaitinglist/articles/histogram_analysis.html) for a comprehensive guide.
## Contributing
If you want to learn more about this project, please join the discussion at the [NHS-R Community Slack](https://nhsrcommunity.slack.com/) group and the specific channel #managing-waiting-lists.
Please see our
[guidance on how to contribute](https://tools.nhsrcommunity.com/contribution.html).
This project is released with a Contributor [Code of Conduct](https://github.com/nhs-r-community/NHSRwaitinglist/blob/main/CODE_OF_CONDUCT.md).
By contributing to this project, you agree to abide by its terms.
The simplest way to contribute is to [raise an issue](https://github.com/nhs-r-community/NHSRwaitinglist/issues) detailing the feature or functionality you would like to see added, or any unexpected behaviour or bugs you have experienced.
### Pull-Request workflow
You are welcome to also submit Pull Requests and, as the `main` branch is protected and won't accept pushes directly even if you have been added to the repository as a member, the workflow will be (from your own forked repository if you are not a member, or a clone of the repository if you are a member):
* Create new branch with a descriptive name
* Commit to the new branch (add code or delete code or make changes)
* Push the commits
* Create a pull-request in GitHub to signal that your work is ready to be merged
* Tag one or more reviewers (@ThomUK and @ChrisMainey) so that your contribution can be reviewed and merged into main
## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://github.com/all-contributors/all-contributors/blob/master/docs/emoji-key.md)):
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tbody>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/jacgrout"><img src="https://avatars.githubusercontent.com/u/103451105?v=4?s=100" width="100px;" alt="Jacqueline Grout"/><br /><sub><b>Jacqueline Grout</b></sub></a><br /><a href="#ideas-jacgrout" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/nhs-r-community/NHSRwaitinglist/commits?author=jacgrout" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ThomUK"><img src="https://avatars.githubusercontent.com/u/10871342?v=4?s=100" width="100px;" alt="Tom Smith"/><br /><sub><b>Tom Smith</b></sub></a><br /><a href="https://github.com/nhs-r-community/NHSRwaitinglist/commits?author=ThomUK" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://www.matt-dray.com/"><img src="https://avatars.githubusercontent.com/u/18232097?v=4?s=100" width="100px;" alt="Matt Dray"/><br /><sub><b>Matt Dray</b></sub></a><br /><a href="https://github.com/nhs-r-community/NHSRwaitinglist/commits?author=matt-dray" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/kaituna"><img src="https://avatars.githubusercontent.com/u/151142766?v=4?s=100" width="100px;" alt="kaituna"/><br /><sub><b>kaituna</b></sub></a><br /><a href="https://github.com/nhs-r-community/NHSRwaitinglist/commits?author=kaituna" title="Documentation">📖</a> <a href="https://github.com/nhs-r-community/NHSRwaitinglist/commits?author=kaituna" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/chrismainey"><img src="https://avatars.githubusercontent.com/u/39626211?v=4?s=100" width="100px;" alt="Chris Mainey"/><br /><sub><b>Chris Mainey</b></sub></a><br /><a href="https://github.com/nhs-r-community/NHSRwaitinglist/commits?author=chrismainey" title="Code">💻</a> <a href="https://github.com/nhs-r-community/NHSRwaitinglist/commits?author=chrismainey" title="Documentation">📖</a> <a href="https://github.com/nhs-r-community/NHSRwaitinglist/commits?author=chrismainey" title="Tests">⚠️</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/PeterSNHS"><img src="https://avatars.githubusercontent.com/u/67410797?v=4?s=100" width="100px;" alt="PeterSNHS"/><br /><sub><b>PeterSNHS</b></sub></a><br /><a href="https://github.com/nhs-r-community/NHSRwaitinglist/commits?author=PeterSNHS" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/neilwalton"><img src="https://avatars.githubusercontent.com/u/53338269?v=4?s=100" width="100px;" alt="neilwalton"/><br /><sub><b>neilwalton</b></sub></a><br /><a href="https://github.com/nhs-r-community/NHSRwaitinglist/commits?author=neilwalton" title="Code">💻</a> <a href="https://github.com/nhs-r-community/NHSRwaitinglist/commits?author=neilwalton" title="Documentation">📖</a></td>
</tr>
</tbody>
</table>
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!