bolster.data_sources.health_ni.diagnostic_waiting_times
NISRA Diagnostic Waiting Times Module.
Provides access to Northern Ireland’s diagnostic waiting times statistics, covering patients waiting for diagnostic tests across HSC Trusts, diagnostic services, and categories of test.
- Waiting Time Bands:
Total: All patients waiting (any duration)
0–9 weeks: Patients waiting 0–9 weeks
>9 weeks: Patients waiting more than 9 weeks
>26 weeks: Patients waiting more than 26 weeks
- Data Coverage:
Q4 2007/08 (quarter ending March 2008) to present
Quarterly frequency
5 HSC Trusts: Belfast, Northern, South Eastern, Southern, Western
Categories: Imaging, Endoscopy, Physiological measurements (and ‘All’)
Individual diagnostic services (endoscopy, radiology, physiological, etc.)
- HSC Trusts:
Belfast, Northern, South Eastern, Southern, Western
- Original data source:
https://www.health-ni.gov.uk/articles/diagnostic-waiting-times
Data is fetched from the NISRA PxStat API using matrix DWT.
Example
>>> from bolster.data_sources.nisra import diagnostic_waiting_times as dwt
>>> df = dwt.get_latest_diagnostic_waiting_times()
>>> sorted(df.columns.tolist())
['category', 'date', 'over_26_weeks', 'over_9_weeks', 'performance_rate', 'quarter', 'total_waiting', 'trust', 'within_9_weeks', 'year']
Attributes
Functions
|
Get diagnostic waiting times by HSC Trust and category of test. |
Validate that diagnostic waiting times data is internally consistent. |
Module Contents
- bolster.data_sources.health_ni.diagnostic_waiting_times.get_latest_diagnostic_waiting_times(trust=None, year=None, force_refresh=False)[source]
Get diagnostic waiting times by HSC Trust and category of test.
Returns aggregate-level data (all diagnostic services combined) pivoted so that each row represents one trust/quarter with waiting band columns.
- Parameters:
trust (str | None) – Optional HSC Trust name to filter (e.g.
"Belfast"). IfNoneall trusts are returned (NI-wide aggregate excluded).year (int | None) – Optional calendar year filter. If
Noneall years returned.force_refresh (bool) – Accepted for API compatibility but ignored; the PxStat API always returns the latest data without caching.
- Returns:
date: Timestamp (quarter end date)quarter: Quarter label (e.g."2023/24Q1")year: Calendar year of the quarter endtrust: HSC Trust namecategory: Category of test ("All categories of test"for this aggregate view)total_waiting: Total patients waiting (any duration)within_9_weeks: Patients waiting 0–9 weeksover_9_weeks: Patients waiting >9 weeksover_26_weeks: Patients waiting >26 weeks
- Return type:
DataFrame with columns
Example
>>> df = get_latest_diagnostic_waiting_times() >>> "Belfast" in df["trust"].values True >>> "total_waiting" in df.columns True
- bolster.data_sources.health_ni.diagnostic_waiting_times.validate_diagnostic_waiting_times(df)[source]
Validate that diagnostic waiting times data is internally consistent.
Checks that required columns are present, values are non-negative, performance rates are within 0–1, and there is sufficient data.
- Parameters:
df (pandas.DataFrame) – DataFrame as returned by
get_latest_diagnostic_waiting_times().- Returns:
Trueif all validation checks pass.- Raises:
ValueError – If any validation check fails.
- Return type: