import{j as n,S as l,o as g}from"./vendor-mui-CBBEb17G.js";import{u as m,a as o}from"./vendor-react-BBazpZul.js";import{fX as A,at as h,aP as j,be as E,aA as I,aQ as w,I as x,aX as k,ao as N,z as d,J as _}from"./index-DdWwwZXu.js";const $=({nationalCode:a})=>{const{deleteRegisteredPrescAsync:T,getDeliveredParaclinicsAsync:u}=A(),D=m(),f=h(),[y,r]=o.useState(!1),[C,S]=o.useState([]),[t,s]=o.useState(),c=async e=>{try{r(!0);const{data:i}=await u({nationalCode:e||(t==null?void 0:t.nationalCode),from:t==null?void 0:t.from,upTo:t==null?void 0:t.upTo});i&&S(i)}finally{r(!1)}},R=e=>{f({content:"آیا از حذف این نسخه اطمینان دارید؟"}).then(async()=>{const{data:i}=await T(e);i!=null&&i.data&&(_.success(i==null?void 0:i.data),c())}).catch(()=>{})};o.useEffect(()=>{a&&(s({nationalCode:a}),c(a))},[a]);const p=[{key:"REGISTER_ID",dataIndex:"REGISTER_ID",title:"شماره ثبت نسخه",render:e=>d(e)??"-",width:100},{key:"EPRSC_ID",dataIndex:"EPRSC_ID",title:"شناسه نسخه",render:e=>d(e)??"-",width:100},{key:"PARTYPEDESC",dataIndex:"PARTYPEDESC",title:"نوع نسخه",width:150},{key:"PRESCDATE",dataIndex:"PRESCDATE",title:"تاریخ تجویز نسخه",width:100,render:e=>e?`${e.slice(0,4)}/${e.slice(4,6)}/${e.slice(6)}`:"-"},{key:"REGDATE",dataIndex:"REGDATE",title:"تاریخ ثبت نسخه",width:100,render:e=>e?`${e.slice(0,4)}/${e.slice(4,6)}/${e.slice(6)}`:"-"},{key:"PATIENT_NATCODE",dataIndex:"PATIENT_NATCODE",title:"کد ملی بیمار",width:100,render:e=>d(e)??"-"},{key:"DOC_FULL_NAME",dataIndex:"DOC_FULL_NAME",title:"نام پزشک معالج",width:150},{key:"delete",dataIndex:"REGISTER_ID",title:"حذف نسخه",width:100,render:e=>n.jsx(g,{color:"error",size:"small",className:"!m-0 !p-0",onClick:()=>R(e),children:n.jsx(x.CloseIcon,{})})}];return n.jsxs(l,{className:"h-[80vh]",spacing:1,children:[n.jsxs(l,{direction:"row",alignItems:"center",spacing:1,children:[n.jsx(j,{label:"کد ملی بیمار",value:(t==null?void 0:t.nationalCode)??"",onChange:e=>s(i=>({...i,nationalCode:e})),fullWidth:!1,focused:!0,className:"!w-48"}),n.jsx(E,{label:"از تاریخ",value:t==null?void 0:t.from,onChange:e=>s(i=>({...i,from:I(e)}))}),n.jsx(E,{label:"تا تاریخ",value:t==null?void 0:t.upTo,onChange:e=>s(i=>({...i,upTo:I(e)}))}),n.jsx(w,{color:"primary",onClick:()=>c(),children:n.jsx(x.SearchIcon,{})})]}),n.jsx(k,{rowKey:"REGISTER_ID",columns:p,data:C,loading:y}),n.jsx(l,{direction:"row",alignItems:"center",justifyContent:"center",spacing:1,children:!a&&n.jsx(N,{color:"primary",className:"!w-32",onClick:()=>D(-1),children:"بازگشت"})})]})};export{$ as T};
