Skip to content

Commit e5d7972

Browse files
committed
notebook for uclh implementation
1 parent d8b96f8 commit e5d7972

96 files changed

Lines changed: 2908 additions & 15786 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
# Set up your environment
22

3-
Skip this notebook if you are just browsing.
3+
Skip this notebook if you are just browsing.
44

55
In this notebook I will explain where the code looks for data and saves models and media by default, and suggest how to set up your environment. There are two README files that may be useful:
66

7-
* [Repository README](https://github.com/UCL-CORU/patientflow#) in the root of the repository
8-
* [Notebooks README](README.md) in this folder
7+
- [Repository README](https://github.com/UCL-CORU/patientflow#) in the root of the repository
8+
- [Notebooks README](README.md) in this folder
99

1010
## Set notebook to reload functions every time a cell is fun
1111

1212
This is useful if you make any changes to any underlying code
1313

14-
1514
```python
1615
# Reload functions every time
17-
%load_ext autoreload
16+
%load_ext autoreload
1817
%autoreload 2
1918
```
2019

2120
## Check that the patientflow package has been installed
2221

23-
2422
```python
2523
try:
2624
import patientflow
@@ -34,11 +32,9 @@ except Exception as e:
3432

3533
✓ patientflow 0.1.0 imported successfully
3634

35+
## Set project_root variable
3736

38-
## Set project_root variable
39-
40-
The variable called project_root tells the notebooks where the patientflow repository resides on your computer. All paths in the notebooks are set relative to project_root. There are various ways to set it, which are described in the notebooks [README](README.md).
41-
37+
The variable called project_root tells the notebooks where the patientflow repository resides on your computer. All paths in the notebooks are set relative to project_root. There are various ways to set it, which are described in the notebooks [README](README.md).
4238

4339
```python
4440
from patientflow.load import set_project_root
@@ -47,11 +43,9 @@ project_root = set_project_root()
4743

4844
Inferred project root: /Users/zellaking/Repos/patientflow
4945

50-
5146
## Set file paths
5247

53-
Now that you have set the project root, you can specify where the data will be loaded from, where images and models are saved, and where to load the config file from. By default, a function called `set_file_paths()` sets these as shown here.
54-
48+
Now that you have set the project root, you can specify where the data will be loaded from, where images and models are saved, and where to load the config file from. By default, a function called `set_file_paths()` sets these as shown here.
5549

5650
```python
5751
# Basic checks
@@ -71,13 +65,11 @@ else:
7165
Repository root: /Users/zellaking/Repos/patientflow
7266
✓ Synthetic data found
7367

74-
75-
The function will set file paths to default values, as shown here. You can override these as required.
76-
68+
The function will set file paths to default values, as shown here. You can override these as required.
7769

7870
```python
7971
from patientflow.load import set_file_paths
80-
data_file_path, media_file_path, model_file_path, config_path = set_file_paths(project_root,
72+
data_file_path, media_file_path, model_file_path, config_path = set_file_paths(project_root,
8173
data_folder_name=data_folder_name)
8274
```
8375

@@ -86,14 +78,11 @@ data_file_path, media_file_path, model_file_path, config_path = set_file_paths(p
8678
Trained models will be saved to: /Users/zellaking/Repos/patientflow/trained-models/synthetic
8779
Images will be saved to: /Users/zellaking/Repos/patientflow/trained-models/synthetic/media
8880

89-
9081
## Summary
9182

92-
In this notebook you have seen
83+
In this notebook you have seen
9384

94-
* how to configure your environment to run these notebooks
95-
* where the notebooks expect to find data, and where they will save models and media, by default
85+
- how to configure your environment to run these notebooks
86+
- where the notebooks expect to find data, and where they will save models and media, by default
9687

9788
Now you are ready to explore the data that has been provided with this repository
98-
99-
Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
11
# Introducing our users
22

3-
This repository offers predictive modelling to support the management of patient flow in hospitals.
3+
This repository offers predictive modelling to support the management of patient flow in hospitals.
44

55
## What is patient flow?
66

7-
Hospitals refer to the streams of patients arriving and leaving as ‘patient flow’. Unplanned admissions create the ‘emergency’ flow, and the hospital must accommodate that flow alongside a flow of ‘elective’ or planned admissions. Sometimes outflows are reduced because patients are waiting for care to become available in another setting.  
7+
Hospitals refer to the streams of patients arriving and leaving as ‘patient flow’. Unplanned admissions create the ‘emergency’ flow, and the hospital must accommodate that flow alongside a flow of ‘elective’ or planned admissions. Sometimes outflows are reduced because patients are waiting for care to become available in another setting.
88

9-
There are various ways people are admitted to a hospital specialty:
9+
There are various ways people are admitted to a hospital specialty:
1010

1111
- via the Accident & Emergency Department, which is referred to by hospitals as the ED (Emergency Department). Some patients are admitted after visiting Same Day Emergency Care (SDEC). Here, we refer to the combined flows from ED and SDEC as coming via the ED
12-
- as planned (or elective) admissions
12+
- as planned (or elective) admissions
1313
- as an emergency admission via another route, like a transfer from another hospital
1414
- as an internal transfer from another specialty in the same hospital
1515

16-
And various ways people leave a hospital specialty:
16+
And various ways people leave a hospital specialty:
1717

1818
- as a discharge from hospital, to home or another care setting
1919
- as an internal transfer to another specialty within the same hospital
2020
- as a death
2121

2222
If patient flow works well, each patient will receive timely and appropriate care from the right specialty team, without undue delays. An example of poor patient flow is when incoming patients experience delays to admission because inpatients are not being discharged.
2323

24-
Due to imbalances in admissions and discharges, pressures can build up in certain parts of the hospital, while other parts remain relatively less pressured. When one specialty is under pressure, new patients may be housed in the wrong ward - ie a ward that is not dedicated to the specialty they are under. In this case they are referred to as 'outliers'. Outlying is not ideal; evidence indicates it can lead to worse clinical outcomes and longer stays in hospitals.
24+
Due to imbalances in admissions and discharges, pressures can build up in certain parts of the hospital, while other parts remain relatively less pressured. When one specialty is under pressure, new patients may be housed in the wrong ward - ie a ward that is not dedicated to the specialty they are under. In this case they are referred to as 'outliers'. Outlying is not ideal; evidence indicates it can lead to worse clinical outcomes and longer stays in hospitals.
2525

26-
Hospitals strive to keep patient flow going, across all specialties, so far as they are able to.
26+
Hospitals strive to keep patient flow going, across all specialties, so far as they are able to.
2727

2828
## Who is responsible for managing patient flow?
2929

3030
All hospital staff share responsibility for patient flow, but a team of bed managers takes primary responsibility for managing it. Bed managers are usually senior nurses with a good understanding of each patient's likely care needs. Their work involves responding to rapidly changing situations caused by delays in patient care, infection outbreaks, excess demand for beds, and other incidents.
3131

3232
To keep track of the changing situation, bed managers convene "flow huddles" three times a day. In these huddles, staff from the emergency department and from each ward meet with bed managers to discuss patients coming in (as either emergency or planned admissions), and review which inpatients are likely to be discharged. The flow huddles provide a picture of likely areas of pressure on beds.
3333

34-
If bed pressures are anticipated, bed managers can take action by trying to accelerate discharges, or opening up temporary beds and finding staff to cover them, or temporarily divert ambulances to another hospital. These decisions have consequences for patients, staff and other hospitals.
34+
If bed pressures are anticipated, bed managers can take action by trying to accelerate discharges, or opening up temporary beds and finding staff to cover them, or temporarily divert ambulances to another hospital. These decisions have consequences for patients, staff and other hospitals.
3535

36-
## What information do bed managers use to manage patient flow?
36+
## What information do bed managers use to manage patient flow?
3737

38-
Bed managers' decisions depend on having a clear picture of current capacity and imminent pressures. They like to know how many beds will be needed for new patients by the end of the day or shift, and how many will become available during that time. To predict how many beds will be needed today, they assume the number will be the same as yesterday. To work out how many patients will leave, they apply a simple rule based on patients' expected dates of discharge.
38+
Bed managers' decisions depend on having a clear picture of current capacity and imminent pressures. They like to know how many beds will be needed for new patients by the end of the day or shift, and how many will become available during that time. To predict how many beds will be needed today, they assume the number will be the same as yesterday. To work out how many patients will leave, they apply a simple rule based on patients' expected dates of discharge.
3939

40-
These are simple rules of thumb, that are based on static information. Many hospitals have Electronic Health Records (EHRs), into which data are being entered all the time. That up-to-date information could provide a better view; bed managers' understanding of the current situation, and their projection of how it will develop, could be refreshed as new information comes into the EHR.
40+
These are simple rules of thumb, that are based on static information. Many hospitals have Electronic Health Records (EHRs), into which data are being entered all the time. That up-to-date information could provide a better view; bed managers' understanding of the current situation, and their projection of how it will develop, could be refreshed as new information comes into the EHR.
4141

42-
## What modelling is useful to bed managers?
42+
## What modelling is useful to bed managers?
4343

44-
I'm [Zella King](https://github.com/zmek/), a health data scientist in the Clinical Operational Research Unit (CORU) at University College London. I started working with University College London Hospital (UCLH) in 2020 because the hospital wanted to make better use of the data streaming into its EHR. My colleague Prof Sonya Crowe led a small project to create a prototype of a predictive model of emergency demand that used real-time data. Through that project, and over the subsequent years, we have come to understand the needs of bed managers from predictive modelling.
44+
I'm [Zella King](https://github.com/zmek/), a health data scientist in the Clinical Operational Research Unit (CORU) at University College London. I started working with University College London Hospital (UCLH) in 2020 because the hospital wanted to make better use of the data streaming into its EHR. My colleague Prof Sonya Crowe led a small project to create a prototype of a predictive model of emergency demand that used real-time data. Through that project, and over the subsequent years, we have come to understand the needs of bed managers from predictive modelling.
4545

46-
*What bed managers want from predictive models*
46+
_What bed managers want from predictive models_
4747

4848
- **Predictions issued at the times of day they need them:**
49-
Our users have a routine where they prepare a situation report of hospital capacity five times each day, and have flow huddles three times a day. They wanted predictions of bed demand to be available to them in the preparation of the reports, and at the flow huddles.
49+
Our users have a routine where they prepare a situation report of hospital capacity five times each day, and have flow huddles three times a day. They wanted predictions of bed demand to be available to them in the preparation of the reports, and at the flow huddles.
5050

5151
- **Predictions over a rolling window:**
52-
The current heuristics used widely across the NHS rely on daily averages, which means that a patient flow meeting will focus on projections up to midnight that day. A rolling prediction of 8 to 12 hours is more useful, because it enables conversation about what needs to be done during the current day or night shift, in order to head off pressures later.
52+
The current heuristics used widely across the NHS rely on daily averages, which means that a patient flow meeting will focus on projections up to midnight that day. A rolling prediction of 8 to 12 hours is more useful, because it enables conversation about what needs to be done during the current day or night shift, in order to head off pressures later.
5353

5454
- **Output at aggregate level rather than individual:**
5555
It is common for researchers using statistics or Machine Learning to produce models that predict each patient's probability of admission. However, this is not useful for bed managers because, when managing capacity, they are mainly interested in overall numbers of beds needed, rather than whether any particular patient will be admitted.
@@ -58,20 +58,13 @@ I'm [Zella King](https://github.com/zmek/), a health data scientist in the Clini
5858
Predictive models can be trained on historical patterns of admissions and discharges. However, if they can make use of real-time data from the EHR, bed managers will have a better sense of today's demand, rather than that of a typical day.
5959

6060
- **A breakdown of demand by specialty:**
61-
Knowing that the whole hospital is going to be short of beds is somewhat useful and does give a sense of the scale of the problem. More precise information - about which specialties are most affected - makes it easier to pinpoint where action is needed.
61+
Knowing that the whole hospital is going to be short of beds is somewhat useful and does give a sense of the scale of the problem. More precise information - about which specialties are most affected - makes it easier to pinpoint where action is needed.
6262

6363
- **Some sense of the uncertainty of predictions:**
64-
Simple heuristics give bed managers a single number to work with. For example, if 50 patients were admitted yesterday, they might plan for 50 today. This doesn't show how likely the number 50 is; could it be 46 or 54? A good model will give a sense of uncertainty around the suggested number of beds. Ironically, knowing the spread of the uncertainty gives a more certain picture.
65-
66-
## What are the elements of patient flow?
67-
68-
Above, I said that bed managers want a breakdown of demand by specialty. Let's break down the sources of that demand.
69-
70-
71-
I intend that this repository will show how to model all of these flows eventually.
72-
73-
74-
64+
Simple heuristics give bed managers a single number to work with. For example, if 50 patients were admitted yesterday, they might plan for 50 today. This doesn't show how likely the number 50 is; could it be 46 or 54? A good model will give a sense of uncertainty around the suggested number of beds. Ironically, knowing the spread of the uncertainty gives a more certain picture.
7565

66+
## What are the elements of patient flow?
7667

68+
Above, I said that bed managers want a breakdown of demand by specialty. Let's break down the sources of that demand.
7769

70+
I intend that this repository will show how to model all of these flows eventually.

0 commit comments

Comments
 (0)