import{j as t,S as g}from"./vendor-mui-CBBEb17G.js";import{B as v}from"./index-DQbmBtLN.js";import{a as s}from"./vendor-react-BBazpZul.js";import{e as N,az as D,aA as p,ch as I,aH as F,be as P,aX as z,a_ as R,z as h}from"./index-DdWwwZXu.js";import"./vendor-utils-BveVE6Uf.js";import{S as A}from"./index-CDArk_1r.js";import"./vendor-charts-tGnAgELZ.js";const j=s.createContext(void 0),B=({children:a})=>{const{getReceptionReportsAsync:r}=F(),{doctorId:n,clinicId:i,officeId:o}=N(x=>x.doctorData),c={doctorId:n,haveElectronicPrescribe:!0,pageNumber:1,pageSize:25,from:p(I(new Date,-30)),upTo:p(I(new Date,1)),DateTimeFilterType:D.Window},[u,l]=s.useState(!1),[e,d]=s.useState(c),[m,C]=s.useState(null),[k,w]=s.useState(),S=async x=>{try{l(!0);let f={...e};x&&(f=c,d(c));const{data:b}=await r(f);C(b)}finally{l(!1)}};s.useEffect(()=>{S()},[e]);const T={states:{loading:u,mainData:m,searchParams:e,selectedItem:k},actions:{setSearchParams:d,setSelectedItem:w},handlers:{fetchData:S}};return t.jsx(j.Provider,{value:T,children:a})},y=()=>s.useContext(j),E=()=>t.jsx("div",{children:"ActionButtons"}),M=()=>{const{states:{loading:a,searchParams:r},actions:{setSearchParams:n}}=y();return t.jsxs(g,{direction:"row",alignItems:"center",spacing:1,flexWrap:"wrap",children:[t.jsx(P,{value:r.from,onChange:i=>n(o=>({...o,from:p(i)})),label:"از تاریخ",disablePast:!1}),t.jsx(P,{value:r.upTo,onChange:i=>n(o=>({...o,upTo:p(i)})),label:"تا تاریخ",disablePast:!1})]})},K=()=>{var c,u,l;const{states:{mainData:a,loading:r},actions:{setSearchParams:n,setSelectedItem:i}}=y(),o=[{title:"تاریخ ثبت",key:"createDate",dataIndex:"createDate",width:100,render:e=>R(e)},{title:"کد بیمار",key:"patientCustomId",dataIndex:"patientCustomId",width:70,render:e=>h(e)},{title:"نام بیمار",key:"patientFullName",dataIndex:"patientFullName",width:150},{title:"کد پذیرش",key:"customId",dataIndex:"customId",width:100,render:e=>h(e)},{title:"نام پزشک",key:"doctorFullName",dataIndex:"doctorFullName",width:150},{title:"سازمان بیمه",key:"insurance",dataIndex:"salamatTrackingCode",width:100,render:e=>e?"بیمه سلامت":"تامین اجتماعی"},{title:"کد رهگیری",key:"trackingCode",dataIndex:"taminTrackingCode",width:100,render:(e,d)=>h(e||d.salamatTrackingCode)}];return t.jsx(g,{className:"!h-[70vh]",children:t.jsx(z,{columns:o,data:(a==null?void 0:a.list)??[],rowKey:"receptionId",loading:r,totalCount:((c=a==null?void 0:a.pagination)==null?void 0:c.totalCount)??0,pageNumber:(((u=a==null?void 0:a.pagination)==null?void 0:u.pageNumber)??1)-1,pageSize:((l=a==null?void 0:a.pagination)==null?void 0:l.pageSize)??25,onPaginationLoad:(e,d)=>n(m=>({...m,pageNumber:e+1,pageSize:d})),onClick:e=>i(e)})})},L=()=>t.jsxs(g,{spacing:1,children:[t.jsx(M,{}),t.jsx(E,{}),t.jsx(K,{})]}),_=()=>t.jsx(B,{children:t.jsxs(A,{children:[t.jsx("div",{className:"",children:t.jsx(v,{prevRoutes:[{path:"/",title:"داشبورد"}],currentRoute:"نسخه های الکترونیک ثبت شده"})}),t.jsx(L,{})]})});export{_ as default};
