PageSourceSearch

https://care.soberpedia.ai/assets/OnDemandVisitsProviderView-CYILoB_P.js

js soberpedia.ai collected 2026-10-05 15:10:46 UTC 6,859 bytes, 1 lines download raw bytes

1import{r as d,j as i}from"./react-vendor-CU6Sz31W.js";import{R as j}from"./RoutePageHeaderContent-FkxdZGox.js";import{R}from"./RoutePageTitle-D_8Od-sv.js";import{al as V,b as E,t as C,eb as M,fJ as _,i as A,S as L,as as O,u as T,be as k,jv as B,E as U}from"./index-DEXJEDAi.js";import{a as W}from"./DataTableCard-BluwWKn_.js";import{P as z}from"./patient-name-link-BAfQKbEs.js";import{u as G}from"./useOpenPatientProfile-CASNKG5E.js";import{listNetworkWaitingRoomVisits as N,claimNetworkSyncVisit as $}from"./visitActionApi-M5kT0GW2.js";import{R as H}from"./radio-B0n_XH9k.js";import{f as q,d as F}from"./firebase-w6DYUbFN.js";import{i as J,n as K}from"./syncVisitClaiming-DMQn7ZCY.js";import{u as Y}from"./useProviderVisitLauncher-C95KBL53.js";import"./payment-icons-Daq1K3F1.js";import"./index-BSuGcRaZ.js";import"./table-CxPdvV_9.js";import"./arrow-up-D6DFVL4j.js";import"./arrow-down-BjUlbB4f.js";import"./pill-filter-CtZSNPVl.js";import"./date-picker-filter-Qp1kqu9t.js";import"./calendar-RV2oTCrW.js";import"./addWeeks-1hrFjz19.js";import"./clear-filters-button-DmPemFGr.js";import"./ExportCsvAction-BJr9eiP6.js";import"./modal-option-cards-Dksohkou.js";import"./text-highlight-BFqqfcjs.js";import"./useNetworkLicensurePolicy-DGC2H23P.js";import"./providerOperations-ELdKx_YD.js";import"./networkLicensurePolicy-Ct3PZM4V.js";import"./visitDisplay-XXmI5Egl.js";import"./useVisitChartingLauncher-B1f2Z2_Q.js";const b=15e3,w={visit_started:"Already connected",client_access:"Not assigned to this client",controlled_encounter_dea_required:"DEA required"};function P(t){if(!Number.isFinite(t))return"—";const n=Math.floor(t/6e4);if(n<1)return"Just now";if(n<60)return`${n} min`;const r=Math.floor(n/60),l=n%60;return l?`${r}h ${l}m`:`${r}h`}function D({onConnectVideo:t,onConnectPhone:n}){const{branding:r}=V(),l=(r==null?void 0:r.accentColor)||E,{openPatientProfile:c,buildPatientProfileHref:m}=G(),[s,o]=d.useState([]),[g,x]=d.useState(!0),[h,v]=d.useState(null),u=d.useRef(null),p=d.useCallback(async({silent:e=!1}={})=>{e||x(!0);try{const a=await N();o(Array.isArray(a.visits)?a.visits:[])}catch(a){a.code==="SYNC_VISIT_CLAIMING_NOT_GRANTED"?o([]):e||(console.error("Error loading waiting room visits:",a),C.error(a.message||"Unable to load the waiting room. Please try again."))}finally{x(!1)}},[]);d.useEffect(()=>{let e=!1,a=null;const f=async()=>{e||(document.visibilityState==="visible"&&!u.current&&await p({silent:!0}),e||(a=setTimeout(f,b)))};p(),a=setTimeout(f,b);const y=()=>{document.visibilityState==="visible"&&p({silent:!0})};return document.addEventListener("visibilitychange",y),()=>{e=!0,a&&clearTimeout(a),document.removeEventListener("visibilitychange",y)}},[p]);async function I(e){if(!u.current){u.current=e.visitId,v(e.visitId);try{await $({visitId:e.visitId,expectedProviderId:e.currentProviderId||null}),o(a=>a.filter(f=>f.visitId!==e.visitId)),e.callMode==="phone"?n==null||n(e):t==null||t(e)}catch(a){console.error("Error connecting to waiting patient:",a),C.error(a.message||"Unable to connect to this patient. Please try again."),await p({silent:!0})}finally{u.current=null,v(null)}}}const S=[{id:"patientName",header:"Patient",csvValue:e=>e.patientName||"Patient",width:"28%",cellClassName:"py-2",renderCell:e=>i.jsx(z,{name:e.patientName||"Patient",patientId:e.patientId,onOpen:c,href:m(e.patientId),className:"text-sm font-medium"})},{id:"waitMillis",header:"Waiting",csvValue:e=>P(e.waitMillis),width:"16%",cellClassName:"py-2",renderCell:e=>i.jsx("span",{className:"text-sm text-content-primary",children:P(e.waitMillis)})},{id:"patientState",header:"State",csvValue:e=>e.patientState||"—",width:"12%",cellClassName:"py-2",renderCell:e=>i.jsx("span",{className:"text-sm text-content-secondary",children:e.patientState||"—"})},{id:"callMode",header:"Call",csvValue:e=>e.callMode==="phone"?e.patientPhone||"Phone":"Video",width:"18%",cellClassName:"py-2",renderCell:e=>e.callMode==="phone"?i.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm text-content-secondary",children:[i.jsx(M,{className:"size-3.5","aria-hidden":!0}),e.patientPhone||"Phone"]}):i.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm text-content-secondary",children:[i.jsx(_,{className:"size-3.5","aria-hidden":!0}),"Video"]})},{id:"connect",header:"Connect",csvValue:e=>e.claimable?e.callMode==="phone"?"Call patient":"Connect":w[e.claimBlockedReason]||"Unavailable",width:"26%",cellClassName:"py-2 text-right",headerClassName:"text-right",renderCell:e=>e.claimable?i.jsx(A,{type:"button",size:"sm",className:"h-7 rounded-full px-3 text-xs text-white hover:opacity-90",style:{backgroundColor:l},disabled:!!h,onClick:a=>{a.stopPropagation(),I(e)},children:h===e.visitId?i.jsx(L,{size:"sm",label:"Connecting"}):e.callMode==="phone"?"Call patient":"Connect"}):i.jsx("span",{className:"text-xs text-content-tertiary",children:w[e.claimBlockedReason]||"Unavailable"})}];return i.jsx(W,{id:"provider-on-demand-waiting-room",title:"Waiting room",description:"Patients waiting to connect now. Connecting assigns the visit to you and opens the chart.",icon:H,accentColor:l,className:"min-w-0",filteredCount:s.length,totalCount:s.length,columns:S,rows:s,rowKey:"visitId",loading:g,csvExport:{feature:"waiting-room",disabled:g||!!h,view:{getRows:async()=>{const e=await N({exportAll:!0});if(!Array.isArray(e.visits))throw new Error("Unable to export the waiting room.");return e.visits}}},maxHeight:"320px",emptyMessage:"Nobody is waiting right now. Patients appear here the moment they start an on-demand visit."})}
1function Q(t,n,r=!0){const[l,c]=d.useState({enabled:!1,granted:!1,loading:!!(r&&t&&n)});return d.useEffect(()=>{if(!r||!t||!n){c({enabled:!1,granted:!1,loading:!1});return}c(s=>s.loading?s:{...s,loading:!0});const m=q(F(O,"ProviderNetworks",t),s=>{const o=s.exists()?s.data():null;c({enabled:K(o).enabled,granted:J(o,n),loading:!1})},()=>{c({enabled:!1,granted:!1,loading:!1})});return()=>m()},[t,n,r]),l}function Re(){const{userDoc:t}=T(),n=t==null?void 0:t.id,r=t==null?void 0:t.providerNetworkId,l=k(t==null?void 0:t.userType,"Provider"),{granted:c,loading:m}=Q(r,n,l),{enterVisitById:s}=Y();return i.jsxs("div",{className:"app-page-shell min-w-0 w-full max-w-full space-y-6",children:[i.jsx(j,{children:i.jsxs("div",{children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[i.jsx(B,{mode:"ondemand"}),i.jsx(R,{className:"app-page-title",children:"On-demand"})]}),i.jsx("p",{className:"mt-1 text-sm text-content-secondary",children:"Connect with patients who are waiting right now"})]})}),c?i.jsx(D,{onConnectVideo:o=>s(o.visitId),onConnectPhone:o=>s(o.visitId)}):m?null:i.jsx(U,{reason:"error",title:"On-demand visits are unavailable",description:"Your access to connect with waiting patients was turned off. Ask your provider network admin to restore it."})]})}export{Re 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.