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.

prioritize() in lib/pipeline/prioritize.ts takes an array of PrioritizeInput objects and today’s ISO date, then returns a sorted PrioritizedLine[]. Every calculation is deterministic arithmetic based on the notice date, billed amount, and recovery probability from triage — no OpenAI calls occur in this step. Because prioritization is pure computation, it is straightforward to unit test and verify independently of any model behavior.

Exported functions

calculateAppealDeadline

export function calculateAppealDeadline(noticeDate: string): string
Computes the Medicare redetermination deadline from the remittance notice date. The calculation adds RECEIPT_PRESUMPTION_DAYS (5) to the notice date to get the presumed receipt date, then adds REDETERMINATION_DAYS (120) to get the filing deadline. The result is an ISO 8601 date string. Example: a notice date of 2025-01-01 produces a presumed receipt date of 2025-01-06 and a deadline of 2025-05-06.

calculateUrgency

export function calculateUrgency(deadline: string, today: string): number
Returns a 01 urgency score. The formula clamps (URGENCY_SCALE_DAYS − daysRemaining) / URGENCY_SCALE_DAYS between 0 and 1. When the deadline is URGENCY_SCALE_DAYS (125) or more days away, urgency is 0. When the deadline has passed, urgency is 1.

adaptForPrioritization

export function adaptForPrioritization(
  claim: Claim,
  serviceLine: ServiceLine,
  triage: DenialTriage,
): PrioritizeInput
A join helper used by the route handler to assemble a PrioritizeInput from the full parsed claim, the specific service line being worked, and its triage result. It promotes notice_date from the remittance header and group_code, carc, rarc, billed_amount, description, and notes from the service line into a flat AdjustmentLine, then pairs that with the DenialTriage.

prioritize

export function prioritize(inputs: readonly PrioritizeInput[], today: string): PrioritizedLine[]
Maps each input to a PrioritizedLine, then sorts the result. For each item it calls calculateAppealDeadline() and calculateUrgency(), then computes priority_score.

Source

export function prioritize(inputs: readonly PrioritizeInput[], today: string): PrioritizedLine[] {
  return inputs
    .map(({ line, triage }) => {
      const deadline = calculateAppealDeadline(line.notice_date);
      const urgency = calculateUrgency(deadline, today);

      return {
        line,
        triage,
        deadline,
        urgency,
        priority_score: line.billed_amount * triage.recovery_probability * urgency,
      };
    })
    .sort((left, right) =>
      left.deadline.localeCompare(right.deadline) || right.priority_score - left.priority_score,
    );
}

Priority score formula

priority_score = billed_amount × recovery_probability × urgency
Each factor contributes a distinct dimension of importance:
  • billed_amount — the financial exposure. Higher billed amounts produce higher scores, reflecting the revenue at stake.
  • recovery_probability — from DenialTriage. A 01 float representing how likely working this denial leads to payment. A write-off line carries 0; a strong timely-filing appeal may carry 0.7 or higher.
  • urgency — from calculateUrgency(). A 01 float that rises as the deadline approaches. Lines with far-off deadlines score near 0; lines whose deadlines have passed score 1.
A line with a high billed amount, high recovery probability, and an imminent deadline will float to the top of the queue. A line with a low billed amount or a write-off probability of 0 will score 0 regardless of urgency.

Sort order

Lines are sorted by two keys in sequence:
  1. deadline ascending — using ISO string .localeCompare(). Lines whose deadlines arrive first are worked first, regardless of score.
  2. priority_score descending — within lines sharing the same deadline, higher-scoring lines appear first.
This means deadline always takes precedence. A low-value line due tomorrow ranks above a high-value line due next month.

Constants

const RECEIPT_PRESUMPTION_DAYS = 5;
const REDETERMINATION_DAYS = 120;
const URGENCY_SCALE_DAYS = 125;
ConstantValuePurpose
RECEIPT_PRESUMPTION_DAYS5CMS presumed receipt window added to the notice date before the 120-day clock starts
REDETERMINATION_DAYS120Medicare redetermination filing window in calendar days
URGENCY_SCALE_DAYS125RECEIPT_PRESUMPTION_DAYS + REDETERMINATION_DAYS — the full window used to normalize urgency to 01
All date arithmetic uses UTC calendar days via Date.setUTCDate() and toISOString().slice(0, 10). This prevents timezone drift from shifting a deadline by a day when the server runs in a non-UTC timezone.

Build docs developers (and LLMs) love