PriorAuthdocs

Encounter triage

Everything downstream begins here: a surgery is on the schedule and nobody has yet asked whether it needs authorization. Running this on a schedule is what turns prior authorization from a reaction into a lead time.

#What it does

  1. Find
    ehr_find_encounters returns scheduled surgeries and in-office procedures, masked. A list view is a trigger, not a chart.
  2. Compose
    ehr_get_encounter assembles the full picture from the clinical record AND practice management. If the two disagree about who the patient is, it refuses.
  3. Ask
    check_auth_requirement asks the payer about this member and these codes. Falls back to the configured rule set only for codes the payer does not answer.
  4. Classify
    required · not required · undetermined. Network-dependent answers are kept as such rather than flattened.
  5. Raise
    A task per encounter that needs one, and per encounter that could not be answered.

#It never writes to the narrative

Triage reads the chart and asks a human to act. It creates tasks; it does not write notes, attach referrals or submit anything. A task ASKS a human to act rather than acting, which is why it is ungated - requiring a human to approve asking a human is circular. Its failure mode is noise rather than harm, so it is bounded instead: forty per practice per hour, because burying a worklist is its own harm.

#No answer is not clearance

The bug this guards against
An empty list and a list of negatives are the same shape to a naive filter. When an async handler returned a promise, result.codes read as undefined, the empty list looked like "nothing needs authorization", and a scheduled surgery was marked cleared. Every code asked about must now come back with an explicit answer, or the encounter is undetermined.

#Example output

json
{
  "scanned": 4,
  "needsAuth": [
    { "encounterRef": "ENC-59315", "payer": "BCBSF", "codes": ["27447"],
      "fromPayer": 1, "networkCaveats": [] }
  ],
  "cleared":  [{ "encounterRef": "ENC-59420", "basis": "the payer answered" }],
  "abstained": [
    { "encounterRef": "ENC-59011", "payer": "UHC", "reason": "unverified_rule",
      "detail": "This entry is a harness fixture, not a payer document..." }
  ],
  "tasksCreated": [ /* one per needsAuth AND one per abstained */ ]
}