feat(backend): add GET /api/{remittances,providers,activity}

This commit is contained in:
Tyler
2026-06-19 19:26:58 -06:00
parent cab8ff6656
commit cbffdbd2af
2 changed files with 130 additions and 0 deletions
+71
View File
@@ -450,4 +450,75 @@ def list_claims(
}
@app.get("/api/remittances")
def list_remittances(
batch_id: str | None = Query(None),
payer: str | None = Query(None),
claim_id: str | None = Query(None),
date_from: str | None = Query(None),
date_to: str | None = Query(None),
sort: str | None = Query(None),
order: str = Query("desc"),
limit: int = Query(100, ge=1, le=1000),
offset: int = Query(0, ge=0),
) -> dict[str, Any]:
common = dict(
batch_id=batch_id,
payer=payer,
claim_id=claim_id,
date_from=date_from,
date_to=date_to,
)
items = list(store.iter_remittances(
sort=sort, order=order, limit=limit, offset=offset, **common,
))
total = len(list(store.iter_remittances(**common)))
return {
"items": items,
"total": total,
"returned": len(items),
"has_more": total > offset + len(items),
}
@app.get("/api/providers")
def list_providers(
npi: str | None = Query(None),
state: str | None = Query(None),
limit: int = Query(100, ge=1, le=1000),
offset: int = Query(0, ge=0),
) -> dict[str, Any]:
items = store.distinct_providers()
if npi is not None:
items = [p for p in items if p["npi"] == npi]
if state is not None:
items = [p for p in items if p.get("state") == state]
paged = items[offset:offset + limit]
return {
"items": paged,
"total": len(items),
"returned": len(paged),
"has_more": len(items) > offset + len(paged),
}
@app.get("/api/activity")
def list_activity(
kind: str | None = Query(None),
since: str | None = Query(None),
limit: int = Query(200, ge=1, le=500),
) -> dict[str, Any]:
events = store.recent_activity(limit=limit)
if kind is not None:
events = [e for e in events if e["kind"] == kind]
if since is not None:
events = [e for e in events if e["timestamp"] >= since]
return {
"items": events,
"total": len(events),
"returned": len(events),
"has_more": False,
}
__all__ = ["app"]