feat(sp7): add per-line reconciliation + matched-remittance types

This commit is contained in:
Tyler
2026-06-20 19:44:23 -06:00
parent b7bda0662f
commit 391a07f877
+135
View File
@@ -69,6 +69,19 @@ export interface Remittance {
* payload small; the detail endpoint (`/api/remittances/{id}`) populates it. * payload small; the detail endpoint (`/api/remittances/{id}`) populates it.
*/ */
adjustments?: CasAdjustment[]; adjustments?: CasAdjustment[];
/**
* SP7: per-line 835 SVC composites on this remittance. Ordered by
* ``lineNumber``. Each SLP carries the per-line CAS adjustments under
* ``serviceLinePayments[i].adjustments`` via the line-reconciliation
* endpoint, or via a follow-up CAS query in the remit drawer.
*/
serviceLinePayments?: ServiceLinePayment[];
/**
* SP7: CLP-level (claim-level) CAS bucket — adjustments that were
* not attached to any SVC composite. Powers the ClaimLevelAdjustments
* panel in the remit drawer.
*/
claimLevelAdjustments?: RemittanceClaimLevelAdjustment[];
} }
/** /**
@@ -563,6 +576,15 @@ export interface ClaimDetail {
rawSegments: string[][]; rawSegments: string[][];
matchedRemittance: ClaimDetailMatchedRemittance | null; matchedRemittance: ClaimDetailMatchedRemittance | null;
stateHistory: ClaimDetailStateHistoryEvent[]; stateHistory: ClaimDetailStateHistoryEvent[];
/**
* SP7: per-line reconciliation slim projection. Parallel to
* ``serviceLines`` and indexed by ``lineNumber``. Populated by the
* claim-detail endpoint so the ServiceLinesTable can render Paid +
* Adjustments columns without a second fetch. ``paid`` /
* ``adjustmentsSum`` are null when the line has no matched 835 SVC
* composite.
*/
lineReconciliation: ClaimDetailLineReconciliation[];
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -640,3 +662,116 @@ export interface BatchDiff {
changed: BatchDiffChangedRow[]; changed: BatchDiffChangedRow[];
summary: BatchDiffSummary; summary: BatchDiffSummary;
} }
// ---------------------------------------------------------------------------
// SP7 — Per-Service-Line Adjustment Audit types.
// See docs/superpowers/specs/2026-06-20-cyclone-line-reconciliation-design.md
// ---------------------------------------------------------------------------
/** One 835 SVC composite (Loop 2110) projected to wire shape. */
export interface ServiceLinePayment {
id: number;
lineNumber: number;
procedureQualifier: string;
procedureCode: string;
modifiers: string[];
charge: string;
payment: string;
units: string | null;
unitType: string | null;
serviceDate: string | null;
}
/** Status of one line on either side of a reconciliation. */
export type LineReconciliationStatus =
| "matched"
| "unmatched_835_only"
| "unmatched_837_only"
| "superseded";
/** Slim per-line projection embedded in `GET /api/claims/{id}`. */
export interface ClaimDetailLineReconciliation {
lineNumber: number;
status: LineReconciliationStatus;
paid: string | null;
adjustmentsSum: string | null;
}
/** Summary block at the top of the line-reconciliation response. */
export interface LineReconciliationSummary {
billedTotal: string;
paidTotal: string;
adjustmentTotal: string;
matchedLines: number;
totalLines: number;
}
/** One line in the line-reconciliation response. */
export interface LineReconciliationRow {
claimServiceLine: {
lineNumber: number;
procedureQualifier: string;
procedureCode: string;
modifiers: string[];
charge: string;
units: string | null;
unitType: string | null;
serviceDate: string | null;
} | null;
serviceLinePayment: ServiceLinePayment | null;
status: LineReconciliationStatus;
adjustments: Array<{
groupCode: string;
reasonCode: string;
amount: string;
}>;
}
/** Top-level shape of `GET /api/claims/{id}/line-reconciliation`. */
export interface LineReconciliationResponse {
claimId: string;
summary: LineReconciliationSummary;
lines: LineReconciliationRow[];
}
/** One CLP-level (claim-level) CAS adjustment on a remittance. */
export interface RemittanceClaimLevelAdjustment {
id: number;
groupCode: string;
reasonCode: string;
amount: string;
quantity: string | null;
}
/** Counts embedded in inbox-lane rows for the `MatchedRemitCard` badge. */
export interface MatchedRemittanceLineCounts {
matchedLines: number;
totalLines: number;
}
/** Inbox-lane claim row carrying the matched-remittance block. */
export interface InboxClaimRow {
id: string;
kind: "claim" | "remit";
patientControlNumber: string;
chargeAmount: number | null;
payerId: string | null;
providerNpi: string | null;
state: string;
rejectionReason: string | null;
rejectedAt: string | null;
serviceDateFrom: string | null;
score: number | null;
scoreTier: string | null;
scoreBreakdown: {
patient: number;
date: number;
amount: number;
provider: number;
} | null;
matchedRemittance: {
id: string;
matchedLines: number;
totalLines: number;
} | null;
}