fix(backend): make 835 summary counts consistent with total_claims
This commit is contained in:
@@ -41,7 +41,8 @@ def test_parse_835_endpoint_returns_json(client: TestClient):
|
||||
assert "claims" in body and len(body["claims"]) == 2
|
||||
assert "summary" in body
|
||||
assert body["summary"]["total_claims"] == 2
|
||||
assert body["summary"]["passed"] == 1
|
||||
assert body["summary"]["passed"] == 2
|
||||
assert body["summary"]["failed"] == 0
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
@@ -79,7 +80,7 @@ def test_parse_835_endpoint_streams_ndjson(client: TestClient):
|
||||
|
||||
# Summary numbers match the JSON path.
|
||||
assert parsed[7]["data"]["total_claims"] == 2
|
||||
assert parsed[7]["data"]["passed"] == 1
|
||||
assert parsed[7]["data"]["passed"] == 2
|
||||
|
||||
|
||||
def test_parse_835_endpoint_streams_ndjson_without_raw_segments(client: TestClient):
|
||||
@@ -123,7 +124,7 @@ def test_parse_835_endpoint_handles_payer_query_param(client: TestClient):
|
||||
assert resp.status_code == 200, (payer, resp.text)
|
||||
body = resp.json()
|
||||
assert body["summary"]["total_claims"] == 2
|
||||
assert body["summary"]["passed"] == 1
|
||||
assert body["summary"]["passed"] == 2
|
||||
|
||||
|
||||
def test_parse_835_endpoint_rejects_unknown_payer(client: TestClient):
|
||||
|
||||
@@ -9,6 +9,7 @@ from cyclone.cli import main
|
||||
|
||||
FIXTURE = Path(__file__).parent / "fixtures" / "minimal_835.txt"
|
||||
UNBALANCED = Path(__file__).parent / "fixtures" / "unbalanced_835.txt"
|
||||
CO_FIXTURE = Path(__file__).parent / "fixtures" / "co_medicaid_835.txt"
|
||||
|
||||
|
||||
def test_cli_parse_835_writes_outputs(tmp_path: Path):
|
||||
@@ -71,3 +72,21 @@ def test_cli_parse_835_generic_payer(tmp_path: Path):
|
||||
assert result.exit_code == 0, result.output
|
||||
summary = json.loads((tmp_path / "summary.json").read_text())
|
||||
assert summary["passed"] == 1
|
||||
|
||||
|
||||
def test_cli_parse_835_summary_counts_consistent(tmp_path: Path):
|
||||
"""Regression: passed + failed must equal total_claims for any batch size.
|
||||
|
||||
The CO Medicaid fixture has 2 claim payments; if the batch validates
|
||||
cleanly, both must show as passed (passed=2, failed=0). A pre-fix
|
||||
implementation set passed=1 regardless of claim count.
|
||||
"""
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(main, ["parse-835", str(CO_FIXTURE), "--output-dir", str(tmp_path)])
|
||||
assert result.exit_code == 0, result.output
|
||||
summary = json.loads((tmp_path / "summary.json").read_text())
|
||||
assert summary["total_claims"] == 2
|
||||
assert summary["passed"] + summary["failed"] == summary["total_claims"]
|
||||
assert summary["passed"] == 2
|
||||
assert summary["failed"] == 0
|
||||
assert summary["failed_claim_ids"] == []
|
||||
|
||||
Reference in New Issue
Block a user