This repository contains the Reproducible Analytical Pipeline (RAP) to produce the quarterly statistics on clinical prioritisation, part of the Stage of Treatment (SoT) publication.
The repository also contains the necessary code to run and deploy the accompanying shiny app.
The publication, released on 06 September 2022, is a one-off retrospective analysis of data relating to the Scottish Government's clinical prioritisation Framework, and covers the period July 2021 to June 2022. The Framework became no longer applicable as of 22 July 2022.
-
Create a
datafolder with subfolderprocessed_data -
Transfer the necessary input files to the
datafolder. You can use the helper function infunctions/admin_functions.Rto do this. See "Input data files" below for the files you need. -
Run
code/Main.R(takes ~ 5 minutes). This-
Processes the data in
dataand saves it out indata/processed data -
Creates plots and saves them out in
plots(the code will create this folder if it doesn't already exist) -
Transfers the processed data from
data/processed datatoshiny_app/dataas .rds files so that the shiny app can run
-
-
Launch shiny app by running
shiny_app/app.R
You will need the following data in your data folder - obtain from colleagues
- Distribution of Waits 4 week bands.xlsx
- Distribution of Waits larger time bands.xlsx
- dq_summaries.csv
- Performance excl. Lothian Dental Monthly.xlsx
- Performance excl. Lothian Dental Quarterly.xlsx
- Removal Reason excl. Lothian Dental.xlsx
- Spec Exclusions.xlsx
The code for the shiny app can be found in the shiny_app folder
You can password protect the app for pre-release access.
-
Open
shiny_app/admin/create_crententials.R(hidden file not pushed to Github - obtain this separately from collaborators) -
Edit the script with the chosen username and password for pre-realease access
credentials_df <- data.frame(
user = c("username"), # insert username here
password = c("password"), # insert password here
stringsAsFactors = FALSE)
-
Save your changes and run the script. The script creates a folder called
admin(if it doesn't already exist). Check that thecredentials.rdsfile is saved to your admin folder. -
Go to
shiny_app/app.R, uncomment thesecure_app()function in the ui. (make sure to uncomment both opening and closing brackets) -
Run the app to check that the login page is active and test your credentials.
-
Note: the
adminfolder is ignored by git to prevent sharing credentials on Github.
-
Open
shiny_app/AppDeployment.R(hidden file not committed to Github - obtain this separately) and edit the paths to point to your localshiny_appfolder -
Run the script to deploy the app
-
datacontains all the data needed for the shiny app. It is populated using theapp_data_preparation.Rscript -
app.Ris the main app file -
AppDeployment.Ris for deploying the app -
setup.Rcontains the necessary packages and some settings. Loads all the data inshiny_app/datainto a list calledapp_data. Initialises two lists of reactive values:plots, which will contain all the rendered plots, andnumberswhich will contain all the rendered numbers and tables. -
wwwcontains the css stylesheet and images -
pagescontains separate R scripts of app content, one for each page of the app -
functionscontains R scripts with the functions corresponding to each of the app pages. Additionallycore_functions.Rhas some useful centralised functions,navigation_buttons.Rhas the links for the navigation buttons andmodals.Rdefines information modals which pop up with information when you click on them