This repository contains the code for a project carried out by the Strategy Unit on behalf of the Networked Data Lab team at the Health Foundation. The project seeks to understand patients' use of community services after hospital discharge in England.
The resulting report from this analysis can be found on the Strategy Unit's Posit Connect server.
The analysis draws upon two key datasets: the Community Services Dataset and the Admitted Patient Care (Spells) dataset.
The analysis is composed of the following components:
-
The identification of patients receiving step-down intermediate care. This involves applying an agreed set of identification rules, agreed with the Health Foundation, to the raw datasets.
-
A description of step-down intermediate care packages (number, service intensity, delivery mode, provider type etc) and changes in the frequency of these packages over time.
-
A description of the characteristics of patients receiving intermediate care, inclusing their demographic characteristics (age, sex, deprivation of area of residence, ethnicity, region), the clinical features of the admission that led to their use of intermediate care (admission method, treatment function, ICD10 chapter of primary diagnosis) and whether they received community services before admission.
-
An analysis of the factors that influence whether a patient receives a step-down intermediate care packages following a hospital dischrage and the intensity of that package.
-
A summary of the progress and outcomes of step-down intermeidate care recipients (hospital length of stay, changes in service intensity over the course of the care package, hospital readmissions, mortality).
-
An exploration of the impact of using alternative rules to identify step-down intermediate care, on the key components of the analysis above.
This code was written and is design to be executed within the National Commissionning Data Repository environment.
In a terminal window at the project root (e.g. from the terminal tab in RStudio) run:
powershell .\create_project_directories.ps1
If you get an error about running scripts being disabled on this system instead you can temporarily disable them:
powershell -executionpolicy remotesigned
Now you can run the script with .\create_project_directories.ps1
The script sql\create_tb_distinct_nhs_nos.sql creates a table of pseudonymised NHS numbers for people who have both a relevant hospital admission and a community services contact within the study period.
The scripts R\get_admissions.R and R\get_csds.R extract relevant event-level data from the SUS Admitted Patient Care and Community Services Dataset tables and saves these as parquet files.
The following scripts process the parquet files from the step above, applying the (primary analysis and sensitivity analysis) rules to identify step-down intermediate care packages and the patients who receive them.
-
R\x01_create_admissions_datasets.R -
R\x02_create_contacts_datasets.R -
R\x03_define_icare_records.R -
R\x04_create_analysis_datasets.R -
R\x05_lookup_nearby_contacts.R -
R\x06_create_nzlos_analysis_dataset.R
The core analysis is carried out in four files using the analysis datasets produced in the previous step. Each produces both tables and visual outputs.
-
R\B SDIC characteristics.Rdescribes the packages of step-down intermediate care that patients receive. -
R\C SDIC patient characteristics.Rdescribes the patients receiving these services. -
R\D Factors influencing package receipt and intensity.Rcreates and explores two regression models which explore the factors that influence who gets a step-down intermediate care package and the intensity of these packages. -
R\E Sensitivity analysis.Rexplores whether the headline figures in the above analysis are sensitive to variations in the rules used to identify step-down intermediate care.
The quarto report, and associated data sheet can be produced without (or with!) running other scripts. Details of what files are needed to produce the report can be found in R\produce_quarto.R.