Skip to content

fixes invest/treat order column in aae hes data - #290

Merged
tomjemmett merged 3 commits into
mainfrom
fix_hes_data
Oct 1, 2026
Merged

tomjemmett merged 3 commits into
mainfrom
fix_hes_data

Conversation

@tomjemmett

Copy link
Copy Markdown
Member

the invest/treat order columns should be a numeric value, 1, 2, 3... etc. but, we were using the column name, so these were coming through as treat_01, treat_02, treat_03, etc.

this fixes that by replacing the strings with the correct integer value

Copilot AI balanced review requested due to automatic review settings October 1, 2026 09:54
@tomjemmett
tomjemmett requested a review from a team as a code owner October 1, 2026 09:54
@tomjemmett tomjemmett self-assigned this Oct 1, 2026

@tomjemmett tomjemmett left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

for information: I have already fixed the data in UDAL using this code.

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.

Copilot review overview

🟡 Changes recommended

The order literal remains quoted ('{i + 1}'), producing a string column instead of the numeric value stated in the PR description and used unquoted in the sibling diagnoses.py helper.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

This PR fixes the treatment_order / investigation_order columns produced by the HES A&E melt (stack) helpers. Previously the order value was set to the source column name (e.g. treat_01, invest_02), so the ordinal position was lost; the change derives the order from the enumeration index instead. This feeds downstream primary-treatment selection in raw_data/aae.py, which filters on *_order == 1.

Changes:

  • Replace the column-name order key with the 1-based enumeration index in the stack expression for A&E treatments.
  • Apply the same fix for A&E investigations.
File Description
src/​nhp/​data/​hes/​aae/​treatments.py Uses i + 1 instead of the column name as the treatment_order value in the stack melt string.
src/​nhp/​data/​hes/​aae/​investigations.py Uses i + 1 instead of the column name as the investigation_order value in the stack melt string.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/nhp/data/hes/aae/investigations.py Outdated
Comment thread src/nhp/data/hes/aae/treatments.py Outdated
tomjemmett and others added 2 commits October 1, 2026 10:58
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@yiwen-h yiwen-h left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Makes sense to me; do we know what the expected difference will be to TPMA data, if any?

@tomjemmett

Copy link
Copy Markdown
Member Author

None, this was an artifact of moving the hes steps into nhp_data.

@tomjemmett
tomjemmett merged commit cd88d8c into main Oct 1, 2026
3 checks passed
@tomjemmett
tomjemmett deleted the fix_hes_data branch October 1, 2026 12:38
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.

3 participants