{"openapi":"3.0.0","paths":{"/eligibility/run":{"post":{"description":"Parses the TSV file, filters rows with status \"Benefits Check Needed\", validates fields, builds Fuse API payloads, submits checks in batches, and polls for results. Returns a complete run summary with counts and check IDs.","operationId":"EligibilityController_run","parameters":[],"responses":{"201":{"description":"Run summary with submission and polling results"}},"summary":"Run batch eligibility checks","tags":["Eligibility"]}},"/eligibility/run/sheet/dry-run":{"post":{"description":"Reads rows with status \"Benefits Check Needed\", validates fields, and builds Fuse payloads — but does NOT submit to Fuse and does NOT write anything back to the sheet. Returns a preview of filtered rows, validation results, unmapped payers, and sample payloads.","operationId":"EligibilityController_dryRunFromSheet","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"spreadsheetId":{"type":"string","description":"Google Sheet ID (from the sheet URL). Falls back to GOOGLE_SHEET_ID env var if omitted.","example":"1aBcDeFgHiJkLmNoPqRsTuVwXyZ"},"sheetName":{"type":"string","description":"Tab name in the spreadsheet (defaults to \"Master_Benefits\")","example":"Master_Benefits"}}}}}},"responses":{"201":{"description":"Dry run preview with validation results and sample payloads"}},"summary":"Dry run — preview what would happen without submitting or updating the sheet","tags":["Eligibility"]}},"/eligibility/run/sheet":{"post":{"description":"Reads rows with status \"Benefits Check Needed\" from the specified Google Sheet, validates fields, submits to Fuse, polls for results, and updates the sheet with check IDs and status. The sheet must be shared with the service account.","operationId":"EligibilityController_runFromSheet","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["spreadsheetId"],"properties":{"spreadsheetId":{"type":"string","description":"Google Sheet ID (from the sheet URL). Falls back to GOOGLE_SHEET_ID env var if omitted.","example":"1aBcDeFgHiJkLmNoPqRsTuVwXyZ"},"sheetName":{"type":"string","description":"Tab name in the spreadsheet (defaults to \"Master_Benefits\")","example":"Master_Benefits"}}}}}},"responses":{"201":{"description":"Run summary with submission results and sheet updates"}},"summary":"Run eligibility checks from a Google Sheet","tags":["Eligibility"]}},"/eligibility/replay/{checkId}":{"post":{"description":"Replays a previously submitted check from a specific step. Useful when a check partially failed or needs re-evaluation from EDI, call, or policy step.","operationId":"EligibilityController_replay","parameters":[{"name":"checkId","required":true,"in":"path","description":"The Fuse check ID to replay","schema":{"type":"string"}},{"name":"fromStep","required":false,"in":"query","description":"Step to replay from (defaults to \"policy\")","schema":{"enum":["edi","call","policy"],"type":"string"}}],"responses":{"201":{"description":"Replay result with new check status"},"400":{"description":"Invalid fromStep parameter"}},"summary":"Replay an eligibility check","tags":["Eligibility"]}},"/eligibility/validate/{checkId}":{"post":{"description":"Fetches the completed check from Fuse and validates the AI-generated summary against EDI source data. Checks deductible amounts, co-insurance percentages, plan status, date accuracy, and CPT coverage. Returns a detailed validation report.","operationId":"EligibilityController_validate","parameters":[{"name":"checkId","required":true,"in":"path","description":"The Fuse check ID to validate","schema":{"type":"string"}}],"responses":{"201":{"description":"Validation report with pass/fail per field"},"404":{"description":"Check not found"}},"summary":"Validate a check against EDI data","tags":["Eligibility"]}},"/eligibility/stats":{"get":{"description":"Returns aggregated stats, global config, and result count from Firestore.","operationId":"EligibilityController_getStats","parameters":[],"responses":{"200":{"description":"Stats, config, and result count"}},"summary":"Get service stats and config","tags":["Eligibility"]}},"/eligibility/config":{"get":{"description":"Returns the global configuration from Firestore.","operationId":"EligibilityController_getConfig","parameters":[],"responses":{"200":{"description":"Global configuration"}},"summary":"Get global config","tags":["Eligibility"]},"post":{"description":"Merges updates into the global configuration in Firestore.","operationId":"EligibilityController_updateConfig","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"defaultSpreadsheetId":{"type":"string"},"defaultSheetName":{"type":"string"},"webhookUrl":{"type":"string"},"webhookSubscriptionId":{"type":"string"},"fuseEnvironment":{"type":"string"},"updatedBy":{"type":"string"}}}}}},"responses":{"201":{"description":"Config updated"}},"summary":"Update global config","tags":["Eligibility"]}},"/eligibility/results":{"get":{"description":"Returns a list of all check IDs that have stored result files.","operationId":"EligibilityController_listResults","parameters":[],"responses":{"200":{"description":"List of result file names and count"}},"summary":"List all stored results","tags":["Eligibility"]}},"/eligibility/results/{checkId}":{"get":{"description":"Retrieves the stored result JSON for a given check ID.","operationId":"EligibilityController_getResult","parameters":[{"name":"checkId","required":true,"in":"path","description":"The check ID to retrieve results for","schema":{"type":"string"}}],"responses":{"200":{"description":"The stored result data"},"404":{"description":"Result not found for the given check ID"}},"summary":"Get a specific result","tags":["Eligibility"]}},"/eligibility/resync":{"post":{"description":"Fetches current check state from Fuse API and re-processes results. Useful when webhooks were missed or results need to be updated. Provide specific checkIds or use filter=incomplete to resync all incomplete checks.","operationId":"EligibilityController_resync","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"checkIds":{"type":"array","items":{"type":"string"},"description":"Specific check IDs to resync"},"filter":{"type":"string","enum":["incomplete"],"description":"Resync all checks matching this filter"}}}}}},"responses":{"201":{"description":"Resync summary"}},"summary":"Resync check results from Fuse","tags":["Eligibility"]}},"/eligibility/resubmit-failed":{"post":{"description":"Reads rows with status \"Fuse Incomplete-Need manual check\" from the Google Sheet, filters to rows with payer-related failures (e.g. \"Unable to communicate\"), and resets their status to \"Benefits Check Needed\" so they can be resubmitted with corrected payer mappings. Call POST /eligibility/run/sheet afterwards to resubmit.","operationId":"EligibilityController_resubmitFailed","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"spreadsheetId":{"type":"string","description":"Google Sheet ID. Falls back to GOOGLE_SHEET_ID env var if omitted."},"sheetName":{"type":"string","description":"Tab name (defaults to \"Master_Benefits\")"},"dryRun":{"type":"boolean","description":"If true, returns rows that would be reset without modifying the sheet"}}}}}},"responses":{"201":{"description":"Summary of reset rows"}},"summary":"Reset failed checks for resubmission","tags":["Eligibility"]}},"/eligibility/stats/recalculate":{"post":{"description":"Scans all result documents in Firestore and recalculates completion/incomplete counters. Preserves non-counter fields like lastRunAt, uniquePayersSeen, etc. Use this when stats counters have drifted from actual data (e.g. due to webhook replays).","operationId":"EligibilityController_recalculateStats","parameters":[],"responses":{"201":{"description":"Recalculated stats"}},"summary":"Recalculate stats from actual data","tags":["Eligibility"]}},"/webhook/fuse":{"post":{"description":"Endpoint for Fuse to deliver eligibility check results via webhook. Saves the result and updates the Google Sheet row with the final status.","operationId":"WebhookController_handleFuseWebhook","parameters":[],"requestBody":{"required":true,"description":"Fuse webhook payload containing check results","content":{"application/json":{"schema":{"type":"object","properties":{"checkId":{"type":"string","example":"chk_abc123"},"status":{"type":"string","example":"COMPLETED"},"data":{"type":"object","properties":{"checkId":{"type":"string"}}}}}}}},"responses":{"201":{"description":"Webhook received and processed","content":{"application/json":{"schema":{"type":"object","properties":{"received":{"type":"boolean","example":true},"checkId":{"type":"string","example":"chk_abc123"},"sheetUpdated":{"type":"boolean","example":true},"timestamp":{"type":"string","example":"2026-03-11T14:00:00.000Z"}}}}}}},"summary":"Receive Fuse webhook","tags":["Webhooks"]}}},"info":{"title":"Fuse Eligibility API","description":"API for managing patient insurance eligibility and benefits checks via the Fuse Eligibility API. Supports batch eligibility runs, individual check replay, validation against EDI data, and webhook ingestion.","version":"0.0.1","contact":{}},"tags":[],"servers":[{"url":"http://localhost:3000","description":"Local"},{"url":"https://fuse-eligibility-dev.getwelby.com","description":"Development (Staging)"},{"url":"https://fuse-eligibility.getwelby.com","description":"Production"}],"components":{"schemas":{}}}