feat: batch eligibility by patient name + "Check All & Appointment Today" option

- Add batch_eligibility_by_name intent so "check Mary and Sinthia" resolves multiple names
- Add "Check All & Appointment Today" button to batch eligibility UI — creates appointment for each patient after their eligibility check completes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ff
2026-06-19 23:32:05 -04:00
co-authored by Claude Sonnet 4.6
parent e081f32648
commit 60689e58f6
4 changed files with 136 additions and 8 deletions
@@ -745,22 +745,31 @@ export default function InsuranceStatusPage() {
// Patient was just created/updated in DB by the Selenium worker before this is called.
const tryAppointmentFromChatbot = async (): Promise<void> => {
try {
// Single-patient flow
const raw = sessionStorage.getItem("chatbot_appt_after_eligibility");
if (!raw) return;
const { memberId: storedMemberId, date: storedDate } = JSON.parse(raw);
sessionStorage.removeItem("chatbot_appt_after_eligibility");
if (!storedMemberId) return;
// Batch flow: create appointment for the current patient after each eligibility check
const isBatch = sessionStorage.getItem("chatbot_batch_appt_after_eligibility") === "true";
const lookupRes = await apiRequest("GET", `/api/patients/by-insurance-id?insuranceId=${encodeURIComponent(storedMemberId)}`);
const useMemberId = raw ? JSON.parse(raw).memberId : isBatch ? memberId : null;
const useDate = raw ? JSON.parse(raw).date : null;
if (raw) sessionStorage.removeItem("chatbot_appt_after_eligibility");
// Clean up batch flag only when no more patients in queue
if (isBatch && !sessionStorage.getItem("chatbot_eligibility_queue")) {
sessionStorage.removeItem("chatbot_batch_appt_after_eligibility");
}
if (!useMemberId) return;
const lookupRes = await apiRequest("GET", `/api/patients/by-insurance-id?insuranceId=${encodeURIComponent(useMemberId)}`);
if (!lookupRes.ok) return;
const patient = await lookupRes.json();
if (!patient?.id) return;
const apptRes = await apiRequest("POST", "/api/ai/create-appointment-today", { patientId: patient.id, date: storedDate ?? undefined });
const apptRes = await apiRequest("POST", "/api/ai/create-appointment-today", { patientId: patient.id, date: useDate ?? undefined });
const apptData = await apptRes.json();
if (apptRes.ok) {
const scheduledOn = storedDate
? new Date(storedDate + "T00:00:00").toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" })
const scheduledOn = useDate
? new Date(useDate + "T00:00:00").toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" })
: "today";
toast({
title: "Appointment created",