Skip to main content

The New Hospital Programme Demand Model

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

Welcome

Welcome to the New Hospital Programme demand and capacity modelling tool.

Smarter Hospital Planning

This repository contains the model code but there are several other repositories which contain useful tools to explore the data underpinning and set the parameters for the model, as well as to explore model outputs. An overview of how the different tools interact with each other is available.

The methodology underpinning this model is outlined in this simple one page explainer. We have a more technical project information site which includes further details about the model and the data that the model was built on.

Running the model

For external users

Although all the code is available openly, it is challenging to run the model if you do not have access to the data and infrastructure at the Strategy Unit.

We use national Hospital Episode Statistics data which goes through extensive processing, as detailed in the nhp_data repository. Some of the types of potentially mitigable activity rely on having access to the full national dataset, not just a local dataset. Without this data and infrastructure, your data will not be correctly formatted to run in the model.

We are working on providing synthetic data so that interested parties can run the model locally to see how it works.

Prospective users of the model should contact the Strategy Unit to enquire about using the model on our existing infrastructure.

Please note that it is important that the parameters of the model are set with great care and with proper support. It is important also that healthcare system partners are appropriately involved in parameter setting. For a description of the full process and support provision that is necessary to ensure the model functions well please see the NHS Futures workspace

For internal users with full access to correctly formatted data

Assuming you have your data in the correct format, store it in the data folder. Further details on the correct formatting for the data to follow.

The model runs using parameters that are set in a JSON file.

Running the model using uv

This package is built using uv. If you have uv installed, run the model using: uv run -m nhp.model path/to/params.json -d path/to/data

Running the model without uv

  1. Install the nhp_model package using pip install .
  2. Run the model using: python -m nhp.model path/to/params.json -d path/to/data

Deployment

The model is deployed to Azure Container Registry and GitHub Container Registry on pull requests, tagging the container as nhp_model:dev, and on releases its deployed to nhp_model:v*.*.* and nhp_model:latest.

Testing

The model has unit, integration, and e2e tests defined. The unit tests run on GitHub Actions whenever we create PRs. We also derive our code coverage from unit tests alone.

Integration and e2e tests require the synthetic dataset to be downloaded, which is currently not released publicly. If you have access to this data, you can run the VS Code task "Download synth data". These tests use pytest-regressions to capture the results of running the model against the current synthetic data.

Any time the model changes, or the synthetic data changes, these tests will need to regenerate snapshots. You can do this with:

uv run pytest -m "e2e or integration" --force-regen

You should see the snapshot files (e.g. .csv and .yml) updated in your git working tree. This can be a useful way to test the impact of changes to the model by reviewing the git diffs.

All tests must be marked with one of the markers:

  • @pytest.mark.unit
  • @pytest.mark.integration
  • @pytest.mark.e2e

If you create a new test and do not mark it, or add more than one of these markers, then pytest discovery will fail and indicate the test which is violating this rule.

JSON Schema

Parameters for the model are set in JSON format; an example can be seen in src/nhp/model/params/params-sample.json. As the model develops, requirements for this JSON file change over time. We use JSON schema to manage changes to the parameters file. From model v3.5 onwards, these are deployed to GitHub pages, following this pattern:

  • on merge to main, the schema is deployed to https://the-strategy-unit.github.io/nhp_model/dev/params-schema.json
  • on release of new model version vX.X, the schema is deployed to https://the-strategy-unit.github.io/nhp_model/vX.X/params-schema.json

Metadata

Release files for nhp-model 6.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nhp-model 6.0.0
File Size Uploaded
nhp_model-6.0.0.tar.gz 238.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nhp-model 6.0.0
File Interpreter ABI Platform
nhp_model-6.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 322.2 kB

Release files / nhp_model-6.0.0.tar.gz

Download URL nhp_model-6.0.0.tar.gz
Size 238.5 kB
Tags Source
SHA-256 checksum
How to use checksums
40e7e06e47fb2868eaf7c7700f93534626775cbfb54f5b96b2dd5470058dfe68
BLAKE2b-256 checksum
How to use checksums
7d429abaf3deb0067439d29e812831bc645e3f958400a7286232d80899703458
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.

Transparency log

Release files / nhp_model-6.0.0-py3-none-any.whl

Download URL nhp_model-6.0.0-py3-none-any.whl
Size 83.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac2df4b24c7bb8b4f82fc070f5f8e5f860e5324e3ab52805e2e16f8b46ab8bef
BLAKE2b-256 checksum
How to use checksums
c28aba02d8d865cd207fe89b6752b68c085cce7d2f0c6fc333aa07c938f3b659
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.

Transparency log

Release history Release notifications | RSS feed

6.1.0

2 release files

This release

6.0.0 This release

2 release files

5.2.0

2 release files

5.1.0

2 release files

5.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page