https://github.com/the-strategy-unit/nhp_inputs
Shiny app: input parameters for the New Hospital Programme (NHP) demand model
https://github.com/the-strategy-unit/nhp_inputs
new-hospital-programme nhp-core nhp-operational
Last synced: 5 months ago
JSON representation
Shiny app: input parameters for the New Hospital Programme (NHP) demand model
- Host: GitHub
- URL: https://github.com/the-strategy-unit/nhp_inputs
- Owner: The-Strategy-Unit
- License: other
- Created: 2022-08-22T13:42:22.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2026-01-22T21:09:32.000Z (5 months ago)
- Last Synced: 2026-01-23T09:16:17.260Z (5 months ago)
- Topics: new-hospital-programme, nhp-core, nhp-operational
- Language: R
- Homepage: https://connect.strategyunitwm.nhs.uk/nhp/inputs/
- Size: 3.64 MB
- Stars: 1
- Watchers: 5
- Forks: 0
- Open Issues: 61
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# NHP Inputs
[](https://www.repostatus.org/#active)
[](https://github.com/The-Strategy-Unit/nhp_inputs/actions/workflows/check.yaml)
## 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](https://connect.strategyunitwm.nhs.uk/nhp/inputs/).
You must have an account and sufficient permissions to view it.
Results can then be viewed in [the outputs app](https://connect.strategyunitwm.nhs.uk/nhp/outputs/), which is generated from the [nhp_outputs](https://github.com/The-Strategy-Unit/nhp_outputs) repository.
You can find more information on [the NHP model project information site](https://connect.strategyunitwm.nhs.uk/nhp/project_information/), including [a diagram](https://connect.strategyunitwm.nhs.uk/nhp/project_information/project_plan_and_summary/components-overview.html) 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](https://the-strategy-unit.github.io/data_science/).
### 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](https://shiny.posit.co/) and the main app uses the [the {golem} package](https://thinkr-open.github.io/golem/). 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:
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 extraction
The app displays trust-specific data to users.
The data is processed via Databricks scripts in [the nhp_data repository](https://github.com/The-Strategy-Unit/nhp_data) 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)