| Current Path : /home/users/unlimited/www/admin.medimeet.codeskitter.site/assets/ |
| Current File : /home/users/unlimited/www/admin.medimeet.codeskitter.site/assets/Update-BcDe8otM.js |
import{r as T,j as e,B as x,F as de,G as me,J as $,y as D,C as M,L as R,w as X,X as Z,T as V,x as v,aB as B,E as y,aD as Ie,Q as We,H as se}from"./index-C50MwByD.js";import{h as qe}from"./index--qiJ8GQ7.js";import{u as Me,B as Qe,j as Ve,i as fe}from"./HasPermission-BP0YFq1v.js";import{u as E}from"./SettingData-DaA8YzRn.js";import{u as Y}from"./useMutation-DiBhxv_U.js";import{u as F,M as Re,b as he,a as Oe,c as ue,g as Te,d as xe,e as je,f as C,L as K,h as Le,F as P}from"./index.esm-BgKkBPdO.js";import{S as l,D as pe,j as Ue,k as He,g as ae,c as Ce,d as Pe,e as W,f as ze,h as q,A as $e,a as Ee}from"./Dashboard-BGHL639E.js";import{g as ye}from"./CancellationReqBadge-DxQkKZHr.js";import{u as ge}from"./UseSearchFilter-CFZNsdXS.js";import{T as we,p as Ke}from"./printPDF-DLArSg1c.js";import{F as u,I as A,d as z}from"./input-BS5AKlHW.js";import{I as J,u as ne,A as Ge}from"./index-Ntz7vSIm.js";import{B as L}from"./visually-hidden.style-C5P7rhbc.js";import{S as Je,a as Xe,b as Ze,C as oe}from"./swiper-react-CL2gnvId.js";import{D as G}from"./use-clickable-BAx6nmpu.js";import{H as et}from"./index-BVf2cFHb.js";import{h as tt,i as st,j as nt}from"./index-DHZdk_rm.js";import{d as Ae}from"./index-DW8kqjNB.js";import{M as ce,a as le,b as be,c as ve}from"./menu-list-mZ34RvWI.js";import{i as at}from"./image-Bvdr-O-Y.js";import{T as it,a as rt,b as _e,c as H,d as ot,e as Q}from"./tr-DxO73Jya.js";import{P as ct}from"./PatientFiles-B4-6TiTj.js";import{C as ie,a as re}from"./card-body-BPIBi6l2.js";import{S as lt}from"./select-CE7kM0jz.js";import"./grid-BCC7IeIL.js";import"./DeletePatientFile-LbGAKk7t.js";import"./list-D99hU98N.js";import"./split-CzYrjwZo.js";function dt({appointmentID:s}){const[n,a]=T.useState(),i=F(),o="Errortoast",d=async()=>{const _=await $(D.token,`get_invoice/appointment/${s}`),S=_.data;return _.data===null?[]:[{id:S.id,status:S.status,totalAmount:S.total_amount,applied_coupon:S.coupon_title||"N/A","coupon value (%)":S.coupon_value||"N/A",coupon_off_amount:S.coupon_off_amount||0,Date:M(S.invoice_date).format("D MMM YY"),patientID:e.jsx(R,{to:`/patient/${S.patient_id}`,children:S.patient_id}),appointmentID:e.jsx(R,{to:`/appointment/${S.appointment_id}`,children:S.appointment_id}),createdAt:M(S.created_at).format("D MMM YY hh:mmA"),paymentID:S.payment_id}]},j=_=>{a(_)},{isLoading:p,data:f,error:m}=E({queryKey:["invoice",s],queryFn:d}),{handleSearchChange:k,filteredData:c}=ge(f);return m&&(i.isActive(o)||i({id:o,title:"oops!.",description:"Something bad happens.",status:"error",duration:2e3,isClosable:!0,position:"top"})),e.jsx(x,{children:p||!f?e.jsxs(x,{children:[e.jsxs(u,{mb:5,justify:"space-between",children:[e.jsx(l,{w:400,h:8}),e.jsx(l,{w:50,h:8})]}),e.jsx(l,{h:300,w:"100%"})]}):e.jsxs(x,{children:[e.jsx(u,{mb:5,justify:"space-between",align:"center",children:e.jsx(A,{size:"md",placeholder:"Search",w:400,maxW:"50vw",onChange:_=>k(_.target.value)})}),e.jsx(pe,{data:c,onActionClick:e.jsx(mt,{rowData:n,onClick:j})})]})})}const mt=({onClick:s,rowData:n})=>{const a=i=>{const o=window.open(i,"_blank");o&&(o.focus(),o.onload=()=>{o.load(),o.onafterprint=()=>{o.close()}})};return e.jsx(u,{justify:"center",children:e.jsx(J,{size:"sm",variant:"ghost",_hover:{background:"none"},onClick:()=>{s(n),a(`${me}/invoice/generatePDF/${n.id}`)},icon:e.jsx(we,{fontSize:18,color:de.colors.blue[500]})})})},ht=s=>{switch(s){case"Credited":return e.jsx(L,{colorScheme:"green",fontSize:12,letterSpacing:.5,p:"5px",size:"sm",children:"Credited"});case"Debited":return e.jsx(L,{colorScheme:"red",fontSize:12,letterSpacing:.5,p:"5px",children:"Debited"});default:return e.jsx(L,{colorScheme:"yellow",fontSize:12,letterSpacing:.5,p:"5px",children:"N/A"})}};function ut({appointmentID:s}){const[n,a]=T.useState(),i=F(),o="Errortoast",d=async()=>{const _=await $(D.token,`get_all_transaction/appointment/${s}`);return _==null?void 0:_.data.map(I=>{const{id:r,user_id:g,patient_id:h,appointment_id:w,payment_transaction_id:t,amount:N,transaction_type:O,is_wallet_txn:U,notes:ee,created_at:b,patient_f_name:te,patient_l_name:Be,user_f_name:Fe,user_l_name:Ne}=I;return{id:r,patient:e.jsx(R,{to:`/patient/${h}`,children:`${te} ${Be}`}),user:g?e.jsx(R,{to:`/user/${g}`,children:`${Fe} ${Ne}`}):"N/A",app_ID:e.jsx(R,{to:`/appointment/${w}`,children:w}),txn_ID:t||"N/A",amount:N,txn_type:ht(O),wallet_Txn:U==1?"Yes":"No",notes:ee||"N/A",createdAt:M(b).format("D MMM YY hh:mmA")}})},j=_=>{a(_)},{isLoading:p,data:f,error:m}=E({queryKey:["transaction",s],queryFn:d}),{handleSearchChange:k,filteredData:c}=ge(f);return m&&(i.isActive(o)||i({id:o,title:"oops!.",description:"Something bad happens.",status:"error",duration:2e3,isClosable:!0,position:"top"})),e.jsx(x,{children:p||!f?e.jsxs(x,{children:[e.jsxs(u,{mb:5,justify:"space-between",children:[e.jsx(l,{w:400,h:8}),e.jsx(l,{w:50,h:8})]}),e.jsx(l,{h:300,w:"100%"})]}):e.jsxs(x,{children:[e.jsx(u,{mb:5,justify:"space-between",align:"center",children:e.jsx(A,{size:"md",placeholder:"Search",w:400,maxW:"50vw",onChange:_=>k(_.target.value)})}),e.jsx(pe,{data:c,onActionClick:e.jsx(xt,{rowData:n,onClick:j})})]})})}const xt=({onClick:s,rowData:n})=>e.jsx(u,{justify:"center",children:e.jsx(J,{size:"sm",variant:"ghost",_hover:{background:"none"},onClick:()=>{s(n)},icon:e.jsx(we,{fontSize:18,color:de.colors.blue[500]})})});function jt({appointmentID:s}){const[n,a]=T.useState(),i=async()=>{const m=await $(D.token,`get_appointment_payment/appintment/${s}`);return m.data===null?[]:(c=>{const{id:_,txn_id:S,invoice_id:I,amount:r,payment_time_stamp:g,payment_method:h,created_at:w,user_id:t,patient_id:N,appointment_id:O,patient_f_name:U,patient_l_name:ee,user_f_name:b,user_l_name:te}=c;return[{id:_,"txn ID":S,invoiceID:I,patient:e.jsx(R,{to:`/patient/${N}`,children:`${U} ${ee}`}),user:e.jsx(R,{to:`/user/${t}`,children:`${b} ${te}`}),"APP ID":e.jsx(R,{to:`/appointment/${O}`,children:O}),amount:r,"payment Method":h,"Time stamp":M(g).format("D MMM YY hh.mmA"),"created At":M(w).format("D MMM YY hh:mmA")}]})(m.data)},o=m=>{a(m)},{isLoading:d,data:j}=E({queryKey:["payment",s],queryFn:i}),{handleSearchChange:p,filteredData:f}=ge(j);return e.jsx(x,{children:d||!j?e.jsxs(x,{children:[e.jsxs(u,{mb:5,justify:"space-between",children:[e.jsx(l,{w:400,h:8}),e.jsx(l,{w:50,h:8})]}),e.jsx(l,{h:300,w:"100%"})]}):e.jsxs(x,{children:[e.jsx(u,{mb:5,justify:"space-between",align:"center",children:e.jsx(A,{size:"md",placeholder:"Search",w:400,maxW:"50vw",onChange:m=>p(m.target.value)})}),e.jsx(pe,{data:f,onActionClick:e.jsx(pt,{rowData:n,onClick:o})})]})})}const pt=({onClick:s,rowData:n})=>e.jsx(u,{justify:"center",children:e.jsx(J,{size:"sm",variant:"ghost",_hover:{background:"none"},onClick:()=>{s(n),Ke(`${me}/invoice/generatePDF/${n.invoiceID}`)},icon:e.jsx(we,{fontSize:18,color:de.colors.blue[500]})})}),gt=()=>{const s=[];for(let n=0;n<15;n++){const a=M().add(n,"days").format("YYYY-MM-DD");s.push(a)}return s},Se=s=>{const n=M(s,"YYYY-MM-DD");return{month:n.format("MMM"),date:n.format("DD"),year:n.format("ddd")}},ft=s=>M(s,"YYYYMMDD").format("dddd"),yt={spaceBetween:20,centeredSlides:!1,loop:!1,slidesPerView:7.5,breakpoints:{1024:{spaceBetween:5,slidesPerView:7.5},768:{spaceBetween:5,slidesPerView:6.5},640:{spaceBetween:5,slidesPerView:5.5},320:{spaceBetween:5,slidesPerView:5.5}}},_t=async s=>{const n=await B(D.token,"appointment_rescheduled",s);if(n.response!==200)throw new Error(n.message);return n};function St({data:s,isOpen:n,onClose:a}){const[i,o]=T.useState(),[d,j]=T.useState(),p=X(),f=F(),m=async()=>(await $(D.token,`get_doctor_time_interval/${s.doct_id}/${ft(i)}`)).data,{isLoading:k,data:c}=E({queryKey:["timeslotes",i,s.doct_id],queryFn:m,enabled:!!i}),_=async()=>(await $(D.token,`get_booked_time_slots?doct_id=${s.doct_id}&date=${M(i).format("YYYY-MM-DD")}&type=OPD`)).data,{isLoading:S,data:I}=E({queryKey:["bookedslotes",i,s.doct_id],queryFn:_,enabled:!!i,staleTime:0,cacheTime:0,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),r=h=>{let w=!0;return I==null||I.forEach(t=>{t.time_slots===h.time_start&&t.date===i&&(w=!1)}),w},g=Y({mutationFn:async()=>{let h={id:s.id,date:i,time_slots:d.time_start};await _t(h)},onSuccess:()=>{o(),j(),C(f,"success","Success"),p.invalidateQueries("appointments"),p.invalidateQueries(["appointment",s.id]),p.invalidateQueries(["bookedslotes",i,s.doct_id]),p.invalidateQueries(["timeslotes",i,s.doct_id]),a()},onError:h=>{C(f,"error",h.message)}});return k||S||g.isPending?e.jsx(Z,{}):e.jsxs(Re,{isOpen:n,onClose:a,isCentered:!0,size:"xl",children:[e.jsx(he,{}),e.jsxs(Oe,{children:[e.jsx(ue,{fontSize:"md",py:3,children:"Reschedule Appointment"}),e.jsx(Te,{top:2}),e.jsx(G,{mt:0}),e.jsxs(xe,{children:[e.jsxs(x,{maxW:"100%",overflow:"hidden",children:[" ",e.jsx(Je,{...yt,style:{cursor:"grab",overflow:"hidden",maxWidth:"100%"},children:gt().map((h,w)=>e.jsx(Xe,{children:e.jsx(x,{onClick:()=>{o(M(h).format("YYYY-MM-DD"))},children:e.jsxs(x,{bg:i===M(h).format("YYYY-MM-DD")?"green.500":"blue.500",mr:3,borderRadius:5,color:"#fff",p:1,cursor:"pointer",children:[e.jsx(V,{fontSize:"xs",fontWeight:"bold",color:"gray.100",textAlign:"center",m:0,children:Se(h).month}),e.jsx(V,{fontSize:"sm",fontWeight:"700",color:"gray.100",textAlign:"center",m:0,children:Se(h).date}),e.jsx(V,{fontSize:"xs",fontWeight:"bold",color:"gray.100",textAlign:"center",m:0,children:Se(h).year})]})},w)},w))})]}),e.jsx(x,{children:i?e.jsxs(x,{mt:5,border:"1px solid",borderColor:"gray.200",p:2,borderRadius:4,children:[e.jsx(V,{textAlign:"left",fontWeight:600,fontSize:16,mb:1,children:"Time Slotes"}),c!=null&&c.length?e.jsx(x,{mt:2,children:e.jsx(Ze,{columns:[3,4,5],spacing:2,children:c==null?void 0:c.map((h,w)=>e.jsxs(v,{size:"sm",fontSize:"xs",fontWeight:600,colorScheme:r(h)?h===d?"blue":"green":"red",variant:"solid",onClick:()=>{r(h)&&j(h)},isDisabled:!r(h),_disabled:{backgroundColor:"red.500"},children:[h.time_start," - ",h.time_end]},w))})}):e.jsx(V,{color:"red.400",fontWeight:700,fontSize:"sm",children:"Sorry , no available time slotes ware found for the selected date."})]}):""})]}),e.jsxs(je,{children:[e.jsx(v,{colorScheme:"gray",mr:3,onClick:a,size:"sm",children:"Close"}),e.jsx(v,{colorScheme:"blue",size:"sm",onClick:()=>{g.mutate()},children:"Reschedule Appointment"})]})]})]})}const wt=[{id:1,name:"Cash",icon:e.jsx(tt,{})},{id:2,name:"Online",icon:e.jsx(Ae,{})},{id:3,name:"Other",icon:e.jsx(Ae,{})},{id:4,name:"Wallet",icon:e.jsx(st,{})},{id:5,name:"UPI",icon:e.jsx(et,{})}],bt=async s=>{const n=await B(D.token,"update_appointment_to_paid",s);if(n.response!==200)throw new Error(n.message);return n};function vt({id:s,isOpen:n,onClose:a}){const[i,o]=T.useState(),d=F(),j=X(),p=Y({mutationFn:async()=>{let f={appointment_id:s,payment_method:i.name};i?bt(f):C(d,"error","Please Select Payment Mode")},onSuccess:()=>{C(d,"success","Success"),j.invalidateQueries("appointments"),j.invalidateQueries(["appointment",s]),j.invalidateQueries(["payment",s]),j.invalidateQueries(["transaction",s]),j.invalidateQueries(["invoice",s]),a()}});return p.isPending?e.jsx(Z,{}):e.jsxs(Re,{isOpen:n,onClose:a,isCentered:!0,size:"sm",children:[e.jsx(he,{}),e.jsxs(Oe,{children:[e.jsx(ue,{fontSize:"md",py:3,children:"Amount Paid"}),e.jsx(Te,{top:2}),e.jsx(G,{mt:0}),e.jsx(xe,{children:e.jsxs(ce,{children:[e.jsx(le,{as:v,rightIcon:e.jsx(oe,{}),w:"full",bg:"transparent",textAlign:"center",pl:0,pt:0,h:8,_hover:{bg:"transparent"},_focus:{bg:"transparent"},borderBottom:"1px solid",borderBottomRadius:0,borderColor:y("gray.200","gray.600"),children:i?e.jsxs(u,{gap:3,align:"center",children:[" ",i.icon," ",i.name]}):"Select Payment Mode"}),e.jsx(be,{children:wt.map(f=>e.jsx(ve,{onClick:()=>{o(f)},children:e.jsxs(u,{gap:3,align:"center",children:[" ",f.icon," ",f.name]})},f.id))})]})}),e.jsxs(je,{children:[e.jsx(v,{colorScheme:"gray",mr:3,onClick:a,size:"sm",children:"Close"}),e.jsx(v,{colorScheme:"blue",size:"sm",onClick:()=>{p.mutate()},children:"Set Amount to Paid"})]})]})]})}function Ct({appointmentID:s,appointmntData:n}){const{hasPermission:a}=Me(),[i,o]=T.useState(),{isOpen:d,onOpen:j,onClose:p}=ne(),f=async()=>(await $(D.token,`get_prescription/appointment/${s}`)).data,{isLoading:m,data:k,error:c}=E({queryKey:["prescriptions",s],queryFn:f}),{handleSearchChange:_,filteredData:S}=ge(k);if(c)return e.jsx(V,{color:"red.500",children:"Error loading data"});const I=r=>{const g=window.open(r,"_blank");g&&(g.focus(),g.onload=()=>{g.load(),g.onafterprint=()=>{g.close()}})};return e.jsxs(x,{children:[m?e.jsxs(x,{children:[e.jsxs(u,{mb:5,justify:"space-between",children:[e.jsx(l,{w:400,h:8}),e.jsx(l,{w:200,h:8})]}),e.jsx(l,{h:10,w:"100%",mt:2}),e.jsx(l,{h:10,w:"100%",mt:2}),e.jsx(l,{h:10,w:"100%",mt:2}),e.jsx(l,{h:10,w:"100%",mt:2}),e.jsx(l,{h:10,w:"100%",mt:2}),e.jsx(l,{h:10,w:"100%",mt:2}),e.jsx(l,{h:10,w:"100%",mt:2}),e.jsx(l,{h:10,w:"100%",mt:2}),e.jsx(l,{h:10,w:"100%",mt:2}),e.jsx(l,{h:10,w:"100%",mt:2})]}):e.jsxs(x,{p:5,children:[e.jsxs(u,{mb:4,alignItems:"center",justify:"space-between",children:[e.jsx(A,{placeholder:"Search",width:"300px",mr:2,icon:e.jsx(Ue,{}),onChange:r=>_(r.target.value),size:"sm"}),a("PRESCRIPTION_ADD")&&e.jsx(v,{colorScheme:"blue",size:"sm",as:R,to:`/add-prescription/?appointmentID=${s}&patientID=${n==null?void 0:n.patient_id}`,children:"New Prescription"})]}),e.jsx(x,{borderWidth:"1px",borderRadius:"lg",overflow:"scroll",maxW:"100%",children:e.jsxs(it,{variant:"simple",children:[e.jsx(rt,{children:e.jsxs(_e,{children:[e.jsx(H,{children:"Patient"}),e.jsx(H,{children:"Doctor"}),e.jsx(H,{children:"Date"}),e.jsx(H,{children:"Pulse Rate"}),e.jsx(H,{children:"Temperature"}),e.jsx(H,{children:"Action"})]})}),e.jsx(ot,{children:k.length>0?S.map(r=>e.jsxs(_e,{children:[e.jsx(Q,{children:`${r.patient_f_name} ${r.patient_l_name}`}),e.jsx(Q,{children:`${n.doct_f_name} ${n.doct_l_name}`}),e.jsx(Q,{children:r.date}),e.jsx(Q,{children:r.pulse_rate}),e.jsx(Q,{children:r.temperature}),e.jsx(Q,{children:e.jsxs(u,{alignItems:"center",children:[" ",e.jsx(J,{as:K,"aria-label":"Filter",icon:e.jsx(Qe,{fontSize:22}),colorScheme:"whatsapp",size:"sm",variant:"ghost",target:"_blank",rel:"noopener noreferrer",onClick:()=>{I(r!=null&&r.pdf_file?`${at}/${r==null?void 0:r.pdf_file}`:`${me}/prescription/generatePDF/${r.id}`)}}),a("PRESCRIPTION_UPDATE")&&e.jsx(J,{isDisabled:!!(r!=null&&r.pdf_file),as:R,"aria-label":"Filter",icon:e.jsx(Ge,{fontSize:24}),colorScheme:"blue",size:"sm",variant:"ghost",to:`/prescription/${r==null?void 0:r.id}/?appointmentID=${r==null?void 0:r.appointment_id}&patientID=${r==null?void 0:r.patient_id}`}),e.jsx(J,{"aria-label":"Filter",icon:e.jsx(Ve,{fontSize:20}),colorScheme:"red",size:"sm",variant:"ghost",onClick:()=>{j(),o(r)}})," "]})})]},r.id)):e.jsx(_e,{children:e.jsx(Q,{colSpan:"7",children:e.jsx(V,{align:"center",children:"No data available in table"})})})})]})})]}),d&&e.jsx(He,{isOpen:d,onClose:p,data:i})]})}let De=["Pending","Confirmed","Rejected","Visited"],Pt=["Pending","Confirmed","Rejected","Completed"];const zt=s=>s==="OPD"?De:s==="Video Consultant"?Pt:De,At=s=>{switch(s){case"Emergency":return e.jsx(L,{colorScheme:"red",p:"5px",px:10,children:s});case"OPD":return e.jsx(L,{colorScheme:"green",p:"5px",px:10,children:s});default:return e.jsx(L,{colorScheme:"green",p:"5px",px:10,children:s})}},Dt=async s=>{const n=await B(D.token,"update_appointment",s);if(n.response!==200)throw new Error(n.message);return n},Ye=async s=>{const n=await B(D.token,"update_appointment_status",s);if(n.response!==200)throw new Error(n.message);return n},kt=async s=>{const n=await B(D.token,"appointment_reject_and_refund",s);if(n.response!==200)throw new Error(n.message);return n},It=async s=>{const n=await B(D.token,"appointment_cancellation_and_refund",s);if(n.response!==200)throw new Error(n.message);return n};function ls(){const{register:s,handleSubmit:n}=Le(),{id:a}=Ie(),i=F(),o=We(),d=X(),[j,p]=T.useState(null),{isOpen:f,onOpen:m,onClose:k}=ne(),{hasPermission:c}=Me(),{isOpen:_,onOpen:S,onClose:I}=ne(),{isOpen:r,onOpen:g,onClose:h}=ne(),w=async()=>{const b=await $(D.token,`get_appointment/${a}`);return p(b.data.status),b.data},{data:t,isLoading:N}=E({queryKey:["appointment",a],queryFn:w}),O=Y({mutationFn:async b=>{await Dt(b)},onSuccess:()=>{d.invalidateQueries("appointments"),d.invalidateQueries("main-appointments"),d.invalidateQueries(["appointment",a])},onError:b=>{C(i,"error",b.message)}}),U=Y({mutationFn:async b=>{await Ye(b)},onSuccess:()=>{d.invalidateQueries("appointments"),d.invalidateQueries("main-appointments"),d.invalidateQueries(["appointment",a])},onError:b=>{C(i,"error",b.message)}}),ee=b=>{O.mutate({...b,status:j})};return N||O.isPending||U.isPending?e.jsx(Z,{}):e.jsxs(x,{children:[" ",e.jsxs(u,{justify:"space-between",alignItems:"center",children:[e.jsxs(u,{justify:"space-between",alignItems:"center",gap:5,children:[e.jsxs(se,{as:"h1",size:"md",children:["Appointment Details #",a]}),ae(t==null?void 0:t.status),e.jsxs(L,{colorScheme:"gray",p:"5px",px:5,children:["Source - ",t.source]}),t.type==="Video Consultant"?t.meeting_link&&e.jsx(v,{rightIcon:e.jsx(qe,{}),size:"sm",variant:"outline",cursor:"pointer",as:K,href:t.meeting_link,isExternal:!0,color:"teal",children:"Join Meeting"}):null,e.jsx(v,{rightIcon:e.jsx(nt,{}),size:"sm",variant:"link",cursor:"pointer",as:K,href:`${me}/consultation_report/${a}`,isExternal:!0,children:"Print Consultation Report"})]}),e.jsx(v,{w:120,size:"sm",variant:y("blackButton","gray"),onClick:()=>{o(-1)},children:"Back"})]}),e.jsxs(Ce,{colorScheme:"blue",mt:3,children:[e.jsxs(Pe,{children:[e.jsx(W,{children:"Overview"}),c("PRESCRIPTION_VIEW")&&e.jsx(W,{children:"Prescriptions"}),c("APPOINTMENT_INVOICE_VIEW")&&e.jsx(W,{children:"Invoice"}),c("ALL_TRANSACTION_VIEW")&&e.jsx(W,{children:"Transaction"}),c("APPOINTMENT_PAYMENTS_VIEW")&&e.jsx(W,{children:"Payments"}),c("FILE_VIEW")&&e.jsx(W,{children:"Patient Files"})]}),e.jsxs(ze,{children:[e.jsx(q,{children:e.jsxs(x,{children:[e.jsxs("form",{onSubmit:n(ee),children:[e.jsxs(u,{gap:8,children:[e.jsxs(x,{w:"55%",children:[" ",e.jsx(ie,{mt:5,bg:y("white","gray.700"),children:e.jsxs(re,{p:3,as:"form",children:[" ",e.jsxs(u,{align:"center",gap:5,children:[" ",e.jsx(se,{as:"h3",size:"sm",children:"Patient Details"}),e.jsx(K,{to:`/patient/${t.patient_id}`,as:R,children:e.jsx(fe,{fontSize:20})})]}),e.jsx(G,{mt:2,mb:5}),e.jsxs(u,{gap:5,children:[e.jsxs(z,{children:[e.jsx(P,{fontSize:"sm",mb:0,color:y("gray.600","gray.300"),children:"Patient First Name"}),e.jsx(A,{size:"sm",isReadOnly:!0,fontWeight:600,variant:"flushed",defaultValue:t.patient_f_name})]}),e.jsxs(z,{children:[e.jsx(P,{fontSize:"sm",mb:0,color:y("gray.600","gray.300"),children:"Patient Last Name"}),e.jsx(A,{size:"sm",isReadOnly:!0,fontWeight:600,variant:"flushed",defaultValue:t.patient_l_name})]})]}),e.jsxs(u,{gap:5,mt:2,children:[e.jsxs(z,{id:"doct_specialization",size:"sm",children:[e.jsx(P,{fontSize:"sm",mb:0,color:y("gray.600","gray.300"),children:"Phone"}),e.jsx(A,{size:"sm",isReadOnly:!0,fontWeight:600,variant:"flushed",defaultValue:t.patient_phone})]}),e.jsxs(z,{id:"dept_title",size:"sm",children:[e.jsx(P,{fontSize:"sm",mb:0,color:y("gray.600","gray.300"),children:"Gender"}),e.jsx(A,{size:"sm",isReadOnly:!0,fontWeight:600,variant:"flushed",defaultValue:t.patient_gender})]})]})]})})]})," ",e.jsxs(x,{w:"45%",children:[" ",e.jsx(ie,{mt:5,bg:y("white","gray.700"),children:e.jsxs(re,{p:3,as:"form",children:[" ",e.jsxs(u,{alignItems:"center",gap:5,children:[e.jsxs(se,{as:"h3",size:"sm",children:["Doctor"," "]})," ",e.jsx(K,{to:`/doctor/${t.doct_id}`,as:R,children:e.jsx(fe,{fontSize:20})})]}),e.jsx(G,{mt:2,mb:5}),e.jsxs(u,{gap:5,children:[e.jsxs(z,{children:[e.jsx(P,{fontSize:"sm",mb:0,color:y("gray.600","gray.300"),children:"Doctor First Name"}),e.jsx(A,{size:"sm",isReadOnly:!0,fontWeight:600,variant:"flushed",defaultValue:t.doct_f_name})]}),e.jsxs(z,{children:[e.jsx(P,{fontSize:"sm",mb:0,color:y("gray.600","gray.300"),children:"Doctor Last Name"}),e.jsx(A,{size:"sm",isReadOnly:!0,fontWeight:600,variant:"flushed",defaultValue:t.doct_l_name})]})]}),e.jsxs(u,{gap:5,mt:2,children:[e.jsxs(z,{id:"doct_specialization",size:"sm",children:[e.jsx(P,{fontSize:"sm",mb:0,color:y("gray.600","gray.300"),children:"Doctor Specialization"}),e.jsx(A,{size:"sm",isReadOnly:!0,fontWeight:600,variant:"flushed",defaultValue:t.doct_specialization})]}),e.jsxs(z,{id:"dept_title",size:"sm",children:[e.jsx(P,{fontSize:"sm",mb:0,color:y("gray.600","gray.300"),children:"Department"}),e.jsx(A,{size:"sm",isReadOnly:!0,fontWeight:600,variant:"flushed",defaultValue:t.dept_title})]})]})]})})]})," "]}),e.jsxs(u,{gap:8,children:[e.jsxs(x,{w:"45%",children:[" ",e.jsx(ie,{mt:5,bg:y("white","gray.700"),children:e.jsxs(re,{p:3,as:"form",children:[" ",e.jsxs(se,{as:"h3",size:"sm",children:["Appointment Details -"," "]})," ",e.jsx(G,{mt:2,mb:5}),e.jsxs(u,{gap:5,children:[e.jsxs(z,{children:[e.jsx(P,{fontSize:"sm",mb:0,color:y("gray.600","gray.300"),children:"Appointment Date"}),e.jsx(A,{size:"sm",fontWeight:600,variant:"flushed",value:M(t==null?void 0:t.date).format("DD-MM-YYYY"),onClick:()=>{if((t==null?void 0:t.status)=="Confirmed"||(t==null?void 0:t.status)=="Pending"||(t==null?void 0:t.status)=="Rescheduled")S();else return},cursor:"pointer"})]}),e.jsxs(z,{children:[e.jsx(P,{fontSize:"sm",mb:0,color:y("gray.600","gray.300"),children:"Appointment Time Slot"}),e.jsx(A,{size:"sm",fontWeight:600,variant:"flushed",value:M(t==null?void 0:t.time_slots,"hh:mm:ss").format("hh:mm A"),onClick:()=>{if((t==null?void 0:t.status)=="Confirmed"||(t==null?void 0:t.status)=="Pending"||(t==null?void 0:t.status)=="Rescheduled")S();else return},cursor:"pointer"})]})]}),e.jsxs(u,{gap:5,mt:2,children:[e.jsxs(z,{id:"status",size:"sm",children:[e.jsx(P,{fontSize:"sm",mb:0,color:y("gray.600","gray.300"),children:"Status"}),e.jsxs(ce,{children:[e.jsx(le,{as:v,rightIcon:e.jsx(oe,{}),bg:"transparent",w:"100%",textAlign:"left",pl:0,pt:0,h:8,_hover:{bg:"transparent"},_focus:{bg:"transparent"},borderBottom:"1px solid",borderBottomRadius:0,borderColor:y("gray.200","gray.600"),children:j?ae(j):ae(t==null?void 0:t.status)}),["Pending","Confirmed","Rescheduled"].includes(t==null?void 0:t.status)&&e.jsx(be,{children:zt(t.type).map(b=>e.jsx(ve,{onClick:()=>{if(t.current_cancel_req_status==="Initiated")return C(i,"error","Please Update the Cancellation request first");if(b==="Rejected")m();else{let te={id:a,status:b};U.mutate(te)}},children:e.jsx(x,{display:"flex",alignItems:"center",children:ae(b)})},b))})]})]}),e.jsxs(z,{id:"doct_specialization",size:"sm",children:[e.jsx(P,{fontSize:"sm",mb:0,color:y("gray.600","gray.300"),children:"Appointment Type"}),e.jsx(ce,{children:e.jsx(le,{as:v,rightIcon:e.jsx(oe,{}),bg:"transparent",w:"100%",textAlign:"left",pl:0,pt:0,h:8,_hover:{bg:"transparent"},_focus:{bg:"transparent"},borderBottom:"1px solid",borderBottomRadius:0,borderColor:y("gray.200","gray.600"),children:At(t.type)})})]})]})]})})]})," ",e.jsxs(x,{w:"55%",children:[" ",e.jsx(ie,{mt:5,bg:y("white","gray.700"),children:e.jsxs(re,{p:3,as:"form",children:[" ",e.jsxs(se,{as:"h3",size:"sm",children:["Other -"," "]})," ",e.jsx(G,{mt:2,mb:5}),e.jsx(u,{gap:5,align:"flex-end",children:e.jsxs(z,{isRequired:!0,children:[e.jsx(P,{fontSize:"sm",mb:0,color:y("gray.600","gray.300"),children:"Payment Status"}),e.jsx(lt,{placeholder:"Select paymemnt status",variant:"flushed",value:t==null?void 0:t.payment_status,...s("payment_status"),isReadOnly:!0,onChange:b=>{if(b.target.value==="Paid")g();else return},children:["Pending","Not Paid","Unpaid"].includes(t.payment_status)||t.payment_status===null?e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"Paid",children:"Paid"}),e.jsx("option",{value:"Pending",children:"Pending"}),e.jsx("option",{value:"Not Paid",children:"Not Paid"}),e.jsx("option",{value:"Refunded",children:"Refunded"})]}):e.jsx(e.Fragment,{children:e.jsx("option",{value:t.payment_status,children:t.payment_status})})})]})}),e.jsxs(u,{gap:5,mt:2,children:[e.jsxs(z,{id:"doct_specialization",size:"sm",children:[e.jsx(P,{fontSize:"sm",mb:0,color:y("gray.600","gray.300"),children:"Meeting ID"}),e.jsx(A,{...s("meeting_id"),size:"sm",fontWeight:600,variant:"flushed",defaultValue:t.meeting_id})]}),e.jsxs(z,{id:"dept_title",size:"sm",children:[e.jsxs(P,{fontSize:"sm",mb:0,color:y("gray.600","gray.300"),display:"Flex",alignItems:"center",gap:2,children:["Meeting Link"," ",t.type==="Video Consultant"?t.meeting_link&&e.jsx(K,{href:t.meeting_link,target:"_blank",children:e.jsx(fe,{fontSize:20,color:de.colors.teal[500]})}):null]}),e.jsx(A,{...s("meeting_link"),size:"sm",fontWeight:600,variant:"flushed",value:t.meeting_link})]})]})]})})]})," "]})]}),e.jsxs(Ce,{mt:5,colorScheme:"red",children:[e.jsx(Pe,{children:e.jsx(W,{fontSize:18,fontWeight:600,children:"Cancellation Req By Patient"})}),e.jsx(ze,{children:e.jsx(q,{px:0,children:e.jsx(Mt,{current_req:t.current_cancel_req_status})})})]})]})}),c("PRESCRIPTION_VIEW")&&e.jsx(q,{children:e.jsx(Ct,{appointmentID:a,appointmntData:t})}),c("APPOINTMENT_INVOICE_VIEW")&&e.jsx(q,{children:e.jsx(dt,{appointmentID:a})}),c("ALL_TRANSACTION_VIEW")&&e.jsx(q,{children:e.jsx(ut,{appointmentID:a})}),c("APPOINTMENT_PAYMENTS_VIEW")&&e.jsx(q,{children:e.jsx(jt,{appointmentID:a})}),e.jsx(q,{children:e.jsx(ct,{id:t.patient_id})})]})]}),e.jsx(Rt,{isOpen:f,onClose:k,id:a,appData:t}),e.jsx(St,{data:t,isOpen:_,onClose:I}),e.jsx(vt,{id:a,isOpen:r,onClose:h})]})}function ke(s){switch(s){case"Initiated":return["Processing","Rejected","Approved"];case"Processing":return["Rejected","Approved"];case"Rejected":return[];case"Approved":return[];default:return[]}}const Mt=({current_req:s})=>{var I,r;const{id:n}=Ie(),a=F(),i=X(),{isOpen:o,onOpen:d,onClose:j}=ne(),[p,f]=T.useState(),m=async()=>{const g=await $(D.token,`get_appointment_cancel_req/appointment/${n}`);return(g==null?void 0:g.data.map(w=>{const{status:t,notes:N,created_at:O}=w;return{Status:ye(t),notes:N,"Created At":M(O).format("DD MMM YY hh:mm A")}})).sort((w,t)=>t.id-w.id)},{isLoading:k,data:c}=E({queryKey:["appointment-canc-req",n],queryFn:m}),_=async g=>{let h={appointment_id:n,status:g};try{const w=await B(D.token,"appointment_cancellation",h);w.response===200?C(a,"success","Updated!"):C(a,"error",w.message)}catch(w){C(a,"error",JSON.stringify(w))}};return Y({mutationFn:async g=>{_(g)},onSuccess:()=>{i.invalidateQueries(["appointment-canc-req",n]),i.invalidateQueries("appointment",n),i.invalidateQueries("appointments"),i.invalidateQueries("main-appointments")}}).isLoading?e.jsx(Z,{}):e.jsxs(x,{children:[k||!c?e.jsxs(x,{children:[e.jsxs(u,{mb:5,justify:"space-between",children:[e.jsx(l,{w:400,h:8}),e.jsx(l,{w:200,h:8})]}),e.jsx(l,{h:10,w:"100%",mt:2}),e.jsx(l,{h:10,w:"100%",mt:2}),e.jsx(l,{h:10,w:"100%",mt:2}),e.jsx(l,{h:10,w:"100%",mt:2}),e.jsx(l,{h:10,w:"100%",mt:2}),e.jsx(l,{h:10,w:"100%",mt:2}),e.jsx(l,{h:10,w:"100%",mt:2}),e.jsx(l,{h:10,w:"100%",mt:2}),e.jsx(l,{h:10,w:"100%",mt:2}),e.jsx(l,{h:10,w:"100%",mt:2})]}):e.jsxs(x,{children:[c.length?e.jsx(u,{mb:5,justify:"space-between",align:"center",children:e.jsxs(z,{size:"sm",children:[e.jsx(P,{fontSize:"sm",mb:0,color:y("gray.600","gray.300"),children:"Update Request Status"}),e.jsxs(ce,{children:[e.jsx(le,{as:v,rightIcon:e.jsx(oe,{}),bg:"transparent",w:"300px",textAlign:"left",pl:0,pt:0,h:8,_hover:{bg:"transparent"},_focus:{bg:"transparent"},borderBottom:"1px solid",borderBottomRadius:0,borderColor:y("gray.200","gray.600"),children:ye(s)}),(I=ke(s))!=null&&I.length?e.jsx(be,{children:(r=ke(s))==null?void 0:r.map(g=>e.jsx(ve,{onClick:()=>{d(),f(g)},children:e.jsx(x,{display:"flex",alignItems:"center",children:ye(g)})},g))}):null]})]})}):null,e.jsx(pe,{minPad:"8px 10px",data:c})]}),e.jsx(Ot,{isOpen:o,onClose:j,id:n,type:p})]})},Rt=({isOpen:s,onClose:n,id:a,appData:i})=>{const o=X(),d=F(),j=Y({mutationFn:async p=>{i.source==="Admin"?await Ye({id:a,status:"Rejected"}):await kt(p)},onSuccess:()=>{C(d,"success","Success"),o.invalidateQueries("appointments"),o.invalidateQueries("main-appointments"),o.invalidateQueries(["appointment",a]),n()},onError:p=>{C(d,"error",p.message)}});return j.isPending?e.jsx(Z,{}):e.jsx($e,{isOpen:s,onClose:n,isCentered:!0,children:e.jsx(he,{children:e.jsxs(Ee,{children:[e.jsxs(ue,{fontSize:"lg",fontWeight:"bold",children:["Reject Appointment , id : ",a]}),e.jsxs(xe,{children:["Are you sure? You ","can't"," undo this action afterwards."]}),e.jsxs(je,{children:[e.jsx(v,{onClick:n,size:"sm",children:"Cancel"}),e.jsx(v,{colorScheme:"red",onClick:()=>{let p={appointment_id:a};j.mutate(p)},ml:3,size:"sm",children:"Reject"})]})]})})})},Ot=({isOpen:s,onClose:n,id:a,type:i})=>{const o=X(),d=F(),j=async m=>{let k={appointment_id:a,status:m};try{const c=await B(D.token,"appointment_cancellation",k);c.response===200?C(d,"success","Updated!"):C(d,"error",c.message)}catch(c){C(d,"error",JSON.stringify(c))}},p=Y({mutationFn:async m=>{await It(m)},onSuccess:()=>{o.invalidateQueries("appointments"),o.invalidateQueries("main-appointments"),o.invalidateQueries(["appointment-canc-req",a]),o.invalidateQueries("appointment",a),n()},onError:m=>{C(d,"error",m.message),n()}}),f=Y({mutationFn:async m=>{await j(m)},onSuccess:()=>{o.invalidateQueries("appointments"),o.invalidateQueries("main-appointments"),o.invalidateQueries(["appointment-canc-req",a]),o.invalidateQueries("appointment",a),n()},onError:m=>{C(d,"error",m.message),n()}});return p.isPending||f.isPending?e.jsx(Z,{}):e.jsx($e,{isOpen:s,onClose:n,isCentered:!0,children:e.jsx(he,{children:e.jsxs(Ee,{children:[e.jsxs(ue,{fontSize:"md",fontWeight:"bold",children:[i," Request , id : ",a]}),e.jsxs(xe,{children:["Are you sure? update cancellation status to ",i]}),e.jsxs(je,{children:[e.jsx(v,{onClick:n,size:"sm",children:"Cancel"}),e.jsxs(v,{colorScheme:"red",onClick:()=>{if(i==="Approved"){let m={appointment_id:a,status:"Approved"};p.mutate(m)}else f.mutate(i)},ml:3,size:"sm",children:[i," Cancellation Request"]})]})]})})})};export{ls as default};