feat(sp14): 5-lane Inbox UI with Payer-Rejected acknowledge action
Closes the gap between the SP10 backend (5 lanes) and the SP6
frontend (4 lanes). The Payer-Rejected lane (277CA STC A4/A6/A7)
is now rendered alongside Rejected/Candidates/Unmatched/Done,
with an Acknowledge bulk action that drops claims from the
working surface without erasing the original 277CA rejection
event (audit log stays intact, SP11).
Backend:
* Migration 0010: add payer_rejected_acknowledged_at +
payer_rejected_acknowledged_actor columns + partial index.
* db.py: surface the two new columns on the Claim model.
* inbox_lanes.py: filter acknowledged claims out of the
payer_rejected lane; expose the new fields on the row payload
for forward-compat (e.g. a future 'Recently acknowledged' view).
* api.py:
- POST /api/inbox/payer-rejected/acknowledge
Bulk-acknowledge. Idempotent. Returns transitioned /
already_acked / not_found / not_rejected counts so the UI
can show '3 of 5 were already acknowledged' on a noop bulk.
Writes a 'claim.payer_rejected_acknowledged' event to the
SP11 hash-chained audit log.
- GET /api/inbox/export.csv: accept 'payer_rejected' lane.
* test_acks.py: bump user_version assertion to 10.
* test_lane_filter_acknowledged.py: 4 tests for the lane filter
and forward-compat row payload.
* test_payer_rejected_acknowledge.py: 6 tests for the endpoint
(happy path, idempotency, no-op on non-rejected, missing
ids, 400 on empty, audit-log wiring + chain integrity).
Frontend:
* lib/inbox-api.ts: add payer_rejected to InboxLanes, add
acknowledgePayerRejected(), update exportInboxCsvUrl union.
* hooks/useInboxLanes.ts: add payer_rejected to initial state.
* hooks/useInboxLanes.test.ts: add payer_rejected to mocks.
* components/inbox/BulkBar.tsx: add 'payer_rejected' lane with
Acknowledge action (no Resubmit, no Dismiss — payer-rejected
is not eligible for either).
* components/inbox/BulkBar.test.tsx: add payer_rejected test.
* pages/Inbox.tsx: render the 5th lane, hook up onAcknowledge,
include payer_rejected in the needEyes count.
* pages/Inbox.test.tsx: 3 new tests (5-lane render, need-eyes
count, acknowledge action hits the right endpoint).
* components/inbox/InboxHeader.tsx: doc comment now explains
why payer_rejected rolls up into need-eyes.
Pre-existing typecheck warnings in BulkBar.test.tsx / InboxRow
.test.tsx / Lane.tsx / download.test.ts are unchanged from
main — not touched here.
Test counts: backend 724 -> 734 (+10). Frontend 350 -> 354 (+4).
This commit is contained in:
+111
-1
@@ -12,13 +12,17 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
describe("Inbox page", () => {
|
||||
it("renders the four lane headers", async () => {
|
||||
it("renders the five lane headers", async () => {
|
||||
// SP14: the Payer-Rejected lane was added (277CA STC A4/A6/A7).
|
||||
// The Inbox now renders 5 lanes: REJECTED, PAYER REJECTED,
|
||||
// CANDIDATES, UNMATCHED, DONE.
|
||||
vi.stubGlobal(
|
||||
"fetch",
|
||||
vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
rejected: [],
|
||||
payer_rejected: [],
|
||||
candidates: [],
|
||||
unmatched: [],
|
||||
done_today: [],
|
||||
@@ -28,12 +32,117 @@ describe("Inbox page", () => {
|
||||
const { container } = render(<Inbox />);
|
||||
await waitFor(() => {
|
||||
expect(container.textContent).toContain("REJECTED");
|
||||
expect(container.textContent).toContain("PAYER REJECTED");
|
||||
expect(container.textContent).toContain("CANDIDATES");
|
||||
expect(container.textContent).toContain("UNMATCHED");
|
||||
expect(container.textContent).toContain("DONE");
|
||||
});
|
||||
});
|
||||
|
||||
it("SP14: payer-rejected row count rolls up into the need-eyes header", async () => {
|
||||
// The "need eyes" total in the header is the operator's
|
||||
// anchor for the day. Payer-rejected claims are actionable
|
||||
// (operator must acknowledge or follow up), so they count
|
||||
// toward the need-eyes total alongside 999 rejected, candidates,
|
||||
// and unmatched.
|
||||
vi.stubGlobal(
|
||||
"fetch",
|
||||
vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
rejected: [],
|
||||
payer_rejected: [
|
||||
{ id: "PR1", kind: "claim", patient_control_number: "PR1",
|
||||
charge_amount: 250, payer_id: "CO_TXIX", provider_npi: "1881068062",
|
||||
state: "submitted", rejection_reason: "A7 invalid dx",
|
||||
service_date_from: null, payer_rejected_status_code: "A7",
|
||||
payer_rejected_reason: "invalid diagnosis",
|
||||
payer_rejected_at: "2026-06-20T10:00:00Z" },
|
||||
],
|
||||
candidates: [],
|
||||
unmatched: [],
|
||||
done_today: [],
|
||||
}),
|
||||
}),
|
||||
);
|
||||
const { container } = render(<Inbox />);
|
||||
await waitFor(() => {
|
||||
expect(container.textContent).toContain("1");
|
||||
expect(container.textContent).toContain("items need eyes");
|
||||
});
|
||||
});
|
||||
|
||||
it("SP14: acknowledging selected payer-rejected claims calls the API and refetches", async () => {
|
||||
// The user selects a payer-rejected claim, hits Acknowledge, and
|
||||
// the inbox calls /api/inbox/payer-rejected/acknowledge with the
|
||||
// claim id, then refetches the lane payload.
|
||||
const fetchMock = vi.fn().mockImplementation(async (url: string) => {
|
||||
if (url.includes("/api/inbox/lanes")) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
rejected: [],
|
||||
payer_rejected: [
|
||||
{ id: "PR1", kind: "claim", patient_control_number: "PR1",
|
||||
charge_amount: 250, payer_id: "CO_TXIX", provider_npi: "1881068062",
|
||||
state: "submitted", rejection_reason: "A7 invalid dx",
|
||||
service_date_from: null, payer_rejected_status_code: "A7",
|
||||
payer_rejected_reason: "invalid diagnosis",
|
||||
payer_rejected_at: "2026-06-20T10:00:00Z" },
|
||||
],
|
||||
candidates: [],
|
||||
unmatched: [],
|
||||
done_today: [],
|
||||
}),
|
||||
};
|
||||
}
|
||||
if (url.includes("/api/inbox/payer-rejected/acknowledge")) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
ok: true,
|
||||
transitioned: 1,
|
||||
already_acked: 0,
|
||||
not_found: 0,
|
||||
not_rejected: 0,
|
||||
}),
|
||||
};
|
||||
}
|
||||
return { ok: true, json: async () => ({}) };
|
||||
});
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
|
||||
const { container, getByTestId } = render(<Inbox />);
|
||||
await waitFor(() => {
|
||||
expect(container.textContent).toContain("PR1");
|
||||
});
|
||||
|
||||
// Select the PR1 claim via its checkbox.
|
||||
const checkbox = container.querySelector(
|
||||
'input[type="checkbox"][aria-label="Select PR1"]',
|
||||
) as HTMLInputElement;
|
||||
expect(checkbox).toBeTruthy();
|
||||
await act(async () => {
|
||||
checkbox.click();
|
||||
});
|
||||
|
||||
// Hit Acknowledge. The bulk action bar button is wired to the
|
||||
// /api/inbox/payer-rejected/acknowledge endpoint.
|
||||
const ackButton = getByTestId("payer-rejected-acknowledge");
|
||||
await act(async () => {
|
||||
ackButton.click();
|
||||
});
|
||||
|
||||
// The mock was called with the acknowledge URL.
|
||||
const ackCall = fetchMock.mock.calls.find(
|
||||
(c) => typeof c[0] === "string" && c[0].includes("/api/inbox/payer-rejected/acknowledge"),
|
||||
);
|
||||
expect(ackCall).toBeTruthy();
|
||||
expect(ackCall).toBeDefined();
|
||||
const ackBody = JSON.parse(ackCall![1].body);
|
||||
expect(ackBody.claim_ids).toEqual(["PR1"]);
|
||||
});
|
||||
|
||||
it("SP8: multi-select resubmit opens bundle modal; Resubmit + Download triggers api + downloadBlob", async () => {
|
||||
// Two rejected claims → user selects both → Re-submit → modal appears
|
||||
// → user clicks Resubmit + Download → backend is hit with
|
||||
@@ -53,6 +162,7 @@ describe("Inbox page", () => {
|
||||
state: "rejected", rejection_reason: "old", service_date: null,
|
||||
score: null },
|
||||
],
|
||||
payer_rejected: [],
|
||||
candidates: [],
|
||||
unmatched: [],
|
||||
done_today: [],
|
||||
|
||||
Reference in New Issue
Block a user