Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/bhp-followups.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A link copied at $0 of earnings opens with $0 in the earnings box and its cards, and the code cites 42 U.S.C. 18051(e)(2), the paragraph that bars Basic Health Program enrollees from the Marketplace.
2 changes: 1 addition & 1 deletion src/aca_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ def run_at_income(data: AtIncomeRequest, year: int, enhanced: bool) -> ScenarioA
for m, c, b, h in zip(medicaid, chip, barred, basic_health)
]
# Only members no program covers can buy a Marketplace plan; Basic Health
# Program enrollees can't (42 U.S.C. 18051(e)).
# Program enrollees can't (42 U.S.C. 18051(e)(2)).
uncovered = [
name for name, person in zip(situation["people"], coverage)
if not (person.medicaid or person.chip or person.basic_health_program)
Expand Down
2 changes: 1 addition & 1 deletion src/aca_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class PersonCoverage(BaseModel):
description=(
"Eligible for the state's Basic Health Program (MinnesotaCare, New "
"York's Essential Plan, OHP Bridge or the Healthy DC Plan), which "
"rules out Marketplace enrollment (42 U.S.C. 18051(e))"
"rules out Marketplace enrollment (42 U.S.C. 18051(e)(2))"
),
)

Expand Down
4 changes: 2 additions & 2 deletions src/components/CalculatorForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const buildShareableUrl = (request, { compare = false, view = "net", income = nu
if (request.zip_code) params.set("zip", request.zip_code);
if (compare) params.set("compare", "1");
if (view !== "net" && VIEWS.includes(view)) params.set("view", view);
if (income > 0) params.set("income", String(income));
if (income != null && income >= 0) params.set("income", String(income));

const baseUrl = window.location.origin + window.location.pathname;
return `${baseUrl}#calculator?${params.toString()}`;
Expand Down Expand Up @@ -112,7 +112,7 @@ const getLinkFromUrl = () => {
form: getFormDataFromUrl(),
compare: params.get("compare") === "1",
view: VIEWS.includes(view) ? view : "net",
income: income > 0 ? income : null,
income: income >= 0 ? income : null,
};
};

Expand Down
65 changes: 65 additions & 0 deletions src/components/CalculatorForm.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// The calculator's links carry the earnings entered. $0 of earnings gets cards
// like any other income, so a link keeps it; a blank box leaves it out.
import { afterEach, describe, expect, test } from "bun:test";
import { buildShareableUrl, getLinkFromUrl } from "./CalculatorForm";

const REQUEST = {
age_head: 40,
age_spouse: null,
dependent_ages: [],
state: "PA",
county: "Lebanon County",
zip_code: "",
};

// The page's address, which the link helpers read from window.location.
const originalWindow = globalThis.window;
function at(hash = "") {
globalThis.window = {
location: { origin: "https://policyengine.org", pathname: "/us/aca-calc", hash },
};
}
afterEach(() => {
globalThis.window = originalWindow;
});

// The query of the link for some income on the "Your household" tab.
function linkQuery(income) {
at();
const hash = new URL(buildShareableUrl(REQUEST, { view: "impact", income })).hash;
return new URLSearchParams(hash.slice(hash.indexOf("?") + 1));
}

// The income a link opens with.
function openedIncome(query) {
at(`#calculator?age=40&state=PA&county=Lebanon+County&view=impact${query}`);
return getLinkFromUrl().income;
}

describe("a link's income", () => {
test("keeps $0", () => {
expect(linkQuery(0).get("income")).toBe("0");
});

test("keeps $40,000", () => {
expect(linkQuery(40_000).get("income")).toBe("40000");
});

test("is left out for a blank box", () => {
expect(linkQuery(null).has("income")).toBe(false);
});

test("opens at $0 when the link asks for $0", () => {
expect(openedIncome("&income=0")).toBe(0);
});

test("opens at the amount a link asks for", () => {
expect(openedIncome("&income=40000")).toBe(40_000);
});

test("opens blank without an income, or with one that isn't a number or is below $0", () => {
expect(openedIncome("")).toBeNull();
expect(openedIncome("&income=abc")).toBeNull();
expect(openedIncome("&income=-5")).toBeNull();
});
});
6 changes: 3 additions & 3 deletions src/components/CalculatorResults.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function describeMembers(indices, people) {
// Medicaid's limit up to 200% FPL. New York's limit was 250% until its section
// 1332 waiver ended on June 30, 2026; the model's eligibility is annual, so it
// keeps 250% for all of 2026. People the program covers can't enroll in a
// Marketplace plan (42 U.S.C. 18051(e)).
// Marketplace plan (42 U.S.C. 18051(e)(2)).
const BASIC_HEALTH_PROGRAMS = {
DC: {
state: "DC",
Expand Down Expand Up @@ -372,12 +372,12 @@ function CalculatorResults({
// The tab and income a link opened on, or an example household's income,
// so its cards match the Overview.
const [activeTab, setActiveTab] = useState(initialTab);
const [userIncome, setUserIncome] = useState(initialIncome ? String(initialIncome) : "");
const [userIncome, setUserIncome] = useState(initialIncome != null ? String(initialIncome) : "");

// Tell the calculator what's on screen, for the page's link.
useEffect(() => {
const income = parseFloat(userIncome);
onViewChange?.({ tab: activeTab, income: income > 0 ? income : null });
onViewChange?.({ tab: activeTab, income: income >= 0 ? income : null });
}, [activeTab, userIncome, onViewChange]);

// An answer from before the API took a year is for 2026.
Expand Down