Skip to content

Remove tretspef grouped - #292

Open
tomjemmett wants to merge 3 commits into
mainfrom
remove_tretspef_grouped
Open

tomjemmett wants to merge 3 commits into
mainfrom
remove_tretspef_grouped

Conversation

@tomjemmett

@tomjemmett tomjemmett commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

closes #296

@tomjemmett tomjemmett self-assigned this Oct 13, 2026
@tomjemmett
tomjemmett added this pull request to stack #294 October 13, 2026 12:53
@tomjemmett
tomjemmett marked this pull request as ready for review October 19, 2026 10:25
@tomjemmett
tomjemmett requested a review from a team as a code owner October 19, 2026 10:25
Copilot AI balanced review requested due to automatic review settings October 19, 2026 10:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It changes the data pipeline output schema (removing a column) and alters tretspef semantics with cross-repository downstream dependencies (nhp_inputs #618), which warrants human verification despite the code itself being clean and consistent.

No open issues 🎉

What changed in this PR

This PR removes the tretspef_grouped treatment-function grouping from the NHP data pipeline so that specialty-level parameters can be set more granularly downstream (closes #296, see also nhp_inputs #618). The old add_tretspef_grouped_column helper (which collapsed specialty codes into ~18 buckets plus "Other (Surgical)"/"Other (Medical)"/"Other") is deleted, and a new replace_invalid_tretspef_values helper normalizes any tretspef code not present in the reference_tretspef_type table to "Other". All producers and consumers of tretspef_grouped are updated to use the raw tretspef column instead.

Changes:

  • Replace add_tretspef_grouped_column with replace_invalid_tretspef_values, applied to inpatients and outpatients raw data.
  • Drop tretspef_grouped from all raw/aggregated selects, inputs renames, A&E baseline, maternity remapping, and the synthetic-data filter.
  • A&E baseline now groups by tretspef (value "Other") rather than emitting a null tretspef, consistent with A&E expat/repat.
File Description
src/​nhp/​data/​raw_data/​helpers.py Removes add_tretspef_grouped_column; adds replace_invalid_tretspef_values validating against reference_tretspef_type.
src/​nhp/​data/​raw_data/​inpatients.py Swaps grouped-column call for invalid-value replacement; drops tretspef_grouped from final select.
src/​nhp/​data/​raw_data/​outpatients.py Same swap and select cleanup as inpatients.
src/​nhp/​data/​raw_data/​ecds.py Drops the hardcoded tretspef_grouped = "Other" column.
src/​nhp/​data/​raw_data/​aae.py Drops the hardcoded tretspef_grouped = "Other" column.
src/​nhp/​data/​aggregated_data/​outpatients.py Removes tretspef_grouped from the aggregated select.
src/​nhp/​data/​aggregated_data/​ecds.py Removes tretspef_grouped from the aggregated select.
src/​nhp/​data/​inputs_data/​ip/​__init__.py Stops dropping tretspef / renaming tretspef_grouped.
src/​nhp/​data/​inputs_data/​op/​__init__.py Stops dropping tretspef / renaming tretspef_grouped.
src/​nhp/​data/​inputs_data/​ip/​baseline.py Removes maternity→"Other (Medical)" remapping.
src/​nhp/​data/​inputs_data/​ip/​expat_repat.py Removes maternity→"Other (Medical)" remapping in two functions.
src/​nhp/​data/​inputs_data/​ae/​baseline.py Groups by tretspef instead of nulling it.
src/​nhp/​data/​model_data/​generate_synthetic_data.py Removes the obsolete tretspef_grouped startswith filter.

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove tretspef_grouped column

2 participants