Skip to main content

New Hospital Programme demand model

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nhp_model-5.2.0.tar.gz (241.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nhp_model-5.2.0-py3-none-any.whl (83.6 kB view details)

Uploaded Python 3

File details

Details for the file nhp_model-5.2.0.tar.gz.

File metadata

  • Download URL: nhp_model-5.2.0.tar.gz
  • Upload date:
  • Size: 241.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for nhp_model-5.2.0.tar.gz
Algorithm Hash digest
SHA256 9874aeca59567d9e4083a3b76772857645343a73e8f8c028739df0465a773e9e
MD5 fe689c6dd93cc81c4a9b64f0134e9f3a
BLAKE2b-256 0ee82bdb0e3887485c4b01d7f97dffc9073e791536d8175d547b499349f969e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for nhp_model-5.2.0.tar.gz:

Publisher: build_app.yaml on The-Strategy-Unit/nhp_model

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nhp_model-5.2.0-py3-none-any.whl.

File metadata

  • Download URL: nhp_model-5.2.0-py3-none-any.whl
  • Upload date:
  • Size: 83.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for nhp_model-5.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90c97a1c0b89bf876f5593974b10aeccaa6a4c4c3f535b7ebf9e1a3635a8655d
MD5 646f4727e39542c73509a2c74047aed7
BLAKE2b-256 eed3111c9a4f5020c839f75a2af9a880cabbe612e6967245ae209147a7778a08

See more details on using hashes here.

Provenance

The following attestation bundles were made for nhp_model-5.2.0-py3-none-any.whl:

Publisher: build_app.yaml on The-Strategy-Unit/nhp_model

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page