Explore and compare schemes' mitigator selections as part of the National Hospital Programme (NHP) modelling process.
This tool is designed primarily for use by model-relationship managers (MRMs) in discussion with schemes so that the mitigator selections can be refined before being finalised.
The app is deployed to Posit Connect (login/permissions required).
The app is built with {shiny}, {golem} and {bslib}.
You must ensure you have installed the packages listed in the DESCRIPTION
.
These can be installed with devtools::install_deps(dependencies = TRUE)
.
This repo doesn't use {renv}.
You must set some environmental variables before you can run the app locally on your machine.
To do this, add an .Renviron
file to the project directory that contains the variables named in the .Renviron.example
file.
You can ask a member of the Data Science team for the values to populate this file.
If using RStudio, you should ensure you're connected to the Posit Connect server. To do this, go to to Tools > Global options > Publishing and then click the 'Connect' button. Follow the steps to connect your account on the connect.strategyunitwm.nhs.uk server via the browser, if you haven't already.
If not using RStudio, the alternative method is to set a couple more environment variables in your .Renviron
file: CONNECT_SERVER
and CONNECT_API_KEY
.
CONNECT_SERVER
is connect.strategyunitwm.nhs.uk
.
Your CONNECT_API_KEY
can be generated by logging into Posit Connect, clicking your name in the upper-right, selecting 'manage your API keys' and then clicking 'add API key'.
Remember to restart your session after you've updated your .Renviron
file.
Source the dev/run_dev.R
script to run the app, assuming you've installed the packages and set up the environment variables.
You can redeploy the app to Posit Connect using the dev/03_deploy.R
script.
This usually happens after a new GitHub release/Git tag.
This app fetches model results files from Azure. These files are large json files that bundle the model results and the the mitigator selections, which are stored in an element called 'params' (parameters).
To avoid the app having to read the entire json file for each scheme's model scenario, there is a system to pre-prepare the params alone. A scheduled Quarto document on Posit Connect has code to select the appropriate json file, extract the params and save them as an RDS file to a pin on Posit Connect. It also saves a CSV file to another pin that contains metadata about the model scenarios. The app then reads data from these pins using the {pins} package. A blogpost by the Data Science team contains note on authenticating RStudio with Posit Connect, should you need to.
Schemes run many scenarios, but the app only displays data from a single scenario, preferably the one used to compile their outputs ('final') report. MRMs tell the Data Science team which particular results file should be labelled manually on Azure with the 'run stage' metadata of 'final' (and possibly 'intermediate' or 'initial'). There's a handy lookup table (login/permissions required) where you can see the scenario files that have been given run-stage metadata.
Supporting data is fetched from Azure. This includes lookups for mitigators and schemes, baseline trend data, as well as data from the National Elicitation Exercise (NEE).