"""Summary CSV: one row per visit with its disposition.""" from datetime import date from decimal import Decimal from pathlib import Path from cyclone.rebill.summary import ( SummaryRow, write_summary_csv, REBILLED_A, REBILLED_B, EXCLUDED_CARC, EXCLUDED_TIMELY_FILING, EXCLUDED_PAYER, EXCLUDED_NO_EVV, ) from cyclone.rebill.reconcile import VisitRow def test_summary_csv_emits_one_row_per_visit(tmp_path: Path): out = tmp_path / "summary.csv" rows = [ SummaryRow( visit=VisitRow(date=date(2026, 6, 27), member_id="J813715", procedure="T1019", billed=Decimal("2.32")), disposition=REBILLED_A, unpaid=Decimal("0.00"), cas_reasons=("CO-45",), file_path="pipeline-a/x.837", ), SummaryRow( visit=VisitRow(date=date(2026, 1, 1), member_id="OLD", procedure="T1019", billed=Decimal("2.32")), disposition=EXCLUDED_TIMELY_FILING, unpaid=Decimal("2.32"), cas_reasons=(), file_path="", ), ] write_summary_csv(rows, out) text = out.read_text() assert "J813715" in text assert "REBILLED_A" in text assert "EXCLUDED_TIMELY_FILING" in text assert "OLD" in text def test_disposition_constants(): assert REBILLED_A == "REBILLED_A" assert REBILLED_B == "REBILLED_B" assert EXCLUDED_CARC == "EXCLUDED_CARC" assert EXCLUDED_TIMELY_FILING == "EXCLUDED_TIMELY_FILING"