Your IP : 216.73.216.93


Current Path : /home/users/unlimited/www/admin.medimeet.codeskitter.site/assets/
Upload File :
Current File : /home/users/unlimited/www/admin.medimeet.codeskitter.site/assets/AddNewAppointment-BJ7pZqHM.js

import{J as B,y as v,j as e,X as _e,B as u,T as C,C as c,x as b,r as m,w as we,E as d,H as G,P as De}from"./index-f5FVPPWf.js";import{u as F}from"./SettingData-HUsgVeqA.js";import{u as Ce}from"./UsePatientsData-2jGB5q0K.js";import{U as J}from"./UsersComboBox-BR1MkjhI.js";import{g as X}from"./Dashboard-QYea_GjR.js";import{u as Me}from"./useMutation-DWP0Ot2c.js";import{M as de,b as ce,a as me,c as ue,g as he,d as pe,u as Pe,f as M,F as x,e as ve}from"./index.esm-CxKpqEdJ.js";import{S as Ae,a as Ye,b as ze,C as Z}from"./swiper-react-CbcsGzjN.js";import{D as R}from"./use-clickable-DJbYv-Vn.js";import{A as Oe}from"./AddPatients-BLpTyXQl.js";import{F as y,d as f,I as k}from"./input-aKY8cD2r.js";import{C as ee,a as te}from"./card-body-U833268K.js";import{M as se,a as re,b as ne,c as ae}from"./menu-list-UQBnhbZh.js";import{S as oe}from"./select-Dt5dI57S.js";import{B as $}from"./visually-hidden.style-BrEqndXz.js";import{u as ie}from"./index-B8iLT9XL.js";const ke=async()=>(await B(v.token,"get_doctor")).data,Be=()=>{const{isLoading:s,data:t,error:h}=F({queryKey:["doctors","dashboard"],queryFn:ke});return{doctorsData:t,doctorsLoading:s,doctorsError:h}},Fe=()=>{const s=[];for(let t=0;t<15;t++){const h=c().add(t,"days").format("YYYY-MM-DD");s.push(h)}return s},V=s=>{const t=c(s,"YYYY-MM-DD");return{month:t.format("MMM"),date:t.format("DD"),year:t.format("ddd")}},q=s=>c(s,"YYYYMMDD").format("dddd"),Te={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}}};function Ee({doctID:s,isOpen:t,onClose:h,selectedSlot:g,setselectedSlot:A,selectedDate:i,setselectedDate:T,type:j}){const Y=async()=>{const a=j==="OPD"?`get_doctor_time_interval/${s}/${q(i)}`:j==="Video Consultant"?`get_doctor_video_time_interval/${s}/${q(i)}`:`get_doctor_time_interval/${s}/${q(i)}`;return(await B(v.token,a)).data},{isLoading:E,data:p}=F({queryKey:["timeslotes",i,s,j],queryFn:Y,enabled:!!i}),W=async()=>(await B(v.token,`get_booked_time_slots?doct_id=${s}&date=${c(i).format("YYYY-MM-DD")}&type=${j}`)).data,{isLoading:z,data:_}=F({queryKey:["bookedslotes",i,s],queryFn:W,enabled:!!i,staleTime:0,cacheTime:0,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),n=a=>{let l=!0;return _==null||_.forEach(S=>{S.time_slots===a.time_start&&S.date===i&&(l=!1)}),l};return E||z?e.jsx(_e,{}):e.jsxs(de,{isOpen:t,onClose:h,isCentered:!0,size:"xl",children:[e.jsx(ce,{}),e.jsxs(me,{children:[e.jsx(ue,{fontSize:"md",py:3,children:"Select date and Time Slot"}),e.jsx(he,{top:2}),e.jsx(R,{mt:0}),e.jsxs(pe,{children:[e.jsxs(u,{maxW:"100%",overflow:"hidden",children:[" ",e.jsx(Ae,{...Te,style:{cursor:"grab",overflow:"hidden",maxWidth:"100%"},children:Fe().map((a,l)=>e.jsx(Ye,{children:e.jsx(u,{onClick:()=>{T(c(a).format("YYYY-MM-DD"))},children:e.jsxs(u,{bg:i===c(a).format("YYYY-MM-DD")?"green.500":"blue.500",mr:3,borderRadius:5,color:"#fff",p:1,cursor:"pointer",children:[e.jsx(C,{fontSize:"xs",fontWeight:"bold",color:"gray.100",textAlign:"center",m:0,children:V(a).month}),e.jsx(C,{fontSize:"sm",fontWeight:"700",color:"gray.100",textAlign:"center",m:0,children:V(a).date}),e.jsx(C,{fontSize:"xs",fontWeight:"bold",color:"gray.100",textAlign:"center",m:0,children:V(a).year})]})},l)},l))})]}),e.jsx(u,{children:i?e.jsxs(u,{mt:5,border:"1px solid",borderColor:"gray.200",p:2,borderRadius:4,children:[e.jsx(C,{textAlign:"left",fontWeight:600,fontSize:16,mb:1,children:"Time Slotes"}),p!=null&&p.length?e.jsx(u,{mt:2,children:e.jsx(ze,{columns:[3,4,5],spacing:2,children:p==null?void 0:p.map((a,l)=>e.jsxs(b,{size:"sm",fontSize:"xs",fontWeight:600,colorScheme:a===g?"blue":n(a)?"green":"red",variant:"solid",onClick:()=>{A(a),h()},_disabled:{backgroundColor:"red.500"},children:[a.time_start," - ",a.time_end]},l))})}):e.jsx(C,{color:"red.400",fontWeight:700,fontSize:"sm",children:"Sorry , no available time slotes ware found for the selected date."})]}):""})]})]})]})}let We=["Pending","Confirmed"];const le=s=>{switch(s){case"Emergency":return e.jsx($,{colorScheme:"red",p:"5px",px:10,children:s});case"OPD":return e.jsx($,{colorScheme:"green",p:"5px",px:10,children:s});default:return e.jsx($,{colorScheme:"blue",p:"5px",px:10,children:s})}},P=(s,t)=>{switch(s){case"Emergency":return t==null?void 0:t.emg_fee;case"OPD":return t==null?void 0:t.opd_fee;case"Video Consultant":return t==null?void 0:t.video_fee;default:return t==null?void 0:t.emg_fee}},Le=[{id:1,name:"Cash"},{id:2,name:"Online"},{id:3,name:"Other"},{id:4,name:"Wallet"},{id:5,name:"UPI"}],$e=async s=>{const t=await De(v.token,"add_appointment",s);if(t.response!==200)throw new Error(t.message);return t};function rt({isOpen:s,onClose:t,PatientID:h}){const g=Pe(),{isOpen:A,onOpen:i,onClose:T}=ie(),{isOpen:j,onOpen:Y,onClose:E}=ie(),{doctorsData:p}=Be(),{patientsData:W}=Ce(),[z,_]=m.useState(),[n,a]=m.useState(),[l,S]=m.useState(),[w,L]=m.useState(),[O,xe]=m.useState("Confirmed"),[o,H]=m.useState(),[D,N]=m.useState(),[U,fe]=m.useState(),I=we(),[ge,je]=m.useState(h),{data:K,isLoading:ye}=F({queryKey:["doctor",n==null?void 0:n.user_id],queryFn:async()=>(await B(v.token,`get_doctor/${n==null?void 0:n.user_id}`)).data,enabled:!!n}),Se=()=>z?n?o?l?w?O?D?D==="Paid"&&!U?"Payment Method":null:"Payment Status":"Appointment status":"Time Slot":"Date":"Appointment Type":"doctor":"patient",Q=Me({mutationFn:async()=>{const r=Se();if(r)throw new Error(`Please select ${r}`);if(ye||!K)throw new Error("Unable to fetch doctor details");if(!r){let be={patient_id:z.id,status:O,date:l,time_slots:w.time_start,doct_id:n.user_id,dept_id:K.department,type:o,fee:P(o,n),total_amount:P(o,n),unit_total_amount:P(o,n),invoice_description:o,payment_method:U||null,service_charge:0,payment_transaction_id:D==="Paid"?"Pay at Hospital":null,is_wallet_txn:0,payment_status:D,source:"Admin"};await $e(be)}},onError:r=>{M(g,"error",r.message)},onSuccess:()=>{M(g,"success","Success"),I.invalidateQueries("appointments"),I.invalidateQueries("main-appointments"),t()}});return e.jsxs(u,{children:[" ",e.jsxs(de,{isOpen:s,onClose:t,size:"2xl",onOverlayClick:!1,children:[e.jsx(ce,{}),e.jsxs(me,{children:[e.jsx(ue,{children:"Add New Appointment"}),e.jsx(he,{}),e.jsxs(pe,{children:[e.jsxs(y,{gap:10,children:[" ",e.jsxs(y,{flex:3,gap:4,align:"center",children:[e.jsx(J,{data:W,name:"Patient",setState:_,defaultData:ge,addNew:!0,addOpen:Y}),"Or",e.jsx(b,{size:"xs",w:120,colorScheme:"blue",onClick:()=>{Y()},children:"Add patient"})]}),e.jsx(y,{flex:2,children:e.jsx(J,{data:p,name:"Doctor",setState:a})})]}),e.jsx(ee,{mt:5,bg:d("white","gray.700"),children:e.jsxs(te,{p:3,as:"form",children:[" ",e.jsxs(G,{as:"h3",size:"sm",children:["Appointment Details -"," "]})," ",e.jsx(R,{mt:2,mb:5}),e.jsxs(y,{gap:5,children:[e.jsxs(f,{id:"doct_specialization",size:"sm",children:[e.jsx(x,{fontSize:"sm",mb:0,color:d("gray.600","gray.300"),children:"Appointment Type"}),e.jsxs(se,{children:[e.jsx(re,{as:b,rightIcon:e.jsx(Z,{}),bg:"transparent",w:"100%",textAlign:"left",pl:0,pt:0,h:8,_hover:{bg:"transparent"},_focus:{bg:"transparent"},borderBottom:"1px solid",borderBottomRadius:0,borderColor:d("gray.200","gray.600"),children:o?le(o):"Select Appointment Type"}),e.jsx(ne,{children:["OPD","Video Consultant","Emergency"].map(r=>e.jsx(ae,{onClick:()=>{r!=="OPD"&&N("Paid"),r==="Emergency"?(H(r),S(c().format("YYYY-MM-DD")),L({time_start:c().format("HH:mm")})):(S(),L(),H(r))},children:e.jsx(u,{display:"flex",alignItems:"center",children:le(r)})},r))})]})]}),e.jsxs(f,{children:[e.jsx(x,{fontSize:"sm",mb:0,color:d("gray.600","gray.300"),children:"Appointment Date"}),e.jsx(k,{size:"sm",fontWeight:600,variant:"flushed",value:c(l).format("DD-MM-YYYY"),onClick:()=>{if(!n)return M(g,"error","Please Select Doctor");if(!o)return M(g,"error","Please Select Appointment Type");i()},cursor:"pointer"})]})]}),e.jsxs(y,{gap:5,mt:2,children:[e.jsxs(f,{children:[e.jsx(x,{fontSize:"sm",mb:0,color:d("gray.600","gray.300"),children:"Appointment Time Slot"}),e.jsx(k,{size:"sm",fontWeight:600,variant:"flushed",value:w?c(w.time_start,"hh:mm").format("hh:mm A"):"Select Time Slot",onClick:()=>{if(!n)return M(g,"error","Please Select Doctor");i()},cursor:"pointer",isReadOnly:!0})]}),e.jsxs(f,{id:"status",size:"sm",children:[e.jsx(x,{fontSize:"sm",mb:0,color:d("gray.600","gray.300"),children:"Status"}),e.jsxs(se,{children:[e.jsx(re,{as:b,rightIcon:e.jsx(Z,{}),bg:"transparent",w:"100%",textAlign:"left",pl:0,pt:0,h:8,_hover:{bg:"transparent"},_focus:{bg:"transparent"},borderBottom:"1px solid",borderBottomRadius:0,borderColor:d("gray.200","gray.600"),children:O?X(O):"Select Status"}),e.jsx(ne,{children:We.map(r=>e.jsx(ae,{onClick:()=>{xe(r)},children:e.jsx(u,{display:"flex",alignItems:"center",children:X(r)})},r))})]})]})]})]})}),e.jsx(ee,{mt:5,bg:d("white","gray.700"),children:e.jsxs(te,{p:3,as:"form",children:[" ",e.jsxs(G,{as:"h3",size:"sm",children:["Payment Details -"," "]})," ",e.jsx(R,{mt:2,mb:5}),e.jsxs(y,{gap:5,children:[e.jsxs(f,{children:[e.jsx(x,{fontSize:"sm",mb:0,color:d("gray.600","gray.300"),children:"Payment Status"}),e.jsxs(oe,{placeholder:"Select paymemnt status",variant:"flushed",onChange:r=>{N(r.target.value)},value:D,children:[e.jsx("option",{value:"Paid",children:"Paid"}),o==="OPD"&&e.jsx("option",{value:"Unpaid",children:"Not Paid"})]})]}),e.jsxs(f,{children:[e.jsx(x,{fontSize:"sm",mb:0,color:d("gray.600","gray.300"),children:"Payment Method"}),e.jsx(oe,{placeholder:"Select paymemnt Method",variant:"flushed",onChange:r=>{fe(r.target.value)},children:Le.map(r=>e.jsx("option",{value:r.name,children:r.name},r.id))})]})]}),e.jsxs(y,{gap:5,mt:4,children:[e.jsxs(f,{w:"50%",children:[e.jsx(x,{fontSize:"sm",mb:0,color:d("gray.600","gray.300"),children:"Fee"}),e.jsx(k,{fontWeight:600,variant:"flushed",size:"sm",isReadOnly:!0,value:n&&o?P(o,n):0})]}),e.jsxs(f,{w:"50%",children:[e.jsx(x,{fontSize:"sm",mb:0,color:d("gray.600","gray.300"),children:"Total Amount"}),e.jsx(k,{fontWeight:600,variant:"flushed",size:"sm",isReadOnly:!0,value:n&&o?P(o,n):0})]})]})]})})]}),e.jsxs(ve,{children:[e.jsx(b,{colorScheme:"gray",mr:3,onClick:t,size:"sm",children:"Close"}),e.jsx(b,{colorScheme:"blue",size:"sm",onClick:()=>{Q.mutate()},isLoading:Q.isPending,children:"Add Appointment"})]})]})]}),A?e.jsx(Ee,{isOpen:A,onClose:T,doctID:n.user_id,selectedDate:l,setselectedDate:S,selectedSlot:w,setselectedSlot:L,type:o}):null,j?e.jsx(Oe,{nextFn:r=>{je(r)},isOpen:j,onClose:E}):null]})}export{rt as A};