diff --git a/changelog.d/medicaid-pregnancy-household-size.fixed.md b/changelog.d/medicaid-pregnancy-household-size.fixed.md new file mode 100644 index 00000000000..9d6294d2a0f --- /dev/null +++ b/changelog.d/medicaid-pregnancy-household-size.fixed.md @@ -0,0 +1 @@ +Count a pregnant member's expected children in the other members' Medicaid household size where the state elects it under 42 CFR 435.603(b), now New Jersey as well as California, and pair a California non-filer's spouse only on a joint return. diff --git a/policyengine_us/parameters/gov/hhs/medicaid/household/pregnant_member_expected_children_cap.yaml b/policyengine_us/parameters/gov/hhs/medicaid/household/pregnant_member_expected_children_cap.yaml new file mode 100644 index 00000000000..fe1885c9165 --- /dev/null +++ b/policyengine_us/parameters/gov/hhs/medicaid/household/pregnant_member_expected_children_cap.yaml @@ -0,0 +1,129 @@ +description: Medicaid counts at most this number of a pregnant woman's expected children in the household size of each other member of her household, under the state's election in 42 CFR 435.603(b). +metadata: + unit: person + period: year + label: Medicaid MAGI household cap on a pregnant member's expected children + breakdown: + - state_code + reference: + - title: 42 CFR 435.603(b), family size + href: https://www.law.cornell.edu/cfr/text/42/435.603#b + - title: California Medicaid State Plan Amendment 13-0023-MM, S10 MAGI-Based Income Methodologies + href: https://www.medicaid.gov/State-resource-center/Medicaid-State-Plan-Amendments/Downloads/CA/CA-13-0023-MM.pdf#page=7 + - title: California DHCS All County Welfare Directors Letter 20-10 + href: https://www.dhcs.ca.gov/wp-content/uploads/2025/10/c20-10.pdf#page=3 + - title: New Jersey Medicaid State Plan Amendment 13-0016-MM3, S10 MAGI-Based Income Methodologies + href: https://www.medicaid.gov/State-resource-center/Medicaid-State-Plan-Amendments/Downloads/NJ/NJ-13-0016-MM3.pdf#page=5 + +# 42 CFR 435.603(b) lets each state count a pregnant woman in the household of +# the other members as herself (0 here), herself plus one (1) or herself plus +# the number of children she is expected to deliver (.inf). Her own household +# always counts every expected child. States other than California and New +# Jersey are not yet researched (issue 5251); they keep 0, the treatment the +# model applied before this parameter. +AK: + 2014-01-01: 0 +AL: + 2014-01-01: 0 +AR: + 2014-01-01: 0 +AZ: + 2014-01-01: 0 +CA: + # S10, effective 2014-01-01: herself plus the number of children she is + # expected to deliver. + 2014-01-01: .inf +CO: + 2014-01-01: 0 +CT: + 2014-01-01: 0 +DC: + 2014-01-01: 0 +DE: + 2014-01-01: 0 +FL: + 2014-01-01: 0 +GA: + 2014-01-01: 0 +HI: + 2014-01-01: 0 +IA: + 2014-01-01: 0 +ID: + 2014-01-01: 0 +IL: + 2014-01-01: 0 +IN: + 2014-01-01: 0 +KS: + 2014-01-01: 0 +KY: + 2014-01-01: 0 +LA: + 2014-01-01: 0 +MA: + 2014-01-01: 0 +MD: + 2014-01-01: 0 +ME: + 2014-01-01: 0 +MI: + 2014-01-01: 0 +MN: + 2014-01-01: 0 +MO: + 2014-01-01: 0 +MS: + 2014-01-01: 0 +MT: + 2014-01-01: 0 +NC: + 2014-01-01: 0 +ND: + 2014-01-01: 0 +NE: + 2014-01-01: 0 +NH: + 2014-01-01: 0 +NJ: + # S10, effective 2014-01-01: herself plus the number of children she is + # expected to deliver. + 2014-01-01: .inf +NM: + 2014-01-01: 0 +NV: + 2014-01-01: 0 +NY: + 2014-01-01: 0 +OH: + 2014-01-01: 0 +OK: + 2014-01-01: 0 +OR: + 2014-01-01: 0 +PA: + 2014-01-01: 0 +RI: + 2014-01-01: 0 +SC: + 2014-01-01: 0 +SD: + 2014-01-01: 0 +TN: + 2014-01-01: 0 +TX: + 2014-01-01: 0 +UT: + 2014-01-01: 0 +VA: + 2014-01-01: 0 +VT: + 2014-01-01: 0 +WA: + 2014-01-01: 0 +WI: + 2014-01-01: 0 +WV: + 2014-01-01: 0 +WY: + 2014-01-01: 0 diff --git a/policyengine_us/tests/core/test_parent_links_properties.py b/policyengine_us/tests/core/test_parent_links_properties.py index cdca0878cb7..540acdd7fde 100644 --- a/policyengine_us/tests/core/test_parent_links_properties.py +++ b/policyengine_us/tests/core/test_parent_links_properties.py @@ -364,7 +364,7 @@ def check_composition(households, members_of): simulation = Simulation(situation=linked_situation(households)) size = by_name(simulation, "medicaid_household_size") income = by_name(simulation, "medicaid_household_income") - pregnancies = by_name(simulation, "ca_medicaid_household_pregnancies") + pregnancies = by_name(simulation, "medicaid_household_pregnancies") # Households without any nonzero id keep main's family-sum expressions, # which the zero-id differential covers; check every household with ids. linked = [ @@ -410,7 +410,7 @@ def test_linked_composition_is_invariant_to_member_order(): "is_parent", "medicaid_household_size", "medicaid_household_income", - "ca_medicaid_household_pregnancies", + "medicaid_household_pregnancies", ]: assert by_name(forward, variable) == by_name(shuffled, variable), variable @@ -625,7 +625,7 @@ def test_tax_dependent_counts_a_co_resident_spouse_exactly_once(): non_filer = by_name(simulation, "medicaid_uses_non_filer_rules") size = by_name(simulation, "medicaid_household_size") income = by_name(simulation, "medicaid_household_income") - pregnancies = by_name(simulation, "ca_medicaid_household_pregnancies") + pregnancies = by_name(simulation, "medicaid_household_pregnancies") placements = {scenario["placement"] for scenario in scenarios} assert placements == set(SPOUSE_PLACEMENTS) for s, scenario in enumerate(scenarios): @@ -687,7 +687,7 @@ def test_tax_dependent_counts_a_co_resident_spouse_exactly_once(): for variable in [ "medicaid_household_size", "medicaid_household_income", - "ca_medicaid_household_pregnancies", + "medicaid_household_pregnancies", ]: assert by_name(simulation, variable) == by_name(reversed_, variable), variable @@ -709,7 +709,7 @@ def test_households_without_ids_keep_their_values_next_to_linked_ones(): "medicaid_uses_non_filer_rules", "medicaid_household_size", "medicaid_household_income", - "ca_medicaid_household_pregnancies", + "medicaid_household_pregnancies", ]: in_mixed = by_name(mixed, variable) for name, value in by_name(alone, variable).items(): diff --git a/policyengine_us/tests/policy/baseline/gov/states/ca/dhcs/medi_cal/ca_medicaid_household_pregnancies.yaml b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/income/medicaid_household_pregnancies.yaml similarity index 82% rename from policyengine_us/tests/policy/baseline/gov/states/ca/dhcs/medi_cal/ca_medicaid_household_pregnancies.yaml rename to policyengine_us/tests/policy/baseline/gov/hhs/medicaid/income/medicaid_household_pregnancies.yaml index 32405c21eee..6e6afa38bf0 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ca/dhcs/medi_cal/ca_medicaid_household_pregnancies.yaml +++ b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/income/medicaid_household_pregnancies.yaml @@ -1,4 +1,7 @@ -# DHCS ACWDL 20-10, pp. 3-5; MAGI Household Size Flowchart, steps 7-8. +# 42 CFR 435.603(b): a pregnant woman counts every expected child in her own +# household; California counts them in every member's household too (S10, SPA +# 13-0023-MM; DHCS ACWDL 20-10, pp. 3-5; MAGI Household Size Flowchart, steps +# 7-8). - name: Case 1, joint filers and dependent count twins once in each household. period: 2025 input: @@ -33,7 +36,7 @@ output: # Tax household of 3 plus the 2 expected children. medicaid_household_size: [5, 5, 5] - ca_medicaid_household_pregnancies: [2, 2, 2] + medicaid_household_pregnancies: [2, 2, 2] - name: Case 2, a pregnant dependent counts for both parents and the dependent. period: 2025 @@ -68,7 +71,7 @@ county_str: SANTA_CLARA_COUNTY_CA output: medicaid_household_size: [4, 4, 4] - ca_medicaid_household_pregnancies: [1, 1, 1] + medicaid_household_pregnancies: [1, 1, 1] - name: Case 3, all expected children count across multiple pregnant members. period: 2025 @@ -105,7 +108,7 @@ output: # 3 members plus 1 + 2 expected children. medicaid_household_size: [6, 6, 6] - ca_medicaid_household_pregnancies: [3, 3, 3] + medicaid_household_pregnancies: [3, 3, 3] - name: Case 4, separately filing unmarried parents with a pregnancy. period: 2025 @@ -154,7 +157,7 @@ # child lives with both parents, so the non-filer rule counts the child, # both parents and person2's unborn child. medicaid_household_size: [2, 2, 4] - ca_medicaid_household_pregnancies: [0, 1, 1] + medicaid_household_pregnancies: [0, 1, 1] - name: Case 5, separately filing married parents with a pregnancy. period: 2025 @@ -201,7 +204,7 @@ # spouse + her unborn child; person2 counts herself, the spouse and the # unborn child. medicaid_household_size: [4, 3, 4] - ca_medicaid_household_pregnancies: [1, 1, 1] + medicaid_household_pregnancies: [1, 1, 1] - name: Case 6, an unrelated pregnant roommate is not counted. period: 2025 @@ -245,7 +248,7 @@ county_str: SANTA_CLARA_COUNTY_CA output: medicaid_household_size: [2, 2, 2] - ca_medicaid_household_pregnancies: [0, 1, 0] + medicaid_household_pregnancies: [0, 1, 0] - name: Case 7, a known externally claimed pregnant dependent is counted without doubling her pregnancy. period: 2025 @@ -285,9 +288,9 @@ output: # Claimant plus the claimed dependent plus her unborn child. medicaid_household_size: [3, 3] - ca_medicaid_household_pregnancies: [1, 1] + medicaid_household_pregnancies: [1, 1] -- name: Case 8, non-California pregnancy household treatment is preserved. +- name: Case 8, Kansas counts the pregnancy only in the pregnant member's household. period: 2025 input: people: @@ -318,14 +321,15 @@ members: [person1, person2, person3] state_code: KS output: - # Outside California only the pregnant member's own household grows. + # Kansas's election is not yet researched and keeps 0: only the pregnant + # member's own household grows. medicaid_household_size: [3, 4, 3] - ca_medicaid_household_pregnancies: [0, 0, 0] + medicaid_household_pregnancies: [0, 1, 0] # ACWDL 20-10, p. 5, non-filer rule for a child: the child, the child's # children, the child's parents in the home and siblings. A pregnant teen mother -# is both a child-age member and a parent, so the union sum counts her one -# pregnancy once for herself and for her baby. +# is both a child-age member and a parent, so her one pregnancy counts once for +# herself and for her baby. - name: Case 9, a pregnant teen mother claimed on another return counts her pregnancy once for herself and her baby. period: 2025 input: @@ -373,16 +377,16 @@ output: medicaid_uses_non_filer_rules: [false, true, true] # person1 follows her own return (no pregnancy in it); person2 and person3 - # sum pregnancies once over the union of child-age members and parents. - ca_medicaid_household_pregnancies: [0, 1, 1] + # count each member of their non-filer households once. + medicaid_household_pregnancies: [0, 1, 1] # Eligibility is not asserted: under DHCS non-filer rules (Box C) the # infant's household is the infant and the teen mother, not the grandmother, # and the model's current composition for the infant is a follow-up. # ACWDL 20-10, p. 5, non-filer rule for a child: both 18-year-old parents are # child-age members (under 19) and parents, and each is the other's spouse. -# The wife's pregnancy is already inside the union sum for the husband, so the -# spouse channel must not add it again; every member counts it exactly once. +# The wife is the husband's spouse and a child-age parent, so her pregnancy +# counts once, not once for each role; every member counts it exactly once. - name: Case 10, married non-filing 18-year-old parents count the wife's pregnancy once for each member. period: 2025 input: @@ -422,7 +426,33 @@ # the same unit with both parents present, so no tax-dependent exception # applies and the child follows the parents' tax household (one pregnancy). medicaid_uses_non_filer_rules: [true, true, false] - # person1: wife's pregnancy via the (child | is_parent) union only, not - # again through the spouse channel; person2: her own pregnancy once; - # person3: the tax household sum over the unit. - ca_medicaid_household_pregnancies: [1, 1, 1] + # person1: the wife's pregnancy once, as his spouse and not again as a + # parent; person2: her own pregnancy once; person3: the tax household sum + # over the unit. + medicaid_household_pregnancies: [1, 1, 1] + +# 42 CFR 435.603(b)'s middle option counts a pregnant woman as 2 people in the +# other members' households, however many children she expects. No researched +# state elects it, so the case sets New Jersey's value to 1. +- name: Case 11, a state counting a pregnant member as herself plus one adds one child for twins. + period: 2026 + input: + gov.hhs.medicaid.household.pregnant_member_expected_children_cap.NJ: 1 + people: + person1: + age: 30 + employment_income: 37_701 + person2: + age: 29 + current_pregnancies: 2 + marital_units: + marital_unit: + members: [person1, person2] + households: + household: + members: [person1, person2] + state_code: NJ + output: + # person1 counts his wife as 2 people; she counts herself plus both twins. + medicaid_household_pregnancies: [1, 2] + medicaid_household_size: [3, 4] diff --git a/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/income/medicaid_household_size.yaml b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/income/medicaid_household_size.yaml index 8487f6a9e9f..a744c39ce1e 100644 --- a/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/income/medicaid_household_size.yaml +++ b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/income/medicaid_household_size.yaml @@ -1,8 +1,8 @@ -# Medicaid MAGI household size (42 CFR 435.603(b) and (f)). Outside California -# a pregnant person counts herself plus her expected children only in her own -# household; California (DHCS ACWDL 20-10, page 3) counts the unborn children of -# every member of the applicant's MAGI household, see -# ca_medicaid_household_pregnancies. +# Medicaid MAGI household size (42 CFR 435.603(b) and (f)). A pregnant person +# counts herself plus her expected children in her own household. In another +# member's household she counts as the state elects (S10 of each state plan): +# California and New Jersey count her expected children too; states not yet +# researched count her as one person. See medicaid_household_pregnancies. - name: Case 1, Kansas joint filers with one child count the pregnancy only in the pregnant member's household. period: 2025 input: @@ -69,7 +69,7 @@ state_code: CA output: # Tax household of 3 plus the 1 expected child for all three members. - ca_medicaid_household_pregnancies: [1, 1, 1] + medicaid_household_pregnancies: [1, 1, 1] medicaid_household_size: [4, 4, 4] - name: Case 3, Kansas single filer without a pregnancy is a household of one. @@ -266,7 +266,7 @@ tax_unit_is_filer: false medicaid_uses_non_filer_rules: [true, true, false] # Case 8's 3 members plus the 1 expected child, which California counts in - # every member's household (ca_medicaid_household_pregnancies). + # every member's household (medicaid_household_pregnancies). medicaid_household_size: [4, 4, 4] - name: Case 10, a non-filing adult and an 18-year-old spouse are each counted once. @@ -424,3 +424,35 @@ # rules: self and both parents. medicaid_uses_non_filer_rules: [true, true, true] medicaid_household_size: [3, 3, 3] + +# New Jersey's S10 (SPA 13-0016-MM3, effective 2014-01-01) counts a pregnant +# woman as herself plus the children she expects in every member's household. +# 2026 guideline: $15,960 plus $5,680 for each additional person. +- name: Case 15, a New Jersey husband counts his pregnant wife's expected child and qualifies for the adult group. + period: 2026 + absolute_error_margin: 0.001 + input: + people: + person1: + age: 30 + employment_income: 37_701 + person2: + age: 29 + is_pregnant: true + marital_units: + marital_unit: + members: [person1, person2] + households: + household: + members: [person1, person2] + state_code: NJ + output: + # Before this election was modeled, person1's household was 2: 37,701 / + # 21,640 = 1.7422 of the guideline, above the 1.38 adult limit. + medicaid_household_pregnancies: [1, 1] + medicaid_household_size: [3, 3] + # 37,701 / 27,320 = 1.37998. The monthly adult limit for 3 is + # 27,320 x 1.38 / 12 = 3,141.80, rounded up to $3,142, and 37,701 / 12 = + # 3,141.75 is within it. + medicaid_income_level: [1.37998, 1.37998] + medicaid_category: [ADULT, PREGNANT] diff --git a/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/income/parent_ids_composition.yaml b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/income/parent_ids_composition.yaml index ba1cca34267..b95887145e6 100644 --- a/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/income/parent_ids_composition.yaml +++ b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/income/parent_ids_composition.yaml @@ -289,7 +289,7 @@ # ACWDL 20-10 adds the unborn children of pregnant members of the # applicant's own MAGI household. The aunt is in her own household and # her child's, not the grandparent's, the mother's or the niece's. - ca_medicaid_household_pregnancies: [0, 0, 1, 0, 1] + medicaid_household_pregnancies: [0, 0, 1, 0, 1] medicaid_household_size: [1, 2, 3, 2, 3] medicaid_household_income: [40_000, 20_000, 10_000, 20_000, 10_000] @@ -1182,7 +1182,7 @@ # the child, the spouse and the spouse's unborn child: 4. The spouse's is # the spouse, the child and her unborn child: 3. The pregnant spouse is # not in the parent's household. - ca_medicaid_household_pregnancies: [0, 1, 1] + medicaid_household_pregnancies: [0, 1, 1] medicaid_household_size: [2, 4, 3] medicaid_household_income: [0, 30_000, 30_000] @@ -1677,7 +1677,7 @@ # As above, and ACWDL 20-10 adds the unborn child of each pregnant member: # the child's household is 3 people plus 1 unborn child, the spouse's 2 # people plus 1. The pregnant spouse is not in the parent's household. - ca_medicaid_household_pregnancies: [0, 1, 1] + medicaid_household_pregnancies: [0, 1, 1] medicaid_household_size: [2, 4, 3] medicaid_household_income: [0, 30_000, 30_000] @@ -2187,7 +2187,7 @@ # ACWDL 20-10 counts the pregnant spouse's unborn child in all three # households; income follows those same household memberships. medicaid_uses_non_filer_rules: [false, false, false] - ca_medicaid_household_pregnancies: [1, 1, 1] + medicaid_household_pregnancies: [1, 1, 1] medicaid_household_size: [4, 4, 3] medicaid_household_income: [60_000, 60_000, 60_000] @@ -2229,7 +2229,7 @@ # that spouse or pregnancy again. A dependent who need not file remains # excluded from the taxpayer's income even when filing voluntarily. medicaid_uses_non_filer_rules: [false, false] - ca_medicaid_household_pregnancies: [1, 1] + medicaid_household_pregnancies: [1, 1] medicaid_household_size: [3, 3] medicaid_household_income: [40_000, 40_000] diff --git a/policyengine_us/tests/policy/baseline/gov/states/ca/dhcs/medi_cal/mixed_households.yaml b/policyengine_us/tests/policy/baseline/gov/states/ca/dhcs/medi_cal/mixed_households.yaml index 8b5e1c100aa..7acce63b82f 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ca/dhcs/medi_cal/mixed_households.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ca/dhcs/medi_cal/mixed_households.yaml @@ -58,7 +58,7 @@ # California: 3 members plus 2 expected children for everyone. Kansas: only # the pregnant member's own household grows. medicaid_household_size: [5, 5, 5, 3, 4, 3] - ca_medicaid_household_pregnancies: [2, 2, 2, 0, 0, 0] + medicaid_household_pregnancies: [2, 2, 2, 0, 1, 0] - name: Case 2, CHIP no-other-coverage exclusion is applied per person in a mixed-state population. period: 2025 diff --git a/policyengine_us/variables/gov/hhs/medicaid/income/_household_sum.py b/policyengine_us/variables/gov/hhs/medicaid/income/_household_sum.py new file mode 100644 index 00000000000..99e4a9d717d --- /dev/null +++ b/policyengine_us/variables/gov/hhs/medicaid/income/_household_sum.py @@ -0,0 +1,66 @@ +"""Sum a value over each person's Medicaid MAGI household.""" + +import numpy as np + +from policyengine_us.model_api import where +from policyengine_us.variables.gov.hhs.medicaid.income._claiming_tax_unit import ( + medicaid_claiming_tax_unit_value, + medicaid_external_claimed_sum, +) +from policyengine_us.variables.gov.hhs.medicaid.income._non_filer_household import ( + medicaid_filer_spouse_sum, + medicaid_non_filer_fallback_sum, + medicaid_non_filer_member_sum, + medicaid_tax_dependent_spouse_sum, +) +from policyengine_us.variables.household.demographic.person._parent_links import ( + household_has_parent_ids, +) + + +def medicaid_household_sum( + person, period, values, spouse_values, separate_spouse_values +): + """Sum ``values`` once over each person's MAGI household. + + Tax filers and tax dependents follow the tax household (42 CFR + 435.603(f)(1), (f)(2) and (f)(4)); people under the non-filer rules + follow (f)(3). medicaid_household_size counts members with ``values`` of + one, and medicaid_household_pregnancies sums each member's counted + expected children. ``spouse_values`` is what the non-filer household's + spouse adds (medicaid_non_filer_fallback_sum's ``spouse_sum``), and + ``separate_spouse_values`` is what a separately filing spouse adds to + every member of the tax household when the tax unit flags cohabiting + spouses. + """ + values = np.asarray(values, dtype=np.float64) + has_parent_ids = household_has_parent_ids(person, period) + non_filer = where( + has_parent_ids, + medicaid_non_filer_member_sum(person, period, values), + medicaid_non_filer_fallback_sum(person, period, values, spouse_values), + ) + # With parent links, a head's or spouse's co-resident spouse outside the + # unit joins the unit's tax household, which its dependents and claimants + # elsewhere share (42 CFR 435.603(f)(2) and (f)(4)). + tax_household = ( + person.tax_unit.sum(values) + + separate_spouse_values + + person.tax_unit.sum(medicaid_filer_spouse_sum(person, period, values)) + + medicaid_external_claimed_sum( + person, period, person.tax_unit("tax_unit_id", period), values + ) + ) + tax_route = where( + person("medicaid_has_known_claiming_tax_unit", period), + medicaid_claiming_tax_unit_value(person, period, tax_household), + tax_household, + ) + # With parent links, a tax dependent's co-resident spouse joins their tax + # household once (42 CFR 435.603(f)(4)). + tax_route = where( + has_parent_ids, + tax_route + medicaid_tax_dependent_spouse_sum(person, period, values), + tax_route, + ) + return where(person("medicaid_uses_non_filer_rules", period), non_filer, tax_route) diff --git a/policyengine_us/variables/gov/hhs/medicaid/income/_non_filer_household.py b/policyengine_us/variables/gov/hhs/medicaid/income/_non_filer_household.py index ea7cd550f7f..16f2d4c1366 100644 --- a/policyengine_us/variables/gov/hhs/medicaid/income/_non_filer_household.py +++ b/policyengine_us/variables/gov/hhs/medicaid/income/_non_filer_household.py @@ -175,7 +175,7 @@ def medicaid_non_filer_member_sum(person, period, values): spouse, (ii) the individual's children under the age limit and (iii) for an individual under the age limit, their parents and their siblings under the age limit. Each pair of co-residents is tested once, so each member - counts once in size, income and California pregnancies. + counts once in size, income and expected children. Links identify parents, children and siblings. Parents are medicaid_parent_indices: the co-resident parents the ids name, plus the diff --git a/policyengine_us/variables/gov/hhs/medicaid/income/medicaid_household_pregnancies.py b/policyengine_us/variables/gov/hhs/medicaid/income/medicaid_household_pregnancies.py new file mode 100644 index 00000000000..c880c207e85 --- /dev/null +++ b/policyengine_us/variables/gov/hhs/medicaid/income/medicaid_household_pregnancies.py @@ -0,0 +1,57 @@ +from policyengine_us.model_api import * +from policyengine_us.variables.gov.hhs.medicaid.income._household_sum import ( + medicaid_household_sum, +) + + +class medicaid_household_pregnancies(Variable): + value_type = int + entity = Person + label = "Expected children in the Medicaid MAGI household size" + documentation = ( + "The expected children counted in the person's MAGI household size. " + "A pregnant woman counts every child she expects in her own household; " + "another member counts up to the state's election under 42 CFR " + "435.603(b) for each pregnant woman in their household." + ) + definition_period = YEAR + reference = ( + "https://www.law.cornell.edu/cfr/text/42/435.603#b", + "https://www.medicaid.gov/State-resource-center/Medicaid-State-Plan-Amendments/Downloads/CA/CA-13-0023-MM.pdf#page=7", + "https://www.medicaid.gov/State-resource-center/Medicaid-State-Plan-Amendments/Downloads/NJ/NJ-13-0016-MM3.pdf#page=5", + ) + + def formula(person, period, parameters): + p = parameters(period).gov.hhs.medicaid.household + state = person.household("state_code_str", period) + expected = person("current_pregnancies", period) + # What each pregnant member adds to the other members' households. + counted = min_(expected, p.pregnant_member_expected_children_cap[state]) + head_or_spouse = person("is_tax_unit_head_or_spouse", period) + head_spouse_count = person.tax_unit("head_spouse_count", period) + joint = head_or_spouse & (head_spouse_count == 2) + same_unit_spouse = joint * ( + person.tax_unit.sum(head_or_spouse * counted) - counted + ) + cohabitating_separate = person.tax_unit("cohabitating_spouses", period) & ( + head_spouse_count == 1 + ) + separate_spouse = where( + cohabitating_separate + & ( + head_or_spouse + | person("claimed_as_dependent_on_another_return", period) + ), + person.marital_unit.sum(counted) - counted, + 0, + ) + household = medicaid_household_sum( + person, + period, + counted, + same_unit_spouse + separate_spouse, + person.tax_unit.sum(head_or_spouse * separate_spouse), + ) + # The household sum includes the person's own capped count; her own + # household counts every child she expects. + return household + expected - counted diff --git a/policyengine_us/variables/gov/hhs/medicaid/income/medicaid_household_size.py b/policyengine_us/variables/gov/hhs/medicaid/income/medicaid_household_size.py index 8bf886f4bf0..2899b700448 100644 --- a/policyengine_us/variables/gov/hhs/medicaid/income/medicaid_household_size.py +++ b/policyengine_us/variables/gov/hhs/medicaid/income/medicaid_household_size.py @@ -1,16 +1,6 @@ from policyengine_us.model_api import * -from policyengine_us.variables.gov.hhs.medicaid.income._claiming_tax_unit import ( - medicaid_claiming_tax_unit_value, - medicaid_external_claimed_sum, -) -from policyengine_us.variables.gov.hhs.medicaid.income._non_filer_household import ( - medicaid_filer_spouse_sum, - medicaid_non_filer_fallback_sum, - medicaid_non_filer_member_sum, - medicaid_tax_dependent_spouse_sum, -) -from policyengine_us.variables.household.demographic.person._parent_links import ( - household_has_parent_ids, +from policyengine_us.variables.gov.hhs.medicaid.income._household_sum import ( + medicaid_household_sum, ) @@ -22,82 +12,24 @@ class medicaid_household_size(Variable): reference = ( "https://www.law.cornell.edu/cfr/text/42/435.603#b", "https://www.law.cornell.edu/cfr/text/42/435.603#f", - # California (ACWDL 20-10) counts the unborn children of every member of - # the applicant's MAGI household; see ca_medicaid_household_pregnancies. - "https://www.dhcs.ca.gov/wp-content/uploads/2025/10/c20-10.pdf#page=3", ) def formula(person, period, parameters): - non_filer_rules = person("medicaid_uses_non_filer_rules", period) head_or_spouse = person("is_tax_unit_head_or_spouse", period) - same_unit_spouse_count = head_or_spouse.astype(int) * ( - person.tax_unit("head_spouse_count", period) - 1 - ) + head_spouse_count = person.tax_unit("head_spouse_count", period) cohabitating_separate = person.tax_unit("cohabitating_spouses", period) & ( - person.tax_unit("head_spouse_count", period) == 1 - ) - claimed_by_another_return = person( - "claimed_as_dependent_on_another_return", period - ) - separate_spouse_count = (head_or_spouse | claimed_by_another_return).astype( - int - ) * cohabitating_separate.astype(int) - spouse_count = same_unit_spouse_count + separate_spouse_count - non_filer_household_size = medicaid_non_filer_fallback_sum( - person, period, np.ones(person.count), spouse_count + head_spouse_count == 1 ) - # With parent links in the household, count each member of the - # applicant's own non-filer household once, spouse included. - non_filer_household_size = where( - household_has_parent_ids(person, period), - medicaid_non_filer_member_sum(person, period, np.ones(person.count)), - non_filer_household_size, + separate_spouse = cohabitating_separate & ( + head_or_spouse | person("claimed_as_dependent_on_another_return", period) ) - tax_household_size = person.tax_unit("tax_unit_size", period) + ( - cohabitating_separate.astype(int) - ) - # With parent links, a head's or spouse's co-resident spouse outside - # the unit joins the unit's tax household, which its dependents and - # claimants elsewhere share (42 CFR 435.603(f)(2) and (f)(4)). - tax_household_size = tax_household_size + person.tax_unit.sum( - medicaid_filer_spouse_sum(person, period, np.ones(person.count)) - ).astype(int) - person_count = np.ones_like(person.tax_unit("tax_unit_id", period)) - tax_household_size = tax_household_size + medicaid_external_claimed_sum( + spouse_count = head_or_spouse * (head_spouse_count - 1) + separate_spouse + members = medicaid_household_sum( person, period, - person.tax_unit("tax_unit_id", period), - person_count, - ).astype(int) - known_claiming_tax_unit = person("medicaid_has_known_claiming_tax_unit", period) - claimant_tax_household_size = medicaid_claiming_tax_unit_value( - person, period, tax_household_size - ).astype(int) - tax_route_size = where( - known_claiming_tax_unit, - claimant_tax_household_size, - tax_household_size, - ) - # With parent links in the household, a tax dependent's co-resident - # spouse joins their tax household once (42 CFR 435.603(f)(4)). - tax_route_size = where( - household_has_parent_ids(person, period), - tax_route_size - + medicaid_tax_dependent_spouse_sum( - person, period, np.ones(person.count) - ).astype(int), - tax_route_size, - ) - - # California counts the unborn children of all members included in the - # applicant's MAGI household. Preserve the existing treatment elsewhere. - state = person.household("state_code", period) - pregnancies = where( - state == StateCode.CA, - person("ca_medicaid_household_pregnancies", period), - person("current_pregnancies", period), - ) - return ( - where(non_filer_rules, non_filer_household_size, tax_route_size) - + pregnancies + np.ones(person.count), + spouse_count, + cohabitating_separate.astype(int), ) + # 42 CFR 435.603(b) adds the expected children of pregnant members. + return members + person("medicaid_household_pregnancies", period) diff --git a/policyengine_us/variables/gov/states/ca/dhcs/medi_cal/ca_medicaid_household_pregnancies.py b/policyengine_us/variables/gov/states/ca/dhcs/medi_cal/ca_medicaid_household_pregnancies.py deleted file mode 100644 index b55af54bc12..00000000000 --- a/policyengine_us/variables/gov/states/ca/dhcs/medi_cal/ca_medicaid_household_pregnancies.py +++ /dev/null @@ -1,140 +0,0 @@ -from policyengine_us.model_api import * -from policyengine_us.variables.gov.hhs.medicaid.income._claiming_tax_unit import ( - medicaid_claiming_tax_unit_value, - medicaid_external_claimed_sum, -) -from policyengine_us.variables.gov.hhs.medicaid.income._non_filer_household import ( - medicaid_filer_spouse_sum, - medicaid_non_filer_member_sum, - medicaid_tax_dependent_spouse_sum, -) -from policyengine_us.variables.household.demographic.person._parent_links import ( - household_has_parent_ids, -) - - -class ca_medicaid_household_pregnancies(Variable): - value_type = int - entity = Person - label = "Unborn children in the California Medi-Cal MAGI household" - documentation = ( - "The number of children expected by every pregnant member of the " - "person's MAGI Medi-Cal household, including the person. California " - "elects the 42 CFR 435.603(b) option to count a pregnant member as " - "herself plus the children she expects when sizing other members' " - "households." - ) - definition_period = YEAR - defined_for = StateCode.CA - reference = ( - # ACWDL 20-10: the unborn children of a pregnant tax filer, spouse, or tax - # dependent belong to each member's household composition. - "https://www.dhcs.ca.gov/wp-content/uploads/2025/10/c20-10.pdf#page=3", - # DHCS MAGI household size flow chart, step 8: add the children expected - # by every other pregnant member of the composition. - "https://www.dhcs.ca.gov/hy/wp-content/uploads/2025/10/MAGIHouseholdSizeFlowChartADA.pdf#page=3", - ) - - def formula(person, period, parameters): - # Follow the applicant's MAGI composition, not the entire residence. - # This parallels medicaid_household_size, with pregnancies as weights. - pregnancies = person("current_pregnancies", period) - child = person("medicaid_non_filer_child_age_eligible", period) - head_or_spouse = person("is_tax_unit_head_or_spouse", period) - head_spouse_pregnancies = person.tax_unit.sum(head_or_spouse * pregnancies) - same_unit_spouse = head_or_spouse * (head_spouse_pregnancies - pregnancies) - cohabitating_separate = person.tax_unit("cohabitating_spouses", period) & ( - person.tax_unit("head_spouse_count", period) == 1 - ) - outside_claim = person("claimed_as_dependent_on_another_return", period) - separate_spouse = where( - cohabitating_separate & (head_or_spouse | outside_claim), - person.marital_unit.sum(pregnancies) - pregnancies, - 0, - ) - spouse_pregnancies = same_unit_spouse + separate_spouse - is_parent = person("is_parent", period) - child_pregnancies = person.family.sum(child * pregnancies) - # ACWDL 20-10 non-filer rule for a child-age applicant: the household is - # the child, the child's children, the parents in the home, and the - # siblings. Sum once over the UNION of child-age members and parents so - # a pregnant member who is both child-age and a parent (a teen mother) - # contributes her pregnancies once, not once per role. - child_household_pregnancies = person.family.sum( - (child | is_parent) * pregnancies - ) - branch_pregnancies = where( - child, - child_household_pregnancies, - pregnancies + child_pregnancies, - ) - - # The spouse channel above must not re-count a spouse who already sits - # inside the branch's family sum. Derive the spouse's child-age and - # parent flags through the same two channels (same tax unit head/spouse; - # cohabitating separate filers via the marital unit). This assumes - # spouses share the family entity, so a spouse inside the branch mask - # is already counted by the family sum. - def spouse_has_flag(flag): - flag = flag.astype(int) - same_unit = head_or_spouse * ( - person.tax_unit.sum(head_or_spouse * flag) - flag - ) - separate = where( - cohabitating_separate & (head_or_spouse | outside_claim), - person.marital_unit.sum(flag) - flag, - 0, - ) - return (same_unit + separate) > 0 - - spouse_child = spouse_has_flag(child) - spouse_parent = spouse_has_flag(is_parent) - spouse_in_branch = where(child, spouse_child | spouse_parent, spouse_child) - non_filer_pregnancies = ( - branch_pregnancies + spouse_pregnancies * ~spouse_in_branch - ) - # With parent links in the household, sum over the same members that - # medicaid_household_size counts, so an excluded relative's pregnancy - # never enters the applicant's household. - non_filer_pregnancies = where( - household_has_parent_ids(person, period), - medicaid_non_filer_member_sum(person, period, pregnancies), - non_filer_pregnancies, - ) - - # Include a separately filing spouse for every member of this tax - # household, including dependents whose own marital unit is a singleton. - tax_pregnancies = person.tax_unit.sum( - pregnancies + head_or_spouse * separate_spouse - ) - # With parent links, add the pregnancies of the co-resident spouse - # outside the unit whom medicaid_household_size adds. - tax_pregnancies += person.tax_unit.sum( - medicaid_filer_spouse_sum(person, period, pregnancies) - ).astype(int) - tax_pregnancies += medicaid_external_claimed_sum( - person, period, person.tax_unit("tax_unit_id", period), pregnancies - ).astype(int) - claimant_pregnancies = medicaid_claiming_tax_unit_value( - person, period, tax_pregnancies - ).astype(int) - tax_route_pregnancies = where( - person("medicaid_has_known_claiming_tax_unit", period), - claimant_pregnancies, - tax_pregnancies, - ) - # With parent links in the household, add the pregnancies of a tax - # dependent's co-resident spouse, whom medicaid_household_size adds. - tax_route_pregnancies = where( - household_has_parent_ids(person, period), - tax_route_pregnancies - + medicaid_tax_dependent_spouse_sum(person, period, pregnancies).astype( - int - ), - tax_route_pregnancies, - ) - return where( - person("medicaid_uses_non_filer_rules", period), - non_filer_pregnancies, - tax_route_pregnancies, - )