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.1.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.1.0
File Size Uploaded
nhp_model-6.1.0.tar.gz 242.3 kB Details

Built distribution (wheel)

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

Total release size: 326.6 kB

Release files / nhp_model-6.1.0.tar.gz

Download URL nhp_model-6.1.0.tar.gz
Size 242.3 kB
Tags Source
SHA-256 checksum
How to use checksums
99f3902437a5f9cfd35aa40ce89b9c22e121947b89932c2d847842fd7d49fdc5
BLAKE2b-256 checksum
How to use checksums
4c3a3ce9f185b2ef84210bbabe1bd4ea2e16dd75922336c068c0f69f7ba32b51
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 Oct 14, 2026.

Transparency log

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

Download URL nhp_model-6.1.0-py3-none-any.whl
Size 84.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a4960b78b714036b228c9bca65b1a9e30759ae6ef28d1fee5158fd95835c50c
BLAKE2b-256 checksum
How to use checksums
5f7b72f07cf5f2bec07fe1a1247057237af622fb4462e2251f5f3d441a15e889
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 Oct 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

6.1.0 This release

2 release files

6.0.0

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