check_prior_auth
Determine Medicare prior authorization requirements for medical procedures by checking CPT/HCPCS codes against coverage policies and providing documentation checklists.
Instructions
Check if procedures require prior authorization for Medicare. Returns PA requirement, confidence level, matched LCD/NCD policies, and documentation checklist. Essential for determining Medicare coverage requirements before procedures.
Examples:
check_prior_auth(["76942"]) - check PA for ultrasound guidance
check_prior_auth(["76942"], { state: "TX" }) - check for Texas patient (determines MAC jurisdiction)
check_prior_auth(["J0585", "64493"]) - check multiple procedure codes
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| procedure_codes | Yes | CPT/HCPCS codes to check (1-10 codes) | |
| state | No | Two-letter state code to determine MAC jurisdiction (e.g., TX, CA) |
Implementation Reference
- src/index.ts:677-692 (handler)The tool handler function. Destructures input parameters procedure_codes and optional state, sends POST request to Verity API /prior-auth/check, formats response with formatPriorAuth, returns formatted text content or error message.async ({ procedure_codes, state }) => { try { const result = await verityRequest<any>("/prior-auth/check", { method: "POST", body: { procedure_codes, state }, }); return { content: [{ type: "text", text: formatPriorAuth(result.data) }], }; } catch (error) { return { content: [{ type: "text", text: `Error checking prior auth: ${error instanceof Error ? error.message : String(error)}` }], }; } }
- src/index.ts:664-675 (schema)Input schema using Zod validation: array of 1-10 procedure codes (required), optional 2-letter state code.inputSchema: { procedure_codes: z .array(z.string()) .min(1) .max(10) .describe("CPT/HCPCS codes to check (1-10 codes)"), state: z .string() .length(2) .optional() .describe("Two-letter state code to determine MAC jurisdiction (e.g., TX, CA)"), },
- src/index.ts:653-693 (registration)MCP server tool registration call including name, description, input schema, and inline handler function.server.registerTool( "check_prior_auth", { description: `Check if procedures require prior authorization for Medicare. Returns PA requirement, confidence level, matched LCD/NCD policies, and documentation checklist. Essential for determining Medicare coverage requirements before procedures. Examples: - check_prior_auth(["76942"]) - check PA for ultrasound guidance - check_prior_auth(["76942"], { state: "TX" }) - check for Texas patient (determines MAC jurisdiction) - check_prior_auth(["J0585", "64493"]) - check multiple procedure codes`, inputSchema: { procedure_codes: z .array(z.string()) .min(1) .max(10) .describe("CPT/HCPCS codes to check (1-10 codes)"), state: z .string() .length(2) .optional() .describe("Two-letter state code to determine MAC jurisdiction (e.g., TX, CA)"), }, }, async ({ procedure_codes, state }) => { try { const result = await verityRequest<any>("/prior-auth/check", { method: "POST", body: { procedure_codes, state }, }); return { content: [{ type: "text", text: formatPriorAuth(result.data) }], }; } catch (error) { return { content: [{ type: "text", text: `Error checking prior auth: ${error instanceof Error ? error.message : String(error)}` }], }; } } );
- src/index.ts:165-227 (helper)Helper function to format the prior authorization check API response into a human-readable string, including PA requirement, confidence, reason, MAC info, matched policies, documentation checklist, and criteria summaries.function formatPriorAuth(result: any): string { const lines: string[] = []; // Main determination lines.push(`Prior Authorization Required: ${result.pa_required ? "YES" : "NO"}`); lines.push(`Confidence: ${result.confidence.toUpperCase()}`); lines.push(`Reason: ${result.reason}`); // MAC info if (result.mac) { lines.push(`\nMAC: ${result.mac.name} (${result.mac.jurisdiction})`); if (result.mac.states) lines.push(`States: ${result.mac.states.join(", ")}`); } // Matched policies if (result.matched_policies?.length > 0) { lines.push("\n--- Matched Policies ---"); result.matched_policies.forEach((p: any) => { lines.push(`\n${p.policy_id}: ${p.title}`); lines.push(`Type: ${p.policy_type}${p.jurisdiction ? ` | Jurisdiction: ${p.jurisdiction}` : ""}`); if (p.codes?.length > 0) { lines.push("Codes:"); p.codes.forEach((c: any) => { lines.push(` - ${c.code} (${c.code_system}): ${c.disposition}`); }); } }); } // Documentation checklist if (result.documentation_checklist?.length > 0) { lines.push("\n--- Documentation Checklist ---"); result.documentation_checklist.forEach((item: string, i: number) => { lines.push(`${i + 1}. ${item}`); }); } // Criteria details if (result.criteria_details) { const cd = result.criteria_details; if (cd.indications?.length > 0) { lines.push("\n--- Indications ---"); cd.indications.slice(0, 5).forEach((ind: any) => { lines.push(`- ${ind.text.slice(0, 200)}${ind.text.length > 200 ? "..." : ""}`); }); if (cd.pagination?.indications?.total > 5) { lines.push(`... and ${cd.pagination.indications.total - 5} more indications`); } } if (cd.limitations?.length > 0) { lines.push("\n--- Limitations ---"); cd.limitations.slice(0, 5).forEach((lim: any) => { lines.push(`- ${lim.text.slice(0, 200)}${lim.text.length > 200 ? "..." : ""}`); }); if (cd.pagination?.limitations?.total > 5) { lines.push(`... and ${cd.pagination.limitations.total - 5} more limitations`); } } } return lines.join("\n"); }
- src/index.ts:25-66 (helper)Shared utility function for making authenticated HTTP requests to the Verity API backend, used by all tools including check_prior_auth. Handles GET/POST, params, auth, error handling.async function verityRequest<T>( endpoint: string, options: { method?: "GET" | "POST"; params?: Record<string, string | number | boolean | undefined>; body?: unknown; } = {} ): Promise<T> { const { method = "GET", params, body } = options; // Build URL with query params const url = new URL(`${VERITY_API_BASE}${endpoint}`); if (params) { Object.entries(params).forEach(([key, value]) => { if (value !== undefined && value !== null && value !== "") { url.searchParams.append(key, String(value)); } }); } const headers: Record<string, string> = { Authorization: `Bearer ${VERITY_API_KEY}`, "Content-Type": "application/json", Accept: "application/json", }; const response = await fetch(url.toString(), { method, headers, body: body ? JSON.stringify(body) : undefined, }); const data = await response.json(); if (!response.ok) { const errorMsg = data.error?.message || `API error: ${response.status}`; const hint = data.error?.hint || ""; throw new Error(hint ? `${errorMsg}. Hint: ${hint}` : errorMsg); } return data as T; }