feat: AI-powered eligibility detection from Copy Agent screenshots
Adds an "AI Detect & Check Eligibility" action to the Copy Agent page that sends captured screenshots to Claude to extract Member ID/DOB, then opens the chatbot's eligibility confirm step pre-filled with the result. - POST /api/ai/detect-eligibility-info: Claude vision extraction of Member ID/DOB from uploaded screenshots. - POST /api/patients/create-temp: auto-creates a placeholder "PID-<id>" patient (matched by insuranceId+dob) when no patient is selected, so screenshots can be saved immediately; the real eligibility check later rewrites the patient's name and Cloud Storage folder automatically via the existing createOrUpdatePatientByInsuranceId matching logic. - Chatbot: Member ID/DOB on the confirm card are now editable (MM/DD/YYYY), with edits synced back to the patient record before the check runs. - Fixed a useEffect ordering bug on the insurance-status page that could silently clear a chatbot-prefilled Member ID/DOB before the auto-trigger effect ran, preventing the eligibility check from ever starting. - Added a local-disk-only screenshot backup (apps/Backend/uploads/ screenshot-backups/) for debugging, not exposed anywhere in the UI. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
// Local-disk-only debug copy of screenshots captured via the Copy Agent page.
|
||||
// Not exposed anywhere in the app UI — purely for finding raw captures on disk when
|
||||
// diagnosing AI detection issues. Never blocks the calling request if it fails.
|
||||
const BACKUP_ROOT = path.join(process.cwd(), "uploads", "screenshot-backups");
|
||||
|
||||
export function backupScreenshots(files: { originalname: string; buffer: Buffer }[]): void {
|
||||
try {
|
||||
const dateDir = new Date().toISOString().slice(0, 10); // YYYY-MM-DD
|
||||
const dir = path.join(BACKUP_ROOT, dateDir);
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
for (const file of files) {
|
||||
const safeName = `${Date.now()}_${file.originalname.replace(/[/\\?%*:|"<>]/g, "-")}`;
|
||||
fs.writeFileSync(path.join(dir, safeName), file.buffer);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("[screenshotBackup] failed to write backup:", err);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user