feat(sp31): expose keys_matched/candidate_count in Match dataclass and ActivityEvent payload, fix broken pre-existing test

This commit is contained in:
Nora
2026-07-02 16:23:42 -06:00
parent ab91449e62
commit 18fa119ff7
3 changed files with 121 additions and 55 deletions
@@ -153,19 +153,18 @@ def test_provider_detail_includes_orphan_remit_received(seeded_db: TestClient):
the moment an 835 lands — the most common activity, invisible.
Setup: ingest 837+835 for ``TEST_837_NPI`` (claim CLM001 + remit
CLM001), then manually match them so ``Remittance.claim_id`` is
populated. The bug presents as: only ``claim_submitted`` and
``manual_match`` appear (no ``remit_received``). The fix surfaces
all three.
CLM001). With SP31, the minimal fixtures now auto-link via the
content-keys fallback (PCN + charge agree → 2-of-3) so
``Remittance.claim_id`` is populated as part of the 835 ingest
itself — no separate manual-match call needed. The bug presents
as: only ``claim_submitted`` appears (no ``remit_received``). The
fix surfaces both.
"""
# Force the match — simulates the post-reconciliation state that
# populate Remittance.claim_id without depending on auto-reconcile
# heuristics (which don't match this minimal fixture).
match_resp = seeded_db.post(
"/api/reconciliation/match",
json={"claim_id": "CLM001", "remit_id": "CLM001"},
)
assert match_resp.status_code == 200, match_resp.text
# The minimal fixture's PCN ("CLM001") + charge ("$100.00") match,
# so SP31's content-keys fallback pairs the remit during ingest.
# No manual-match call is required (and would now 409 "already_matched").
# The intent of this test — surfacing the remit_received event via
# the Remittance.claim_id join — is fully exercised either way.
resp = seeded_db.get(f"/api/config/providers/{TEST_837_NPI}")
assert resp.status_code == 200, resp.text