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:
@@ -394,6 +394,18 @@ export function ChatbotButton() {
|
||||
prefillAndNavigate(first!.memberId, first!.dob, first!.autoCheck);
|
||||
};
|
||||
|
||||
const handleBatchEligibilityAndAppointment = () => {
|
||||
if (!batchEligibilityData || batchEligibilityData.length === 0) return;
|
||||
addMsg("user", `Check all & appointment today (${batchEligibilityData.length} patients)`);
|
||||
addMsg("bot", `Checking ${batchEligibilityData.length} patients — appointments will be created after each check...`);
|
||||
sessionStorage.setItem("chatbot_batch_appt_after_eligibility", "true");
|
||||
const [first, ...rest] = batchEligibilityData;
|
||||
if (rest.length > 0) {
|
||||
sessionStorage.setItem("chatbot_eligibility_queue", JSON.stringify(rest));
|
||||
}
|
||||
prefillAndNavigate(first!.memberId, first!.dob, first!.autoCheck);
|
||||
};
|
||||
|
||||
const handleEligibilityAndAppointment = async (targetDate?: string) => {
|
||||
if (!eligibilityIdData) return;
|
||||
const dateLabel = targetDate
|
||||
@@ -896,6 +908,14 @@ export function ChatbotButton() {
|
||||
<Stethoscope className="h-3 w-3 mr-1" />
|
||||
Check All ({batchEligibilityData.length} patients)
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
className="w-full h-8 text-xs bg-green-600 hover:bg-green-700 text-white"
|
||||
onClick={handleBatchEligibilityAndAppointment}
|
||||
>
|
||||
<Calendar className="h-3 w-3 mr-1" />
|
||||
Check All & Appointment Today
|
||||
</Button>
|
||||
<Button size="sm" variant="ghost" className="w-full h-8 text-xs" onClick={resetStep}>
|
||||
Cancel
|
||||
</Button>
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user