Skip to content

The-Strategy-Unit/nhp_inputs

Repository files navigation

NHP Inputs

Project Status: Active – The project has reached a stable, usable state and is being actively developed. check

About

A web app to input the parameters needed to run scenarios through the New Hospital Programme (NHP) demand model.

The app is deployed to Posit Connect. You must have an account and sufficient permissions to view it.

Results can then be viewed in the outputs app, which is generated from the nhp_outputs repository.

You can find more information on the NHP model project information site, including a diagram of how the components of the modelling process fit together.

For developers

The app is built and maintained by members of the Strategy Unit’s Data Science team.

Structure

Technically there are two apps: the main app in the main branch, and the inputs selection app (where users start or edit a scenario) in the inputs_selection_app branch. Users arrive at the selection app before being routed to the main app.

Both apps are built with Shiny and the main app uses the the {golem} package. Server and UI modules can be found in R/, configuration in inst/golem-config.yml and supporting data and text in inst/app/.

Packages used in the app are listed in DESCRIPTION, and can be installed with devtools::install_deps(dependencies = TRUE).

Run locally

Run the app locally on your machine to test that your changes work as expected.

To prepare, add an .Renviron file to the project root that contains the required environment variables. There is an .Renviron.example file which describes the required variables. You can get these from a member of the Data Science team.

Then, from the main branch (or your development branch of it), use Git’s worktree function to put the inputs_selection_app branch (or your development branch of it) in its own subfolder.

In the terminal:

git fetch origin inputs_selection_app
git worktree add inputs_selection_app inputs_selection_app

If you want a development version of the inputs selection app, you can specify the branch name as the second of the arguments to git worktree add.

To run the app from RStudio, start up the selection app by opening the dev/watch.R script, go to the ‘Background Jobs’ tab of the console pane and click the ‘Start Background Job’ button. In the ‘Run Script as Background Job’ dialog box select the project root as the ‘Working Directory’, then hit ‘Start’. When ready, the app will tell you to visit http://127.0.0.1:9081/ in your browser.

Note that your selections in the app remain local to you and the resulting json file of parameters for your scenario will live in your local params/development/ directory. These scenarios will be selectable and editable in future from your locally-run inputs selection app.

If you need to remove the selection-app folder at any point, you can terminate the background job (if running) and in the terminal run:

git worktree remove inputs_selection_app

Test in dev

During pre-release QA we test both apps on the server. This helps us spot any issues that are server-specific and might be overlooked if running the apps locally.

To test the unreleased app in our development environment, first ensure you’ve (a) merged any PRs you want to test into the main branch and, if you’ve made any changes to the inputs selection app, (b) run the manual deploy() call under the ‘development’ heading in the deploy.R script in your selection app development branch.

When using the dev inputs selection app on Connect, make sure to set the ‘Model Version’ dropdown to ‘dev’ in the expandable ‘Advanced Options’ box. That way you’ll be taken to the dev inputs app when you hit ‘Start’.

Data extraction

The app displays trust-specific data to users. The data is processed via Databricks scripts in the nhp_data repository and stored in Azure storage.

Deployment

Deployment is controlled by GitHub Actions, where:

  • pushes to the main branch redeploy the app to /nhp/dev/inputs/ for purposes of quality assurance
  • tagged releases trigger a new deployment to /nhp/vX-Y/inputs/, where ‘vX-Y’ is the current version (note the hyphen)

About

Shiny application which controls to input parameters used to run the NHP model

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Packages

No packages published

Contributors 9

Languages