1import{r as a,j as r}from"./react-vendor-CU6Sz31W.js";import{i as o,E as C,ax as E,c6 as A,ez as w,eA as L,eB as k,dX as T,be as I}from"./index-DEXJEDAi.js";import{A as M}from"./AccessDenied-Ba4b0-Uz.js";import{u as F,P as d}from"./usePracticeRoute-BanfQY79.js";import{g as b}from"./patientStatusPresentation-E5PKaeUS.js";import{R as O}from"./RoutePageHeader-9W0v4VlT.js";import{a as q}from"./DataTableCard-BluwWKn_.js";import{P as z}from"./patient-name-link-BAfQKbEs.js";import{u as B}from"./useOpenPatientProfile-CASNKG5E.js";import{p as V}from"./clinicalApi--8E0qkZ_.js";import"./firebase-w6DYUbFN.js";import"./payment-icons-Daq1K3F1.js";import"./shield-alert-DjOj07_r.js";import"./RoutePageHeaderContent-FkxdZGox.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";function v({practiceId:n,showHeader:u=!0,patient:i=!1}){const{openPatientProfile:s,buildPatientProfileHref:m}=B(),[f,S]=a.useState({prescriptions:[],nextCursor:null}),[h,x]=a.useState([""]),[R,P]=a.useState(0),[c,j]=a.useState(!0),[g,y]=a.useState(""),[l,p]=a.useState(null),N=h.at(-1);a.useEffect(()=>{const e=new AbortController;return j(!0),y(""),p(null),V(n,{query:{cursor:N},signal:e.signal}).then(t=>{e.signal.aborted||S(t)}).catch(t=>{e.signal.aborted||y(t.message)}).finally(()=>{e.signal.aborted||j(!1)}),()=>e.abort()},[n,N,R]);const D=[...i?[]:[{id:"patientName",header:"Patient",renderCell:e=>r.jsx(z,{patientId:e.patientId,name:e.patientName,href:m(e.patientId),onOpen:s})}],{id:"medicationName",header:"Medication",renderCell:e=>e.medicationName||e.drugName||"Prescription"},{id:"status",header:"Status",renderCell:e=>i?b(e.status):e.status||"Pending"},{id:"providerName",header:"Provider",renderCell:e=>e.providerName||"Not recorded"},{id:"pharmacyName",header:"Pharmacy",renderCell:e=>e.pharmacyName||"Not recorded"},{id:"actions",header:"Actions",renderCell:e=>r.jsx(o,{variant:"outline",size:"sm",onClick:()=>p(e),children:"View prescription"})}];return r.jsxs("div",{className:"app-page-shell space-y-6",children:[u&&r.jsx(O,{title:"Prescriptions",description:i?"Review your prescriptions and pharmacy fulfillment.":"Review prescriptions and pharmacy fulfillment for your Practice."}),r.jsx("div",{className:"flex justify-end",children:r.jsx(o,{variant:"outline",disabled:c,onClick:()=>P(e=>e+1),children:"Refresh prescriptions"})}),g?r.jsx(C,{reason:"error",title:"Unable to load prescriptions",description:g,action:r.jsx(o,{onClick:()=>P(e=>e+1),children:"Try again"})}):r.jsx(q,{columns:D,rows:f.prescriptions,loading:c,tableLabel:"Practice prescriptions",emptyMessage:r.jsx(C,{reason:"empty",title:"No prescriptions yet",description:i?"Your prescriptions will appear here after your provider records them.":"Prescriptions will appear here after they are recorded for Practice patients.",action:null})}),r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx(o,{variant:"outline",disabled:c||h.length<2,onClick:()=>x(e=>e.slice(0,-1)),children:"Previous page"}),r.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",h.length]}),r.jsx(o,{variant:"outline",disabled:c||!!g||!f.nextCursor,onClick:()=>x(e=>[...e,f.nextCursor]),children:"Next page"})]}),l&&r.jsx(E,{open:!0,size:"lg",title:"Prescription",description:"Medication and pharmacy details.",mobileStickyFooter:!0,onOpenChange:e=>{e||p(null)},footer:r.jsx(o,{variant:"outline",onClick:()=>p(null),children:"Close"}),children:r.jsx(A,{children:r.jsx(w,{title:l.medicationName||l.drugName||"Medication",children:r.jsx(L,{children:[["Status","status"],["Dosage","dosage"],["Directions","directions"],["Quantity","quantity"],["Days supply","daysSupply"],["Refills","refills"],["Provider","providerName"],["Pharmacy","pharmacyName"],["Tracking number","trackingNumber"]].map(([e,t])=>r.jsx(k,{label:e,children:i&&t==="status"?b(l[t]):l[t]??"Not recorded"},t))})})})})]})}function fe({showHeader:n=!0}
1){const{loading:u,role:i,practiceId:s,userType:m}=F();return u?r.jsx(T,{title:"Prescriptions",description:"Review Practice prescriptions.",message:"Loading prescriptionsâ¦"}):s&&I(m,"Patient")?r.jsx(v,{practiceId:s,showHeader:n,patient:!0},s):[d.ADMIN,d.STAFF,d.PROVIDER,d.DELEGATE].includes(i)?r.jsx(v,{practiceId:s,showHeader:n},s):r.jsx(M,{subject:"prescriptions"})}export{fe 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.