PageSourceSearch

https://aehpbhcp.base44.app/assets/CrisisCommandCenter-BAi2bxEQ.js

js aehpbhcp.base44.app collected 2026-10-03 03:13:58 UTC 10,443 bytes, 1 lines download raw bytes

1import{r as h,b as r,z as A,ar as v,D as c,j as e,S as k,aL as _,a2 as N,aC as D,B as M,c3 as F,ad as B,U as p,a$ as K,e as o,H as T,bs as U,bu as z,c4 as O,c5 as H,c6 as L,c7 as G,c8 as Q,c9 as W}from"./index-CZ54c6IG.js";const I={Tier1:"bg-green-100 text-green-700 border-green-200",Tier2:"bg-yellow-100 text-yellow-700 border-yellow-200",Tier3:"bg-orange-100 text-orange-700 border-orange-200",Tier4:"bg-red-100 text-red-700 border-red-200 animate-pulse"};function $(){var w;const[a,C]=h.useState(null),[l,b]=h.useState(null),[d,g]=h.useState("overview");h.useEffect(()=>{r.auth.me().then(s=>{if(!(s.role==="admin"||A(s)==="provider")){window.location.href=v("Home");return}C(s)}).catch(()=>{window.location.href=v("Welcome")})},[]);const{data:f=[]}=c({queryKey:["cmd-patients",a==null?void 0:a.email],queryFn:()=>r.entities.PatientProvider.filter({provider_email:a.email,status:"active"}),enabled:!!(a!=null&&a.email)}),{data:E=[]}=c({queryKey:["all-users-cmd"],queryFn:()=>r.entities.User.list(),enabled:f.length>0}),n=E.filter(s=>f.some(t=>t.patient_email===s.email)),{data:P=[]}=c({queryKey:["all-risk-assessments"],queryFn:()=>r.entities.RiskAssessment.list("-created_date",200),refetchInterval:3e4}),{data:u=[]}=c({queryKey:["cmd-crises"],queryFn:()=>r.entities.CrisisEvent.filter({outcome:"ongoing"},"-created_date",50),refetchInterval:5e3}),{data:j=[]}=c({queryKey:["cmd-incidents"],queryFn:()=>r.entities.IncidentEvent.list("-created_date",100),refetchInterval:15e3}),{data:S=[]}=c({queryKey:["cmd-checkins"],queryFn:()=>r.entities.CheckIn.list("-created_date",500)}),{data:y=[]}=c({queryKey:["cmd-overdue-tasks"],queryFn:async()=>{const s=new Date().toISOString().split("T")[0];return(await r.entities.CarePathwayTask.list("-due_date",200)).filter(i=>i.due_date<s&&(i.status==="pending"||i.status==="in_progress"))},refetchInterval:6e4}),x=s=>P.filter(i=>i.user_email===s)[0]||null,m=n.filter(s=>{var t;return((t=x(s.email))==null?void 0:t.risk_level)==="Tier4"}),q=n.filter(s=>{var t;return((t=x(s.email))==null?void 0:t.risk_level)==="Tier3"}),R=[{key:"overview",label:"Command Overview",icon:k},{key:"patients",label:"Patient Monitor",icon:p},{key:"timeline",label:"Incident Timeline",icon:T},{key:"toolkit",label:"Intervention Tools",icon:U},{key:"analytics",label:"Analytics",icon:z}];return e.jsxs("div",{className:"min-h-screen bg-slate-900 text-white",children:[e.jsx("div",{className:"border-b border-slate-700 px-6 py-4",children:e.jsxs("div",{className:"max-w-7xl mx-auto flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-red-600 rounded-xl flex items-center justify-center",children:e.jsx(k,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-bold text-white",children:"BHCP Crisis Command Center"}),e.jsxs("p",{className:"text-xs text-slate-400",children:[_(new Date,"EEEE, MMMM d, yyyy · h:mm a")," · Real-Time"]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[m.length>0&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-red-600 rounded-xl animate-pulse",children:[e.jsx(N,{className:"w-4 h-4"}),e.jsxs("span",{className:"text-sm font-bold",children:[m.length," IMMINENT CRISIS"]})]}
1),e.jsx(D,{to:v("ProviderDashboard"),children:e.jsx(M,{size:"sm",variant:"outline",className:"border-slate-600 text-slate-300 hover:bg-slate-800",children:"Back to Dashboard"})})]})]})}),e.jsx("div",{className:"border-b border-slate-700 px-6 py-3 bg-slate-800",children:e.jsx("div",{className:"max-w-7xl mx-auto grid grid-cols-2 sm:grid-cols-5 gap-4",children:[{label:"Active Crises",value:u.length,color:u.length>0?"text-red-400":"text-emerald-400",icon:N},{label:"Tier 3/4 Patients",value:q.length+m.length,color:"text-orange-400",icon:F},{label:"Overdue Tasks",value:y.length,color:y.length>0?"text-yellow-400":"text-emerald-400",icon:B},{label:"Total Patients",value:n.length,color:"text-blue-400",icon:p},{label:"Incidents Today",value:j.filter(s=>new Date(s.created_date)>new Date(Date.now()-864e5)).length,color:"text-purple-400",icon:K}].map((s,t)=>{const i=s.icon;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(i,{className:o("w-4 h-4",s.color)}),e.jsxs("div",{children:[e.jsx("p",{className:o("text-xl font-bold",s.color),children:s.value}),e.jsx("p",{className:"text-xs text-slate-500",children:s.label})]})]},t)})})}),e.jsx("div",{className:"border-b border-slate-700 px-6 bg-slate-800",children:e.jsx("div",{className:"max-w-7xl mx-auto flex gap-1 overflow-x-auto",children:R.map(s=>{const t=s.icon;return e.jsxs("button",{onClick:()=>g(s.key),className:o("flex items-center gap-2 px-4 py-3 text-sm font-medium whitespace-nowrap border-b-2 transition-all",d===s.key?"border-indigo-400 text-indigo-300":"border-transparent text-slate-400 hover:text-slate-200"),children:[e.jsx(t,{className:"w-4 h-4"}),s.label]},s.key)})})}),e.jsxs("div",{className:"max-w-7xl mx-auto px-6 py-6",children:[d==="overview"&&e.jsxs("div",{className:"space-y-6",children:[m.length>0&&e.jsxs("div",{className:"bg-red-950/50 border border-red-700 rounded-2xl p-5",children:[e.jsxs("h3",{className:"text-red-400 font-bold mb-3 flex items-center gap-2",children:[e.jsx(N,{className:"w-5 h-5"}),"IMMINENT CRISIS: Requires Immediate Action"]}),e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-3",children:m.map(s=>e.jsxs("button",{onClick:()=>{b(s),g("patients")},className:"bg-red-900/60 border border-red-600 rounded-xl p-4 text-left hover:bg-red-900/80 transition-all",children:[e.jsx("p",{className:"font-bold text-white",children:s.full_name}),e.jsx("p",{className:"text-xs text-red-300 mt-1",children:s.email}),e.jsx("span",{className:"text-xs bg-red-600 text-white px-2 py-0.5 rounded-full mt-2 inline-block",children:"Tier 4 (Imminent)"})]},s.id))})]}),e.jsx("div",{className:"bg-slate-800 rounded-2xl p-5",children:e.jsx(O,{providerEmail:a==null?void 0:a.email,patients:n})}),e.jsxs("div",{className:"bg-slate-800 rounded-2xl p-5",children:[e.jsxs("h3",{className:"text-slate-300 font-bold mb-4 flex items-center gap-2",children:[e.jsx(p,{className:"w-5 h-5"}),"Patient Risk Monitor"]}),e.jsxs("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:[n.map(s=>{const t=x(s.email),i=(t==null?void 0:t.risk_level)||"Tier1";return e.jsxs("button",{onClick:()=>{b(s),g("patients")},className:"bg-slate-700 hover:bg-slate-600 border border-slate-600 rounded-xl p-4 text-left transition-all",children:[e.jsx("p",{className:"font-semibold text-white text-sm truncate",children:s.full_name||s.email}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[e.jsx("span",{className:o("text-xs px-2 py-0.5 rounded-full border font-medium",I[i]),children:i}),(t==null?void 0:t.composite_score)!==void 0&&e.jsxs("span",{className:"text-xs text-slate-400",children:["Score: ",t.composite_score]})]})]},s.id)}),n.length===0&&e.jsx("p",{className:"text-slate-500 text-sm col-span-4",children:"No assigned patients yet."})]})]})]}),d==="patients"&&e.jsxs("div",{className:"grid lg:grid-cols-4 gap-6",children:[e.jsxs("div",{className:"lg:col-span-1 bg-slate-800 rounded-2xl p-4",children:[e.jsx("p",{className:"text-xs text-slate-400 font-semibold uppercase tracking-wide mb-3",children:"Patients"}),e.jsx("div",{className:"space-y-2",children:n.map(s=>{const t=x(s.email),i=(t==null?void 0:t.risk_level)||"Tier1";return e.jsxs("button",{onClick:()=>b(s),className:o("w-full text-left px-3 py-3 rounded-xl border transition-all text-sm",(l==null?void 0:l.id)===s.id?"border-indigo-500 bg-indigo-900/40":"border-slate-700 hover:border-slate-500 bg-slate-700/50"),children:[e.jsx("p",{className:"font-medium text-white truncate",children:s.full_name||s.email}),e.jsx("span",{className:o("text-xs px-1.5 py-0.5 rounded-full border mt-1 inline-block",I[i]),children:i})]},s.id)})})]}),e.jsx("div",{className:"lg:col-span-3 space-y-4",children:l?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-slate-800 rounded-2xl p-4",children:[e.jsx("h3",{className:"text-white font-bold text-lg",children:l.full_name}),e.jsx("p",{className:"text-slate-400 text-sm",children:l.email})]}),e.jsx(H,{patientEmail:l.email,patientName:l.full_name,checkIns:S.filter(s=>s.user_email===l.email),crisisEvents:u.filter(s=>s.user_email===l.email)}),e.jsx(L,{riskTier:((w=x(l.email))==null?void 0:w.risk_level)||"Tier1",patientEmail:l.email,patientName:l.full_name,clinicianEmail:a==null?void 0:a.email}),e.jsx(G,{patientEmail:l.email,clinicianEmail:a==null?void 0:a.email,clinicianName:a==null?void 0:a.full_name})]}):e.jsxs("div",{className:"bg-slate-800 rounded-2xl p-12 text-center",children:[e.jsx(p,{className:"w-12 h-12 text-slate-600 mx-auto mb-3"}),e.jsx("p",{className:"text-slate-400",children:"Select a patient to view their risk profile and command tools"})]})})]}),d==="timeline"&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"bg-slate-800 rounded-2xl p-5",children:[e.jsxs("h3",{className:"text-slate-200 font-bold mb-4 flex items-center gap-2",children:[e.jsx(T,{className:"w-5 h-5"}),"All Recent Incident Events"]}),e.jsxs("div",{className:"space-y-3 max-h-[600px] overflow-y-auto",children:[j.slice(0,50).map(s=>e.jsxs("div",{className:"flex items-start gap-3 p-3 bg-slate-700 rounded-xl",children:[e.jsx("div",{className:"text-xs text-slate-400 flex-shrink-0 w-28",children:_(new Date(s.created_date),"MMM d h:mm a")}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-1",children:[e.jsx("span",{className:"text-xs bg-slate-600 text-slate-300 px-2 py-0.5 rounded-full capitalize",children:s.event_type}),s.severity&&e.jsx("span",{className:"text-xs text-slate-400 capitalize",children:s.severity}),e.jsx("span",{className:"text-xs text-indigo-400",children:s.patient_name||s.user_email})]}),e.jsx("p",{className:"text-sm text-slate-200",children:s.description}),s.created_by&&e.jsxs("p",{className:"text-xs text-slate-500 mt-0.5",children:["by ",s.created_by]})]})]},s.id)),j.length===0&&e.jsx("p",{className:"text-slate-500 text-sm",children:"No incident events recorded yet."})]})]})}),d==="toolkit"&&e.jsx("div",{className:"max-w-3xl",children:e.jsx(Q,{})}),d==="analytics"&&e.jsx("div",{className:"bg-white rounded-2xl p-6",children:e.jsx(W,{providerEmail:a==null?void 0:a.email,patients:n})})]})]})}export{$ as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.