plan(SP22): Task 5 — apply Task 4 fixes (4xx terminal, RuntimeError) to list_claims and parse_837
This commit is contained in:
@@ -980,7 +980,8 @@ Add the methods to the `CycloneClient` class (below `scheduler_status`):
|
|||||||
params: dict[str, str] = {"limit": str(limit)}
|
params: dict[str, str] = {"limit": str(limit)}
|
||||||
if since:
|
if since:
|
||||||
params["since"] = since
|
params["since"] = since
|
||||||
assert self._http is not None
|
if self._http is None:
|
||||||
|
raise RuntimeError("use `async with CycloneClient(...)`")
|
||||||
last_exc: Exception | None = None
|
last_exc: Exception | None = None
|
||||||
for attempt in range(MAX_RETRIES):
|
for attempt in range(MAX_RETRIES):
|
||||||
try:
|
try:
|
||||||
@@ -992,7 +993,12 @@ Add the methods to the `CycloneClient` class (below `scheduler_status`):
|
|||||||
ClaimSummary.model_validate(c)
|
ClaimSummary.model_validate(c)
|
||||||
for c in _extract_items(resp.json())
|
for c in _extract_items(resp.json())
|
||||||
]
|
]
|
||||||
except (httpx.HTTPStatusError, httpx.RequestError) as e:
|
except httpx.HTTPStatusError as e:
|
||||||
|
# 4xx is terminal — surface immediately, do not retry
|
||||||
|
if e.response is not None and e.response.status_code < 500:
|
||||||
|
raise
|
||||||
|
last_exc = e
|
||||||
|
except httpx.RequestError as e:
|
||||||
last_exc = e
|
last_exc = e
|
||||||
if attempt < MAX_RETRIES - 1:
|
if attempt < MAX_RETRIES - 1:
|
||||||
await asyncio.sleep(BACKOFF_S[attempt])
|
await asyncio.sleep(BACKOFF_S[attempt])
|
||||||
@@ -1003,11 +1009,13 @@ Add the methods to the `CycloneClient` class (below `scheduler_status`):
|
|||||||
self, file_path, payer: str = "co_medicaid"
|
self, file_path, payer: str = "co_medicaid"
|
||||||
) -> ParseSummary:
|
) -> ParseSummary:
|
||||||
"""POST the .edi/.txt file to cyclone's parse endpoint.
|
"""POST the .edi/.txt file to cyclone's parse endpoint.
|
||||||
Returns a typed summary.
|
Returns a typed summary. POSTs are not retried on transport
|
||||||
|
failures (caller is responsible for dedup).
|
||||||
"""
|
"""
|
||||||
from pathlib import Path # local import keeps the top of the file lean
|
from pathlib import Path # local import keeps the top of the file lean
|
||||||
path = Path(file_path)
|
path = Path(file_path)
|
||||||
assert self._http is not None
|
if self._http is None:
|
||||||
|
raise RuntimeError("use `async with CycloneClient(...)`")
|
||||||
with path.open("rb") as f:
|
with path.open("rb") as f:
|
||||||
resp = await self._http.post(
|
resp = await self._http.post(
|
||||||
"/api/parse-837",
|
"/api/parse-837",
|
||||||
|
|||||||
Reference in New Issue
Block a user