afd6cead06
Per the SP41-goal verifier feedback on AC2/AC3: the committed
select_spot_check_visits reimplemented reconcile inline against
service_line_payments on (procedure, DOS) only. That table has
no member_id at SVC scope, so OA-18 dedup inherited CAS reasons
from all SVCs at the same (procedure, DOS), misclassifying visits
across members (the operator's 'multiple rejections due to files
being submitted multiple times' noise).
This commit restructures the spot-check pipeline per the
strategist recommendation:
1. Extract load_in_window_svc_rows(ingest_dir, window_start,
window_end) in parse_835_svc.py as the canonical ingest helper.
run.py's existing loop is replaced with a one-line call.
2. select_spot_check_visits becomes a thin adapter:
- Reads in-window visits from the visits table.
- Loads SVCs via load_in_window_svc_rows.
- Calls reconcile_visits_to_835 (authoritative match key).
- Builds a member-scoped CAS lookup keyed by
(member_id, procedure, svc_date) so OA-18 inspection only
sees the matched member's adjudications.
- Returns the top-N DENIED / PARTIAL / NOT_IN_835 by
billed_amount desc.
3. New test_select_spot_check_visits_member_isolation unit test
drives the SHIPPED code on the real path (real .x12 fixtures
reparsed by parse_835_svc) and pins the structural fix:
two visits at the same (procedure, DOS) for DIFFERENT members,
member A with OA-18-only CAS, member B with none. A is
excluded, B stays a candidate. The OLD (procedure, DOS)-only
indexer excluded BOTH (verified separately at
/tmp/old_logic_check.py).
4. Existing OA-18 test rewritten to use real .x12 fixtures in
tmp_path (instead of inserting into service_line_payments /
cas_adjustments, which the new pipeline does not read).
Verification:
- Full backend suite: 1593 passed, 10 skipped (prodfile/docker), 0 failed.
- Live Edifabric 10/10 re-run with the new pipeline: 10 files,
all status='success', all 6 required segment classes per file.
Evidence at /tmp/grok-goal-4336f8e1af6d/implementer/spot-check.json