fix(acks): make 999 source_batch_id unique per file + surface PCN
Gainwell's MFT ships every 999 with the same ISA interchange
control number (`000000001`) and one 999 ack covers a whole
batch, not a single claim — so the AK2 set_control_number
(patient_control_number) is the same for the ~96 999s in a
batch. With the old synthetic-id formula (`999-{icn}`), all 385
daily acks collapsed onto a single row the operator couldn't
distinguish.
The new formula is `999-{pcn}-{filename_hash8}` (or
`999-{icn}-{filename_hash8}` for envelope-only 999s without an
AK2). The PCN gives the operator a human-readable handle to the
claim batch; the 8-char hash of the inbound filename guarantees
uniqueness within a batch. Fits in the VARCHAR(32) source_batch_id
column (max 22 chars).
Also surface `patient_control_number` in /api/acks list response
(extracted from raw_json's set_responses[0].set_control_number)
and in the Acks UI as the primary label, with the synthetic id
shown dimmed after a middle dot. The detail endpoint already
exposed raw_json for the full 999 parse tree.
This commit is contained in:
@@ -738,6 +738,7 @@ interface RawAckRow {
|
||||
received_count: number;
|
||||
ack_code: "A" | "E" | "R" | "P";
|
||||
parsed_at: string;
|
||||
patient_control_number?: string | null;
|
||||
}
|
||||
|
||||
function mapAck(row: RawAckRow): Ack {
|
||||
@@ -749,6 +750,7 @@ function mapAck(row: RawAckRow): Ack {
|
||||
receivedCount: row.received_count,
|
||||
ackCode: row.ack_code,
|
||||
parsedAt: row.parsed_at,
|
||||
patientControlNumber: row.patient_control_number ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+12
-1
@@ -365,7 +365,18 @@ export function Acks() {
|
||||
{a.id}
|
||||
</TableCell>
|
||||
<TableCell className="font-mono text-[12px] text-muted-foreground truncate max-w-[180px]">
|
||||
{a.sourceBatchId}
|
||||
{a.patientControlNumber ? (
|
||||
<>
|
||||
<span className="text-foreground">
|
||||
{a.patientControlNumber}
|
||||
</span>
|
||||
<span className="text-muted-foreground/60">
|
||||
{" "}· {a.sourceBatchId}
|
||||
</span>
|
||||
</>
|
||||
) : (
|
||||
a.sourceBatchId
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell className="text-right display mono text-[hsl(var(--success))]">
|
||||
{a.acceptedCount}
|
||||
|
||||
@@ -529,6 +529,14 @@ export interface Ack {
|
||||
receivedCount: number;
|
||||
ackCode: "A" | "E" | "R" | "P";
|
||||
parsedAt: string;
|
||||
/**
|
||||
* AK2 set_control_number from the inbound 999 — the
|
||||
* patient_control_number of the original claim batch this 999
|
||||
* acks. Surfaced in the list endpoint so the operator can
|
||||
* correlate a 999 to a claim batch in the UI without a second
|
||||
* round-trip to the detail endpoint.
|
||||
*/
|
||||
patientControlNumber?: string | null;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user