"""835 SVC-level parser with member_id at SVC scope.""" from pathlib import Path from decimal import Decimal from cyclone.rebill.parse_835_svc import parse_835_svc FIX = Path(__file__).parent / "fixtures" / "835_sample_svc_with_member.txt" def test_parse_835_svc_extracts_member_id(): """NM1*QC NM109 at the CLP scope must propagate to every SVC row.""" rows = list(parse_835_svc(FIX)) assert len(rows) >= 1 for r in rows: assert r.member_id == "J813715" assert r.procedure # non-empty assert r.svc_date # non-empty assert r.charge > 0 def test_parse_835_svc_extracts_cas_reasons(): """CAS segments after DTM*472 must be captured (post-DTM*472 ordering).""" rows = list(parse_835_svc(FIX)) # at least one row should have an OA-18 reason assert any("OA-18" in r.cas_reasons for r in rows) def test_parse_835_svc_picks_up_status_22_reversals(): """Status 22 (reversal of previous payment) must be preserved.""" rows = list(parse_835_svc(FIX)) statuses = {r.status for r in rows} assert statuses & {"1", "4", "22"} # at least one of each present