Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/sputhenofficial/claimjumper/llms.txt

Use this file to discover all available pages before exploring further.

app/lib/approved-drafts.ts provides three pure functions used by the browser client to manage approval state and produce the downloadable work packet. No server round-trips are involved — approval lives entirely in React session state (useState<Set<string>>), and the formatted download is assembled client-side from the TriageResponse already held in memory. Closing or refreshing the tab clears all approvals.

ApprovedDraft interface

Before the functions, the module defines the shape of a resolved approved item:
interface ApprovedDraft {
  item: QueueItem;
  artifact: DraftArtifact;
}
artifact is always defined on an ApprovedDraft — the approvedDrafts() filter guarantees this by excluding any item whose artifact is undefined.

queueItemIdentity(item: QueueItem): string

Returns a stable, human-readable string key that uniquely identifies a queue item within a triage session.
function queueItemIdentity(item: QueueItem): string
Parameters
NameTypeDescription
itemQueueItemThe queue item to identify.
Returns string — a key in the format "{claim_id}-{line_number}", e.g. "CLM-00123-2". Usage This key is used as the value stored in the Set<string> that tracks which items have been approved in the UI. Passing it to approved.has() checks approval status; passing it to approved.add() marks an item approved.
// Marking an item approved
setApprovedLines((current) => new Set(current).add(queueItemIdentity(item)));

// Checking if an item is approved
const isApproved = approvedLines.has(queueItemIdentity(item));

approvedDrafts(items, approved): ApprovedDraft[]

Filters a queue to the items that are eligible for download: in an actionable lane, have a generated artifact, and have been explicitly approved by the user.
function approvedDrafts(
  items: readonly QueueItem[],
  approved: ReadonlySet<string>,
): ApprovedDraft[]
Parameters
NameTypeDescription
itemsreadonly QueueItem[]The full ranked queue from TriageResponse.items.
approvedReadonlySet<string>The set of queueItemIdentity keys the user has approved.
Returns ApprovedDraft[] — a filtered, artifact-guaranteed array. Order mirrors the input items order (priority-ranked). Inclusion criteria — all three conditions must hold for an item to be included:
  1. item.prioritized.triage.lane is "appeal" or "corrected_claim".
  2. item.artifact is not undefined.
  3. queueItemIdentity(item) is present in approved.
Excluded unconditionally — items in the "human_review", "patient_bill", and "write_off" lanes are never included in the downloadable packet, regardless of approval state. Human review briefs are surfaced in the queue UI but are not exported through this path.
Pass the result of approvedDrafts() directly to formatApprovedDrafts() to produce the download content, or check .length to decide whether the download button should be enabled.

formatApprovedDrafts(drafts): string

Produces a plain-text download bundle from a list of approved drafts. The output is a single string intended to be written to a .txt file.
function formatApprovedDrafts(drafts: readonly ApprovedDraft[]): string
Parameters
NameTypeDescription
draftsreadonly ApprovedDraft[]The array returned by approvedDrafts().
Returns string — a newline-joined plain-text document. Format The document opens with a fixed header block, then repeats a structured section for each draft:
CLAIMJUMPER — APPROVED DRAFTS
DRAFTS FOR HUMAN REVIEW — This download does not submit, file, or send anything to a payer.
Verify payer-specific requirements, required forms, supporting records, and signer information before use.

=== Appeal Draft ===
Claim: CLM-00123; Patient: Jane Doe; Line: 2
Service date: 2024-09-15; Procedure: 99213

[artifact body content — full draft text]

Citations:
- parse: service_line.carc = 50
- parse: claim.claim.claim_id = CLM-00123
- legend: CARC:50.definition = Not medically necessary

=== Corrected Claim Worklist ===
Claim: CLM-00124; Patient: John Smith; Line: 1
Service date: 2024-09-16; Procedure: 99214

[artifact body content]

Citations:
- parse: service_line.group_code = CO
- parse: service_line.carc = 4

Each section contains:
  • === {artifact.title} === as the section heading
  • A claim context line: Claim: {claim_id}; Patient: {patient_name}; Line: {line_number}
  • A service line context line: Service date: {service_date}; Procedure: {procedure_code}
  • A blank line
  • artifact.content — the full draft body
  • A blank line
  • Citations: followed by each citation as - {source}: {field_path} = {value}
  • A trailing blank line before the next section

Download flow in the UI

The TriageWorkspace component in app/components/triage-workspace.tsx wires these three functions into the download flow:
  1. Approval state is held in const [approvedLines, setApprovedLines] = useState<Set<string>>(() => new Set()). The TriageQueue component calls onApprove(item) when the user approves a line, which runs setApprovedLines((current) => new Set(current).add(queueItemIdentity(item))).
  2. Downloadable count is derived on every render: const downloadableDrafts = approvedDrafts(result.items, approvedLines). The download button label shows the current count and is disabled when downloadableDrafts.length === 0.
  3. downloadApprovedDrafts() is called when the button is clicked:
function downloadApprovedDrafts() {
  const content = formatApprovedDrafts(downloadableDrafts);
  const url = URL.createObjectURL(new Blob([content], { type: "text/plain;charset=utf-8" }));
  const link = document.createElement("a");
  link.href = url;
  link.download = "claimjumper-approved-drafts.txt";
  link.click();
  URL.revokeObjectURL(url);
}
The function creates a Blob from the formatted string, generates a temporary object URL, programmatically clicks a synthetic <a> element to trigger the browser’s save dialog, then immediately revokes the URL to release memory. The filename is always claimjumper-approved-drafts.txt.
  1. Session reset — when the user clicks “Choose another EOB”, setApprovedLines(new Set()) clears all approvals alongside the triage result. Approvals are never persisted to localStorage or any server.
The downloaded file does not submit, file, email, or send anything to a payer. It is a plain-text work packet for human use only. A billing team member must verify payer-specific appeal requirements, required forms, supporting clinical records, and authorized signer information before using any draft content in an actual submission.

Build docs developers (and LLMs) love