bolster.data_sources.nisra.emergency_care_waiting_times

NISRA Emergency Care Waiting Times Module.

Provides access to Northern Ireland’s emergency care (A&E) waiting times statistics, measuring performance against the 4-hour target across HSC Trusts and hospital departments.

The 4-hour target requires that 95% of emergency care attendances are seen, treated, admitted or discharged within 4 hours of arrival.

Data Coverage:
  • April 2008 to present (monthly, by hospital department)

  • 5 HSC Trusts: Belfast, Northern, South Eastern, Southern, Western

  • Attendance types: Type 1 (major A&E), Type 2 (single specialty), Type 3 (MIU/UTC)

Data Source:

Department of Health Northern Ireland publishes emergency care waiting times through quarterly HTML interactive data publications at https://www.health-ni.gov.uk/articles/emergency-care-waiting-times.

Update Frequency:

Quarterly, approximately 3 months after the end of each quarter.

Example

>>> from bolster.data_sources.nisra import emergency_care_waiting_times as ecwt
>>> df = ecwt.get_latest_data()
>>> 'pct_within_4hrs' in df.columns
True
Publication Details:

Attributes

logger

DOH_LANDING_PAGE

DOH_BASE_URL

EXPECTED_TRUSTS

Functions

get_latest_url()

Return the URL of the most recent interactive data HTML from datavis.nisra.gov.uk.

parse_data(payload)

Convert a raw DT widget payload into a clean emergency care DataFrame.

get_latest_data([force_refresh])

Fetch and return the latest emergency care waiting times data.

validate_data(df)

Validate that the emergency care DataFrame is internally consistent.

Module Contents

bolster.data_sources.nisra.emergency_care_waiting_times.logger[source]
bolster.data_sources.nisra.emergency_care_waiting_times.DOH_LANDING_PAGE = 'https://www.health-ni.gov.uk/articles/emergency-care-waiting-times'[source]
bolster.data_sources.nisra.emergency_care_waiting_times.DOH_BASE_URL = 'https://www.health-ni.gov.uk'[source]
bolster.data_sources.nisra.emergency_care_waiting_times.EXPECTED_TRUSTS[source]
bolster.data_sources.nisra.emergency_care_waiting_times.get_latest_url()[source]

Return the URL of the most recent interactive data HTML from datavis.nisra.gov.uk.

Scrapes the Department of Health landing page to find the most recent quarterly publication, then follows to the publication page to extract the data HTML link.

Returns:

URL of the HTML page containing the embedded DataTables widget.

Raises:

NISRADataNotFoundError – If no publication or data link can be found.

Return type:

str

bolster.data_sources.nisra.emergency_care_waiting_times.parse_data(payload)[source]

Convert a raw DT widget payload into a clean emergency care DataFrame.

Parameters:

payload (dict) – The x sub-dict from the DT widget, as returned by fetch_datatables_json().

Returns:

date, year, month, trust, dept, attendance_type, under_4hrs, btw_4_12hrs, over_12hrs, total, pct_within_4hrs.

pct_within_4hrs is always in the range [0.0, 1.0].

Return type:

DataFrame with columns

Raises:

NISRAValidationError – If expected columns are missing from the payload.

bolster.data_sources.nisra.emergency_care_waiting_times.get_latest_data(force_refresh=False)[source]

Fetch and return the latest emergency care waiting times data.

Downloads the most recent quarterly interactive data HTML, extracts the embedded DataTables widget, and returns a clean DataFrame.

Parameters:

force_refresh (bool) – Ignored (HTML pages are always re-fetched; use for API consistency with other NISRA modules).

Returns:

  • date (datetime): First of the month for the reporting period

  • year (int): Calendar year

  • month (str): Month name, e.g. “April”

  • trust (str): HSC Trust name

  • dept (str): Hospital department / site name

  • attendance_type (str): Type 1, Type 2, or Type 3

  • under_4hrs (int): Attendances seen within 4 hours

  • btw_4_12hrs (int): Attendances between 4 and 12 hours

  • over_12hrs (int): Attendances waiting over 12 hours

  • total (int): Total attendances

  • pct_within_4hrs (float): Proportion seen within 4 hours (0.0–1.0)

Return type:

DataFrame with columns

Raises:
  • NISRADataNotFoundError – If the data page cannot be located or fetched.

  • NISRAValidationError – If the downloaded data fails schema validation.

bolster.data_sources.nisra.emergency_care_waiting_times.validate_data(df)[source]

Validate that the emergency care DataFrame is internally consistent.

Parameters:

df (pandas.DataFrame) – DataFrame as returned by get_latest_data().

Returns:

True if validation passes.

Raises:

NISRAValidationError – If validation fails.

Return type:

bool