Skip to content

Restore medical_out_of_pocket_expenses as deprecated alias#8236

Closed
hua7450 wants to merge 1 commit into
PolicyEngine:mainfrom
hua7450:deprecation-shim-medical-oop-expenses
Closed

Restore medical_out_of_pocket_expenses as deprecated alias#8236
hua7450 wants to merge 1 commit into
PolicyEngine:mainfrom
hua7450:deprecation-shim-medical-oop-expenses

Conversation

@hua7450

@hua7450 hua7450 commented May 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

PR #8178 (shipped in policyengine-us 1.673.0) removed the umbrella medical_out_of_pocket_expenses Person variable in favor of program-specific aggregates (itemized_medical_expenses, snap_allowable_medical_expenses, hud_medical_expenses, medicaid_medically_needy_medical_expenses, pa_ccw_medical_expenses) plus decomposed inputs (health_insurance_premiums, other_medical_expenses, over_the_counter_health_expenses, medicare_part_b_premium, ...).

Household-API partners that still pass medical_out_of_pocket_expenses as input now hit VariableNotFoundError (HTTP 500) without prior notice — see PolicyEngine/policyengine-household-api#1493 for the MyFriendBen fixture migration that surfaced this.

This PR re-adds medical_out_of_pocket_expenses as a deprecation alias that forwards into other_medical_expenses, giving partners a window to migrate.

Approach

  • New Person-level input variable medical_out_of_pocket_expenses (default 0). Label and documentation mark it deprecated.
  • other_medical_expenses now declares adds = [\"medical_out_of_pocket_expenses\"]. PolicyEngine input-override semantics mean partners who already pass other_medical_expenses (or the new premium inputs) directly are unaffected — direct input always wins over adds. Pattern matches existing variables that combine uprating and adds (e.g. employment_income, self_employment_income).

Tradeoff

This is an alias to other_medical_expenses only — the non-premium catch-all. For partners whose legacy medical_out_of_pocket_expenses value previously included health insurance premiums, the shim silently routes those dollars into the non-premium path; they will need to migrate that portion to health_insurance_premiums to retain correct downstream calculations. Of the three customer-input fixtures in policyengine-household-api (my_friend_ben, amplifi, impactica), only MyFriendBen passed the legacy variable, and they don't pass any premium inputs — so the simple alias is correct for them.

Removal plan

The shim is a temporary migration aid. We should track its removal as a follow-up issue and pull it after partners have had at least one minor-version cycle to migrate.

Files

  • policyengine_us/variables/household/expense/health/medical_out_of_pocket_expenses.py (new)
  • policyengine_us/variables/household/expense/health/other_medical_expenses.py (modified)
  • policyengine_us/tests/policy/baseline/household/expense/health/medical_out_of_pocket_expenses.yaml (new)
  • changelog.d/restore-medical-oop-expenses-alias.added.md (new)

Test plan

  • YAML test verifies legacy input flows into other_medical_expenses
  • YAML test verifies direct other_medical_expenses input overrides the alias
  • YAML test verifies default-zero behavior when neither input is supplied
  • CI passes

🤖 Generated with Claude Code

PR PolicyEngine#8178 (1.673.0) removed the umbrella `medical_out_of_pocket_expenses`
variable in favor of program-specific aggregates. Existing API partners
who pass the legacy variable as input now hit `VariableNotFoundError`
without warning.

Re-add the variable as a Person input that forwards into
`other_medical_expenses` via `adds`. PolicyEngine input-override
semantics keep already-migrated callers (who pass `other_medical_expenses`
or the new premium inputs directly) on the new path. The label and
documentation mark the variable deprecated; partners with premium
spend folded into the legacy value should migrate to
`health_insurance_premiums` to retain correct downstream behavior.
This shim is a temporary migration aid and will be removed in a
future release.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hua7450 hua7450 marked this pull request as draft May 6, 2026 14:57
@hua7450 hua7450 closed this May 6, 2026
@codecov

codecov Bot commented May 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (623a65c) to head (0a72f97).
⚠️ Report is 134 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##              main     #8236    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           12         2    -10     
  Lines          173        17   -156     
  Branches         4         0     -4     
==========================================
- Hits           173        17   -156     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant