> ## Documentation Index
> Fetch the complete documentation index at: https://agents.nanonets.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Coding Precheck

> `coding_precheck` runs the documentation precheck for a medical-coding encounter before CPT coding.

`coding_precheck` runs the documentation precheck for a medical-coding encounter before CPT coding. It is part of the **Nanonets Coding Engine** tool group.

The full precheck system prompt and the appointment-type template rules (ported from Fleming `getPreCheckPrompt` / `ProcessVisitForPreChecks`) are baked into the tool. The agent only supplies the dynamic encounter inputs — there is no need to paste a raw `ai_call` body.

## Inputs

* `encounter_context` (required): the full encounter note / documentation to validate, including insurance and closed-date details. May wrap the target encounter in `<current_encounter>` tags.
* `appointment_type` (required): selects the matching documentation template.
* `encounter_duration` (optional): falls back to whatever is present in the note context.
* `encounter_provider` (optional): used for the sign-off / provider-match check.

## Output

```json theme={null}
{
  "tool_name": "coding_precheck",
  "passed": false,
  "reasons": ["Encounter is not closed"],
  "reason": "Encounter is not closed",
  "warnings": ["Insurance eligibility is unverified"],
  "raw_status": "fail",
  "completed_at": "2026-06-01T00:00:00Z"
}
```

The precheck evaluates every rule and returns **all** blocking reasons in `reasons[]` (it no longer stops at the first failure), so a non-codeable encounter reports every problem consistently across runs instead of whichever single reason the model happened to pick. `reason` is the combined string (all reasons joined) for consumers that read a single escalation string. On a pass, `reasons` is empty and `reason` is "".

**Insurance eligibility states** are distinguished: the precheck fails only on **confirmed ineligible/inactive** ("Insurance is not eligible for the visit") or **self-pay** ("Insurance is Self-Pay"). An **"Unverified"** / unchecked eligibility does **not** block — it is surfaced as a non-blocking entry in `warnings[]` ("Insurance eligibility is unverified") so the agent/biller is aware without escalating on it.

The tool parses the `{"status":"pass|fail","reasons":[...]}` shape as well as the legacy single `reason` and `{"passed":bool,...}` shapes (combined and de-duped). If none parse, it returns `passed=false` with reason `"could not parse precheck response"` and includes the raw `response`.

## Human-readable text

In the task feed the tool renders a `## Precheck` table (result PASSED/FAILED, raw status) and a `## Reasons` list with every failing reason. The full result struct stays in `structuredContent`.

## Agent Instruction Guidance

If `passed=false`, stop the workflow and set the final `escalation_reason` to the precheck reason. Do not write back to the EHR.

## Notes

* LLM tool. Billed per call; the static prompt is cached where the provider supports it.
* `default_enabled` is false (opt-in).
