feat(frontend): ClaimDetail type + api.getClaimDetail
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user