A web app to explore opportunities to reduce hospital care via Types of Potentially-Mitigatable Activity (TPMAs).
The app is deployed openly to Posit Connect with no access requirements. Developers can also access a development version of the app.
This section is aimed at maintainers of the tool who work for The Strategy Unit Data Science team.
The app is made with Shiny and is an R package following the nolem approach.
To develop the app, you must first:
- create an
.Renvironfile from the.Renviron.exampletemplate (restart R after making changes to this file) - run
pak::pak()to install required and developmental dependencies from theDESCRIPTION - install Air, which is used for formatting the code
- install Jarl, which is used for linting the code
To launch the app locally for development purposes, run pkgload::load_all() and then run_app().
Before submitting a pull request, run locally:
- an R-CMD check, e.g. from the R console with
devtools::check() - the test suite, e.g. from the R console with
testthat::test(), noting that you must reach 100% test coverage - a format check, e.g. in your terminal with
air format . - a lint check, e.g. in your terminal with
jarl check .
When ready to deploy to Posit Connect, step through the dev/deploy.R script.
Note that you should deploy to the 'dev' deployment following pull-requests, or to 'prod' following a release.
Underlying data is generated via the NHP inputs-data pipeline in the nhp_data repository and is read into the app from the parquet files in the relevant Azure container (named in the AZ_CONTAINER_INPUTS environment variable).
The version of the data fetched by the app is controlled by the DATA_VERSION environment variable.
The value should be dev for local development and for the dev deployment.
The production deployment should set this value to the latest version of the data in the form 'v5.2'.
Note that the inputs-data parquet files are downloaded to the app_data/ folder when you run_app().
Locally, you can force-redownload the data by (a) deleting app_data/ and re-sourcing app.R, or (b) by running get_all_data() with the argument redownload = TRUE.
On the server, authorised devs can invalidate the current data cache by appending ?reset_cache=true to the apps' canonical URLs (i.e. https://connect.strategyunitwm.nhs.uk/tpma-explorer and /tpma-explorer-dev).
The data will be re-fetched the next time the app starts up.
In:
app_data/you can find data downloaded from Azure (ifrun_app()has been run at least once)data-raw/you can can find code used to generate lookups ininst/app/reference/dev/you can find thedeploy.Rscript to deploy to Posit Connectinst/you can find:golem-config.yaml, which contains configuration (copied originally from nhp_inputs)- lookup data files in
app/reference/ - Markdown files under
app/text/, which contain body and tooltip text
R/you can find:- Shiny modules (server and UI components) that are stored in
mod_*.Rscripts - functions to help prepare data in
utils_*.Rscripts - logic for user facing outputs (plots, tables) in
fct_*.Rscripts
- Shiny modules (server and UI components) that are stored in