Skip to content

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 guidance below is for the members of the Strategy Unit's Data Science team, who built and maintain this app.

Structure

Technically this app uses the inputs selection app packaged up for use here in directing users to either the latest (default) or a previous version that they select.

Both apps are built with Shiny and this uses 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/.

Run locally

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

Setup

First, install the required packages listed in the DESCRIPTION with

pak::local_install_dev_deps(dependencies = TRUE)

Then add an .Renviron file to the project root that contains the required environment variables. Copy into it the required variables, which are listed in the .Renviron.example. You can get the values you need from a member of the Data Science team.

Run the app

Once setup, we can run the app

source('dev/watch.R')

Making selections in the app will cause values to be written to a local json file, which will live in your local params/[development]/ directory. These scenarios will be selectable and editable in future from your locally-run inputs selection app. They will not be available from the deployed 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:

  1. Merge any PRs you want to test into the main branch.
  2. If you’ve changed any dependencies, run dev/generate_manifest.R to update manifest.json.
  3. If you’ve made any changes to the inputs selection app, 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

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.

If the data updates and you need to invalidate the current cache, you force a reset by appending ?reset_cache=true to the app’s canonical URL at https://connect.strategyunitwm.nhs.uk/nhp/inputs/ (authorised devs only).

Deployment

Deployment is controlled by GitHub Actions in .github/workflows/, 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)
  • manual deployment is possible with connect-publish-manual.yaml

About

Shiny app: input parameters for the New Hospital Programme (NHP) demand model

Topics

Resources

Stars

2 stars

Watchers

4 watching

Forks

Releases

Used by

Contributors

Languages