Utilities for calculating IHACPA National Weighted Activity Units
Project description
nwau_py
This package provides utilities for working with IHACPA funding weights.
Installation
The project is standardizing on uv for local development and validation.
Install and sync the environment with:
uv sync --locked --group dev --group test --group coverage --group typing --group property --group mutation --group profiling --group docs
The SAS calculators for each pricing year should be extracted under
archive/sas/<YEAR>/ so the modules can read the reference tables.
Development targets Python 3.10 through 3.14. The current quality-gate stack
uses uv, Ruff, pytest, pytest-cov, ty, Codecov, Hypothesis,
mutmut, Scalene, and on-demand Vale alongside the calculator
libraries. ty is the active type checker in this phase; mypy remains only
as a transitional comparator while the migration is completed. Codecov is fed
by the XML coverage artifact produced in CI so the same report can be reviewed
in the UI and in local runs.
Rust contributors should also run cargo fmt --all --check, cargo clippy --all-targets --all-features -- -D warnings, and cargo test against the
workspace under rust/.
The slow-validation workflow is split between a weekly scheduled run and a
manual workflow_dispatch run. Its profiling job writes Scalene output under
.cache/validation/scalene/, which keeps generated reports outside version
control while still making them easy to inspect locally.
The calculator implementation still uses pandas in places, while the longer-term data stack is moving toward Arrow-backed interchange and Polars where parity work allows it.
Data preparation
The Python calculators load tables directly from the SAS releases archived under
archive/sas/<YEAR>/. If you need the original Excel workbook outputs, the
helper script excel_calculator/scripts/extract_all.py can recreate
weights.csv and formula.json from the workbooks stored in
excel_calculator/archive/<year>.
CLI usage
Once installed you can calculate funding from the command line using the
nwau_py CLI:
python -m nwau_py.cli.main acute patient_data.csv --output funding.csv --year 2025
patient_data.csv should contain the variables expected by the SAS programs.
The output CSV will include an NWAU25 column with the calculated weights.
Validation Workflow
The package is validated through manifest-driven fixture packs and explicit
parity checks rather than broad claims of complete coverage. Use the shared
fixture helpers in nwau_py.fixtures to load packs, read payloads, and run
runner-neutral checks that can later be consumed by Python, C#, and web
tooling.
For the acute 2025 pilot there is also an explicit Rust-backed opt-in path,
nwau_py.calculators.calculate_acute_rust_2025(), which loads the optional
nwau_py._rust extension through nwau_py.rust_bridge and returns the same
NWAU25 values for the synthetic fixture pack without changing the default
Python calculator path.
Formula JSON
The file excel_calculator/data/formula.json is a structured representation of
the workbook formula used by IHACPA and is kept for archival purposes. It lists
each symbol (for example PW, APaed, AInd) and the corresponding column
heading in excel_calculator/data/weights.csv. A full mapping is provided in
FORMULA_MAPPING.md.
The steps array enumerates the intermediate calculations that build up the
final NWAU25 value. Starting from the base price weight, paediatric and other
adjustments are applied, ICU hours are added, private patient adjustments and
readmission penalties are subtracted and the result is multiplied by the
National Efficient Price (NEP). The last step yields the overall NWAU25
figure used for funding.
Documentation
Detailed notes on each calculator module are available in docs/calculators.md.
Golden Fixture Packs
The project uses manifest-driven fixture packs for cross-language parity checks.
The current pilot pack lives under tests/fixtures/golden/acute_2025/ and includes
a JSON manifest plus input.csv and expected.csv payloads.
Use nwau_py.fixtures to work with these packs:
load_fixture_pack()validates the manifest and resolves payload paths.discover_fixture_packs()finds packs under a fixture root.read_payload_frame()loads the manifest-declared input or expected output tables.iter_fixture_cases()maps manifests to calculator cases.fixture_case_params()turns cases into pytest parameters with stable ids.iter_fixture_pytest_params_from_root()discovers packs and generates pytest parameters from manifest metadata.run_fixture_case()executes a calculator against one manifest case.run_fixture_suite()executes and validates a set of cases.run_fixture_suite_from_root()discovers packs and runs every valid case in order.assert_fixture_case_output()checks the result against the declared tolerance and rounding policy.
Pytest coverage is generated from the same manifests by parameterizing over the discovered fixture cases. That keeps the test matrix and the helper runner in sync without hard-coding runner-specific logic.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nwau_py-0.2.2.tar.gz.
File metadata
- Download URL: nwau_py-0.2.2.tar.gz
- Upload date:
- Size: 150.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0998035a2e0ceebe913717170994ef668159c6e384524932c55c18fc1ce0480
|
|
| MD5 |
bb1418ceea5b4a2431878d272f92fc61
|
|
| BLAKE2b-256 |
905fb64f960d692ac550af6ac05239f34c61f40093cc41d7d9f529c434bb204b
|
Provenance
The following attestation bundles were made for nwau_py-0.2.2.tar.gz:
Publisher:
publish.yml on edithatogo/mchs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nwau_py-0.2.2.tar.gz -
Subject digest:
c0998035a2e0ceebe913717170994ef668159c6e384524932c55c18fc1ce0480 - Sigstore transparency entry: 1556612514
- Sigstore integration time:
-
Permalink:
edithatogo/mchs@8b88b8417a9649d73a5d68f40583bf2b066c309f -
Branch / Tag:
refs/heads/master - Owner: https://github.com/edithatogo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8b88b8417a9649d73a5d68f40583bf2b066c309f -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file nwau_py-0.2.2-py3-none-any.whl.
File metadata
- Download URL: nwau_py-0.2.2-py3-none-any.whl
- Upload date:
- Size: 178.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22f2de99c11dfb4396f51f6a4d1efcbe0002c4901e91a9de57511be6a12a5028
|
|
| MD5 |
ad179bbf4f2180d311509c970adcc77a
|
|
| BLAKE2b-256 |
2fd0e881e7c98a7827a3df2db1a67c948a206a0d69d549267b78d5225ac13e63
|
Provenance
The following attestation bundles were made for nwau_py-0.2.2-py3-none-any.whl:
Publisher:
publish.yml on edithatogo/mchs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nwau_py-0.2.2-py3-none-any.whl -
Subject digest:
22f2de99c11dfb4396f51f6a4d1efcbe0002c4901e91a9de57511be6a12a5028 - Sigstore transparency entry: 1556612797
- Sigstore integration time:
-
Permalink:
edithatogo/mchs@8b88b8417a9649d73a5d68f40583bf2b066c309f -
Branch / Tag:
refs/heads/master - Owner: https://github.com/edithatogo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8b88b8417a9649d73a5d68f40583bf2b066c309f -
Trigger Event:
workflow_dispatch
-
Statement type: