Skip to content

Apply immigration tests to Medicare and Medicare Savings Programs - #10632

Open
hua7450 wants to merge 5 commits into
PolicyEngine:mainfrom
hua7450:medicare-immigration-test
Open

hua7450 wants to merge 5 commits into
PolicyEngine:mainfrom
hua7450:medicare-immigration-test

Conversation

@hua7450

@hua7450 hua7450 commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #10627

What and why

is_medicare_eligible read no immigration status, so an undocumented person aged 65 or older got Medicare and a Medicare Savings Program (MSP) tier. A Texas 70-year-old with a $10,000 pension got QMB worth $202.90 a month and a medicare_cost of $16,548.20.

Medicare. The variable now applies these rules:

  • 8 USC 1611(b)(3) limits Medicare benefits for noncitizens to those "lawfully present in the United States".
  • 42 USC 1395mmm(a), added by Pub. L. 119-21 section 71201, limits Medicare to citizens and nationals, permanent residents, Cuban and Haitian entrants, and Compact of Free Association residents.
  • 42 USC 1395o(a)(2) allows Part B enrollment at 65 for "a citizen" or "an alien lawfully admitted for permanent residence who has resided in the United States continuously during the 5 years immediately preceding the month in which he applies".
  • 42 USC 1395o(a)(1) also opens Part B to anyone entitled to Part A, so a person with an allowed status and 40 quarters (medicare_quarters_of_coverage) qualifies.

Two new parameters hold these rules. gov.hhs.medicare.eligibility.permanent_resident_years holds the five years, read against years_since_us_entry. gov.hhs.medicare.eligibility.immigration_statuses holds the allowed statuses by date:

Period Allowed statuses Source
Through 2026 Every status except UNDOCUMENTED 8 USC 1611(b)(3), applied back to 1966 as an approximation
From 2027 CITIZEN, LEGAL_PERMANENT_RESIDENT, CUBAN_HAITIAN_ENTRANT 42 USC 1395mmm

The SSDI route reads the same list, so it needs lawful presence through 2026 and one of those three statuses from 2027. It has no five-year or quarters test.

Ruling on the 1395mmm transition. Subsection (a) applies at once to a person who wasn't entitled or enrolled on July 4, 2025. For a person who was, subsection (b)(1) says "subsection (a) shall apply beginning on the date that is 18 months after July 4, 2025", which is January 4, 2027. No input records enrollment on July 4, 2025. Ruled by the project lead, 2026-11-02: the model treats everyone as grandfathered through 2026 and applies the list to everyone from 2027. This result overstates 2025 and 2026 eligibility for people in the seven removed statuses who first enrolled after July 4, 2025. Applying the list from 2026 would instead remove grandfathered people for that year. is_medicare_eligible reads parameters at January 1 of its year, so the list is dated January 1, 2027; a January 4 date wouldn't apply until 2028.

Medicare Savings Programs. These are Medicaid benefits, so is_qmb_eligible, is_slmb_eligible, is_qi_eligible and msp_part_b_premium_coverage now read is_medicaid_immigration_status_eligible, which applies the Medicaid immigration test:

  • 42 USC 1396b(v)(1) says "no payment may be made to a State under this section for medical assistance furnished to an alien" outside the groups it names.
  • 8 USC 1611(a) says "an alien who is not a qualified alien (as defined in section 1641 of this title) is not eligible for any Federal public benefit". This bars a person with temporary protected status (TPS).
  • 8 USC 1613(a) makes a qualified alien "not eligible for any Federal means-tested public benefit for a period of 5 years". This bars a permanent resident inside five years, whom 1396b(v)(1) doesn't reach.

A 70-year-old in Texas in 2026, with a $10,000 pension:

Status Medicare MSP tier before MSP tier after
Citizen Yes QMB QMB
Undocumented No (was yes) QMB None
TPS, 40 quarters Yes through 2026, no from 2027 QMB None
Permanent resident, 2 years, 40 quarters Yes QMB None
Permanent resident, 4 years, no quarters No (was yes) QMB None

Merge order. Merge #10633 before this PR. On this branch alone, msp_countable_income combines a couple's income only when both spouses are on Medicare, so a citizen's aged spouse who is barred from Medicare has no income counted. A Texas citizen aged 70 with a $12,000 pension, married to an undocumented 70-year-old with an $18,000 pension, counts $980 and gets QMB in 2026. Under PR 10633 the same citizen counts $1,000 + $1,500 - $20 = $2,480, above the $2,434.50 limit, and gets no tier. From 2027 the same applies to a spouse barred by the 1395mmm list. PR 10633 carries the test for this couple, Case 28 in msp_countable_income.yaml, so this PR adds none.

Other changes:

  • The premium tax credit treats Medicare eligibility as other coverage (gov.aca.ineligible_coverage), so a person this test removes from Medicare can now qualify. A Texas permanent resident aged 70, in the United States for 2 years, with 0 quarters and a $30,000 taxable pension in 2026, goes from an aca_ptc of $0 to $16,550.29. A TPS holder with 39 quarters gets the same amount in 2026, and an undocumented person stays at $0.
  • gov.hhs.medicare.part_a.premium_free_quarters_threshold now starts in 1966, the same year as min_age, because is_medicare_eligible reads it for every year. The value stays 40, the ceiling under 42 USC 414(a). People reaching 62 before 1991 needed fewer quarters, so the value applies backward as an approximation.
  • snap/eligibility/immigration/integration.yaml Case 13 now sets medicare_quarters_of_coverage: 0. Its permanent resident of two years would otherwise be on Medicare through the default 40 quarters, lose MSP inside the five-year bar and pay a Part B premium, which the case's "no medical costs" doesn't intend. No other existing case changes.

Limits:

  • Nationals and Compact of Free Association residents have no immigration_status value, so the 2027 list can't name them.
  • years_since_us_entry counts years since entry or a status grant, which can differ from continuous residence. It defaults to 5, and Remove the years_since_us_entry default of 5 #9732 proposes removing that default.
  • medicare_quarters_of_coverage defaults to 40, so a person with an allowed status and no input stays eligible. The input should reflect entitlement on the person's own or a spouse's record (42 USC 426(a)). The model doesn't apply the limit in 8 USC 1611(b)(3) to wages from authorized employment.
  • The population effect hasn't been estimated. Modeled Medicare enrollment and cost fall for anyone the data marks undocumented and, from 2027, for anyone it marks with one of the seven removed statuses.
  • Known follow-up, in a file this PR doesn't change: parameters/gov/aca/ineligible_immigration_statuses.yaml omits CONDITIONAL_ENTRANT from 2027, while Pub. L. 119-21 section 71301(b) treats only permanent residents, Cuban and Haitian entrants and Compact residents as eligible aliens. The 2027 Medicare list removes the Medicare block, so a 70-year-old conditional entrant with 40 quarters and a $30,000 taxable pension now gets the credit in 2027 (is_aca_ptc_eligible is true).

Test plan

  • For policy changes: 29 new cases, with expected values worked by hand from the statutes above: 15 in is_medicare_eligible.yaml, 7 in msp_category.yaml, 2 each in msp_part_b_premium_coverage.yaml, medicare_enrolled.yaml and medicare_cost.yaml, and 1 in is_aca_ptc_eligible.yaml. They cover each status route, both sides of the five-year test, both sides of the 40-quarter test, the SSDI route, the 2027 list on both routes, the SLMB, QI and Part B status gates against citizen controls, medicare_enrolled and medicare_cost for noncitizens, and the premium tax credit path.
  • If this PR takes a reading where sources disagree: not applicable. The statutes above agree, and the ruling on the 1395mmm transition fills a missing input, so no candidate id or register entry applies.
  • make format (ruff format on the changed variables)
  • Changelog fragment in changelog.d/

Test suites were not run locally; CI validates. Values were checked by hand and in one process per case.

axiom: TheAxiomFoundation/rulespec-us#2009 queued

🤖 Generated with Claude Code

…on test input

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hua7450 and others added 2 commits November 2, 2026 22:18
Pub. L. 119-21 section 71201 limits Medicare to citizens, nationals, permanent
residents, Cuban and Haitian entrants and Compact residents. The model treats
everyone as grandfathered through 2026, since no input records enrollment on
July 4, 2025. Also pins the MSP and premium gates and corrects citations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DTrim99

DTrim99 commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

PR Review: Apply immigration tests to Medicare and Medicare Savings Programs

Summary

I checked the law before the code. The Medicare side is right. The pre-2027 list follows 8 U.S.C. 1611(a) and (b)(3): lawful presence, so every status except UNDOCUMENTED. The 2027 list follows 42 U.S.C. 1395mmm(a)(1) to (3). Three age-65 routes are modelled:

  • a citizen (1395o(a)(2)(A));
  • a permanent resident with five years' residence (1395o(a)(2)(B); 42 CFR 406.20(b)(2) and 407.10(a)(2));
  • anyone with an allowed status who is entitled to premium-free Part A (42 U.S.C. 426(a), then 1395o(a)(1)).

The SSDI route needs only an allowed status. A lawfully present insured worker is not wrongly denied Part A through 2026. From 2027, 1395mmm(a) ("may be entitled to, or enrolled for, benefits ... only if") lawfully removes insured refugees and TPS holders.

The MSP side has one real gap. The new gate reuses is_medicaid_immigration_status_eligible, and that variable also passes California's state-funded Medi-Cal statuses. TPS and DACA Medicare enrollees in California therefore still get QMB, SLMB or QI, against the PR's own stated rule.

Two more items need action before merge:

The axiom line is valid and CI is green.

Critical (must fix)

1. The MSP immigration gate passes California TPS and DACA Medicare enrollees through state-only Medi-Cal

  • Files: is_qmb_eligible.py:23-24, is_slmb_eligible.py and is_qi_eligible.py (the same new term), and msp_part_b_premium_coverage.py:36.
  • Why the gate is too wide: Each gate reads is_medicaid_immigration_status_eligible. That variable returns federally_eligible_status | lawfully_residing_option_eligible | undocumented_eligible | ca_eligible_regardless_of_immigration_status (is_medicaid_immigration_status_eligible.py:52-56). The last term is California's state-funded coverage under W&I Code 14007.8. Its status list, gov.states.ca.chhs.ca_state_funded_immigration_statuses, is UNDOCUMENTED, DACA and TPS, and TPS and DACA are not affected by the 2026 enrollment freeze.
  • Probe at the head:
    • California, 2026: age 70, TPS, default 40 quarters, $10,000 pension. is_medicaid_immigration_status_eligible is true, msp_category (2026-01) is QMB, and msp_part_b_premium_coverage is $2,434.80.
    • The same person in Texas gets NONE, which is this PR's own msp_category Case 9.
  • Law:
    • QMB, SLMB and QI are Medicaid eligibility groups (42 U.S.C. 1396a(a)(10)(E), 1396d(p)).
    • 42 U.S.C. 1396b(v)(1) bars federal payment for TPS and DACA holders. The comment the PR adds to each gate names 1396b(v), 1611(a) and 1613(a), and none of them reaches state-only coverage.
    • California's administering agency requires satisfactory status for these programs. LA County DPSS, Medicare Savings Program: "You must be a Citizen or have Satisfactory Immigration Status to qualify for MSP." Under CONTRIBUTING.md, the administering agency's reading governs where the text doesn't settle the question.
  • Reach: 2026 and earlier (from 2027 the Medicare list itself removes TPS and DACA). main gives the same QMB, but this PR's stated purpose is exactly this household, and it fixes it only outside California.
  • Fix:
    • Gate the four MSP variables on the federal part of the test only. For example, move federally_eligible_status | lawfully_residing_option_eligible into a new variable, such as is_federal_medicaid_immigration_status_eligible. is_medicaid_immigration_status_eligible would then combine it with the state-funded terms, and the MSP gates would read the new variable.
    • Add a California TPS case to msp_category.yaml expecting NONE, so a return to the broader variable fails a test.
    • Update the gate comments, the msp_part_a_premium_coverage and msp_part_b_premium_coverage docstrings, and the companion tests in rulespec-us#2009.

Should address

1. Merge blocker: this head on its own changes a mixed-status couple's MSP result until #10633 lands

msp_countable_income combines a couple's income only when both spouses are Medicare-eligible. This PR takes Medicare away from an undocumented spouse, so the citizen spouse is tested on their own income alone.

2. Seven entries in the pre-2027 status list are unpinned (immigration_statuses.yaml:15-25)

  • Unpinned entries: REFUGEE, ASYLEE, DEPORTATION_WITHHELD, CUBAN_HAITIAN_ENTRANT, CONDITIONAL_ENTRANT, PAROLED_ONE_YEAR and DACA.
  • How I checked: I scanned every YAML test at the head. None of these statuses appears in 2026 or earlier for a person aged 65 or over (or with 24 months of SSDI) whose outputs read Medicare. The only such cases are SF CAAP, the NH SSP and the SNAP waiting period, and none of their outputs reads Medicare. Deleting any of the seven fails no test.
  • Pinned entries: only CITIZEN (unit test 4, the 2023 SSDI case), LEGAL_PERMANENT_RESIDENT (unit test 8) and TPS (unit tests 9 and 12) are pinned in the 1966 list.
  • Fix: add one vectorized 2026 case to is_medicare_eligible.yaml: seven people aged 70, one per status, each with 40 quarters, expecting true for all seven. Add the same case for 2027 expecting [false, false, false, true, false, false, false]; it also pins the 2027 list. A probe at the head returns exactly these values for both years.

Suggestions

  1. Conditional entrants get the premium tax credit from 2027 (a documented follow-up with no tracked issue).
    • Probe: Texas, 2027, age 70, CONDITIONAL_ENTRANT, 40 quarters, $30,000 taxable pension. is_medicare_eligible is false and is_aca_ptc_eligible is true.
    • Pub. L. 119-21 section 71301(b) treats only permanent residents, Cuban and Haitian entrants and Compact residents as eligible aliens. The 2027 list in parameters/gov/aca/ineligible_immigration_statuses.yaml omits CONDITIONAL_ENTRANT.
    • The defect predates this PR (a conditional entrant aged 50 already gets the credit in 2027 on main), but this PR extends it to people aged 65 and over.
    • Either add CONDITIONAL_ENTRANT to that list here with a test, or file an issue and link it from the PR body; I found no such issue.
  2. How the five years are measured.
    • POMS HI 00805.005: "The 5 years' continuous residence may begin prior to the date that the lawful admission for permanent residence is granted."
    • years_since_us_entry is read as years in qualified status by SNAP (7 CFR 273.4(a)(6)(iii)) and by the Medicaid 1613 bar. Take a permanent resident who adjusted status 2 years ago after 10 years of residence, entered as 2 for those programs. Without 40 quarters, that person is denied Medicare, although SSA would count all 10 years.
    • Cite the POMS rule in the comment at is_medicare_eligible.py:44-48 and in permanent_resident_years.yaml, and consider a separate residence input later.
    • Interaction with Remove the years_since_us_entry default of 5 #9732 (default 0): a permanent resident with no entry year still gets Medicare through the default 40 quarters, and one with 0 quarters doesn't. A probe with years_since_us_entry: 0 gives [true, false].
  3. References for permanent_resident_years.yaml. It cites only 1395o(a). The same five-year rule governs premium Part A (42 U.S.C. 1395i-2(a)(3); 42 CFR 406.20(b)(2)) and Part B (42 CFR 407.10(a)(2)(iii)), so citing them documents both routes. 42 CFR 406.28 is "End of entitlement", not the residence rule.
  4. Transition proxy (optional, given the recorded ruling). 1395mmm(a) bars new entrants after July 4, 2025 at once. Age could separate likely July 4, 2025 enrollees from people who first reach 65 in 2026 (for example, age at least min_age + 1 in 2026), which would narrow the 2026 overstatement. This is not blocking.
  5. Premium tax credit and premium Part A (pre-existing).
    • IRS Notice 2013-41 treats Part A that requires a premium as minimum essential coverage only when the person is enrolled.
    • gov.aca.ineligible_coverage lists is_medicare_eligible, so a citizen or a five-year permanent resident with fewer than 40 quarters (the households in unit tests 6 and 11) is barred from the credit even when not enrolled.
    • This is outside the PR's scope. A follow-up could block the credit only for premium-free Part A eligibility or for actual enrollment.

Verified correct

The law against the code

  • Before 2027:
    • 8 U.S.C. 1611(a) bars only non-qualified aliens.
    • 1611(b)(3) lets them have Medicare when they are lawfully present.
    • 1613 doesn't apply because Medicare is not means-tested.
    • So the list of every status except UNDOCUMENTED is right.
    • The authorized-employment limit on Part A wages in 1611(b)(3) has no input, and the code says so.
  • From 2027:
    • 1395mmm(a) lists (1) citizens and nationals, (2) permanent residents, (3) Cuban and Haitian entrants and (4) Compact residents. The code's CITIZEN, LEGAL_PERMANENT_RESIDENT and CUBAN_HAITIAN_ENTRANT match. The test-comment pinpoints (a)(2) and (a)(3) are right.
    • (b)(1) delays the list to January 4, 2027 for people enrolled on July 4, 2025. Dating the list January 1, 2027 for a YEAR variable is reasoned and documented.
    • Section 71201 is on PDF pages 249-250 of Pub. L. 119-21, matching #page=249, the title "#page 249-250" and the variable's "# PDF pages 249-250" comment.
  • The age-65 routes:
    • Citizen: unit test 11 (0 quarters, true).
    • Permanent resident with five years: unit tests 6 and 7 (5 years true, 4 years false).
    • Allowed status with 40 quarters: unit tests 8, 9 and 19 (true) and unit test 10 (39 quarters, false). Under 1395i-2(a), only a citizen or a five-year permanent resident may buy Part A.
    • A permanent resident inside five years with 40 quarters is eligible in both 2026 and 2027 (unit tests 8 and 19).
    • Using 40 as the threshold matches the ceiling in 42 U.S.C. 414(a).
  • The SSDI route (426(b)): allowed status only (unit tests 12, 13 and 16).
  • MSP as a Medicaid benefit:
    • The 1613 five-year bar applies, and bar-exempt statuses pass.
    • QI's Medicaid exclusion is unchanged.
    • msp_part_a_premium_coverage inherits the gate through is_qmb_eligible.
    • No path to medically needy Medicaid is added, so the SPM medical out-of-pocket cycle stays closed.

Hand-checked expectations (2026 Texas unless noted; 2026 FPG is $15,960 for one person, $1,330 a month)

  1. msp_category Case 11: $18,240 / 12 - $20 = $1,500. This is above $1,330 and below 1.2 x $1,330 = $1,596, so SLMB.
  2. Case 13: $20,640 / 12 - $20 = $1,700. This is at least $1,596 and below 1.35 x $1,330 = $1,795.50, and the person isn't Medicaid-eligible in Texas, so QI.
  3. Cases 9, 12 and 14 (TPS): $10,000 / 12 - $20 = $813.33 is in the QMB band, and the other two are in the SLMB and QI bands. TPS isn't on the 2026 Medicaid status list, so NONE.
  4. Case 10: a permanent resident of 2 years is inside the bar (2 < 5) and not bar-exempt, so NONE. Medicare holds through the default 40 quarters.
  5. msp_part_b_premium_coverage, citizen: $1,500 < $1,795.50, so $202.90 x 12 = $2,434.80. TPS gets $0.
  6. medicare_cost, TPS with 40 quarters: $18,983 per-capita cost - $0 Part A premium - $2,434.80 Part B premium = $16,548.20. Undocumented: not eligible, so not enrolled, so $0.
  7. is_medicare_eligible, 2027: TPS and refugee are false (not on the list). A Cuban and Haitian entrant is true with 40 quarters and false with 0 (neither a citizen nor a permanent resident). A permanent resident of 2 years with 40 quarters is true.
  8. is_aca_ptc_eligible: $30,000 / $15,650 (the 2025 FPG used for 2026) = 1.92, inside 1.00 to 4.00. The person is inside the Medicaid bar and off Medicare, so true.
  9. Unit tests 12, 13 and 16: TPS with SSDI is true in 2026 and false in 2027. Undocumented with SSDI is false.

Readers of Medicare eligibility and enrollment

  • gov.aca.ineligible_coverage; is_basic_health_program_eligible; is_adult_for_medicaid_nfc; medicaid_work_requirement_eligible.
  • medicaid_optional_senior_or_disabled_countable_income and medical_expense_health_insurance_premiums (Part B premium terms).
  • The Medicare premium variables (base_part_a_premium, base_part_b_premium, gross_medicare_part_b_premium and their siblings), medicare_cost, and medicare_part_d_enrolled.
  • msp_countable_income (Should 1).
  • State readers: TX DART, IL CTA/RTA reduced fares, MA MBTA, IL SMIB, MS HMW, and the OH medical-expense deductions.
  • Each change follows the law in direction: no Medicare premiums or Medicare-card routes for people barred from Medicare, and adult-group Medicaid and the premium tax credit opening where those programs' own immigration tests allow. A probe confirms that a California TPS SSDI recipient aged 50 in 2027 leaves Medicare and enters the adult group.
  • SSI reads no Medicare variable.

Other checks

  • Vectorization, entity and period: np.isin on decoded strings, all YEAR inputs, and monthly MSP gates reading period.this_year.
  • NH Add New Hampshire state supplementation for 2026 #10156 pattern: no new state-gated key, so it doesn't apply.
  • Changelog: changelog.d/medicare-immigration-test.fixed.md is top-level and typed fixed.
  • Test files: all tests are in variable-named files.
  • SNAP integration Case 13: the medicare_quarters_of_coverage: 0 edit is justified and commented.
  • Partner tests: no partner test file changes. The two partner cases with aged noncitizens don't move. ssi_aged_undocumented_ineligible inputs is_medicare_eligible: false, and ssi_aged_lpr_status stays eligible through the defaults. Partner suites are green at the head, so the partner gate isn't triggered.
  • Source conflicts: the added comments contain no source-conflict wording. The 1395mmm transition fills a missing input rather than choosing between sources, so it needs no marker.

Axiom line assessment

axiom: TheAxiomFoundation/rulespec-us#2009 queued is valid.

  • The issue is OPEN and labelled pe-parity, and it names head 2127c66dac.
  • It gives module paths and corpus citations, quotes the law verbatim, and lists the required outputs.
  • It has 25 companion tests worked by hand from the statutes.
  • It records the blockers: 42 U.S.C. 1395o is not in the bundles, and a billed run needs approval.

When Critical 1 and Should 2 are addressed, update the issue: add the California TPS case and the vectorized status cases, and refresh the head SHA.

CI status

All 34 checks pass at 2127c66dac (re-checked at the end of this review). None are pending.

Branch status

Verdict: REQUEST_CHANGES

@DTrim99 DTrim99 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Requesting changes: 1 critical (the MSP gate reuses is_medicaid_immigration_status_eligible, which includes California's state-funded TPS and DACA coverage, so a 70-year-old CA TPS holder gets QMB and $2,434.80 of Part B coverage; gate on the federal part only and add a CA TPS test), 2 should (merge only after #10633, since this head alone gives a TX citizen with an undocumented spouse QMB; seven pre-2027 status entries are unpinned). The Medicare side matches the law. Full report in the comment above.

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.

Medicare and Medicare Savings Programs: add an immigration test for undocumented people

2 participants