VirtualPR/frontend/dist/assets/index-iF15iw48.js

2 lines
3.4 KiB
JavaScript

import{r as n,d as c,j as s,C as v,B as d,R as C,l as m}from"./index-B92aEPQH.js";import{P as R}from"./PageBreadcrumb-Dsn9CkpH.js";import{C as o,a as h}from"./Card-DPmHd5BI.js";import{T as u}from"./Table-BCHyhTAY.js";import"./PageMetaData-DFmRpQLs.js";function k(){const[x,b]=n.useState([]),[N,g]=n.useState([]),[r,f]=n.useState({sessionsRun:0,attendance:0,possibleAttendance:0,reassignments:[]}),[j,p]=n.useState("");n.useEffect(()=>{Promise.all([c("/api/reports/patients"),c("/api/reports/utilization"),c("/api/reports/productivity")]).then(([e,t,i])=>{b(e.items||[]),g(t.items||[]),f(i)}).catch(e=>p(e.message))},[]);const a=e=>{fetch(`/api/reports/export?type=${e}`,{credentials:"include"}).then(t=>t.blob()).then(t=>{const i=URL.createObjectURL(t),l=document.createElement("a");l.href=i,l.download=`${e}-report.csv`,l.click(),URL.revokeObjectURL(i)}).catch(t=>p(t.message))};return s.jsxs(v,{fluid:!0,children:[s.jsx(R,{title:"Reports",subtitle:"Program"}),j?s.jsx("div",{className:"alert alert-danger",children:j}):null,s.jsxs("div",{className:"d-flex gap-2 mb-3",children:[s.jsx(d,{variant:"outline-primary",onClick:()=>a("patients"),children:"Export patients CSV"}),s.jsx(d,{variant:"outline-primary",onClick:()=>a("utilization"),children:"Export utilization CSV"}),s.jsx(d,{variant:"outline-primary",onClick:()=>a("vitals"),children:"Export vitals CSV"})]}),s.jsxs(C,{className:"g-3",children:[s.jsx(m,{lg:7,children:s.jsx(o,{children:s.jsxs(h,{children:[s.jsx("h5",{className:"mb-3",children:"Patient progress"}),s.jsxs(u,{responsive:!0,size:"sm",className:"mb-0",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Patient"}),s.jsx("th",{children:"Cohort"}),s.jsx("th",{children:"PRT"}),s.jsx("th",{children:"First session"}),s.jsx("th",{children:"Completed"})]})}),s.jsxs("tbody",{children:[x.map(e=>s.jsxs("tr",{children:[s.jsxs("td",{children:[e.name,s.jsx("div",{className:"small text-muted",children:e.diseaseType})]}),s.jsx("td",{children:e.cohort?.name||"—"}),s.jsx("td",{children:e.prt?`${e.prt.firstName} ${e.prt.lastName}`:"—"}),s.jsx("td",{children:e.firstSession||"—"}),s.jsx("td",{children:e.completed})]},e.id)),x.length?null:s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"text-muted",children:"No confirmed patients."})})]})]})]})})}),s.jsxs(m,{lg:5,children:[s.jsx(o,{className:"mb-3",children:s.jsxs(h,{children:[s.jsx("h5",{className:"mb-3",children:"Utilization"}),s.jsxs(u,{responsive:!0,size:"sm",className:"mb-0",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"PRT"}),s.jsx("th",{children:"Cohorts"}),s.jsx("th",{children:"Idle"}),s.jsx("th",{children:"Cancelled"})]})}),s.jsx("tbody",{children:N.map(e=>s.jsxs("tr",{children:[s.jsx("td",{children:e.name}),s.jsxs("td",{children:[e.used,"/",e.max]}),s.jsx("td",{children:e.idle}),s.jsx("td",{children:e.cancelled})]},e.id))})]})]})}),s.jsx(o,{children:s.jsxs(h,{children:[s.jsx("h5",{className:"mb-2",children:"Productivity"}),s.jsxs("p",{className:"mb-1",children:["Sessions run: ",r.sessionsRun]}),s.jsxs("p",{className:"mb-3",children:["Attendance: ",r.attendance,"/",r.possibleAttendance]}),s.jsx("h6",{children:"Recent reassignments"}),(r.reassignments||[]).length?s.jsx("ul",{className:"mb-0",children:r.reassignments.map(e=>s.jsxs("li",{children:[e.date,": ",e.cohort," ",e.from," → ",e.to||"open"," (",e.reason,")"]},e.id))}):s.jsx("p",{className:"text-muted mb-0",children:"None yet."})]})})]})]})]})}export{k as default};