From 69919e1ecabf3e1bbb80089eb03da87a15f0c1fc Mon Sep 17 00:00:00 2001 From: Gitead Date: Fri, 15 May 2026 00:26:09 -0400 Subject: [PATCH] feat: update new patient LangGraph flow diagram to reflect current AI flow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the old after-hours/new-patient SVG with an accurate diagram of the current conversation flow: 3-message TwiML entry → insurance check → MassHealth consent + ID/DOB → Selenium eligibility → ACTIVE/INACTIVE paths, inactive branch asks for other insurance then collects contact info, and office-hours-validated date/time scheduling with appointment creation. Existing patient branch shows same-insurance confirmation, MassHealth auto-check (stored ID+DOB), and Selenium result paths. Co-Authored-By: Claude Sonnet 4.6 --- .../settings/ai-chat-settings-card.tsx | 450 ++++++++++-------- 1 file changed, 261 insertions(+), 189 deletions(-) diff --git a/apps/Frontend/src/components/settings/ai-chat-settings-card.tsx b/apps/Frontend/src/components/settings/ai-chat-settings-card.tsx index ba7d86e1..b9cf2ecf 100644 --- a/apps/Frontend/src/components/settings/ai-chat-settings-card.tsx +++ b/apps/Frontend/src/components/settings/ai-chat-settings-card.tsx @@ -280,259 +280,331 @@ function LangGraphFlow() { ); } -// ─── New Patient / After-Hours flow diagram ─────────────────────────────────── +// ─── New Patient flow diagram (updated) ────────────────────────────────────── function NewPatientFlow() { // ── Canvas ─────────────────────────────────────────────────────────────── - const W = 760; - const cx = 380; // top-node horizontal center - const nW = 220; - const nx = cx - nW / 2; // 270 + const W = 900; + const cx = 450; - // ── Sequential top nodes ───────────────────────────────────────────────── - const n1y = 15, n1h = 58; - const n2y = 115, n2h = 58; - const n3y = 215, n3h = 58; - const n4y = 315, n4h = 60; + // ── Coordinates ────────────────────────────────────────────────────────── + const nW = 240; const nx = cx - nW / 2; - // ── Main fork ──────────────────────────────────────────────────────────── - const forkHY = n4y + n4h + 20; // 395 - const lcx = 165; // New Patient branch center - const rcx = 590; // Existing Patient branch center - const brW = 200; + // Top sequence + const n1y = 14; const n1h = 84; + const n2y = n1y + n1h + 14; const n2h = 52; + const forkHY = n2y + n2h + 18; - // ── Main branch nodes ───────────────────────────────────────────────────── - const brY = forkHY + 50; // 445 - const brH = 62; + // Main branch centres + const lcx = 210; // New Patient + const rcx = 690; // Existing Patient + const brW = 210; - // ── Sub-forks ───────────────────────────────────────────────────────────── - const sfHY = brY + brH + 18; // 525 - const llcx = 100; const lrcx = 230; // New Patient sub-branches (centered on 165) - const rlcx = 510; const rrcx = 660; // Existing Patient sub-branches + // ── NEW PATIENT layout ──────────────────────────────────────────────────── + // insurance question + const npInsY = forkHY + 44; const npInsH = 52; + // sub-fork 1: has-ins / no-ins + const npSf1Y = npInsY + npInsH + 18; + const lhcx = 140; // has insurance + const lncx = 325; // no insurance + // no-ins leaf + const npNoInsY = npSf1Y + 20; const npNoInsH = 76; const npNoInsW = 130; + // what kind? + const npWkY = npSf1Y + 20; const npWkH = 52; const npWkW = 192; + // sub-fork 2: masshealth / other + const npSf2Y = npWkY + npWkH + 18; + const mhcx = 82; // masshealth + const othcx = 210; // other + // other ins leaf + const npOthY = npSf2Y + 20; const npOthH = 76; const npOthW = 130; + // masshealth consent node + const npMhY = npSf2Y + 20; const npMhH = 76; const npMhW = 155; + // selenium + const npSelY = npMhY + npMhH + 18; const npSelH = 66; const npSelW = 148; + // active / inactive fork + const npResHY = npSelY + npSelH + 14; + const npActCx = 40; const npInaCx = 140; + const npResY = npResHY + 22; + // active result + const npActH = 76; const npActW = 110; + // inactive → other insurance? + const npInaH = 52; const npInaW = 110; + // other-insurance-after-inactive + const npOins2Y = npResY + Math.max(npActH, npInaH) + 16; + const npOins2H = 52; const npOins2W = 150; + // final: yes=transfer / no=contact info + const npFinalY = npOins2Y + npOins2H + 18; + const npTxCx = npInaCx - 44; const npCiCx = npInaCx + 46; + const npTxH = 44; const npTxW = 86; + const npCiH = 64; const npCiW = 132; - // ── Leaf nodes ──────────────────────────────────────────────────────────── - const leafY = sfHY + 46; // 571 - const leafW = 118; - const leafH = 80; + const totalH_np = npFinalY + npCiH + 18; - // ── New patient: Selenium chain (below LL at cx=100) ───────────────────── - const npSelY = leafY + leafH + 34; // 685 — Selenium node top - const npSelW = 140; - const npSelH = 56; - const npResHY = npSelY + npSelH + 16; // 757 — result fork y - const npActCx = 52; // ACTIVE result center (100-48) - const npInaCx = 148; // INACTIVE result center (100+48) - const npResY = npResHY + 34; // 791 - const npResW = 80; - const npResH = 72; + // ── EXISTING PATIENT layout ─────────────────────────────────────────────── + const epInsY = forkHY + 44; const epInsH = 64; const epInsW = 210; + const epSf1Y = epInsY + epInsH + 18; + const epSameCx = 638; const epDiffCx = 760; + // no-same (transfer) + const epDiffY = epSf1Y + 20; const epDiffH = 52; const epDiffW = 130; + // same confirmed + const epSameY = epSf1Y + 20; const epSameH = 52; const epSameW = 192; + // sub-fork 2: masshealth / other + const epSf2Y = epSameY + epSameH + 18; + const epMhCx = 586; const epOthCx = 706; + // other ins leaf + const epOthY = epSf2Y + 20; const epOthH = 76; const epOthW = 130; + // mh auto-check + const epMhY = epSf2Y + 20; const epMhH = 62; const epMhW = 175; + // selenium + const epSelY = epMhY + epMhH + 18; const epSelH = 66; const epSelW = 148; + // active / inactive + const epResHY = epSelY + epSelH + 14; + const epActCx = 534; const epInaCx = 648; + const epResY = epResHY + 22; + const epActH = 76; const epActW = 110; + const epInaH = 64; const epInaW = 120; - // ── Existing patient: YES → MassHealth auto-check (below RL at cx=510) ── - const exForkHY = leafY + leafH + 26; // 677 - const exMhCx = 445; // MassHealth sub-branch center - const exOtherCx = 558; // Other insurance center - const exCheckY = exForkHY + 34; // 711 - const exCheckW = 116; - const exCheckH = 52; - const exSelY = exCheckY + exCheckH + 18; // 781 - const exSelW = 128; - const exSelH = 52; - const exResHY = exSelY + exSelH + 16; // 849 - const exActCx = 401; // (445-44) - const exInaCx = 489; // (445+44) - const exLeafY = exResHY + 34; // 883 - const exLeafW = 80; - const exLeafH = 62; + const totalH_ep = epResY + Math.max(epActH, epInaH) + 18; - const totalH = Math.max(npResY + npResH, exLeafY + exLeafH) + 22; + const totalH = Math.max(totalH_np, totalH_ep) + 10; return ( - - + - {/* ═══════════ TOP SEQUENCE ═══════════════════════════════════ */} + {/* ═══════════ ENTRY — 3-message flow ═════════════════════════ */} - Patient texts after hours - or staff selects - "Schedule a New Patient" + Patient texts the office number + AI sends 3 messages (TwiML, guaranteed order): + ① Self-intro (New Patient Greeting template) + ② Empathetic ack · ③ "New or existing patient?" - + - AI sends New Patient Greeting - "Hi! My name is Lisa..." - - - - - Patient replies - "I want an appointment / cleaning" - - - - - AI: New or existing patient? - "Are you a new or existing patient?" + AI classifies patient reply + "new patient" / "existing" / "old patient" / … {/* ═══════════ MAIN FORK ══════════════════════════════════════ */} - - - - + + + + - + New Patient - + Existing Patient - {/* ═══════════ LEFT BRANCH — NEW PATIENT ══════════════════════ */} + {/* ═══════════ NEW PATIENT BRANCH ═════════════════════════════ */} - - Do you have any - dental insurance? + {/* Insurance? */} + + Do you have dental insurance? + "Yes" / "No" / "MassHealth" / … - - - - + {/* Sub-fork 1 */} + + + + - - MassHealth - - No ins. + + Yes + + No ins. - {/* NP: MassHealth leaf — ask for ID+DOB */} - - Check MassHealth - "Text me your - Member ID & DOB" + {/* No insurance → schedule */} + + No insurance + Ask preferred date & time + Office hours check + → Appointment created - {/* NP: No insurance leaf */} - - Schedule - "When would - you like to come?" + {/* What kind? */} + + What kind of insurance? + "MassHealth" / "Blue Cross" / … - {/* NP: Selenium check (patient texts ID+DOB) */} - - + + + + + + MassHealth + + Other + + {/* Other ins → schedule */} + + Other insurance + Ask preferred date & time + Office hours check + → Appointment created + + {/* MassHealth consent + ID+DOB */} + + Check MassHealth now? + Yes → send Member ID + + DOB (MM/DD/YYYY) + No → ask date preference + + {/* NP Selenium */} + + - - Selenium - MassHealth Portal - Auto-checks eligibility - → result SMS to patient + + Selenium + MassHealth Portal + Auto-checks eligibility + Result sent via SMS - {/* NP: Post-Selenium ACTIVE/INACTIVE fork */} - - - - + {/* NP ACTIVE / INACTIVE fork */} + + + + ACTIVE INACTIVE - - Check-up or - tooth problem? - → book appt + {/* NP ACTIVE result */} + + MassHealth active! + Ask date & time + Office hours check + → Appt created - - Inactive. - Self-pay? - YES/NO + {/* NP INACTIVE → other insurance? */} + + Coverage inactive + or not verified - {/* ═══════════ RIGHT BRANCH — EXISTING PATIENT ════════════════ */} + + + Other insurance? + "Yes" or "No" - - Do you still have - the same insurance? + {/* Final fork: yes=transfer, no=contact info */} + + + + - - - - + + Yes + + No - - YES - - NO + + Transfer + to staff - {/* EP: YES — "Same insurance confirmed" */} - - Same insurance - MassHealth → auto-check - Other → schedule + + Leave name & phone + Receptionist will + contact you shortly - {/* EP: NO — Transfer */} - - Transfer - "Our staff will - assist you" + {/* ═══════════ EXISTING PATIENT BRANCH ════════════════════════ */} - {/* EP: YES → MassHealth sub-fork */} - - - - + {/* Same insurance? */} + + Got it — existing patient! + Same insurance on file? + "Yes" / "No" / "Changed" - - MassHealth - - Other ins. + {/* Sub-fork 1 */} + + + + - {/* EP: MassHealth — "Checking 30-60s" node */} - - Wait 30-60 secs… - Using saved ID & DOB + + YES + + NO - {/* EP: Other insurance — schedule directly */} - - Schedule - "When to come in?" + {/* Changed → transfer */} + + Insurance changed + Transfer to staff - {/* EP: MassHealth → Selenium */} - - + Insurance confirmed + MassHealth or Other? + + {/* Sub-fork 2 */} + + + + + + + MassHealth + + Other + + {/* Other ins → schedule */} + + Other insurance + Ask preferred date & time + Office hours check + → Appointment created + + {/* EP MassHealth auto-check */} + + MassHealth auto-check + Using stored ID + DOB + Please wait 30-60 secs… + + {/* EP Selenium */} + + - - Selenium - MassHealth Portal - Auto-checks eligibility + + Selenium + MassHealth Portal + Auto-checks eligibility + Result sent via SMS - {/* EP: ACTIVE / INACTIVE fork */} - - - - + {/* EP ACTIVE / INACTIVE */} + + + + - - ACTIVE - - INACTIVE + + ACTIVE + + INACTIVE - - When to - come in? - → book appt + + Coverage active! + Ask date & time + Office hours check + → Appt created - - Inactive. - Self-pay? - YES/NO + + Coverage inactive + Self-pay offer? + YES → schedule / NO → close ); } @@ -974,7 +1046,7 @@ export function AiChatSettingsCard() { Reminder & Reschedule Flow - New Patient / After-Hours Flow + New Patient Flow