feat(frontend): ClaimDetail type + api.getClaimDetail

This commit is contained in:
Tyler
2026-06-20 10:01:40 -06:00
parent b984c01d9a
commit 44e1c4616d
3 changed files with 256 additions and 1 deletions
+25
View File
@@ -23,6 +23,7 @@
import type {
Ack,
ClaimDetail,
ClaimOutput,
ClaimPayment,
Envelope,
@@ -451,6 +452,29 @@ async function listClaims<T = unknown>(
return (await res.json()) as PaginatedResponse<T>;
}
/**
* Fetch one claim with the full SP4 detail-drawer context (header, state,
* parties, validation, service lines, diagnoses, raw segments, recent
* ``stateHistory``, and a populated ``matchedRemittance`` when paired).
*
* Drives ``GET /api/claims/{claim_id}``. Throws ``ApiError`` on non-2xx —
* including 404, which the spec §3.4 calls out as a distinct "claim
* doesn't exist" state in the drawer (separate from a transient fetch
* failure). Callers should branch on ``error.status === 404`` to render
* the not-found state instead of the generic error toast.
*/
async function getClaimDetail(id: string): Promise<ClaimDetail> {
if (!isConfigured) throw notConfiguredError();
const res = await fetch(joinUrl(`/api/claims/${encodeURIComponent(id)}`), {
headers: { Accept: "application/json" },
});
if (!res.ok) {
const detail = await readErrorBody(res);
throw new ApiError(res.status, detail || res.statusText);
}
return (await res.json()) as ClaimDetail;
}
async function listRemittances<T = unknown>(
params: ListRemittancesParams
): Promise<PaginatedResponse<T>> {
@@ -649,6 +673,7 @@ export const api = {
listBatches,
getBatch,
listClaims,
getClaimDetail,
listRemittances,
getRemittance,
listProviders,