hplx-feature-library 1.0.420 → 1.0.421
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -12289,7 +12289,7 @@ const Ja = /* @__PURE__ */ vn(Ws), Qa = (i) => {
|
|
|
12289
12289
|
L ? (await a(), S?.("Success", L?.message, "Success", 3e3), d("")) : S?.("Error", "Something went wrong please try again", "Error", 3e3);
|
|
12290
12290
|
}
|
|
12291
12291
|
} catch (L) {
|
|
12292
|
-
console.error("Error in deleting bill item", L);
|
|
12292
|
+
console.error("Error in deleting bill item", L), S?.("Error", L?.data?.message || "Something went wrong please try again", "Error", 3e3);
|
|
12293
12293
|
}
|
|
12294
12294
|
},
|
|
12295
12295
|
className: "hfl-flex-1 hfl-items-center hfl-justify-center hfl-bg-Primary-600 hfl-text-White_20 hover:hfl-bg-Primary-800"
|
|
@@ -14,7 +14,7 @@ This usually means you need to need to name your plugin hook by setting the 'plu
|
|
|
14
14
|
hfl-z-10 hfl-block hfl-w-max hfl-max-w-xs
|
|
15
15
|
hfl-translate-x-[-50%] hfl-text-left hfl-opacity-0 hfl-transition hfl-delay-1000
|
|
16
16
|
group-hover:hfl-visible group-hover:hfl-opacity-100
|
|
17
|
-
`,children:[h&&e.jsxRuntimeExports.jsxs("div",{className:"text:hfl-Gray-700 hfl-mb-3 hfl-w-[207px] hfl-rounded-lg hfl-bg-White hfl-p-3 hfl-shadow-lg",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-justify-between",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text sm",children:"Line Item Discount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Medium",type:"Text sm",children:["₹"," ",["1","2","3"].reduce((B,L)=>B+parseInt(h.bill_summary[L]?.order_item_sum_discount||"0"),0)]})]}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text sm",children:"Additional Discount"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",children:["1","2","3"].map(B=>e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-justify-between",children:[e.jsxRuntimeExports.jsxs("div",{children:[B==="1"&&"Consultations",B==="2"&&"Lab Services",B==="3"&&"Other Services"]}),"₹ ",h.bill_summary[B]?.order_discount||"0"]},B))})]}),e.jsxRuntimeExports.jsx("div",{className:"text:hfl-Gray-700 hfl-absolute hfl-bottom-2 hfl-left-1/2 hfl-h-3 hfl-w-3 hfl-translate-x-[-50%] hfl-rotate-45 hfl-bg-White"})]})]})]}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹"," - ",parseInt(h.bill_summary[1]?.order_item_sum_discount||"0")+parseInt(h.bill_summary[2]?.order_item_sum_discount||"0")+parseInt(h.bill_summary[3]?.order_item_sum_discount||"0")+parseInt(h.bill_summary[1]?.order_discount||"0")+parseInt(h.bill_summary[2]?.order_discount||"0")+parseInt(h.bill_summary[3]?.order_discount||"0")]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-inline-flex hfl-flex-1 hfl-items-center hfl-text-Gray-800 ",children:"Tax Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹"," ",parseInt(h.bill_summary[1]?.order_service_tax||"0")+parseInt(h.bill_summary[2]?.order_service_tax||"0")+parseInt(h.bill_summary[3]?.order_service_tax||"0")]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Final Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹"," ",parseInt(h.bill_summary[1]?.net_bill_amount||"0")+parseInt(h.bill_summary[2]?.net_bill_amount||"0")+parseInt(h.bill_summary[3]?.net_bill_amount||"0")]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Received Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹"," ",parseInt(h.bill_summary[1]?.order_paid_amount||"0")+parseInt(h.bill_summary[2]?.order_paid_amount||"0")+parseInt(h.bill_summary[3]?.order_paid_amount||"0")]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Refund Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹"," - ",parseInt(h.bill_summary[1]?.refund_amount||"0")+parseInt(h.bill_summary[2]?.refund_amount||"0")+parseInt(h.bill_summary[3]?.refund_amount||"0")]})]}),D&&e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px]",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Past Due Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹ ",N?.total_amount]}),e.jsxRuntimeExports.jsx("div",{className:"hx_close hfl-flex-shrink-0 hfl-cursor-pointer hfl-text-4",onClick:()=>Q()})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Total Balance"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Bold",type:"Text lg",className:"hfl-text-Gray-800",children:["₹"," ",(parseInt(h.bill_summary[1]?.balance_amount||"0")||0)+(parseInt(h.bill_summary[2]?.balance_amount||"0")||0)+(parseInt(h.bill_summary[3]?.balance_amount||"0")||0)+(D&&parseInt(N?.total_amount||"0")||0)]})]}),e.jsxRuntimeExports.jsx(Al,{isPayDue:D,rightSegment:c,pastDueData:N,showDiscount:w,showRefund:l,summaryData:h,date:d,getBillSummarydata:V,handleRightSegment:n,getPastDueAmount:g,refreshBillsList:k,deleteLastPaymemntMode:P,setDeleteLastPaymentMode:I,walletBalance:O,setRefreshWallet:W})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-px-2 hfl-pb-2",children:[e.jsxRuntimeExports.jsx(p.Ku,{"data-qa":"to-print",hierarchy:"Tertiary",size:"md",textField:"Print",disabled:!1,icon:"Left",onClick:()=>y([1,2,3],"billPrintPreview",!1),iconFile:"hx_print",className:" hfl-flex-1 hfl-items-center hfl-justify-center hfl-border hfl-border-Gray-300 hfl-bg-White hfl-text-Gray-700 hover:hfl-bg-Gray-100"}),e.jsxRuntimeExports.jsx(p.Ku,{"data-qa":"to-share",hierarchy:"Tertiary",size:"md",textField:"Share",icon:"Left",onClick:()=>y([1,2,3],"billSharePreview",!0),iconFile:"hx_share",className:" hfl-flex-1 hfl-items-center hfl-justify-center hfl-border hfl-border-Gray-300 hfl-bg-White hfl-text-Gray-700 hover:hfl-bg-Gray-100"})]})]})},oa=a=>{const{editedTableData:d,handleRightSegment:c,getBillSummarydata:n,order_date:y,editRowId:w,setTableData:l,refreshBillsList:T,handleRevertEdit:N}=a,{patientIDs:h,showToast:V,doctorListArr:g,billPreferences:k,formattedService:O,ppEventProps:W,variable:D}=_.useContext(It),[A,P]=_.useState(),I={bill_item_details:{doctor_name:D.window_var.doc_name_for_seg,referrer_doctor_role_id:D.window_var.doctor_role_id_for_seg,lab_owner_name:"",lab_owner_id:"",appointment_details:{appnt_id:"",doctor_role_id:"",appnt_date:"",appnt_time:"",appnt_duration:0,appnt_status:0},appnt_doctor_role_id:""}},[R,Q]=_.useState(()=>({...d,...I})),B=(K,ue)=>{let ce={};K==="labowner"?ce={lab_owner_name:ue.labOwnerName,lab_owner_id:ue.LabOwnerDocRoleID||""}:ce={doctor_name:ue.docName,referrer_doctor_role_id:ue.docRoleID},Q(X=>({...X,bill_item_details:{...X.bill_item_details,...ce}}))},L=async(K="")=>{try{const ue=await Nn(K,D);P(ue)}catch(ue){console.error("Error in getReferalDoctorList API Call:",ue)}};_.useEffect(()=>{L()},[]);const z=async()=>{if(d?.order_item_id)try{const K=await Cl(d?.order_item_id,h.patientRoleID,D);Q(ue=>{const ce=K.data;return{...ue,...sn,...ce,service_category:St[2],service_category_id:"3",order_item_service_tax_percentage:O?.[+ce.service_id]?.service_tax||0,bill_item_details:{...ue.bill_item_details,...ce.bill_item_details,appnt_doctor_role_id:"",referrer_doctor_role_id:""}}})}catch(K){console.error("Error fetching bill item data:",K)}};return _.useEffect(()=>{d&&Q({...R,...d})},[d]),_.useEffect(()=>{z()},[R.order_item_id]),e.jsxRuntimeExports.jsxs("div",{className:"hfl-relative hfl-h-full",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-h-8 hfl-shrink-0 hfl-items-center hfl-justify-between hfl-gap-2 hfl-border-b-1 hfl-border-b-Gray-200 hfl-px-2",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text md",className:"hfl-max-w-[300px] hfl-truncate",children:R?.service_name}),e.jsxRuntimeExports.jsx("div",{className:"hx_close hfl-flex-shrink-0 hfl-cursor-pointer hfl-text-4",onClick:()=>{c(),N()}})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-gap-[14px] hfl-px-3 hfl-py-4",children:[k?.billing?.enable_add_service_owner!=0&&e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(p.tj,{label:"Doctor Name",labelSize:"Text sm",labelColor:"hfl-text-Gray-800",input1value:"Dr.",input2value:R.bill_item_details.doctor_name,end_icon:"hx_down hfl-bg-White_20",inputProps:{disabled:!0},suffixInputProps:{placeholder:"Doctor Name"},className:"hfl-w-12 hfl-flex-none hfl-text-ellipsis hfl-bg-Gray-50 hfl-text-Gray-500",suffixClassName:" hfl-w-[220px] hfl-text-ellipsis hfl-bg-White_20",suffixDropdownClassName:"hfl-ml-12",widthSufixDrpdwn:"hfl-w-[250px]",suffixOptions:g?.doctor_list?.map(K=>({label:K.doctor_name,value:K.doctor_name,appnt_doctor_role_id:K.doctor_identifier})),handleSuffixValChange:K=>{B("",{docName:K,docRoleID:""})},onSuffixDropdownClick:K=>{B("",{docName:K.label,docRoleID:K.appnt_doctor_role_id})}})}),k?.billing?.enable_add_service_owner!=0&&e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(p.tj,{label:"Lab Owner (Referred By)",labelSize:"Text sm",labelColor:"hfl-text-Gray-800",end_icon:"hx_down hfl-bg-White_20",input2value:R.bill_item_details.lab_owner_name,inputProps:{disabled:!0},suffixInputProps:{placeholder:"Lab Owner (Referred By)"},className:"hfl-hidden hfl-w-12 hfl-text-ellipsis hfl-bg-Gray-50 hfl-text-Gray-500",suffixClassName:" hfl-border-l-0 hfl-w-[270px] hfl-text-ellipsis hfl-bg-White_20",widthSufixDrpdwn:"hfl-w-[305px]",suffixOptions:A?.referrals?.map(K=>({label:K.referralName,value:K.referralName,referralId:K.referralId})),onlySuffixDropdownItemsAllowed:!1,handleSuffixValChange:K=>{L(K),B("labowner",{labOwnerName:K,LabOwnerDocRoleID:""})},onSuffixDropdownClick:K=>{B("labowner",{labOwnerName:K.label,LabOwnerDocRoleID:K.referralId})}})}),e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Primary",size:"lg",textField:"Update",className:"hfl-flex hfl-h-9 hfl-w-full hfl-shrink-0 hfl-items-center hfl-justify-center hfl-gap-1 hfl-self-stretch hfl-rounded-md hfl-p-3",onClick:async()=>{const K=await Pl(R,V,h.patientRoleID,Ie.dayjs(y).format("YYYY-MM-DD"),W,St[2],D);R.bill_item_details.lab_owner_name&&An(R.bill_item_details.lab_owner_name,h?.patientRoleID||"",D),K&&(l(ue=>ue.map((ce,X)=>w==X.toString()?{...ce,order_item_id:K.order_item_id||R.order_item_id}:ce)),(K.order_item_id||R.order_item_id)&&(n(),c(),T(y)))}})})]}),e.jsxRuntimeExports.jsx("div",{className:"hfl-absolute hfl-bottom-4 hfl-left-2 hfl-w-full",children:e.jsxRuntimeExports.jsx(p.Ku,{className:"hfl-h-8 hfl-shrink-0 hfl-border-l-Gray-200 hfl-bg-White_20 hfl-text-Gray-500 hfl-shadow-md hover:hfl-bg-Gray-100",hierarchy:"Tertiary",size:"md",textField:"Go Back",icon:"Left",iconFile:"hx_arrow-left hfl-text-Gray-500",onClick:()=>{c(),N()}})})]})},ua="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='50'%20height='49'%20viewBox='0%200%2050%2049'%20fill='none'%3e%3cg%20opacity='0.3'%20clip-path='url(%23clip0_916_82588)'%3e%3cpath%20d='M48.2399%2011.218V38.5495C48.2399%2039.4022%2047.9011%2040.2201%2047.2981%2040.8231C46.6951%2041.4261%2045.8772%2041.7649%2045.0244%2041.7649H4.83118C3.97839%2041.7649%203.16052%2041.4261%202.55751%2040.8231C1.95449%2040.2201%201.61572%2039.4022%201.61572%2038.5495V11.218L2.41959%2010.4142H47.436L48.2399%2011.218Z'%20fill='%23F9FAFB'/%3e%3cpath%20d='M48.2399%208.00245V11.2179H1.61572V8.00245C1.61572%207.14965%201.95449%206.33179%202.55751%205.72877C3.16052%205.12576%203.97839%204.78699%204.83118%204.78699H45.0244C45.8772%204.78699%2046.6951%205.12576%2047.2981%205.72877C47.9011%206.33179%2048.2399%207.14965%2048.2399%208.00245Z'%20fill='%23D0D5DD'/%3e%3cpath%20d='M10.4572%203.17951C10.4572%202.29158%209.73735%201.57178%208.84943%201.57178C7.9615%201.57178%207.2417%202.29158%207.2417%203.17951V6.39497C7.2417%207.28289%207.9615%208.0027%208.84943%208.0027C9.73735%208.0027%2010.4572%207.28289%2010.4572%206.39497V3.17951Z'%20fill='%23F9FAFB'/%3e%3cpath%20d='M18.4967%203.17951C18.4967%202.29158%2017.7769%201.57178%2016.889%201.57178C16.0011%201.57178%2015.2812%202.29158%2015.2812%203.17951V6.39497C15.2812%207.28289%2016.0011%208.0027%2016.889%208.0027C17.7769%208.0027%2018.4967%207.28289%2018.4967%206.39497V3.17951Z'%20fill='%23F9FAFB'/%3e%3cpath%20d='M26.5348%203.17951C26.5348%202.29158%2025.815%201.57178%2024.9271%201.57178C24.0391%201.57178%2023.3193%202.29158%2023.3193%203.17951V6.39497C23.3193%207.28289%2024.0391%208.0027%2024.9271%208.0027C25.815%208.0027%2026.5348%207.28289%2026.5348%206.39497V3.17951Z'%20fill='%23F9FAFB'/%3e%3cpath%20d='M34.5734%203.17951C34.5734%202.29158%2033.8536%201.57178%2032.9656%201.57178C32.0777%201.57178%2031.3579%202.29158%2031.3579%203.17951V6.39497C31.3579%207.28289%2032.0777%208.0027%2032.9656%208.0027C33.8536%208.0027%2034.5734%207.28289%2034.5734%206.39497V3.17951Z'%20fill='%23F9FAFB'/%3e%3cpath%20d='M42.6124%203.17951C42.6124%202.29158%2041.8926%201.57178%2041.0047%201.57178C40.1168%201.57178%2039.397%202.29158%2039.397%203.17951V6.39497C39.397%207.28289%2040.1168%208.0027%2041.0047%208.0027C41.8926%208.0027%2042.6124%207.28289%2042.6124%206.39497V3.17951Z'%20fill='%23F9FAFB'/%3e%3cpath%20d='M24.928%2034.5299C29.8115%2034.5299%2033.7705%2030.571%2033.7705%2025.6874C33.7705%2020.8038%2029.8115%2016.8449%2024.928%2016.8449C20.0444%2016.8449%2016.0854%2020.8038%2016.0854%2025.6874C16.0854%2030.571%2020.0444%2034.5299%2024.928%2034.5299Z'%20fill='%23D0D5DD'/%3e%3cpath%20d='M29.7505%2024.0798H26.5351V20.8644C26.5351%2020.6512%2026.4504%2020.4467%2026.2996%2020.2959C26.1489%2020.1452%2025.9444%2020.0605%2025.7312%2020.0605H24.1235C23.9103%2020.0605%2023.7058%2020.1452%2023.5551%2020.2959C23.4043%2020.4467%2023.3196%2020.6512%2023.3196%2020.8644V24.0798H20.1042C19.891%2024.0798%2019.6865%2024.1645%2019.5357%2024.3153C19.385%2024.466%2019.3003%2024.6705%2019.3003%2024.8837V26.4914C19.3003%2026.7046%2019.385%2026.9091%2019.5357%2027.0598C19.6865%2027.2106%2019.891%2027.2953%2020.1042%2027.2953H23.3196V30.5107C23.3196%2030.7239%2023.4043%2030.9284%2023.5551%2031.0791C23.7058%2031.2299%2023.9103%2031.3146%2024.1235%2031.3146H25.7312C25.9444%2031.3146%2026.1489%2031.2299%2026.2996%2031.0791C26.4504%2030.9284%2026.5351%2030.7239%2026.5351%2030.5107V27.2953H29.7505C29.9637%2027.2953%2030.1682%2027.2106%2030.319%2027.0598C30.4697%2026.9091%2030.5544%2026.7046%2030.5544%2026.4914V24.8837C30.5544%2024.6705%2030.4697%2024.466%2030.319%2024.3153C30.1682%2024.1645%2029.9637%2024.0798%2029.7505%2024.0798Z'%20fill='white'/%3e%3cpath%20d='M13.6731%2048.1958C15.8929%2048.1958%2017.6925%2046.3963%2017.6925%2044.1765C17.6925%2041.9567%2015.8929%2040.1572%2013.6731%2040.1572C11.4533%2040.1572%209.65381%2041.9567%209.65381%2044.1765C9.65381%2046.3963%2011.4533%2048.1958%2013.6731%2048.1958Z'%20fill='%2398A2B3'/%3e%3cpath%20d='M45.0241%203.9834H43.4164V3.17954C43.4164%202.53994%2043.1623%201.92655%2042.71%201.47428C42.2578%201.02202%2041.6444%200.767944%2041.0048%200.767944C40.3652%200.767944%2039.7518%201.02202%2039.2995%201.47428C38.8472%201.92655%2038.5932%202.53994%2038.5932%203.17954V3.9834H35.3777V3.17954C35.3777%202.53994%2035.1236%201.92655%2034.6714%201.47428C34.2191%201.02202%2033.6057%200.767944%2032.9661%200.767944C32.3265%200.767944%2031.7131%201.02202%2031.2609%201.47428C30.8086%201.92655%2030.5545%202.53994%2030.5545%203.17954V3.9834H27.3391V3.17954C27.3391%202.53994%2027.085%201.92655%2026.6327%201.47428C26.1805%201.02202%2025.5671%200.767944%2024.9275%200.767944C24.2879%200.767944%2023.6745%201.02202%2023.2222%201.47428C22.7699%201.92655%2022.5159%202.53994%2022.5159%203.17954V3.9834H19.3004V3.17954C19.3004%202.53994%2019.0463%201.92655%2018.5941%201.47428C18.1418%201.02202%2017.5284%200.767944%2016.8888%200.767944C16.2492%200.767944%2015.6358%201.02202%2015.1836%201.47428C14.7313%201.92655%2014.4772%202.53994%2014.4772%203.17954V3.9834H11.2618V3.17954C11.2618%202.53994%2011.0077%201.92655%2010.5554%201.47428C10.1032%201.02202%209.48977%200.767944%208.85017%200.767944C8.21058%200.767944%207.59718%201.02202%207.14492%201.47428C6.69265%201.92655%206.43858%202.53994%206.43858%203.17954V3.9834H4.83085C3.76525%203.98468%202.74366%204.40855%201.99017%205.16205C1.23667%205.91554%200.8128%206.93713%200.811523%208.00273L0.811523%2038.5496C0.8128%2039.6152%201.23667%2040.6368%201.99017%2041.3903C2.74366%2042.1438%203.76525%2042.5676%204.83085%2042.5689H9.13152C8.80047%2043.5017%208.7644%2044.5137%209.02822%2045.4677C9.29203%2046.4217%209.84294%2047.2714%2010.6062%2047.9015C11.3695%2048.5317%2012.3081%2048.9117%2013.2948%2048.9902C14.2814%2049.0686%2015.2683%2048.8416%2016.1216%2048.3399C16.9748%2047.8382%2017.653%2047.0862%2018.0642%2046.1859C18.4754%2045.2856%2018.5996%2044.2805%2018.4201%2043.3072C18.2405%2042.3338%2017.7659%2041.4393%2017.0605%2040.7449C16.3552%2040.0506%2015.4533%2039.59%2014.4772%2039.4258V31.3148C14.4772%2030.6752%2014.2231%2030.0618%2013.7709%2029.6096C13.3186%2029.1573%2012.7052%2028.9032%2012.0656%2028.9032H10.8598C10.54%2028.9032%2010.2333%2028.7762%2010.0072%2028.55C9.78107%2028.3239%209.65404%2028.0172%209.65404%2027.6974C9.65404%2027.3776%209.78107%2027.0709%2010.0072%2026.8448C10.2333%2026.6187%2010.54%2026.4916%2010.8598%2026.4916H15.3221C15.5196%2028.9036%2016.6173%2031.153%2018.397%2032.793C20.1767%2034.4329%2022.5082%2035.3433%2024.9283%2035.3433C27.3483%2035.3433%2029.6799%2034.4329%2031.4596%2032.793C33.2393%2031.153%2034.3369%2028.9036%2034.5345%2026.4916H35.3777C35.5909%2026.4916%2035.7954%2026.5763%2035.9461%2026.7271C36.0969%2026.8778%2036.1816%2027.0823%2036.1816%2027.2955V32.5206C36.1816%2033.2668%2036.478%2033.9824%2037.0056%2034.5101C37.5333%2035.0377%2038.2489%2035.3341%2038.9951%2035.3341C39.7413%2035.3341%2040.4569%2035.0377%2040.9846%2034.5101C41.5122%2033.9824%2041.8086%2033.2668%2041.8086%2032.5206V24.8115C42.9313%2024.6208%2043.9503%2024.0394%2044.6858%2023.1701C45.4213%2022.3007%2045.8258%2021.1994%2045.8279%2020.0607V15.2375C45.8279%2014.8111%2045.6586%2014.4022%2045.3571%2014.1007C45.0555%2013.7992%2044.6466%2013.6298%2044.2202%2013.6298H43.4164C43.2032%2013.6298%2042.9987%2013.7145%2042.8479%2013.8652C42.6972%2014.016%2042.6125%2014.2204%2042.6125%2014.4336C42.6125%2014.6468%2042.6972%2014.8513%2042.8479%2015.0021C42.9987%2015.1528%2043.2032%2015.2375%2043.4164%2015.2375H44.2202V20.0607C44.2202%2020.9135%2043.8814%2021.7314%2043.2784%2022.3344C42.6754%2022.9374%2041.8576%2023.2762%2041.0048%2023.2762C40.152%2023.2762%2039.3341%2022.9374%2038.7311%2022.3344C38.1281%2021.7314%2037.7893%2020.9135%2037.7893%2020.0607V15.2375H38.5932C38.8064%2015.2375%2039.0108%2015.1528%2039.1616%2015.0021C39.3123%2014.8513%2039.397%2014.6468%2039.397%2014.4336C39.397%2014.2204%2039.3123%2014.016%2039.1616%2013.8652C39.0108%2013.7145%2038.8064%2013.6298%2038.5932%2013.6298H37.7893C37.3629%2013.6298%2036.954%2013.7992%2036.6525%2014.1007C36.351%2014.4022%2036.1816%2014.8111%2036.1816%2015.2375V20.0607C36.1837%2021.1994%2036.5882%2022.3007%2037.3237%2023.1701C38.0592%2024.0394%2039.0783%2024.6208%2040.2009%2024.8115V32.5206C40.2009%2032.8404%2040.0739%2033.1471%2039.8477%2033.3732C39.6216%2033.5994%2039.3149%2033.7264%2038.9951%2033.7264C38.6753%2033.7264%2038.3686%2033.5994%2038.1425%2033.3732C37.9163%2033.1471%2037.7893%2032.8404%2037.7893%2032.5206V27.2955C37.7893%2026.6559%2037.5352%2026.0425%2037.083%2025.5902C36.6307%2025.138%2036.0173%2024.8839%2035.3777%2024.8839H34.5328C34.3353%2022.4719%2033.2377%2020.2225%2031.458%2018.5825C29.6782%2016.9426%2027.3467%2016.0322%2024.9267%2016.0322C22.5066%2016.0322%2020.1751%2016.9426%2018.3954%2018.5825C16.6157%2020.2225%2015.518%2022.4719%2015.3205%2024.8839H10.8598C10.1136%2024.8839%209.39801%2025.1803%208.87037%2025.708C8.34273%2026.2356%208.04631%2026.9512%208.04631%2027.6974C8.04631%2028.4436%208.34273%2029.1592%208.87037%2029.6869C9.39801%2030.2145%2010.1136%2030.5109%2010.8598%2030.5109H12.0656C12.2788%2030.5109%2012.4833%2030.5956%2012.634%2030.7464C12.7848%2030.8971%2012.8695%2031.1016%2012.8695%2031.3148V39.4258C11.7956%2039.6088%2010.8152%2040.15%2010.0881%2040.9612H4.83085C4.19125%2040.9612%203.57785%2040.7071%203.12559%2040.2548C2.67333%2039.8026%202.41925%2039.1892%202.41925%2038.5496V12.0221H47.4357V38.5496C47.4357%2039.1892%2047.1816%2039.8026%2046.7293%2040.2548C46.2771%2040.7071%2045.6637%2040.9612%2045.0241%2040.9612H20.1043C19.8911%2040.9612%2019.6866%2041.0459%2019.5359%2041.1966C19.3851%2041.3474%2019.3004%2041.5519%2019.3004%2041.7651C19.3004%2041.9782%2019.3851%2042.1827%2019.5359%2042.3335C19.6866%2042.4842%2019.8911%2042.5689%2020.1043%2042.5689H45.0241C46.0897%2042.5676%2047.1113%2042.1438%2047.8648%2041.3903C48.6183%2040.6368%2049.0421%2039.6152%2049.0434%2038.5496V8.00273C49.0421%206.93713%2048.6183%205.91554%2047.8648%205.16205C47.1113%204.40855%2046.0897%203.98468%2045.0241%203.9834ZM24.9275%2017.6491C26.5174%2017.6491%2028.0715%2018.1206%2029.3935%2019.0039C30.7154%2019.8872%2031.7458%2021.1426%2032.3542%2022.6115C32.9626%2024.0804%2033.1218%2025.6967%2032.8117%2027.256C32.5015%2028.8154%2031.7359%2030.2477%2030.6116%2031.3719C29.4874%2032.4962%2028.0551%2033.2618%2026.4957%2033.5719C24.9364%2033.8821%2023.3201%2033.7229%2021.8512%2033.1145C20.3823%2032.5061%2019.1269%2031.4757%2018.2436%2030.1538C17.3603%2028.8318%2016.8888%2027.2776%2016.8888%2025.6878C16.8912%2023.5565%2017.7388%2021.5132%2019.2459%2020.0062C20.7529%2018.4991%2022.7962%2017.6514%2024.9275%2017.6491ZM13.6734%2040.9612C14.3093%2040.9612%2014.931%2041.1498%2015.4598%2041.5031C15.9886%2041.8564%2016.4007%2042.3586%2016.6441%2042.9461C16.8874%2043.5337%2016.9511%2044.1802%2016.827%2044.804C16.703%2045.4277%2016.3967%2046.0006%2015.947%2046.4503C15.4973%2046.9%2014.9244%2047.2063%2014.3007%2047.3303C13.6769%2047.4544%2013.0304%2047.3907%2012.4429%2047.1473C11.8553%2046.904%2011.3531%2046.4918%2010.9998%2045.9631C10.6465%2045.4343%2010.4579%2044.8126%2010.4579%2044.1766C10.4579%2043.3239%2010.7967%2042.506%2011.3997%2041.903C12.0027%2041.3%2012.8206%2040.9612%2013.6734%2040.9612ZM40.2009%203.17954C40.2009%202.96634%2040.2856%202.76187%2040.4363%202.61112C40.5871%202.46037%2040.7916%202.37567%2041.0048%202.37567C41.218%202.37567%2041.4224%202.46037%2041.5732%202.61112C41.7239%202.76187%2041.8086%202.96634%2041.8086%203.17954V6.395C41.8086%206.6082%2041.7239%206.81266%2041.5732%206.96342C41.4224%207.11417%2041.218%207.19886%2041.0048%207.19886C40.7916%207.19886%2040.5871%207.11417%2040.4363%206.96342C40.2856%206.81266%2040.2009%206.6082%2040.2009%206.395V3.17954ZM32.1622%203.17954C32.1622%202.96634%2032.2469%202.76187%2032.3977%202.61112C32.5484%202.46037%2032.7529%202.37567%2032.9661%202.37567C33.1793%202.37567%2033.3838%202.46037%2033.5345%202.61112C33.6853%202.76187%2033.77%202.96634%2033.77%203.17954V6.395C33.77%206.6082%2033.6853%206.81266%2033.5345%206.96342C33.3838%207.11417%2033.1793%207.19886%2032.9661%207.19886C32.7529%207.19886%2032.5484%207.11417%2032.3977%206.96342C32.2469%206.81266%2032.1622%206.6082%2032.1622%206.395V3.17954ZM24.1236%203.17954C24.1236%202.96634%2024.2083%202.76187%2024.359%202.61112C24.5098%202.46037%2024.7143%202.37567%2024.9275%202.37567C25.1407%202.37567%2025.3451%202.46037%2025.4959%202.61112C25.6466%202.76187%2025.7313%202.96634%2025.7313%203.17954V6.395C25.7313%206.6082%2025.6466%206.81266%2025.4959%206.96342C25.3451%207.11417%2025.1407%207.19886%2024.9275%207.19886C24.7143%207.19886%2024.5098%207.11417%2024.359%206.96342C24.2083%206.81266%2024.1236%206.6082%2024.1236%206.395V3.17954ZM16.085%203.17954C16.085%202.96634%2016.1696%202.76187%2016.3204%202.61112C16.4712%202.46037%2016.6756%202.37567%2016.8888%202.37567C17.102%202.37567%2017.3065%202.46037%2017.4572%202.61112C17.608%202.76187%2017.6927%202.96634%2017.6927%203.17954V6.395C17.6927%206.6082%2017.608%206.81266%2017.4572%206.96342C17.3065%207.11417%2017.102%207.19886%2016.8888%207.19886C16.6756%207.19886%2016.4712%207.11417%2016.3204%206.96342C16.1696%206.81266%2016.085%206.6082%2016.085%206.395V3.17954ZM8.04631%203.17954C8.04631%202.96634%208.131%202.76187%208.28175%202.61112C8.43251%202.46037%208.63697%202.37567%208.85017%202.37567C9.06337%202.37567%209.26783%202.46037%209.41859%202.61112C9.56934%202.76187%209.65404%202.96634%209.65404%203.17954V6.395C9.65404%206.6082%209.56934%206.81266%209.41859%206.96342C9.26783%207.11417%209.06337%207.19886%208.85017%207.19886C8.63697%207.19886%208.43251%207.11417%208.28175%206.96342C8.131%206.81266%208.04631%206.6082%208.04631%206.395V3.17954ZM2.41925%2010.4143V8.00273C2.41925%207.36313%202.67333%206.74973%203.12559%206.29747C3.57785%205.84521%204.19125%205.59113%204.83085%205.59113H6.43858V6.395C6.43858%207.03459%206.69265%207.64799%207.14492%208.10025C7.59718%208.55252%208.21058%208.80659%208.85017%208.80659C9.48977%208.80659%2010.1032%208.55252%2010.5554%208.10025C11.0077%207.64799%2011.2618%207.03459%2011.2618%206.395V5.59113H14.4772V6.395C14.4772%207.03459%2014.7313%207.64799%2015.1836%208.10025C15.6358%208.55252%2016.2492%208.80659%2016.8888%208.80659C17.5284%208.80659%2018.1418%208.55252%2018.5941%208.10025C19.0463%207.64799%2019.3004%207.03459%2019.3004%206.395V5.59113H22.5159V6.395C22.5159%207.03459%2022.7699%207.64799%2023.2222%208.10025C23.6745%208.55252%2024.2879%208.80659%2024.9275%208.80659C25.5671%208.80659%2026.1805%208.55252%2026.6327%208.10025C27.085%207.64799%2027.3391%207.03459%2027.3391%206.395V5.59113H30.5545V6.395C30.5545%207.03459%2030.8086%207.64799%2031.2609%208.10025C31.7131%208.55252%2032.3265%208.80659%2032.9661%208.80659C33.6057%208.80659%2034.2191%208.55252%2034.6714%208.10025C35.1236%207.64799%2035.3777%207.03459%2035.3777%206.395V5.59113H38.5932V6.395C38.5932%207.03459%2038.8472%207.64799%2039.2995%208.10025C39.7518%208.55252%2040.3652%208.80659%2041.0048%208.80659C41.6444%208.80659%2042.2578%208.55252%2042.71%208.10025C43.1623%207.64799%2043.4164%207.03459%2043.4164%206.395V5.59113H45.0241C45.6637%205.59113%2046.2771%205.84521%2046.7293%206.29747C47.1816%206.74973%2047.4357%207.36313%2047.4357%208.00273V10.4143H2.41925Z'%20fill='%2398A2B3'/%3e%3cpath%20d='M22.5154%2028.0995V30.5111C22.5154%2030.9375%2022.6848%2031.3465%2022.9863%2031.648C23.2878%2031.9495%2023.6968%2032.1189%2024.1231%2032.1189H25.7309C26.1573%2032.1189%2026.5662%2031.9495%2026.8677%2031.648C27.1692%2031.3465%2027.3386%2030.9375%2027.3386%2030.5111V28.0995H29.7502C30.1766%2028.0995%2030.5855%2027.9301%2030.887%2027.6286C31.1885%2027.3271%2031.3579%2026.9182%2031.3579%2026.4918V24.8841C31.3579%2024.4577%2031.1885%2024.0487%2030.887%2023.7472C30.5855%2023.4457%2030.1766%2023.2763%2029.7502%2023.2763H27.3386V20.8647C27.3386%2020.4384%2027.1692%2020.0294%2026.8677%2019.7279C26.5662%2019.4264%2026.1573%2019.257%2025.7309%2019.257H24.1231C23.6968%2019.257%2023.2878%2019.4264%2022.9863%2019.7279C22.6848%2020.0294%2022.5154%2020.4384%2022.5154%2020.8647V23.2763H20.1038C19.6774%2023.2763%2019.2685%2023.4457%2018.967%2023.7472C18.6655%2024.0487%2018.4961%2024.4577%2018.4961%2024.8841V26.4918C18.4961%2026.9182%2018.6655%2027.3271%2018.967%2027.6286C19.2685%2027.9301%2019.6774%2028.0995%2020.1038%2028.0995H22.5154ZM20.1038%2024.8841H23.3193C23.5325%2024.8841%2023.7369%2024.7994%2023.8877%2024.6486C24.0385%2024.4979%2024.1231%2024.2934%2024.1231%2024.0802V20.8647H25.7309V24.0802C25.7309%2024.2934%2025.8156%2024.4979%2025.9663%2024.6486C26.1171%2024.7994%2026.3215%2024.8841%2026.5347%2024.8841H29.7502V26.4918H26.5347C26.3215%2026.4918%2026.1171%2026.5765%2025.9663%2026.7272C25.8156%2026.878%2025.7309%2027.0825%2025.7309%2027.2957V30.5111H24.1231V27.2957C24.1231%2027.0825%2024.0385%2026.878%2023.8877%2026.7272C23.7369%2026.5765%2023.5325%2026.4918%2023.3193%2026.4918H20.1038V24.8841Z'%20fill='%2398A2B3'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_916_82588'%3e%3crect%20width='48.2319'%20height='48.2319'%20fill='white'%20transform='translate(0.811523%200.767883)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",ca=a=>{const{showToast:d,patientIDs:c,doctorListArr:n,patientDetails:y,billPreferences:w,formattedService:l,ppEventProps:T,variable:N}=_.useContext(It),{bill_date:h,handleRightSegment:V,getBillSummarydata:g,editedTableData:k,setTableData:O,editRowId:W,refreshBillsList:D,handleRevertEdit:A,checkAppointmentForBilling:P}=a,[I,R]=_.useState([]),Q=new Date().toLocaleString("en-US",{hour:"numeric",minute:"numeric",hour12:!0}),B=n?.doctor_list?.length===1?n?.doctor_list[0]:{doctor_name:"",doctor_identifier:""},L={...ql,appnt_doctor_name:window.role_id=="11"?window.doc_name_for_seg:B?.doctor_name,appnt_doctor_role_id:window.role_id=="11"?window.doctor_role_id_for_seg:B?.doctor_identifier,appnt_duration:+w?.print?.bill?.appnt_minute_slab,appnt_time_time:Q?.split(" ")[0]||"",appnt_time_format:Q?.split(" ")[1]||"",total_price:"",appnt_date:Ie.dayjs().format("YYYY-MM-DD"),appnt_service_id:k?.service_id||"",appnt_service_name:k?.service_name||"",...k},[z,K]=_.useState(L),[ue,ce]=_.useState(!1),X=async()=>{if(k?.order_item_id)try{const $=await Cl(k.order_item_id,c.patientRoleID,N),{created_on:fe,order_item_service_tax:H,service_id:De,bill_item_details:Me,order_item_id:Le,item_quantity:xt,order_unit_item_price:ht,order_item_price:at,order_item_discount:We,service_name:it}=$.data,{appointment_details:Pt,doctor_name:gt}=Me,{appnt_id:At,appnt_date:Gt=Ie.dayjs().format("YYYY-MM-DD"),appnt_time:G,appnt_status:Te,appnt_duration:Ze,doctor_role_id:se}=Pt,J=new Date("1970-01-01T"+G+"Z").toLocaleTimeString("en-US",{timeZone:"UTC",hour12:!0,hour:"numeric",minute:"numeric"}),U={appnt_time_time:"",appnt_time_format:""};J&&J!=="Invalid Date"&&(U.appnt_time_time=J?.split(" ")[0],U.appnt_time_format=J?.split(" ")[1]),K(ie=>({...ie,appnt_id:At,patient_role_id:c.patientRoleID,appnt_doctor_role_id:se,appnt_service_id:De,appnt_date:Gt,appnt_time:G,appnt_status:Te,appnt_duration:Ze,appnt_doctor_name:gt,appnt_service_name:it,appnt_mode:"inperson",order_item_id:Le,item_quantity:xt,order_unit_item_price:ht,order_item_price:at,order_item_discount:We,order_item_service_tax:""+Math.floor(+H),order_item_service_tax_percentage:l[+De]?.service_tax||0,total_price:"",appnt_created_on:fe,order_item_created_on:fe,...U}))}catch($){K(L),console.error("Error fetching bill item data:",$)}};_.useEffect(()=>{k&&K({...z,...k})},[k]),_.useEffect(()=>{X()},[z.order_item_id]);const[ee,ve]=_.useState(!1),de=($,fe)=>{K(H=>({...H,[$]:fe}))},Ue=async()=>{try{const $=await hn(k.service_id,Ie.dayjs(h).format("YYYY-MM-DD"),c.patientRoleID,N);if($?.appointments?.length)for(const fe of $.appointments){const H=new Date("1970-01-01T"+fe.appnt_time+"Z").toLocaleTimeString("en-US",{timeZone:"UTC",hour12:!0,hour:"numeric",minute:"numeric"});H&&H!=="Invalid Date"&&(fe.appnt_time_time=H?.split(" ")[0],fe.appnt_time_format=H?.split(" ")[1])}R($?.appointments)}catch{console.log("error in getAppointmentsList API Call")}};_.useEffect(()=>{Ue()},[k?.service_id]);const pe=z.appnt_date&&Ie.dayjs(z.appnt_date).format("YYYY-MM-DD")<Ie.dayjs().format("YYYY-MM-DD");return e.jsxRuntimeExports.jsxs("div",{className:"hfl-relative hfl-h-full",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-h-8 hfl-w-[340px] hfl-shrink-0 hfl-items-center hfl-justify-between hfl-gap-2 hfl-border-b-1 hfl-border-b-Gray-200 hfl-px-2",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text md",className:"hfl-truncate hfl-capitalize",title:k?.service_name||"",children:k?.service_name||""}),e.jsxRuntimeExports.jsx("div",{className:"hx_close hfl-flex-shrink-0 hfl-cursor-pointer hfl-text-4",onClick:()=>{V(),A()}})]}),I.length>0&&!ee&&e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-items-center hfl-gap-2.5 hfl-px-[13px] hfl-py-3",children:[I.map(($,fe)=>e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-full hfl-shrink-0 hfl-flex-col hfl-items-start hfl-gap-[5px] hfl-rounded-md hfl-border-Gray-200 hfl-bg-White_20 hfl-px-3 hfl-py-2 hfl-shadow-md hover:hfl-bg-Gray-100",onClick:()=>{ve(!0),K(H=>({...H,...$}))},children:[e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",children:["Consultation with ",$.appnt_doctor_name]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-gap-3",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text sm",children:`${$.appnt_time_time} ${$.appnt_time_format}`}),e.jsxRuntimeExports.jsx("div",{className:"hfl-h-[11px] hfl-w-[1px] hfl-bg-Gray-200"}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex",children:[e.jsxRuntimeExports.jsx("div",{className:"hx_inperson hfl-text-3"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",children:"In-Person"})]})]})]},fe)),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Secondary-Grey",size:"md",textField:"Create New Appointment",disabled:Ie.dayjs(h).format("YYYY-MM-DD")!==Ie.dayjs().format("YYYY-MM-DD"),className:"hfl-h-10 hfl-w-full hfl-justify-center hfl-bg-White_20 hfl-text-[13px] hover:hfl-bg-Gray-100",onClick:()=>{ve(!0),K(L)}})]}),(Ie.dayjs(h).format("YYYY-MM-DD")===Ie.dayjs().format("YYYY-MM-DD")&&I.length==0||ee)&&e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-full hfl-flex-col hfl-gap-4 hfl-px-3 hfl-py-4",children:[e.jsxRuntimeExports.jsx(p.tj,{label:"Doctor Name",labelSize:"Text sm",labelColor:"hfl-text-Gray-800",input1value:"Dr.",input2value:z.appnt_doctor_name,end_icon:"hx_down hfl-bg-White_20",inputProps:{disabled:!0},suffixInputProps:{placeholder:"Doctor Name"},className:"hfl-w-12 hfl-flex-none hfl-text-ellipsis hfl-bg-Gray-50 hfl-text-Gray-500",suffixClassName:`hfl-w-[220px] hfl-text-ellipsis hfl-bg-White_20 ${pe?" hfl-pointer-events-none":""}`,suffixDropdownClassName:"hfl-ml-12",widthSufixDrpdwn:"hfl-w-[250px]",suffixOptions:n?.doctor_list?.map($=>({label:$.doctor_name,value:$.doctor_name,appnt_doctor_role_id:$.doctor_identifier})),handleSuffixValChange:$=>{de("appnt_doctor_name",$),de("appnt_doctor_role_id","")},onSuffixDropdownClick:$=>{de("appnt_doctor_name",$.label),de("appnt_doctor_role_id",$.appnt_doctor_role_id)}}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-gap-1.5",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text sm",children:"Date & Time of Appointment"}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-gap-2",children:[pe?e.jsxRuntimeExports.jsx(p.Si,{className:"!hfl-h-[40px]",width:"120px",start_icon:"hx_calendar",inputProps:{value:z.appnt_date,disabled:!0}}):e.jsxRuntimeExports.jsx(p.ZC,{placeholder:"Today",width:"120px",height:"!hfl-h-[40px]",selectDate:new Date(Ie.dayjs(z.appnt_date).format("DD-MMM-YYYY")),dateVar:$=>{de("appnt_date",Ie.dayjs($).format("YYYY-MM-DD"))},isborderRequired:!0,minDate:new Date}),e.jsxRuntimeExports.jsx(p.tj,{className:` hfl-w-20 ${pe?" hfl-pointer-events-none":""}`,suffixClassName:` hfl-w-10 ${pe?" hfl-pointer-events-none":""}`,suffixDropdownClassName:"hfl-ml-[80px]",input1value:z?.appnt_time_time||"",input2value:z?.appnt_time_format||"",end_icon:"hx_down",inputProps:{placeholder:"10:00",onBlur:$=>{de("appnt_time_time",$.target.value)}},onlySuffixDropdownItemsAllowed:!0,suffixInputProps:{placeholder:"AM"},suffixOptions:[{label:"AM",value:"AM"},{label:"PM",value:"PM"}],onSuffixDropdownClick:$=>{de("appnt_time_format",$.value)}})]})]}),e.jsxRuntimeExports.jsx(p.Ap,{value:{label:Br.find($=>$.value==z.appnt_duration)?.label,value:z.appnt_duration},label:"Duration",className:`hfl-text-Gray-800 ${pe?" hfl-pointer-events-none":""}`,onChange:$=>{de("appnt_duration",$.value)},options:Br}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-gap-1.5",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text sm",children:"Type"}),e.jsxRuntimeExports.jsx(p.ju,{options:[{start_icon:"hx_inperson hfl-text-3",label:"In-Person",value:"inperson"}],disabled:!1,value:"inperson"})]}),window?.partner_service_enabled==="1"&&y?.insurance_details?.policy_id?.length&&e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-gap-1.5",children:e.jsxRuntimeExports.jsx(p.Oi,{size:"md",disabled:!1,isMarked:ue,text:"Partner Enabled",onClick:()=>ce($=>!$),"data-qa":"skip-billing"})}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2",children:[e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Tertiary",size:"md",textField:"Cancel",icon:"No",className:"hfl-flex-1 hfl-items-center hfl-justify-center hfl-border hfl-border-Gray-300 hfl-bg-White hfl-text-Gray-700 hover:hfl-bg-Gray-100",onClick:()=>{V(),ve(!1)}}),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Primary",size:"md",textField:z?.appnt_id?.length?"Update":"Create",icon:"No",onClick:async()=>{if(Ie.dayjs(h).format("YYYY-MM-DD")<Ie.dayjs().format("YYYY-MM-DD"))await Pl(z,d,c.patientRoleID,Ie.dayjs(h).format("YYYY-MM-DD"),T,St[0],N)&&V();else{const $=await $l(z,!1,d,y,c,T,ue,!0,N);$&&(O(fe=>fe.map((H,De)=>W==De.toString()?{...H,order_item_id:$.order_item_id||z.order_item_id}:H)),K(fe=>({...fe,order_item_id:$.order_item_id,appnt_id:$.appnt_id,order_id:$.order_id})),$.order_item_id&&$.appnt_id&&V())}g(),D(h),P()},className:"hfl-flex-1 hfl-items-center hfl-justify-center hfl-bg-Primary-600 hfl-text-White_20 hover:hfl-bg-Primary-800"})]})]}),Ie.dayjs(h).format("YYYY-MM-DD")!==Ie.dayjs().format("YYYY-MM-DD")&&I.length==0&&e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-items-center hfl-gap-[11px]",children:[e.jsxRuntimeExports.jsx("img",{className:"hfl-w-[58px] hfl-pb-4",src:ua,alt:"no-bills"}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-gap-1.5 hfl-text-Error-600",children:[e.jsxRuntimeExports.jsx("div",{className:"hx_error-filled hfl-h-5 hfl-w-5 "}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text sm",children:"There is no visit/prescription on this date."})]}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text sm",children:"Bill cannot be created without a visit"})]}),e.jsxRuntimeExports.jsx("div",{className:"hfl-sticky hfl-bottom-4 hfl-left-2 hfl-w-full",children:e.jsxRuntimeExports.jsx(p.Ku,{className:"hfl-h-8 hfl-shrink-0 hfl-border-l-Gray-200 hfl-bg-White_20 hfl-text-Gray-500 hfl-shadow-md hover:hfl-bg-Gray-100",hierarchy:"Tertiary",size:"md",textField:"Go Back",icon:"Left",iconFile:"hx_arrow-left hfl-text-Gray-500",onClick:()=>{ee?ve(!1):V(),A()}})})]})},da=a=>{const{handleRightSegment:d,editedTableData:c,getBillSummarydata:n,order_date:y,setTableData:w,editRowId:l,refreshBillsList:T,handleRevertEdit:N}=a,{patientIDs:h,showToast:V,doctorListArr:g,billPreferences:k,formattedService:O,ppEventProps:W,variable:D}=_.useContext(It)||{},A={bill_item_details:{appointment_details:{appnt_id:"",doctor_role_id:"",appnt_date:"",appnt_time:"",appnt_duration:0,appnt_status:0},doctor_name:D.window_var.doc_name_for_seg,referrer_doctor_role_id:D.window_var.doctor_role_id_for_seg,lab_owner_name:"",lab_owner_id:"",appnt_doctor_role_id:""}},[P,I]=_.useState({...c,...A}),R=_.useCallback(async()=>{if(c?.order_item_id)try{const B=await Cl(c.order_item_id,h?.patientRoleID||"",D);I({...c,...B.data,service_category:St[1],service_category_id:"2",order_item_service_tax_percentage:O?.[+B.data.service_id]?.service_tax||0,bill_item_details:{...A.bill_item_details,...B.data.bill_item_details,appointment_details:{appnt_id:"",doctor_role_id:"",appnt_date:"",appnt_time:"",appnt_duration:0,appnt_status:0},lab_owner_name:"",lab_owner_id:"0",appnt_doctor_role_id:"",referrer_doctor_role_id:""}})}catch(B){console.error("Error fetching bill item data:",B)}},[A.bill_item_details,c,O,h?.patientRoleID,D]);_.useEffect(()=>{c&&I(B=>({...B,...c}))},[c]),_.useEffect(()=>{R()},[R,P.order_item_id]);const Q=B=>{const L={...P,service_category:St[1],bill_item_details:{doctor_name:B.docName,appointment_details:null,lab_owner_name:"",lab_owner_id:"",referrer_doctor_role_id:B.docRoleID}};I(L)};return e.jsxRuntimeExports.jsxs("div",{className:"hfl-relative hfl-h-full",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-h-8 hfl-w-[330px] hfl-shrink-0 hfl-items-center hfl-justify-between hfl-gap-2 hfl-border-b-1 hfl-border-b-Gray-200 hfl-px-2",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text lg",children:P?.service_name}),e.jsxRuntimeExports.jsx("div",{className:"hx_close hfl-flex-shrink-0 hfl-cursor-pointer hfl-text-4",onClick:()=>{d(),N()}})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-gap-[14px] hfl-px-3 hfl-py-4",children:[k?.billing?.enable_add_service_owner!=0&&e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(p.tj,{label:"Doctor Name",labelSize:"Text sm",labelColor:"hfl-text-Gray-800",input1value:"Dr.",input2value:P.bill_item_details.doctor_name,end_icon:"hx_down hfl-bg-White_20",inputProps:{disabled:!0},suffixInputProps:{placeholder:"Doctor Name"},className:"hfl-w-12 hfl-flex-none hfl-text-ellipsis hfl-bg-Gray-50 hfl-text-Gray-500",suffixClassName:" hfl-w-[220px] hfl-text-ellipsis hfl-bg-White_20",suffixDropdownClassName:"hfl-ml-12",suffixOptions:g?.doctor_list?.map(B=>({label:B.doctor_name,value:B.doctor_name,appnt_doctor_role_id:B.doctor_identifier})),handleSuffixValChange:B=>{Q({docName:B,docRoleID:""})},onSuffixDropdownClick:B=>{Q({docName:B.label,docRoleID:B.appnt_doctor_role_id})}})}),e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Primary",size:"lg",textField:"Update",className:"hfl-flex hfl-h-9 hfl-w-full hfl-shrink-0 hfl-items-center hfl-justify-center hfl-gap-1 hfl-self-stretch hfl-rounded-md hfl-p-3",onClick:async()=>{const B=await Pl(P,V,h?.patientRoleID||"",Ie.dayjs(y).format("YYYY-MM-DD"),W,St[1],D);B&&(w(L=>L.map((z,K)=>l==K.toString()?{...z,order_item_id:B?.order_item_id||P.order_item_id}:z)),(B?.order_item_id||P.order_item_id)&&(n(),d(),T(y)))}})})]}),e.jsxRuntimeExports.jsx("div",{className:"hfl-absolute hfl-bottom-4 hfl-left-2 hfl-w-full",children:e.jsxRuntimeExports.jsx(p.Ku,{className:"hfl-h-8 hfl-shrink-0 hfl-border-l-Gray-200 hfl-bg-White_20 hfl-text-Gray-500 hfl-shadow-md hover:hfl-bg-Gray-100",hierarchy:"Tertiary",size:"md",textField:"Go Back",icon:"Left",iconFile:"hx_arrow-left hfl-text-Gray-500",onClick:()=>{d(),N()}})})]})};var Bs={exports:{}},fa=Bs.exports,Yl;function pa(){return Yl||(Yl=1,function(a,d){(function(c,n){a.exports=n()})(fa,function(){var c="minute",n=/[+-]\d\d(?::?\d\d)?/g,y=/([+-]|\d\d)/g;return function(w,l,T){var N=l.prototype;T.utc=function(D){var A={date:D,utc:!0,args:arguments};return new l(A)},N.utc=function(D){var A=T(this.toDate(),{locale:this.$L,utc:!0});return D?A.add(this.utcOffset(),c):A},N.local=function(){return T(this.toDate(),{locale:this.$L,utc:!1})};var h=N.parse;N.parse=function(D){D.utc&&(this.$u=!0),this.$utils().u(D.$offset)||(this.$offset=D.$offset),h.call(this,D)};var V=N.init;N.init=function(){if(this.$u){var D=this.$d;this.$y=D.getUTCFullYear(),this.$M=D.getUTCMonth(),this.$D=D.getUTCDate(),this.$W=D.getUTCDay(),this.$H=D.getUTCHours(),this.$m=D.getUTCMinutes(),this.$s=D.getUTCSeconds(),this.$ms=D.getUTCMilliseconds()}else V.call(this)};var g=N.utcOffset;N.utcOffset=function(D,A){var P=this.$utils().u;if(P(D))return this.$u?0:P(this.$offset)?g.call(this):this.$offset;if(typeof D=="string"&&(D=function(B){B===void 0&&(B="");var L=B.match(n);if(!L)return null;var z=(""+L[0]).match(y)||["-",0,0],K=z[0],ue=60*+z[1]+ +z[2];return ue===0?0:K==="+"?ue:-ue}(D),D===null))return this;var I=Math.abs(D)<=16?60*D:D;if(I===0)return this.utc(A);var R=this.clone();if(A)return R.$offset=I,R.$u=!1,R;var Q=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();return(R=this.local().add(I+Q,c)).$offset=I,R.$x.$localOffset=Q,R};var k=N.format;N.format=function(D){var A=D||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return k.call(this,A)},N.valueOf=function(){var D=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*D},N.isUTC=function(){return!!this.$u},N.toISOString=function(){return this.toDate().toISOString()},N.toString=function(){return this.toDate().toUTCString()};var O=N.toDate;N.toDate=function(D){return D==="s"&&this.$offset?T(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():O.call(this)};var W=N.diff;N.diff=function(D,A,P){if(D&&this.$u===D.$u)return W.call(this,D,A,P);var I=this.local(),R=T(D).local();return W.call(I,R,A,P)}}})}(Bs)),Bs.exports}var ha=pa();const Dl=p.getDefaultExportFromCjs(ha),Tl=a=>{Ie.dayjs.extend(Dl);const{categorySummaryData:d,serviceDetails:c,walletBalance:n,rightSegment:y,serviceItem:w,bill_date:l,handleRightSegment:T,getBillSummarydata:N,getPastDueAmount:h,refreshBillsList:V,closePrintModal:g,setRefreshWallet:k}=a,O=_.useContext(It);if(!O)throw new Error("ServiceLevelBillSummary must be used within an AppContext.Provider");const{patientDetails:W,patientIDs:D,billPreferences:A,setShowPrintModal:P,currentWindow:I,showPrintModal:R,variable:Q}=O,B=()=>{switch(w){case St[0]:return"Consultation Bill";case St[1]:return"Other Service Bill";case St[2]:return"Lab Service Bill";default:return`${w} Bill`}},L=async(z,K,ue)=>{if(R?.visible&&g(),!d)return;const ce=await Xl(d.order_id,D?.patientRoleID||"",Q),X=c.map(Le=>({serviceName:Le.service_name,price:+Le.order_unit_item_price,gst:+Le.order_item_service_tax,discount:+Le.order_item_discount,netPrice:+Le.net_amount,itemQty:+Le.item_quantity})),ee=+d.order_paid_amount,ve=+d.refund_amount,de=+d.balance_amount,Ue=+d.order_discount,pe=+d.order_item_sum_discount,$=+d.order_service_tax,fe={paymentStatus:ee-ve===0?"red":de===0?"green":"yellow",paymentMode:ce?.paymentModes?.length?ce.paymentModes.join(", "):"",billedAmount:+d.order_total,discountAmount:Ue+pe,gstAmount:$,cgstAmount:($/2).toFixed(2),sgstAmount:($/2).toFixed(2),finalAmount:+d.net_bill_amount,receivedAmount:ee,balanceAmount:de,refundAmount:ve},De=[W?.age&&typeof W.age=="number"?`${W.age}y`:W?.org_person_dob?hr(W.org_person_dob):"",W?.gender?Jr[W.gender]:"",W?.blood_group].filter(Boolean).join(", "),Me={name:`${ar(W?.name??"")}${De?` (${De})`:""}`,billDate:Ie.dayjs(d.order_date).format("DD-MMM-YYYY"),mobileNumber:W?.phone_number??"",email:W?.email??"",billNumber:d.order_id_str,patientId:W?.org_person_bid_str??"",patientIdForEmail:D?.patientRoleID??"",billStatus:de===0?"PAID":"UNPAID",address:[W?.address,W?.city,W?.pincode].filter(Boolean).join(", "),referredBy:ce?.lab_owner_name?ar(ce.lab_owner_name):W?.ref_doc_name?ar(W.ref_doc_name):"--"};P({printDataFrom:"patient_popup",visible:!0,whichPreview:z,printData:"",visitId:"",visit_date:"",visit_number:1,currentPrintTime:new Date().getTime(),printType:"bill",details:{showPrintPreviewForBill:K,preferences:{...A?.print?.bill,...A?.org_details},billSummaryDetails:fe,billServiceDetails:X,billPatientDetails:Me,isWholeBill:!1,payloadDataforEmail:{orderDate:"",orderNumber:d?.order_id}},trackEventHandler:()=>{console.log(ue)}})};return e.jsxRuntimeExports.jsxs("div",{className:"hfl-relative hfl-h-full ",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-h-8 hfl-w-[330px] hfl-shrink-0 hfl-items-center hfl-gap-2 hfl-border-b-1 hfl-border-b-Gray-200 hfl-px-2",children:[e.jsxRuntimeExports.jsx("div",{className:"hx_arrow-left hfl-flex-shrink-0 hfl-cursor-pointer hfl-text-4",onClick:()=>T(pt[0])}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-flex hfl-items-center",children:[B()," : ",e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",className:"hfl-text-Primary-600",children:d?.order_id_str})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-items-start hfl-px-3 hfl-py-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Gross Bill Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹ ",d?.order_total??0]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Discount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹"," - ",+(d?.order_discount||0)+ +(d?.order_item_sum_discount||0)]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Tax Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹ ",d?.order_service_tax]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Net Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-text-Gray-800",children:["₹ ",d?.net_bill_amount]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Collected Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹ ",d?.order_paid_amount]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Refund Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹"," - ",d?.refund_amount]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Net Paid Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Success-500",children:["₹ ",+(d?.order_paid_amount||0)-+(d?.refund_amount||0)]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Total Balance Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Warning-500 ",children:["₹ ",d?.balance_amount]})]}),e.jsxRuntimeExports.jsx(Al,{showDiscount:I!==wt[4],showRefund:I!==wt[4],rightSegment:y,summaryData:d,getBillSummarydata:N,handleRightSegment:T,serviceItem:w,getPastDueAmount:h,date:l,refreshBillsList:V,setRefreshWallet:k,walletBalance:n})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-px-1 hfl-pb-2",children:[e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Tertiary",size:"md",textField:"Print",icon:"Left",onClick:()=>L("billPrintPreview",!1,"BILL_PRINT"),iconFile:"hx_print",className:" hfl-flex-1 hfl-items-center hfl-justify-center hfl-border hfl-border-Gray-300 hfl-bg-White hfl-text-Gray-700 hover:hfl-bg-Gray-100"}),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Tertiary",size:"md",textField:"Share",icon:"Left",onClick:()=>L("billSharePreview",!0,"BILL_SHARE"),iconFile:"hx_share",className:" hfl-flex-1 hfl-items-center hfl-justify-center hfl-border hfl-border-Gray-300 hfl-bg-White hfl-text-Gray-700 hover:hfl-bg-Gray-100"})]})]})},Il=({depositAmount:a,handleRightSegment:d,rightSegment:c,setRefreshWallet:n})=>e.jsxRuntimeExports.jsxs("div",{className:" hfl-flex hfl-flex-col",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-border-b hfl-border-Gray-200 hfl-py-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-full hfl-items-center hfl-px-1",children:[e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-gap-1"}),e.jsxRuntimeExports.jsx("i",{className:"hx_arrow-left hfl-cursor-pointer hfl-text-4 hfl-font-inter-2",onClick:()=>{d()}}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text md",className:"hfl-flex hfl-items-center",children:"Deposit Amount"})]}),e.jsxRuntimeExports.jsx("i",{className:"hx_close hfl-cursor-pointer hfl-text-right hfl-text-4 hfl-font-inter-2",onClick:()=>{d()}})]}),e.jsxRuntimeExports.jsxs("div",{className:`${a>0?"hfl-bg-Success-50":"hfl-bg-Warning-50"} hfl-m-3 hfl-flex hfl-flex-col hfl-items-center hfl-justify-center hfl-rounded-lg hfl-border hfl-border-Gray-200 hfl-px-2 hfl-py-3`,children:[e.jsxRuntimeExports.jsx("span",{className:`hfl-text-5 hfl-font-inter-3 ${a>0?"hfl-text-Success-600":"hfl-text-Gray-800"} `,children:"₹"+a}),e.jsxRuntimeExports.jsx("span",{className:"hfl-mt-[-8px] hfl-text-1 hfl-text-Gray-500",children:"Balance"})]}),e.jsxRuntimeExports.jsx("div",{className:"hfl-w-full hfl-px-3",children:e.jsxRuntimeExports.jsx(Al,{rightSegment:c,showDeposit:!0,showPayment:!1,showDiscount:!1,showDepositRefund:!0,showRefund:!1,handleRightSegment:d,walletBalance:a,setRefreshWallet:n})})]}),ma=({closePrintModal:a})=>{if(!_.useContext(It))throw new Error("AddBills component must be used within an PatientPopupContext.Provider");const{patientDetails:d,patientIDs:c,billPreferences:n,setShowPrintModal:y,showPrintModal:w,setLoading:l,showToast:T,variable:N}=_.useContext(It),[h,V]=_.useState(new Date),[g,k]=_.useState(),[O,W]=_.useState(pt[0]),[D,A]=_.useState([]),[P,I]=_.useState([]),[R,Q]=_.useState(""),[B,L]=_.useState(),[z,K]=_.useState(!1),[ue,ce]=_.useState(pl),[X,ee]=_.useState("-1"),[ve,de]=_.useState({bill_summary:{},status:!1,message:""}),[Ue,pe]=_.useState(!1),[$,fe]=_.useState(0),H=G=>{Q(G)},De=async G=>{l(!0);try{await ht(G),V(G)}catch(Te){console.error(Te)}l(!1)},Me=async()=>{try{const G=await dn(c.patientRoleID,Ie.dayjs(h).format("YYYY-MM-DD"),N);de(G)}catch(G){console.error("Error in getBillSummary API Call:",G)}},Le=()=>{ce(G=>P.length>+X&&+X>=0?[...G.slice(0,+X),{order_id:P[X].order_id,order_date:P[X].order_date,order_created_on:P[X].order_created_on,service_category:P[X].service_category,service_category_id:P[X].service_category_id,order_id_str:P[X].order_id_str,order_total:P[X].order_total,order_paid_amount:P[X].order_paid_amount,order_item_sum_discount:P[X].order_item_sum_discount,order_discount:P[X].order_discount,refund_amount:P[X].refund_amount,order_service_tax:P[X].order_service_tax,balance_amount:P[X].balance_amount,net_bill_amount:P[X].net_bill_amount,order_item_id:P[X].order_item_id,service_id:P[X]?.service_id,service_name:P[X].service_name,item_quantity:P[X].item_quantity,order_unit_item_price:P[X].order_unit_item_price,order_item_price:P[X].order_item_price,order_item_discount:P[X].order_item_discount,order_item_service_tax:""+Math.floor(P[X].order_item_service_tax),order_item_service_tax_percent:P[X].order_item_service_tax_percent,net_amount:P[X].net_amount,created_on:P[X].created_on},...G.slice(+X+1)]:G)},xt=async()=>{try{const G=await Gs(Ie.dayjs(h).format("YYYY-MM-DD"),c.patientRoleID,1,10,!0,N);K(G?.total_records>0)}catch{console.log("error in checkAppointmentForBilling API Call")}};_.useEffect(()=>{Me(),it(),window?.partner_service_enabled!=="1"&&xt()},[h]);const ht=async(G=Ie.dayjs().format("YYYY-MM-DD"))=>{l(!0);try{const Te=await yl(Ie.dayjs(G).format("YYYY-MM-DD"),c.patientRoleID,1,100,N);k(Te),ce(pl);const Ze=Te?.bill_list.flatMap(se=>{const{order_items:J,...U}=se;return J.map(ie=>({...U,...ie})).filter(ie=>Ie.dayjs(ie?.created_on).format("YYYY-MM-DD")===Ie.dayjs(new Date).format("YYYY-MM-DD"))});if(I(Ze),Te?.bill_list?.length){const se=Te?.bill_list.reduce((J,U)=>{const ie=U.order_items.filter(Be=>Ie.dayjs(Be?.created_on).isBefore(Ie.dayjs(new Date).format("YYYY-MM-DD"))).map(Be=>({...Be,service_category:U.service_category,service_category_id:U.service_category_id}));return[...J,...ie]},[]);A(se)}else ce(pl),A([])}catch{console.log("error in getBillsList API Call")}l(!1)};_.useEffect(()=>{ht()},[]);const at=async()=>{try{const G=await Sl(c.patientRoleID,N);fe(G?.wallet_balance||0)}catch(G){console.error("Failed to fetch wallet balance:",G)}};_.useEffect(()=>{at()},[Ue]);const We=_.useCallback(async()=>{try{const G=await bl(Ie.dayjs(h).format("YYYY-MM-DD"),c.patientRoleID,!1,N);L(G)}catch(G){console.error("Error in getPastDueAmount API Call:",G)}},[h,bl,c.patientRoleID]);_.useEffect(()=>{We()},[We]);const it=(G=pt[0])=>{W(G)},Pt=G=>{switch(G?.original?.service_category.toLowerCase()){case St[0].toLowerCase():it(pt[2]);break;case St[1].toLowerCase():it(pt[4]);break;case St[2].toLowerCase():it(pt[3]);break;default:it(pt[0]);break}},gt=(G,Te)=>Te.reduce((Ze,se)=>Ze+(parseInt(ve.bill_summary[se]?.[G]||"0")||0),0),At=(G,Te)=>Te.map(Ze=>ve.bill_summary[Ze]?.[G]).filter(Ze=>Ze),Gt=async(G,Te,Ze)=>{if(w?.visible&&a(),ve?.bill_summary&&Object.keys(ve?.bill_summary).length>0){const se=await zn(At("order_id",G),c?.patientRoleID,N),J=[...new Set(G.map(yt=>se.paymentsData.get(yt)).flat())].map(yt=>cr[yt]??void 0)?.filter(yt=>yt),U=gt("order_service_tax",G??[1,2,3]),ie={billedAmount:gt("order_total",G??[1,2,3]),gstAmount:U,cgstAmount:(U/2).toFixed(2),sgstAmount:(U/2).toFixed(2),discountAmount:gt("order_item_sum_discount",G??[1,2,3])+gt("order_discount",G??[1,2,3]),finalAmount:gt("net_bill_amount",G??[1,2,3]),receivedAmount:gt("order_paid_amount",G??[1,2,3]),balanceAmount:gt("balance_amount",G??[1,2,3]),refundAmount:gt("refund_amount",G??[1,2,3])},Se=[...ue,...D].filter(yt=>G.includes(parseInt(yt?.service_category_id))).map(yt=>({serviceName:yt.service_name,price:yt.order_unit_item_price,gst:Math.floor(yt.order_item_service_tax),discount:yt.order_item_discount,netPrice:yt.net_amount,itemQty:yt.item_quantity})),Qt=[d?.age&&typeof d?.age=="number"?`${d?.age}y`:d?.org_person_dob?hr(d?.org_person_dob):"",Jr[d?.gender]??"",d?.blood_group].filter(yt=>yt).join(", ");y({printDataFrom:"patient_popup",visible:!0,whichPreview:Te,printData:"",visitId:"",visit_date:"",visit_number:1,currentPrintTime:new Date().getTime(),printType:"bill",details:{showPrintPreviewForBill:Ze,preferences:{...n?.print?.bill,...n?.org_details,...n?.branch_details},billSummaryDetails:{...ie,paymentStatus:parseInt(ie?.receivedAmount||"0")-parseInt(ie?.refundAmount||"0")===0?"red":parseInt(ie?.balanceAmount||"0")===0?"green":"yellow",paymentMode:J?.join(", ")},billServiceDetails:Se,billPatientDetails:{name:ar(d?.name)+(Qt?` (${Qt}) `:""),billDate:Ie.dayjs(h).format("DD-MMM-YYYY"),mobileNumber:d?.phone_number,email:d?.email,billNumber:At("order_id_str",G)?.toString(),patientId:d?.org_person_bid_str,patientIdForEmail:c.patientRoleID,billStatus:parseInt(ie?.balanceAmount||"0")===0?"PAID":"UNPAID",address:[d?.address??"",d?.city??"",d?.pincode??""].filter(yt=>yt).join(", "),referredBy:se?.lab_owner_name?ar(se?.lab_owner_name):d?.ref_doc_name?ar(d?.ref_doc_name):"--"},isWholeBill:G.length===3,payloadDataforEmail:{orderDate:G.length===3?Ie.dayjs(h).format("YYYY-MM-DD"):"",orderNumber:At("order_id",G)?.join("_")}},trackEventHandler:yt=>{console.log("Bill Print Event",yt)}})}else T("Error","Please add a service to create bill","Error",3e3)};return e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex",children:[e.jsxRuntimeExports.jsx(aa,{tab:"add_bills",children:e.jsxRuntimeExports.jsxs("div",{className:`hfl-relative hfl-h-full hfl-overflow-auto ${O===pt[7]?"hfl-opacity-30":""}`,children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-ml-4 hfl-mr-1 hfl-flex hfl-flex-col hfl-gap-1 hfl-self-stretch",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-justify-between",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-gap-3",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",className:"hfl-text-Gray-700",children:"Bill Date :"}),e.jsxRuntimeExports.jsx("div",{"data-qa":"calendar",children:e.jsxRuntimeExports.jsx(p.ZC,{selectDate:new Date(Ie.dayjs(h).format("DD-MMM-YYYY")),dateVar:G=>{V(G),De(G)},maxDate:new Date})}),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Secondary-Grey",size:"md",textField:"Today",className:"hfl-h-10",onClick:()=>De(new Date),"data-qa":"today"})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-row hfl-items-center hfl-justify-center hfl-text-Gray-700",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",children:"Deposit Amount:"}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-center hfl-gap-1 hfl-rounded-lg hfl-bg-Gray-50 hfl-p-1",children:[e.jsxRuntimeExports.jsx("i",{className:"hx_rupee hfl-text-3 hfl-text-Success-500"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",className:" hfl-text-Success-500",children:$}),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Secondary-Grey",size:"md",textField:"",icon:"Only",iconFile:"hx_add-circle hfl-text-4",className:"hfl-items-center hfl-justify-center",onClick:()=>it(pt[7])})]})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"-hfl-gap-[1px] hfl-flex hfl-h-[590px] hfl-flex-col hfl-items-start",children:[e.jsxRuntimeExports.jsx(zl,{tableBodyData:P,tableData:ue,isDisabled:!1,addBillButton:!0,handleEditRow:Pt,handleRightSegment:it,setTableData:ce,setEditRowId:ee,getBillSummarydata:Me,refreshBillsList:ht}),D&&D?.length>0&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[" ",e.jsxRuntimeExports.jsxs(p.bi,{variant:"Semibold",type:"Text lg",className:"hfl-py-3 hfl-text-Gray-700",children:["Old Bill"," "]}),e.jsxRuntimeExports.jsx(zl,{tableBodyData:D,tableData:D,isDisabled:!0,addBillButton:!1,handleEditRow:Pt,handleRightSegment:it,setTableData:ce,setEditRowId:ee,getBillSummarydata:()=>{},refreshBillsList:()=>{}})]})]})]}),e.jsxRuntimeExports.jsx("div",{className:" mt-2 hfl-sticky hfl-bottom-0 hfl-w-full",children:z&&e.jsxRuntimeExports.jsx(na,{})})]})}),e.jsxRuntimeExports.jsxs(Nl,{tab:"add_bills",children:[O===pt[0]&&e.jsxRuntimeExports.jsx(ia,{summaryData:ve,date:h,rightSegment:O,handleRightSegment:it,billSummaryClicked:(G,Te,Ze)=>Gt(G,Te,Ze),showDiscount:!1,showRefund:!1,handleServiceItem:H,pastDueData:B,getBillSummarydata:Me,refreshBillsList:ht,getPastDueAmount:We,walletBalance:$,setRefreshWallet:pe}),O===pt[1]&&e.jsxRuntimeExports.jsx(Tl,{bill_date:h,rightSegment:O,serviceDetails:g?.bill_list.find(G=>G.service_category.toLowerCase()===R.toLowerCase())?.order_items??[],categorySummaryData:ve?.bill_summary[`${St.indexOf(R)+1}`],serviceItem:R,handleRightSegment:it,getBillSummarydata:Me,refreshBillsList:ht,getPastDueAmount:We,walletBalance:$,setRefreshWallet:pe,closePrintModal:a}),O===pt[2]&&e.jsxRuntimeExports.jsx(ca,{bill_date:h,handleRightSegment:it,getBillSummarydata:Me,editedTableData:ue?.[X],setTableData:ce,editRowId:X,handleRevertEdit:Le,refreshBillsList:ht,checkAppointmentForBilling:xt}),O===pt[4]&&e.jsxRuntimeExports.jsx(da,{order_date:h,handleRightSegment:it,getBillSummarydata:Me,editedTableData:ue?.[X],setTableData:ce,editRowId:X,refreshBillsList:ht,handleRevertEdit:Le}),O===pt[3]&&e.jsxRuntimeExports.jsx(oa,{order_date:h,handleRightSegment:it,editedTableData:ue?.[X],getBillSummarydata:Me,setTableData:ce,editRowId:X,refreshBillsList:ht,handleRevertEdit:Le}),O===pt[7]&&e.jsxRuntimeExports.jsx(Il,{depositAmount:$,handleRightSegment:it,rightSegment:O,setRefreshWallet:pe})]})]})},Rl=a=>{const{appointments:d,isDisabled:c,handleAppointData:n,leftNav:y,today:w}=a,l=_.useCallback(A=>{n(A)},[n]),T=_.useMemo(()=>[{Header:"Date",accessor:"appnt_date",Cell:({row:A})=>e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-w-[130px] hfl-items-center hfl-justify-center",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:` ${c?"":"hfl-rounded-sm hfl-bg-Success-50 hfl-px-2 hfl-text-Success-600"} `,children:Ie.dayjs(A?.original?.appnt_date).format("DD-MMM-YYYY")})})},{Header:"Time",accessor:"appnt_time",Cell:({row:A})=>e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:" ",children:A?.original?.appnt_time&&new Date("1970-01-01T"+A?.original?.appnt_time+"Z").toLocaleTimeString("en-US",{timeZone:"UTC",hour12:!0,hour:"numeric",minute:"numeric"})})},{Header:"Status",accessor:"appnt_status",Cell:({row:A})=>e.jsxRuntimeExports.jsx("div",{className:" hfl-flex hfl-w-[100px] hfl-items-center hfl-justify-center focus:hfl-outline-none",children:e.jsxRuntimeExports.jsx(p.bi,{className:" hfl-flex hfl-w-[100px] hfl-items-center focus:hfl-outline-none",variant:"Regular",type:"Text sm",children:vl.find(P=>P.value==A?.original?.appnt_status)?.text})})},{Header:"Doctor",accessor:"appnt_doctor_name",Cell:({row:A})=>e.jsxRuntimeExports.jsx(p.bi,{className:" hfl-flex hfl-w-[316px] hfl-items-center hfl-capitalize focus:hfl-outline-none",variant:"Regular",type:"Text sm",children:"Dr. "+A.original.appnt_doctor_name})},{Header:"Type",accessor:"order_unit_item_price",Cell:()=>e.jsxRuntimeExports.jsx(p.bi,{className:" hfl-flex hfl-w-[100px] hfl-items-center focus:hfl-outline-none",variant:"Regular",type:"Text sm",children:"In-Person"})},{Header:"Service",accessor:"appnt_service_name",Cell:({row:A})=>e.jsxRuntimeExports.jsx("div",{className:" [100px] hfl-flex hfl-items-center hfl-justify-center ",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex hfl-w-[116px] hfl-items-center hfl-capitalize",children:A.original.appnt_service_name})})},{Header:"Bill",accessor:"total_price",Cell:({row:A})=>A.original.order_item_id!=0||c||y!="today"?e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-center hfl-text-Error-500 ",children:[e.jsxRuntimeExports.jsx("i",{className:" hx_f-rupee"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex hfl-w-[106px] hfl-items-center",children:A.original.total_price})]}):e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Secondary",size:"sm",textField:"",icon:"Left",iconFile:"hx_rupee-bill-filled hfl-text-3",onClick:()=>{l(A.original)},children:"Add Bill"})},{Header:"",accessor:"edit",Cell:({row:A})=>e.jsxRuntimeExports.jsx("i",{className:` ${c?"hfl-text-White":""} ${y==="today"&&"hx_edit"} hfl-p-4 hfl-text-Primary-700 `,onClick:()=>{y==="today"&&l(A.original)},"data-qa":"edit-icon"})}],[l,c,y]),N=_.useMemo(()=>d||[],[d]),{getTableProps:h,getTableBodyProps:V,headerGroups:g,rows:k,prepareRow:O}=Qr.useTable({columns:T,data:N}),W=A=>{const P=[];return A?.headers?.length&&A.headers.map(I=>{P.push(e.jsxRuntimeExports.jsx("th",{...I.getHeaderProps(),className:"hfl-rounded hfl-border-1 hfl-border-Gray-200 hfl-bg-Blue_gray-50 hfl-px-2 hfl-py-1 hfl-text-left",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-text-Gray-600",children:I.render("Header")})}))}),P},D=()=>{const A=[];return k.map((P,I)=>{O(P),A.push(e.jsxRuntimeExports.jsx("tr",{"data-qa":I+1+"",...P.getRowProps(),className:`${P?.original?.appnt_status===1?"hfl-bg-Gray-50 hfl-text-Gray-400 hover:hfl-bg-White hover:hfl-text-Gray-500":"hfl-bg-White"} hfl-group hfl-h-9 hfl-w-full hfl-border-t-1 hfl-border-Gray-200 ${c?"hfl-bg-Gray-100":""}`,children:P.cells.map(R=>e.jsxRuntimeExports.jsx("td",{"data-qa":I+1+"-"+R.column.id,...R.getCellProps(),className:"hfl-relative hfl-border-1 hfl-border-Gray-200 hfl-px-2 hfl-text-left",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:`${P?.original?.appnt_status===1?"hfl-text-Gray-300 group-hover:hfl-text-Gray-500":"hfl-text-Gray-500"}`,children:R.render("Cell")})}))}))}),A};return e.jsxRuntimeExports.jsx("div",{className:`${c?" hfl-pointer-events-none":"hfl-cursor-pointer"} ${w?" hfl-h-[500px] hfl-overflow-y-scroll":""} `,children:d&&e.jsxRuntimeExports.jsxs("table",{...h(),className:"hfl-table-fixed hfl-rounded-lg hfl-border-1 hfl-border-Gray-200 hfl-pb-8 hfl-shadow-md",children:[e.jsxRuntimeExports.jsx("thead",{children:g.map(A=>e.jsxRuntimeExports.jsx("tr",{...A.getHeaderGroupProps(),className:"hfl-h-9 hfl-rounded-lg hfl-bg-Blue_gray-50 hfl-py-2",children:W(A)}))}),e.jsxRuntimeExports.jsx("tbody",{...V(),className:"hfl-rounded-lg hfl-border-1 hfl-border-Gray-200",children:D()})]})})},es=a=>{const{currentPage:d,totalRecord:c,handleLoadMore:n,isLoading:y=!1,currentTotal:w}=a;return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[!y&&e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-between",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text sm",className:"hfl-text-Gray-500",children:`1 — ${w} of ${c} results`}),w!==c?e.jsxRuntimeExports.jsx(p.Ku,{className:"hfl-text-Blue-^00 hfl-flex hfl-justify-center",hierarchy:"Link-Colour",size:"lg",textField:"Load more... ",onClick:()=>n(d)}):e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text sm",className:"hfl-text-Gray-500",children:"End of List"})]}),y&&e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center hfl-justify-center",children:e.jsxRuntimeExports.jsx(p.Eu,{size:"xxs",progress:10,spinnerMode:!0})})]})},xa=a=>{const{handleAddNewAppnt:d,handleAppointData:c,sortAppointments:n}=a,[y,w]=_.useState(),[l,T]=_.useState(1),[N,h]=_.useState([]),[V,g]=_.useState([]),[k,O]=_.useState(""),{patientIDs:W,setLoading:D,variable:A}=_.useContext(It),P=async I=>{let R=I;if(D(!0),R<=Math.ceil((y?.total_records||0)/10)){if(R=I+1,R!==I){const Q=await Gs("all",W?.patientRoleID||"",R,10,!1,A);h(B=>[...B,...Q.appointments.filter(L=>L.appnt_date>=Ie.dayjs(new Date).format("YYYY-MM-DD"))]),g(B=>[...B,...Q.appointments.filter(L=>L.appnt_date<Ie.dayjs(new Date).format("YYYY-MM-DD"))])}T(R)}D(!1)};return _.useEffect(()=>{D(!0);const I=async()=>{try{const R=await Gs("all",W?.patientRoleID||"",1,10,!1,A);R&&(w(R),h(R?.appointments?.filter(Q=>Q.appnt_date>=Ie.dayjs(new Date).format("YYYY-MM-DD"))),g(R?.appointments?.filter(Q=>Q.appnt_date<Ie.dayjs(new Date).format("YYYY-MM-DD")))),O(R?.appointments?.length?"":"No Appointment")}catch{console.log("error in getAppointmentsList API Call")}};D(!1),I()},[W?.patientRoleID,D,A]),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-max-h-[550px] hfl-w-full hfl-flex-col hfl-overflow-y-scroll",children:[N.length>0&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-full hfl-items-center hfl-justify-between hfl-px-3 hfl-py-2 ",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",className:"",children:"Upcoming Appointments"}),e.jsxRuntimeExports.jsx(p.Ku,{"data-qa":"new-appointment",hierarchy:"Primary",size:"md",className:"text",icon:"Left",iconFile:"hx_add-circle",textField:"New Appointment",onClick:d})]}),e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-px-4 ",children:e.jsxRuntimeExports.jsx(Rl,{appointments:n(N),handleAppointData:c})})]}),V.length>0&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",className:"hfl-w-full hfl-items-center hfl-px-3 hfl-py-2 hfl-pt-4 ",children:"Past Appointments"}),e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-px-4 hfl-pb-4 xxs:max-md:hfl-w-[885px] xxs:max-md:hfl-overflow-y","data-qa":"all-appoint-table",children:e.jsxRuntimeExports.jsx(Rl,{isDisabled:!0,appointments:V,handleAppointData:c})})]})]}),V.length>0||N.length>0?e.jsxRuntimeExports.jsx("div",{className:"hfl-px-6 hfl-py-2",children:e.jsxRuntimeExports.jsx(es,{currentPage:l,totalRecord:y?.total_records||0,currentTotal:l===Math.ceil((y?.total_records||0)/10)?y?.total_records||0:l*10,handleLoadMore:P})}):e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-h-full hfl-w-full hfl-items-center hfl-justify-center",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",children:k})})]})},ga=()=>{const{showToast:a,patientDetails:d,doctorListArr:c,serviceListArr:n,patientIDs:y,setLoading:w,billPreferences:l,docPreference:T,formattedService:N,ppEventProps:h,getAndSetServiceListArr:V,variable:g}=_.useContext(It),[k,O]=_.useState(g.window_var?.partner_service_enabled==="1"&&d?.insurance_details?.policy_id?.length?!0:l?.billing?.prepaid_consultation!=="1"),[W,D]=_.useState("today"),[A,P]=_.useState(!1),[I,R]=_.useState([]),Q=new Date().toLocaleString("en-US",{hour:"numeric",minute:"numeric",hour12:!0}),B=_.useMemo(()=>c?.doctor_list?.length===1?c.doctor_list[0]:{doctor_name:"",doctor_identifier:""},[c]),L=_.useMemo(()=>({...ql,deleted:!1,appnt_date:Ie.dayjs().format("YYYY-MM-DD"),appnt_doctor_name:g.window_var.role_id=="11"?g.window_var.doc_name_for_seg:B?.doctor_name,appnt_doctor_role_id:g.window_var.role_id=="11"?g.window_var.doctor_role_id_for_seg:B?.doctor_identifier,appnt_duration:l?.print?.bill?.appnt_minute_slab||"",appnt_time_time:Q?.split(" ")[0]||"",appnt_time_format:Q?.split(" ")[1]||"",total_price:"0",order_item_service_tax_percentage:0,order_item_service_tax:"0",item_quantity:"1",order_unit_item_price:"0",order_item_price:"0",order_id:"",order_date:"",order_created_on:"",service_category:"",service_category_id:"",order_id_str:"",order_total:"",order_paid_amount:"",order_item_sum_discount:"",order_discount:"",refund_amount:"",order_service_tax:"",balance_amount:"",net_bill_amount:"",service_id:"",service_name:"",order_item_service_tax_percent:"",created_on:"",net_amount:""}),[l?.print?.bill?.appnt_minute_slab,Q,B?.doctor_identifier,B?.doctor_name,g.window_var.doc_name_for_seg,g.window_var.doctor_role_id_for_seg,g.window_var.role_id]),[z,K]=_.useState(L),[ue,ce]=_.useState(!1);_.useEffect(()=>{O(g.window_var?.partner_service_enabled==="1"&&d?.insurance_details?.policy_id?!0:l?.billing?.prepaid_consultation!=="1")},[A,l,W,d,g.window_var?.partner_service_enabled]),_.useEffect(()=>{ce(G=>k&&G)},[k]),_.useEffect(()=>{if(!+z?.order_item_id&&!z?.order_unit_item_price){const G=N?.[z.appnt_service_id];G&&K(Te=>({...Te,order_unit_item_price:G.price.toString(),item_quantity:"1",order_item_discount:"0",order_item_service_tax_percentage:G?.service_tax||0}))}},[k,A,z.order_item_id,z.order_unit_item_price,z.appnt_service_id,N]);const X=_.useCallback(G=>{const{order_unit_item_price:Te=0,item_quantity:Ze=0,order_item_discount:se=0,appnt_service_id:J}=G;if(!J)return;let U=0;const ie=N?.[J]?.service_tax||0;let Be=0;if(Number(Te)>0&&Number(Ze)>0){const Se=Number(Te)*Number(Ze);U=Math.floor(Se*.01*ie),Be=Se+U-Number(se)}K(Se=>({...Se,order_item_service_tax:U.toString(),order_item_price:Be.toString()}))},[N]),ee=_.useMemo(()=>[{...z,order_item_service_tax:Math.floor(+z.order_item_service_tax).toString()}],[z]),ve=G=>{gt();const Te=new Date(`1970-01-01T${G.appnt_time}Z`).toLocaleTimeString("en-US",{timeZone:"UTC",hour12:!0,hour:"numeric",minute:"numeric"});K(Ze=>({...Ze,...G,appnt_time_time:Te?.split(" ")[0]??"",appnt_time_format:Te?.split(" ")[1]??"",order_item_service_tax_percentage:N?.[G.appnt_service_id]?.service_tax||0,order_item_price:G.total_price.toString(),deleted:!1}))},de=(G,Te)=>{if(G==="appnt_service_name"){const{appnt_service_name:Ze,appnt_service_id:se,order_item_discount:J,order_unit_item_price:U,item_quantity:ie,order_item_service_tax_percentage:Be}=Te,Se={...z,appnt_service_name:Ze,appnt_service_id:se,order_unit_item_price:U,item_quantity:ie,order_item_discount:J,order_item_service_tax_percentage:Be};K(Se),X(Se)}else G==="appnt_date"&&Te>Ie.dayjs().format("YYYY-MM-DD")&&(O(!0),k||a("Error","Cannot add bill for future appointments. Continue without billing?","Error",5e3)),K(Ze=>({...Ze,[G]:Te}))},Ue=()=>{O(G=>!G)},pe=()=>{ce(G=>!G)},$=(G,Te)=>{K(Ze=>({...Ze,[Te]:G}))};_.useEffect(()=>{X(z)},[z.order_unit_item_price,z.item_quantity,z.order_item_discount,X,z]);const fe=G=>[...G].sort((Te,Ze)=>new Date(Te.appnt_date).getTime()-new Date(Ze.appnt_date).getTime()),H=_.useMemo(()=>[{Header:"Unit Price",accessor:"order_unit_item_price",Cell:({row:G})=>e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-center",children:[e.jsxRuntimeExports.jsx("i",{className:" hx_f-rupee"}),T?.permissions?.edit_service_unit_price?e.jsxRuntimeExports.jsx("input",{type:"text",className:"hfl-flex hfl-w-[120px] hfl-items-center focus:hfl-outline-none",value:G?.original?.order_unit_item_price,onChange:Te=>$(Te.target.value,"order_unit_item_price")}):e.jsxRuntimeExports.jsx("input",{className:"hfl-pointer-events-none hfl-flex hfl-w-[120px] hfl-items-center focus:hfl-outline-none",value:G?.original?.order_unit_item_price})]})},{Header:"Qty",accessor:"item_quantity",Cell:({row:G})=>e.jsxRuntimeExports.jsx("input",{type:"text",className:"hfl-flex hfl-w-[74px] hfl-items-center focus:hfl-outline-none",value:G?.original?.item_quantity,onChange:Te=>$(Te.target.value,"item_quantity")})},{Header:"Discount",accessor:"order_item_discount",Cell:({row:G})=>e.jsxRuntimeExports.jsx("input",{type:"text",className:"hfl-flex hfl-w-[74px] hfl-items-center focus:hfl-outline-none",value:G?.original?.order_item_discount,onChange:Te=>$(Te.target.value,"order_item_discount")})},{Header:"GST in %",accessor:"order_item_service_tax_percentage",Cell:({row:G})=>{const Te=Number(G?.original?.appnt_service_id||"0");return e.jsxRuntimeExports.jsx("input",{className:"hfl-pointer-events-none hfl-flex hfl-w-[120px] hfl-items-center focus:hfl-outline-none",value:N?.[Te]?.service_tax||0,readOnly:!0})}},{Header:"GST In Rs",accessor:"order_item_service_tax",Cell:({row:G})=>e.jsxRuntimeExports.jsx("input",{className:"hfl-pointer-events-none hfl-flex hfl-w-[120px] hfl-items-center",value:G?.original?.order_item_service_tax,readOnly:!0})},{Header:"Net Price",accessor:"order_item_price",Cell:({row:G})=>e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-center hfl-text-Error-500 ",children:[e.jsxRuntimeExports.jsx("i",{className:" hx_f-rupee"}),e.jsxRuntimeExports.jsx("input",{type:"number",className:"hfl-pointer-events-none hfl-flex hfl-w-[120px] hfl-items-center",value:G?.original?.order_item_price,readOnly:!0})]})}],[T?.permissions?.edit_service_unit_price,N]),De=_.useMemo(()=>ee,[ee]),{getTableProps:Me,getTableBodyProps:Le,headerGroups:xt,rows:ht,prepareRow:at}=Qr.useTable({columns:H,data:De}),We=G=>{const Te=[];return G?.headers?.length&&G.headers.map(Ze=>{Te.push(e.jsxRuntimeExports.jsx("th",{...Ze.getHeaderProps(),className:"hfl-rounded hfl-border-1 hfl-border-Gray-200 hfl-bg-Blue_gray-50 hfl-px-2 hfl-py-1 hfl-text-left",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-text-Indigo-600",children:Ze.render("Header")})}))}),Te},it=()=>{const G=[];return ht.map((Te,Ze)=>{at(Te),G.push(e.jsxRuntimeExports.jsx("tr",{id:Ze.toString(),...Te.getRowProps(),className:`${Te?.original?.appnt_status===1?"hfl-bg-Gray-50 hfl-text-Gray-400 hover:hfl-bg-White hover:hfl-text-Gray-500":"hfl-bg-White"} hfl-group hfl-h-9 hfl-w-full hfl-border-t-1 hfl-border-Gray-200`,children:Te.cells.map(se=>e.jsxRuntimeExports.jsx("td",{"data-qa":Ze+1+"-"+se.column.id,...se.getCellProps(),className:"hfl-relative hfl-border-1 hfl-border-Gray-200 hfl-px-2 hfl-text-left",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:`${Te?.original?.appnt_status===1?"hfl-text-Gray-300 group-hover:hfl-text-Gray-500":"hfl-text-Gray-500"}`,children:se.render("Cell")})}))}))}),G},Pt=(G,Te,Ze)=>e.jsxRuntimeExports.jsxs("div",{className:`hfl-flex hfl-w-[60px] hfl-flex-col hfl-items-center hfl-rounded hfl-px-1 hfl-py-2 hfl-text-center ${W===G?"hfl-bg-Primary-50 hfl-text-Primary-600":""} hfl-cursor-pointer`,onClick:()=>D(G),"data-qa":G,children:[e.jsxRuntimeExports.jsx("div",{className:Te}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text sm",children:Ze})]},G),gt=_.useCallback(()=>{D("today"),K(L),P(!0)},[L]),At=_.useCallback(async()=>{w(!0);try{const G=await Gs(W=="today"?Ie.dayjs().format("YYYY-MM-DD"):"all",y?.patientRoleID||"",1,W=="today"?100:10,!1,g);R(G?.appointments?.filter(Te=>Te.appnt_date===Ie.dayjs().format("YYYY-MM-DD"))),G.appointments.length===0&>(),w(!1)}catch{w(!1),console.log("error in getAppointmentsList API Call")}},[gt,W,y?.patientRoleID,w,g]);_.useEffect(()=>{A||At()},[A,At]),_.useEffect(()=>{W==="today"&&At()},[At,W]);const Gt=async()=>{z.appnt_date>Ie.dayjs().format("YYYY-MM-DD")&&(O(!0),k||a("Error","Cannot add bill for future appointments. Continue without billing?","Error",5e3)),await $l(z,k||z.appnt_date>Ie.dayjs().format("YYYY-MM-DD"),a,d,y,h,ue,!1,g)&&P(!1)};return e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-h-[73.55vh] hfl-bg-White",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-gap-4 hfl-border-r-1 hfl-border-Gray-200 hfl-bg-Gray-50 hfl-px-1 hfl-py-2",children:[Pt("today","hx_calendar-add hfl-text-5","Today's Appts"),Pt("all","hx_calendar hfl-text-5","All Appts")]}),W==="today"&&e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-flex-1 hfl-flex-col hfl-items-center hfl-gap-6 hfl-overflow-y-auto",children:I.length<=0||A?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-gap-2 hfl-self-stretch hfl-bg-Gray-100 hfl-p-2",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",className:"hfl-flex-1",children:z.appnt_id.length?"Update Appointment":"New Appointment"}),e.jsxRuntimeExports.jsx("div",{className:"hx_close hfl-flex-shrink-0 hfl-cursor-pointer hfl-text-4",onClick:()=>{P(!1)},"data-qa":"close-new-ppointment"})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-item-center hfl-flex hfl-flex-col hfl-gap-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-[739px] hfl-flex-wrap hfl-content-start hfl-items-start hfl-gap-6",children:[e.jsxRuntimeExports.jsx(p.tj,{label:"Doctor Name",labelSize:"Text sm",labelColor:"hfl-text-Gray-800",input1value:"Dr.",input2value:z.appnt_doctor_name,end_icon:"hx_down hfl-bg-White_20",inputProps:{disabled:!0},suffixInputProps:{placeholder:"Doctor Name"},className:"hfl-relative hfl-w-12 hfl-flex-none hfl-text-ellipsis hfl-bg-Gray-50 hfl-text-Gray-500",suffixClassName:" hfl-w-[270px] hfl-text-ellipsis hfl-bg-White_20",suffixDropdownClassName:"hfl-ml-12",suffixOptions:c?.doctor_list?.map(G=>({label:G.doctor_name,value:G.doctor_name,appnt_doctor_role_id:G.doctor_identifier})),handleSuffixValChange:G=>{de("appnt_doctor_name",G),de("appnt_doctor_role_id","")},onSuffixDropdownClick:G=>{de("appnt_doctor_name",G.label),de("appnt_doctor_role_id",G.appnt_doctor_role_id)}}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-[350px] hfl-flex-col hfl-gap-1.5",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text sm",children:"Date & Time of Appointment"}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-gap-2 ",children:[e.jsxRuntimeExports.jsx(p.ZC,{placeholder:"Today",height:"!hfl-h-[40px]",selectDate:new Date(Ie.dayjs(z.appnt_date).format("DD-MMM-YYYY")),dateVar:G=>{de("appnt_date",Ie.dayjs(G).format("YYYY-MM-DD"))},isborderRequired:!0,minDate:new Date}),e.jsxRuntimeExports.jsx(p.tj,{className:"hfl-w-24",suffixClassName:"hfl-w-10 ",suffixDropdownClassName:"hfl-ml-[96px]",input1value:z?.appnt_time_time||"",input2value:z?.appnt_time_format||"",end_icon:"hx_down",classNamedoubleInput:"hfl-relative",inputProps:{placeholder:"10:00",onBlur:G=>{de("appnt_time_time",G.target.value)}},onlySuffixDropdownItemsAllowed:!0,suffixInputProps:{placeholder:"AM"},suffixOptions:[{label:"AM",value:"AM"},{label:"PM",value:"PM"}],onSuffixDropdownClick:G=>{de("appnt_time_format",G.value)}})]})]}),z.appnt_id.length>1&&z.order_item_id.length>1?e.jsxRuntimeExports.jsx(p.tj,{label:"Service",labelSize:"Text sm",labelColor:"hfl-text-Gray-800",end_icon:"hfl-bg-White_20",input2value:z.appnt_service_name,inputProps:{disabled:!0},widthSufixDrpdwn:"hfl-w-[350px]",suffixInputProps:{placeholder:"Service Name",disabled:!0},className:"hfl-hidden hfl-w-12 hfl-text-ellipsis hfl-bg-Gray-50 hfl-text-Gray-500 ",classNamedoubleInput:"hfl-relative",suffixClassName:" hfl-border-l-0 hfl-w-[318px] hfl-text-ellipsis hfl-bg-White_20"}):e.jsxRuntimeExports.jsx(p.tj,{label:"Service",labelSize:"Text sm",labelColor:"hfl-text-Gray-800",end_icon:"hx_down hfl-bg-White_20",input2value:z.appnt_service_name,inputProps:{disabled:!1},widthSufixDrpdwn:"hfl-w-[350px]",suffixInputProps:{placeholder:"Service Name",onClick:async()=>{n?.service_list?.length||V()}},className:"hfl-hidden hfl-w-12 hfl-text-ellipsis hfl-bg-Gray-50 hfl-text-Gray-500 ",classNamedoubleInput:"hfl-relative",suffixClassName:"hfl-border-l-0 hfl-w-[318px] hfl-text-ellipsis hfl-bg-White_20",suffixOptions:n?.service_list?.filter(G=>G.service_category==="Doctor consultation")?.map(G=>({label:G.service_name,value:G.service_name,appnt_service_id:G.service_identifier,order_unit_item_price:G.price,item_quantity:1,order_item_discount:G.order_item_discount||0,order_item_service_tax_percentage:G.service_tax,appnt_service_name:G.service_name})),handleSuffixValChange:G=>{de("appnt_service_name",{appnt_service_name:G})},onSuffixDropdownClick:G=>{de("appnt_service_name",G)}}),e.jsxRuntimeExports.jsx(p.Ap,{value:{label:Br.find(G=>G.value==Number(z.appnt_duration))?.label||"",value:z.appnt_duration},label:"Duration",className:"hfl-w-[350px] hfl-text-Gray-800",onChange:G=>{de("appnt_duration",G.value)},options:Br,"data-qa":"time picker"}),e.jsxRuntimeExports.jsx(p.Ap,{value:{label:vl.find(G=>G.value==z?.appnt_status)?.text||""},label:"Booking Status",className:"hfl-w-[350px] hfl-text-Gray-800",onChange:G=>{de("appnt_status",G.value)},options:vl.map(G=>({label:G.text,value:G.value})),"data-qa":"click-status"}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-[350px] hfl-flex-col hfl-gap-1.5",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text sm",children:"Type"}),e.jsxRuntimeExports.jsx(p.ju,{options:[{start_icon:"hx_inperson hfl-text-3",label:"In-Person",value:"inperson"}],disabled:!1,value:"inperson","data-qa":"data-type"})]}),g.window_var?.partner_service_enabled==="1"&&d?.insurance_details?.policy_id?.length&&e.jsxRuntimeExports.jsx(p.Oi,{size:"md",disabled:!1,isMarked:ue,text:"Partner Enabled",onClick:pe,"data-qa":"skip-billing"}),!+z?.order_item_id&&e.jsxRuntimeExports.jsx(p.Oi,{size:"md",disabled:!1,isMarked:k,text:"Skip Billing",onClick:Ue,"data-qa":"skip-billing"})]}),!k||+z?.order_item_id?e.jsxRuntimeExports.jsx("div",{className:`${+z?.appnt_id&&+z?.order_item_id?"hfl-pointer-events-none":""}`,children:e.jsxRuntimeExports.jsxs("table",{...Me(),className:"hfl-table-fixed hfl-rounded-lg hfl-border-1 hfl-border-Gray-200 hfl-pb-8 hfl-shadow-md",children:[e.jsxRuntimeExports.jsx("thead",{children:xt.map(G=>e.jsxRuntimeExports.jsx("tr",{...G.getHeaderGroupProps(),className:"hfl-h-10 hfl-rounded-lg hfl-bg-Blue_gray-50",children:We(G)}))}),e.jsxRuntimeExports.jsx("tbody",{...Le(),className:"hfl-rounded-lg hfl-border-1 hfl-border-Gray-200",children:it()})]})}):"",e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-justify-center hfl-gap-4",children:[e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Tertiary",size:"md",textField:"Cancel",icon:"No",className:"hfl-w-[150px] hfl-items-center hfl-justify-center hfl-border hfl-border-Gray-300 hfl-bg-White hfl-text-Gray-700 hover:hfl-bg-Gray-100",onClick:()=>{P(!1)},"data-qa":"cancel"}),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Primary",size:"md",textField:z.appnt_id.length?"Update Appointment":"Book Appointment",icon:"No",onClick:Gt,className:"hfl-w-[150px] hfl-items-center hfl-justify-center hfl-bg-Primary-600 hfl-text-White_20 hover:hfl-bg-Primary-800","data-qa":"book-appointment"})]})]})]}):e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-full hfl-flex-col",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-full hfl-items-center hfl-justify-between hfl-px-3 hfl-py-2",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",children:"Today’s Appointments"}),e.jsxRuntimeExports.jsx(p.Ku,{"data-qa":"new-appointment",hierarchy:"Primary",size:"md",className:"text",icon:"Left",iconFile:"hx_add-circle",textField:"New Appointment",onClick:gt})]}),e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-px-4 ","data-qa":"appointment-table",children:e.jsxRuntimeExports.jsx(Rl,{today:!0,leftNav:W,appointments:fe(I),handleAppointData:ve})})]})}),W==="all"&&e.jsxRuntimeExports.jsx(xa,{sortAppointments:fe,handleAddNewAppnt:gt,handleAppointData:ve})]})},va=({columns:a,data:d})=>{const{getTableProps:c,getTableBodyProps:n,headerGroups:y,rows:w,prepareRow:l}=Qr.useTable({columns:a,data:d}),T=h=>{const V=[];return h?.headers?.length&&h.headers.map(g=>{V.push(e.jsxRuntimeExports.jsx("th",{...g.getHeaderProps(),className:"hfl-rounded hfl-border-1 hfl-border-Gray-200 hfl-bg-Blue_gray-50 hfl-px-2 hfl-py-1 hfl-text-left",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-text-Gray-600",children:g.render("Header")})}))}),V},N=()=>{const h=[];return w.map((V,g)=>{l(V),h.push(e.jsxRuntimeExports.jsx("tr",{id:g.toString(),...V.getRowProps(),className:`${V.original.appnt_status===1?"hfl-bg-Gray-50 hfl-text-Gray-400 hover:hfl-bg-White hover:hfl-text-Gray-500":"hfl-bg-White"} hfl-group hfl-border-t-1 hfl-border-Gray-200`,children:V.cells.map((k,O)=>e.jsxRuntimeExports.jsx("td",{"data-qa":g+1+"-"+(O+1),...k.getCellProps(),className:"hfl-relative hfl-border-1 hfl-border-Gray-200 hfl-px-2 hfl-text-left",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:`hfl-text-[13px] ${V.original.appnt_status===1?"hfl-text-Gray-300 group-hover:hfl-text-Gray-500":"hfl-text-Gray-500"}`,children:k.render("Cell")})}))}))}),h};return e.jsxRuntimeExports.jsx("div",{className:"hfl-max-h-[55vh] hfl-overflow-y-auto xxs:max-md:hfl-overflow-x-auto hfl-overflow-x-hidden","data-qa":"past-visit-table",children:e.jsxRuntimeExports.jsxs("table",{...c(),className:"hfl-table-fixed hfl-rounded-lg hfl-border-1 hfl-border-Gray-200 hfl-pb-8 hfl-shadow-md",children:[e.jsxRuntimeExports.jsx("thead",{children:y.map(h=>e.jsxRuntimeExports.jsx("tr",{...h.getHeaderGroupProps(),className:"hfl-h-10 hfl-rounded-lg hfl-bg-Blue_gray-50 ",children:T(h)}))}),e.jsxRuntimeExports.jsx("tbody",{...n(),className:"hfl-rounded-",children:N()})]})})},ya="data:image/svg+xml,%3csvg%20width='87'%20height='86'%20viewBox='0%200%2087%2086'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cellipse%20opacity='0.1'%20cx='43.5'%20cy='83.42'%20rx='43.5'%20ry='2.58'%20fill='%234E5BA6'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M17.179%2014.1224C16.5958%2013.0118%2015.2122%2012.5787%2014.0887%2013.1552C12.9651%2013.7317%2012.5271%2015.0994%2013.1102%2016.21L15.2825%2020.347C15.8657%2021.4576%2017.2493%2021.8906%2018.3729%2021.3141C19.4964%2020.7377%2019.9345%2019.37%2019.3513%2018.2593L17.179%2014.1224ZM14.8903%2014.6818C15.1609%2014.543%2015.4942%2014.6473%2015.6346%2014.9148L17.8069%2019.0517C17.9474%2019.3193%2017.8419%2019.6487%2017.5712%2019.7875C17.3006%2019.9264%2016.9674%2019.8221%2016.8269%2019.5546L14.6546%2015.4176C14.5141%2015.1501%2014.6196%2014.8207%2014.8903%2014.6818ZM22.9352%2024.0112C20.0523%2024.0112%2017.7152%2026.3214%2017.7152%2029.1712V65.3801C17.7152%2068.2299%2020.0523%2070.5401%2022.9352%2070.5401H57.7352C60.6181%2070.5401%2062.9552%2068.2299%2062.9552%2065.3801V59.7953C59.3146%2057.7135%2056.8652%2053.8225%2056.8652%2049.366C56.8652%2044.9095%2059.3146%2041.0186%2062.9552%2038.9368V29.1712C62.9552%2026.3214%2060.6181%2024.0112%2057.7352%2024.0112H54.1652V25.3157C54.1652%2027.6905%2052.2177%2029.6157%2049.8152%2029.6157H32.5952C30.1928%2029.6157%2028.2452%2027.6905%2028.2452%2025.3157V24.0112H22.9352ZM64.6952%2038.1166V29.1712C64.6952%2025.3714%2061.5791%2022.2912%2057.7352%2022.2912H46.2996C45.7087%2020.0557%2043.6519%2018.406%2041.2052%2018.406C38.7586%2018.406%2036.7018%2020.0557%2036.1109%2022.2912H22.9352C19.0913%2022.2912%2015.9752%2025.3714%2015.9752%2029.1712V65.3801C15.9752%2069.1798%2019.0913%2072.2601%2022.9352%2072.2601H57.7352C61.5791%2072.2601%2064.6952%2069.1798%2064.6952%2065.3801V60.6155C66.0461%2061.1262%2067.5126%2061.406%2069.0452%2061.406C75.772%2061.406%2081.2252%2056.0155%2081.2252%2049.366C81.2252%2042.7165%2075.772%2037.326%2069.0452%2037.326C67.5126%2037.326%2066.0461%2037.6058%2064.6952%2038.1166ZM6.33244%2020.881C6.89862%2019.7618%208.27544%2019.3082%209.40766%2019.8679L13.625%2021.9526C14.7572%2022.5123%2015.2161%2023.8733%2014.6499%2024.9925C14.0837%2026.1117%2012.7069%2026.5652%2011.5747%2026.0056L7.35734%2023.9209C6.22512%2023.3612%205.76626%2022.0002%206.33244%2020.881ZM8.62943%2021.4063C8.35671%2021.2715%208.02508%2021.3807%207.8887%2021.6503C7.75233%2021.9199%207.86286%2022.2477%208.13557%2022.3825L12.3529%2024.4672C12.6256%2024.602%2012.9572%2024.4928%2013.0936%2024.2232C13.23%2023.9536%2013.1195%2023.6258%2012.8468%2023.491L8.62943%2021.4063ZM36.2851%2041.3145C36.2851%2040.127%2037.2589%2039.1645%2038.4601%2039.1645H53.2501C54.4513%2039.1645%2055.4251%2040.127%2055.4251%2041.3145C55.4251%2042.5019%2054.4513%2043.4645%2053.2501%2043.4645H38.4601C37.2589%2043.4645%2036.2851%2042.5019%2036.2851%2041.3145ZM38.4601%2049.2325C37.2589%2049.2325%2036.2851%2050.1951%2036.2851%2051.3825C36.2851%2052.5699%2037.2589%2053.5325%2038.4601%2053.5325H53.2501C54.4513%2053.5325%2055.4251%2052.5699%2055.4251%2051.3825C55.4251%2050.1951%2054.4513%2049.2325%2053.2501%2049.2325H38.4601ZM38.0251%2051.3825C38.0251%2051.145%2038.2199%2050.9525%2038.4601%2050.9525H53.2501C53.4903%2050.9525%2053.6851%2051.145%2053.6851%2051.3825C53.6851%2051.62%2053.4903%2051.8125%2053.2501%2051.8125H38.4601C38.2199%2051.8125%2038.0251%2051.62%2038.0251%2051.3825ZM36.2851%2061.9099C36.2851%2060.7225%2037.2589%2059.7599%2038.4601%2059.7599H53.2501C54.4513%2059.7599%2055.4251%2060.7225%2055.4251%2061.9099C55.4251%2063.0974%2054.4513%2064.0599%2053.2501%2064.0599H38.4601C37.2589%2064.0599%2036.2851%2063.0974%2036.2851%2061.9099ZM38.4601%2061.4799C38.2199%2061.4799%2038.0251%2061.6725%2038.0251%2061.9099C38.0251%2062.1474%2038.2199%2062.3399%2038.4601%2062.3399H53.2501C53.4903%2062.3399%2053.6851%2062.1474%2053.6851%2061.9099C53.6851%2061.6725%2053.4903%2061.4799%2053.2501%2061.4799H38.4601ZM26.5647%2040.5435C26.5647%2039.1186%2027.7333%2037.9635%2029.1747%2037.9635H30.5547C31.9962%2037.9635%2033.1647%2039.1186%2033.1647%2040.5435V41.9076C33.1647%2043.3325%2031.9962%2044.4876%2030.5547%2044.4876H29.1747C27.7333%2044.4876%2026.5647%2043.3325%2026.5647%2041.9076V40.5435ZM29.1747%2048.0315C27.7333%2048.0315%2026.5647%2049.1866%2026.5647%2050.6115V51.9757C26.5647%2053.4006%2027.7333%2054.5557%2029.1747%2054.5557H30.5547C31.9962%2054.5557%2033.1647%2053.4006%2033.1647%2051.9757V50.6115C33.1647%2049.1866%2031.9962%2048.0315%2030.5547%2048.0315H29.1747ZM28.3047%2050.6115C28.3047%2050.1366%2028.6942%2049.7515%2029.1747%2049.7515H30.5547C31.0352%2049.7515%2031.4247%2050.1366%2031.4247%2050.6115V51.9757C31.4247%2052.4506%2031.0352%2052.8357%2030.5547%2052.8357H29.1747C28.6942%2052.8357%2028.3047%2052.4506%2028.3047%2051.9757V50.6115ZM26.5647%2061.139C26.5647%2059.7141%2027.7333%2058.559%2029.1747%2058.559H30.5547C31.9962%2058.559%2033.1647%2059.7141%2033.1647%2061.139V62.5031C33.1647%2063.928%2031.9962%2065.0831%2030.5547%2065.0831H29.1747C27.7333%2065.0831%2026.5647%2063.928%2026.5647%2062.5031V61.139ZM29.1747%2060.279C28.6942%2060.279%2028.3047%2060.664%2028.3047%2061.139V62.5031C28.3047%2062.9781%2028.6942%2063.3631%2029.1747%2063.3631H30.5547C31.0352%2063.3631%2031.4247%2062.9781%2031.4247%2062.5031V61.139C31.4247%2060.664%2031.0352%2060.279%2030.5547%2060.279H29.1747ZM58.6052%2049.366C58.6052%2043.6665%2063.2793%2039.046%2069.0452%2039.046C74.811%2039.046%2079.4852%2043.6665%2079.4852%2049.366C79.4852%2055.0656%2074.811%2059.686%2069.0452%2059.686C63.2793%2059.686%2058.6052%2055.0656%2058.6052%2049.366ZM66.8702%2043.776C66.8702%2042.5886%2067.844%2041.626%2069.0452%2041.626C70.2464%2041.626%2071.2202%2042.5886%2071.2202%2043.776V48.936C71.2202%2050.1235%2070.2464%2051.086%2069.0452%2051.086C67.844%2051.086%2066.8702%2050.1235%2066.8702%2048.936V43.776ZM69.0452%2043.346C68.8049%2043.346%2068.6102%2043.5386%2068.6102%2043.776V48.936C68.6102%2049.1735%2068.8049%2049.366%2069.0452%2049.366C69.2854%2049.366%2069.4802%2049.1735%2069.4802%2048.936V43.776C69.4802%2043.5386%2069.2854%2043.346%2069.0452%2043.346ZM69.0452%2057.106C67.844%2057.106%2066.8702%2056.1435%2066.8702%2054.956C66.8702%2053.7686%2067.844%2052.806%2069.0452%2052.806C70.2464%2052.806%2071.2202%2053.7686%2071.2202%2054.956C71.2202%2056.1435%2070.2464%2057.106%2069.0452%2057.106ZM68.6102%2054.956C68.6102%2055.1935%2068.8049%2055.386%2069.0452%2055.386C69.2854%2055.386%2069.4802%2055.1935%2069.4802%2054.956C69.4802%2054.7186%2069.2854%2054.526%2069.0452%2054.526C68.8049%2054.526%2068.6102%2054.7186%2068.6102%2054.956Z'%20fill='%23AFB5D9'/%3e%3c/svg%3e",_a=({closePrintModal:a,setLatestMetaData:d,setInvestigationDropdown:c,setCustomTranslations:n,getVisitpadPreferenceHandler:y,updateVPPrefUsingDocPref:w})=>{const{patientIDs:l,setShowPrintModal:T,setEndConsultationClicked:N,preferences:h,variable:V,docPreference:g}=_.useContext(It),k=_.useMemo(()=>window.is_junior_doc==="1",[]),O=g?.permissions?.can_junior_print,[W,D]=_.useReducer((ee,ve)=>({...ee,...ve}),{currentPage:1,totalRecord:0,pastVisits:[],isVisitLoading:!1}),{pastVisits:A,currentPage:P,isVisitLoading:I,totalRecord:R}=W,Q=_.useCallback(async ee=>{if(l?.patientRoleID)try{D({isVisitLoading:!0});const ve=await bn(ln,ee,l.patientRoleID,V),de=ve?.visits??[];D({currentPage:ee,pastVisits:ee===1?de:[...A,...de],isVisitLoading:!1,totalRecord:+ve.total_visit_count})}catch(ve){console.error("Failed to fetch visits:",ve),D({isVisitLoading:!1})}},[l?.patientRoleID]),B=_.useCallback(async(ee,ve,de=!0)=>{if(l?.patientRoleID){a(),D({isVisitLoading:!0});try{const pe=(await vn(ee.original.visit_date,l.patientRoleID,ee.original.visit_id,V))?.visits?.[0];if(!pe)throw new Error("Visit details not found.");let $=null;const{doctor_id:fe="",doctor_role_id:H=""}=pe;V.window_var.doctor_role_id_for_seg!==H?$=await y({doc_id:fe,doc_rid:H}):h&&await w(h,h.printDefaultPrefIndex,H,!1),d(pe.latest_visit_metadata||{}),T({printDataFrom:"patient_popup",visible:!0,whichPreview:"offlinePrint",printData:"",visitId:pe.visit_id,visit_date:pe.visit_date,visit_number:R-ee.index,currentPrintTime:0,printType:"visit",details:pe,visitpadPref:$,appointmentInfo:{appnt_id:ee.original.appnt_id||"",appnt_type:ee.original.appnt_type||""},trackEventHandler:()=>{}}),N(de)}catch(Ue){console.error("Failed to prepare print data:",Ue)}finally{D({isVisitLoading:!1})}}},[a,y,V,l.patientRoleID,h,N,d,T,w,R]),L=_.useCallback(async()=>{try{const ee=await Fn(V),ve={};ee.transalation_records.forEach(de=>{ve[de.language]=de}),n(ve)}catch(ee){console.error("Failed to get custom translations:",ee)}},[n,V]),z=_.useCallback(async()=>{try{const ee=await Hn(V);if(ee?.test_ranges){const ve=ee.test_ranges.map(de=>({test_id:de.test_id,test_names:de.test_names,test_range_rule:de.test_range_rule,loinc_code:de?.loinc_code||"",test_range_text:de.test_range_text,test_units:de.test_units,value:de.test_names}));c(ve)}}catch(ee){console.error("Failed to get investigation test names:",ee)}},[c,V]);_.useEffect(()=>{Q(1),L(),z()},[L,z]);const K=_.useMemo(()=>({visit_date:"100px",doctor_name:"350px",appnt_type:"100px",service_name:"150px",view:"250px"}),[]),ue=_.useMemo(()=>[{Header:"Date",accessor:"visit_date",Cell:({row:ee})=>e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text [13px]",className:`hfl-text-Gray-600 hfl-w-[${K.visit_date}]`,children:ee.original.visit_date?Ie.dayjs(ee.original.visit_date).format("DD-MMM-YYYY"):"N/A"})},{Header:"Doctor",accessor:"doctor_name",Cell:({row:ee})=>e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text [13px]",className:`hfl-text-Gray-600 hfl-w-[${K.doctor_name}]`,children:["Dr. ",ee.original.doctor_name||"N/A"]})},{Header:"Type",accessor:"appnt_type",Cell:({row:ee})=>e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text [13px]",className:`hfl-text-Gray-600 hfl-w-[${K.appnt_type}]`,children:ee.original.appnt_type||"N/A"})},{Header:"Service",accessor:"service_name",Cell:({row:ee})=>e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text [13px]",className:`hfl-text-Gray-600 hfl-w-[${K.service_name}]`,children:ee.original.service_name||"N/A"})},{Header:"Prescription",id:"view",Cell:({row:ee})=>e.jsxRuntimeExports.jsxs("div",{className:"hfl-mx-2 hfl-my-1 hfl-flex hfl-gap-2",children:[e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Secondary-Grey",size:"sm",textField:"Print",iconFile:"hx_print",icon:"Left",onClick:()=>B(ee,"VISIT_PRINT",!1),className:"hfl-w-[74px]","data-qa":"to-print",disabled:k&&!O}),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Secondary-Grey",size:"sm",textField:"Share",iconFile:"hx_share",icon:"Left",onClick:()=>B(ee,"VISIT_SHARE",!0),className:"hfl-w-[74px]","data-qa":"to-share",disabled:k&&!O})]})}],[K,B,k,O]),ce=_.useMemo(()=>A?A.filter(ee=>!(ee.junior_doctor_role_ids||[]).includes(String(ee.last_modified_by_role_id))):[],[A]),X=async()=>{if(!l?.patientRoleID)return;let ee="../ipdv2/viewPatientsCase";if(V.window_var?.enable_ipd_v2!=="1"){ee="../ipd/viewPatientsCase.php";try{const ve=await wn(V,l.patientRoleID),{status:de=0,case_id:Ue=0}=ve,pe=new Date().toISOString().slice(0,10);ee=de&&Ue?`../ipd/viewPatientRecords.php?pid=${l.patientRoleID}&case_id=${Ue}`:`../ipd/viewAddPatientsCase.php?pid=${l.patientRoleID}&date=${pe}`}catch(ve){console.error("Failed to get IPD Case by PID:",ve)}}window.open(ee,"_blank")};return e.jsxRuntimeExports.jsxs("div",{className:"hfl-mx-[12%] hfl-h-[69vh] hfl-overflow-auto hfl-py-[20px]",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-between hfl-pb-2",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text md",className:"hfl-text-Gray-600",children:"Past Visits"}),V.window_var.ipd_module==="1"&&e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Primary",size:"sm",textField:"Go to IPD","data-qa":"go-to-ipd",className:"hfl-justify-center hfl-bg-Primary-600 hfl-text-White hover:hfl-bg-Primary-700",onClick:()=>{X()}})]}),ce?.length>0&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(va,{columns:ue,data:ce,columnWidth:K}),e.jsxRuntimeExports.jsx(es,{currentPage:P,totalRecord:R,handleLoadMore:()=>Q(P+1),isLoading:I,currentTotal:ce.length})]}),ce.length===0&&!I&&e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-h-[calc(100%_-_80px)] hfl-flex-col hfl-items-center hfl-justify-center hfl-gap-4",children:[e.jsxRuntimeExports.jsx("img",{className:"hfl-w-[80px] hfl-text-Blue_gray-500",src:ya,alt:"empty-bills"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text md",className:"hfl-items-center hfl-justify-center hfl-text-Gray-400",children:"There are no visits for the patient"})]})]})},ba=({fontBaseUrl:a})=>(ae.Font.register({family:"notoKannada",src:`${a}/fonts/NotoSansKannada.ttf`}),ae.Font.register({family:"notoKannadaBold",src:`${a}/fonts/NotoSansKannada-Bold.ttf`}),ae.Font.register({family:"notoHindi",src:`${a}/fonts/NotoSansHindi.ttf`}),ae.Font.register({family:"notoHindiBold",src:`${a}/fonts/NotoSansHindi-Bold.ttf`}),ae.Font.register({family:"notoUrdu",src:`${a}/fonts/Jameel-Nastaleeq.ttf`}),ae.Font.register({family:"notoUrduBold",src:`${a}/fonts/Jameel-Nastaleeq.ttf`}),ae.Font.register({family:"notoArabic",src:`${a}/fonts/NotoSansArabic.ttf`}),ae.Font.register({family:"notoArabicBold",src:`${a}/fonts/NotoSansArabic-Bold.ttf`}),ae.Font.register({family:"notoGujarati",src:`${a}/fonts/NotoSerifGujarati-Regular.ttf`}),ae.Font.register({family:"notoGujaratiBold",src:`${a}/fonts/NotoSerifGujarati-Bold.ttf`}),ae.Font.register({family:"notoMalayalam",src:`${a}/fonts/AnekMalayalam-Regular.ttf`}),ae.Font.register({family:"notoMalayalamBold",src:`${a}/fonts/AnekMalayalam-Bold.ttf`}),ae.Font.register({family:"notoOriya",src:`${a}/fonts/NotoSansOriya.ttf`}),ae.Font.register({family:"notoOriyaBold",src:`${a}/fonts/NotoSansOriya-Bold.ttf`}),ae.Font.register({family:"notoPunjabi",src:`${a}/fonts/MuktaMaheePunjabi-Regular.ttf`}),ae.Font.register({family:"notoPunjabiBold",src:`${a}/fonts/MuktaMaheePunjabi-Bold.ttf`}),ae.Font.register({family:"notoTamil",src:`${a}/fonts/NotoSansTamil.ttf`}),ae.Font.register({family:"notoTamilBold",src:`${a}/fonts/NotoSansTamil-Bold.ttf`}),ae.Font.register({family:"notoTelugu",src:`${a}/fonts/Noto-Sans-Telugu-Regular.ttf`}),ae.Font.register({family:"notoTeluguBold",src:`${a}/fonts/Noto-Sans-Telugu-Bold.ttf`}),ae.Font.register({family:"notoBengali",src:`${a}/fonts/NotoSerifBengali-Regular.ttf`}),ae.Font.register({family:"notoBengaliBold",src:`${a}/fonts/NotoSerifBengali-Bold.ttf`}),ae.Font.register({family:"Verdana",src:`${a}/fonts/Verdana.ttf`}),ae.Font.register({family:"Verdana-Bold",src:`${a}/fonts/Verdana-Bold.ttf`}),ae.Font.register({family:"Verdana-Italic",src:`${a}/fonts/Verdana-Italic.ttf`}),ae.Font.register({family:"Verdana-BoldItalic",src:`${a}/fonts/Verdana-Bold-Italic.ttf`}),ae.Font.register({family:"Arial",src:`${a}/fonts/Arial.ttf`}),ae.Font.register({family:"Arial-Bold",src:`${a}/fonts/Arial-Bold.ttf`}),ae.Font.register({family:"Arial-Italic",src:`${a}/fonts/Arial-Italic.ttf`}),ae.Font.register({family:"Arial-BoldItalic",src:`${a}/fonts/Arial-Bold-Italic.ttf`}),ae.Font.register({family:"Rupee",src:`${a}/fonts/Roboto-Regular.ttf`}),e.jsxRuntimeExports.jsx(ae.PDFViewer,{style:{display:"none"},children:e.jsxRuntimeExports.jsx(ae.Document,{children:e.jsxRuntimeExports.jsxs(ae.Page,{children:[e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoKannada"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoHindi"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoUrdu"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoArabic"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoGujarati"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoMalayalam"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoOriya"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoPunjabi"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoTamil"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoTelugu"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoBengali"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoKannadaBold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoHindiBold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoUrduBold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoArabicBold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoGujaratiBold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoMalayalamBold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoOriyaBold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoPunjabiBold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoTamilBold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoTeluguBold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoBengaliBold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"Verdana"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"Verdana-Bold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"Verdana-Italic"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"Verdana-BoldItalic"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"Arial"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"Arial-Bold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"Arial-Italic"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"Arial-BoldItalic"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"Rupee"},children:"load font"})]})})})),ja=a=>{const{billsData:d,handleRowClick:c,handleRightSegment:n,getRowIndices:y,getRefundAmt:w,closePrintModal:l}=a,{patientIDs:T,patientDetails:N,billPreferences:h,setShowPrintModal:V,showPrintModal:g,variable:k}=_.useContext(It)||{},O=({label:R,className:Q})=>e.jsxRuntimeExports.jsx("th",{className:Q,children:e.jsxRuntimeExports.jsxs(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-text-Gray-600",children:[" ",R]})}),W=R=>{switch(R){case St[0]:return"hx_service-appointment-filled hfl-text-Primary-500";case St[1]:return"hx_service-other-filled hfl-text-Pink-500";case St[2]:return"hx_service-lab-filled hfl-text-Purple-600";default:return"hx_service-other-filled hfl-text-Pink-500"}},D=R=>{switch(R){case St[0]:return"Consultation";case St[1]:return"Other";case St[2]:return"Lab";default:return"Other"}},A=async(R,Q,B)=>{if(g?.visible&&l(),R?.order_id){const L=await Xl(R?.order_id,T?.patientRoleID||"",k),z={finalAmount:R.net_bill_amount,billedAmount:R.order_total,gstAmount:R.order_service_tax,cgstAmount:(+R.order_service_tax/2).toFixed(2),sgstAmount:(+R.order_service_tax/2).toFixed(2),discountAmount:R.order_item_sum_discount,receivedAmount:R.order_paid_amount,refundAmount:R.refund_amount,balanceAmount:R.balance_amount,paymentMode:L?.paymentModes.length?L?.paymentModes.join(", "):"",paymentStatus:parseInt(R?.order_paid_amount||"0")-parseInt(R?.refund_amount||"0")===0?"red":parseInt(R?.balance_amount||"0")===0?"green":"yellow"},ue=[N?.age&&typeof N?.age=="number"?`${N?.age}y`:N?.org_person_dob?hr(N?.org_person_dob):"",Jr[N?.gender]??"",N?.blood_group].filter(ce=>ce).join(", ");V({printDataFrom:"patient_popup",visible:!0,whichPreview:Q,printData:"",visitId:"",visit_date:"",visit_number:1,currentPrintTime:new Date().getTime(),printType:"bill",details:{preferences:{...h?.print?.bill,...h?.org_details,...h?.branch_details},billSummaryDetails:z,billServiceDetails:R?.order_items?.map(ce=>({serviceName:ce.service_name,price:ce.order_unit_item_price,gst:Math.floor(+ce.order_item_service_tax),discount:ce.order_item_discount,netPrice:ce.net_amount,itemQty:ce.item_quantity})),billPatientDetails:{name:ar(N?.name)+(ue?` (${ue}) `:""),billDate:Ie.dayjs(R?.order_date).format("DD-MMM-YYYY"),mobileNumber:N?.phone_number,email:N?.email,billNumber:R.order_id_str,patientId:N?.org_person_bid_str,patientIdForEmail:T?.patientRoleID,billStatus:parseInt(R?.balance_amount||"0")===0?"PAID":"UNPAID",address:[N?.address??"",N?.city??"",N?.pincode??""].filter(ce=>ce).join(", "),referredBy:L?.lab_owner_name?ar(L?.lab_owner_name):N?.ref_doc_name?ar(N?.ref_doc_name):"--"},showPrintPreviewForBill:B,isWholeBill:!1,payloadDataforEmail:{orderDate:"",orderNumber:R?.order_id}},trackEventHandler:()=>{}})}},P={table:"hfl-table-fixed hfl-rounded-lg hfl-shadow-md hfl-border-Gray-200 hfl-border-1 hfl-pb-8 ",th:"hfl-bg-Blue_gray-50",td:"hfl-px-2 hfl-h-[36px] hfl-align-top hfl-border-Gray-200 hfl-py-1.5 hfl-border-1 hfl-truncate hfl-text-Gray-500",td_without_truncate:"hfl-px-2 hfl-h-[36px] hfl-align-top hfl-border-Gray-200 hfl-py-1.5 hfl-border-1 hfl-text-Gray-500"},I=[{label:"Date",className:"focus:hfl-outline-none hfl-items-start hfl-w-[120px] hfl-border-Gray-200 hfl-border-1"},{label:"#Bill",className:"focus:hfl-outline-none hfl-items-start hfl-w-[90px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Department",className:"focus:hfl-outline-none hfl-items-start hfl-w-[106px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Paid",className:"focus:hfl-outline-none hfl-items-start hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Due",className:"focus:hfl-outline-none hfl-items-start hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Billed",className:"focus:hfl-outline-none hfl-items-start hfl-truncate hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Discount",className:"focus:hfl-outline-none hfl-items-start hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Refund",className:"focus:hfl-outline-none hfl-items-start hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Service",className:"focus:hfl-outline-none hfl-items-center hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Price",className:"focus:hfl-outline-none hfl-items-center hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"GST",className:"focus:hfl-outline-none hfl-items-center hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"",className:"focus:hfl-outline-none hfl-items-center hfl-w-[36px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"}];return e.jsxRuntimeExports.jsx("div",{"data-qa":"bills-table",children:d.length>0&&e.jsxRuntimeExports.jsxs("table",{className:`${P.table} `,children:[e.jsxRuntimeExports.jsx("thead",{className:`${P.th}`,children:e.jsxRuntimeExports.jsx("tr",{children:I.map((R,Q)=>e.jsxRuntimeExports.jsx(O,{label:R.label,className:R.className},Q))})}),e.jsxRuntimeExports.jsx("tbody",{children:d.length>0&&d.map((R,Q)=>e.jsxRuntimeExports.jsx(_.Fragment,{children:R.order_items.map((B,L)=>e.jsxRuntimeExports.jsxs("tr",{className:"hfl-border-1",children:[L===0&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("td",{rowSpan:R.order_items.length,className:`${P.td}`,children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:`${Ie.dayjs(R.order_date).format("DD-MMM-YY")===Ie.dayjs(new Date).format("DD-MMM-YY")?"hfl-w-[80px] hfl-bg-Success-25 hfl-px-1 hfl-text-Success-500":""}`,children:Ie.dayjs(R.order_date).format("DD-MMM-YY")})}),e.jsxRuntimeExports.jsx("td",{rowSpan:R.order_items.length,className:`${P.td} hfl-w-[70px]`,children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",children:R.order_id_str})}),e.jsxRuntimeExports.jsx("td",{rowSpan:R.order_items.length,className:`${P.td} hfl-w-[70px]`,children:e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center",children:[e.jsxRuntimeExports.jsx("i",{className:` hfl-flex ${W(R.service_category)}`}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-truncate",children:[" ",D(R.service_category)]})]})}),e.jsxRuntimeExports.jsx("td",{rowSpan:R.order_items.length,className:`${P.td} hfl-w-[70px]`,children:e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",children:["₹ ",parseInt(R.order_paid_amount)-parseInt(R.refund_amount)]})})}),e.jsxRuntimeExports.jsx("td",{rowSpan:R.order_items.length,className:`${P.td} hfl-w-[70px]`,children:e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm","data-qa":Q+1+"-due-amount",children:["₹ ",R.balance_amount]})})}),e.jsxRuntimeExports.jsx("td",{rowSpan:R.order_items.length,className:`${P.td} hfl-w-[84px]`,children:e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-between",children:[e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:`${R.order_paid_amount===void 0||R.refund_amount===void 0||R.balance_amount===void 0||parseInt(R.order_paid_amount)-parseInt(R.refund_amount)===0?"hfl-text-Error-500":parseInt(R.balance_amount)===0?"hfl-text-Success-500":"hfl-text-Warning-500"} hfl-cursor-pointer`,onClick:()=>{c(R)},"data-qa":Q+1+"-total-bill",children:["₹ ",R.net_bill_amount]}),e.jsxRuntimeExports.jsx("i",{className:" hx_print-filled hfl-cursor-pointer hfl-text-2 hfl-text-Gray-500",onClick:()=>A(R,"billPrintPreview",!1),"data-qa":Q+1+"-print-bill"})]})}),e.jsxRuntimeExports.jsx("td",{rowSpan:R.order_items.length,className:`${P.td} hfl-w-[84px]`,children:e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",children:["₹ ",parseInt(R.order_discount)+parseInt(R.order_item_sum_discount)]})})}),e.jsxRuntimeExports.jsx("td",{rowSpan:R.order_items.length,className:`${P.td} hfl-max-w-[70px]`,children:e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",children:["₹ ",R.refund_amount]})})})]}),e.jsxRuntimeExports.jsx("td",{className:`${P.td} hfl-w-8 hfl-max-w-[96px]`,title:B.service_name,children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-truncate",children:B.service_name})}),e.jsxRuntimeExports.jsx("td",{className:`${P.td} hfl-max-w-[64px]`,children:e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",children:["₹ ",B.order_item_price]})})}),e.jsxRuntimeExports.jsx("td",{className:`${P.td} hfl-max-w-[46px]`,children:e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",children:["₹ ",B.order_item_service_tax]})})}),e.jsxRuntimeExports.jsx("td",{"data-qa":Q+1+"-"+(L+1)+"-delete-bill",className:`${P.td_without_truncate} hfl-max-w-[36px] hfl-cursor-pointer`,onClick:()=>{y(Q,L),n(pt[6]),parseInt(R.order_paid_amount)-parseInt(R.refund_amount)<=parseInt(R.net_bill_amount)-parseInt(R.order_items[L].net_amount)?w(0):w(parseInt(R.order_paid_amount)-parseInt(R.refund_amount))},children:e.jsxRuntimeExports.jsx("i",{className:"hx_delete hfl-text-Gray-500"})})]},`${Q}-${L}`))},Q))})]})})},Ra=a=>{const{refundAmt:d,handleRightSegment:c,bills:n,billsListIndex:y,orderItemsIndex:w,getBillsList:l}=a,{patientIDs:T,showToast:N,variable:h}=_.useContext(It)||{},[V,g]=_.useState("");return e.jsxRuntimeExports.jsxs("div",{className:"hfl-relative hfl-h-full hfl-bg-Error-25",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-h-8 hfl-shrink-0 hfl-items-center hfl-justify-between hfl-gap-2 hfl-border-b-1 hfl-border-b-Gray-200 hfl-px-2",children:[e.jsxRuntimeExports.jsxs(p.bi,{variant:"Medium",type:"Text lg",className:"hfl-flex",children:["Bill :",e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text lg",className:"hfl-flex hfl-text-Blue-600",children:n?.bill_list[y].order_id_str})]}),e.jsxRuntimeExports.jsx("div",{className:"hx_close hfl-flex-shrink-0 hfl-cursor-pointer hfl-text-4",onClick:()=>c("")})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-items-center hfl-gap-2.5 hfl-px-[13px] hfl-py-3",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-full hfl-shrink-0 hfl-flex-col hfl-items-start hfl-gap-[5px] hfl-rounded-md hfl-border-Gray-200 hfl-bg-White_20 hfl-px-3 hfl-py-2 hfl-shadow-md",children:[e.jsxRuntimeExports.jsxs(p.bi,{variant:"Semibold",type:"Text sm",children:["Service: ",n?.bill_list[y].order_items[w].service_name]}),d>0&&e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center hfl-gap-3",children:e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",children:["Refund of",e.jsxRuntimeExports.jsx("div",{className:"hfl-inline hfl-font-inter-2 hfl-text-Error-600",children:" ₹ "+d+" "}),"will be given to delete this item"]})})]}),e.jsxRuntimeExports.jsx("div",{className:"hfl-w-full",children:e.jsxRuntimeExports.jsx(p.bu,{className:"hfl-w-[100%]",rows:4,inputProps:{value:V,placeholder:"Enter Reason",onChange:k=>{g(k.target.value)}},isDynamicHeight:!0})}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-full hfl-items-start hfl-gap-2",children:[e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Tertiary",size:"md",textField:"Cancel",icon:"Left",iconFile:"hx_close",className:"hfl-flex-1 hfl-items-center hfl-justify-center hfl-border hfl-border-Gray-300 hfl-bg-White hfl-text-Gray-700 hover:hfl-bg-Gray-100",onClick:()=>{c("")}}),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Primary",size:"md",textField:"Delete",icon:"Left",iconFile:"hx_delete",onClick:async()=>{try{if(n?.bill_list?.[y].order_id){const k=await Ul(n?.bill_list?.[y].order_id,n?.bill_list?.[y].order_items[w].order_item_id,T?.patientRoleID||"",V,"0",h);k?(await l(),N?.("Success",k?.message,"Success",3e3),c("")):N?.("Error","Something went wrong please try again","Error",3e3)}}catch(k){console.error("Error in deleting bill item",k)}},className:"hfl-flex-1 hfl-items-center hfl-justify-center hfl-bg-Primary-600 hfl-text-White_20 hover:hfl-bg-Primary-800"})]})]}),e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-flex-col hfl-gap-[14px] hfl-px-3 hfl-py-4"}),e.jsxRuntimeExports.jsx("div",{className:"hfl-absolute hfl-bottom-4 hfl-left-2 hfl-w-full",children:e.jsxRuntimeExports.jsx(p.Ku,{className:"hfl-h-8 hfl-shrink-0 hfl-border-l-Gray-200 hfl-bg-White_20 hfl-text-Gray-500 hfl-shadow-md hover:hfl-bg-Gray-100",hierarchy:"Tertiary",size:"md",textField:"Go Back",icon:"Left",iconFile:"hx_arrow-left hfl-text-Gray-500",onClick:()=>c("")})})]})},wa="data:image/svg+xml,%3csvg%20width='87'%20height='86'%20viewBox='0%200%2087%2086'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cellipse%20opacity='0.1'%20cx='43.5'%20cy='83.42'%20rx='43.5'%20ry='2.58'%20fill='%234E5BA6'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M33.6751%2018.92C34.2431%2016.9347%2036.0897%2015.48%2038.2799%2015.48H55.9277C54.4566%2016.3563%2053.188%2017.5313%2052.2081%2018.92H33.6751ZM51.1971%2020.64H25.6649C22.782%2020.64%2020.445%2022.9502%2020.445%2025.8V57.62H47.4149H47.8499C48.3304%2057.62%2048.7199%2058.005%2048.7199%2058.48V62.995C48.7199%2066.676%2051.7387%2069.66%2055.4624%2069.66C59.1862%2069.66%2062.2049%2066.676%2062.2049%2062.995V37.84C55.4781%2037.84%2050.0249%2032.4495%2050.0249%2025.8C50.0249%2023.9534%2050.4455%2022.2039%2051.1971%2020.64ZM63.9449%2037.7181V61.8486C66.4138%2061.4392%2068.2949%2059.3168%2068.2949%2056.76V36.2293C66.9805%2036.9809%2065.5108%2037.4967%2063.9449%2037.7181ZM70.0349%2035.0228V56.76C70.0349%2060.2756%2067.3674%2063.1753%2063.924%2063.5893C63.6156%2067.9429%2059.9451%2071.38%2055.4624%2071.38C55.3865%2071.38%2055.3108%2071.379%2055.2354%2071.377L55.2449%2071.38H23.925C19.1201%2071.38%2015.225%2067.5296%2015.225%2062.78V61.06C15.225%2059.1601%2016.783%2057.62%2018.705%2057.62V25.8C18.705%2022.0003%2021.821%2018.92%2025.6649%2018.92H31.8855C32.49%2015.9759%2035.1232%2013.76%2038.2799%2013.76H61.3349V13.7902C61.6223%2013.7702%2061.9124%2013.76%2062.2049%2013.76C68.9318%2013.76%2074.3849%2019.1505%2074.3849%2025.8C74.3849%2029.5023%2072.6945%2032.8142%2070.0349%2035.0228ZM10.44%2066.005C10.44%2065.6488%2010.7321%2065.36%2011.0925%2065.36C11.4528%2065.36%2011.745%2065.6488%2011.745%2066.005V66.22C11.745%2070.9696%2015.6401%2074.82%2020.445%2074.82H22.4459C22.7823%2074.82%2023.055%2075.0895%2023.055%2075.422C23.055%2075.7545%2022.7823%2076.024%2022.4459%2076.024H20.445C14.6698%2076.024%2010.44%2071.9104%2010.44%2066.22V66.005ZM11.0925%2063.64C9.77111%2063.64%208.69995%2064.6988%208.69995%2066.005V66.22C8.69995%2072.8786%2013.7274%2077.744%2020.445%2077.744H22.4459C23.7433%2077.744%2024.795%2076.7044%2024.795%2075.422C24.795%2074.1396%2023.7433%2073.1%2022.4459%2073.1H20.445C16.601%2073.1%2013.485%2070.0197%2013.485%2066.22V66.005C13.485%2064.6988%2012.4138%2063.64%2011.0925%2063.64ZM24.795%2043.43C24.795%2042.2426%2025.7687%2041.28%2026.9699%2041.28H40.0199C41.2212%2041.28%2042.195%2042.2426%2042.195%2043.43C42.195%2044.6174%2041.2212%2045.58%2040.0199%2045.58H26.9699C25.7687%2045.58%2024.795%2044.6174%2024.795%2043.43ZM26.9699%2043C26.7297%2043%2026.535%2043.1925%2026.535%2043.43C26.535%2043.6675%2026.7297%2043.86%2026.9699%2043.86H40.0199C40.2602%2043.86%2040.4549%2043.6675%2040.4549%2043.43C40.4549%2043.1925%2040.2602%2043%2040.0199%2043H26.9699ZM32.15%2037.9752C32.2163%2038.0407%2032.3208%2038.0735%2032.4635%2038.0735C32.5859%2038.0735%2032.6751%2038.0407%2032.7312%2037.9752C32.7923%2037.9097%2032.8229%2037.8064%2032.8229%2037.6653V37.0531C33.297%2037.0027%2033.7277%2036.8691%2034.1152%2036.6525C34.5026%2036.4307%2034.8135%2036.1082%2035.048%2035.685C35.2876%2035.2566%2035.4074%2034.7275%2035.4074%2034.0977C35.4074%2033.5534%2035.2825%2033.105%2035.0327%2032.7522C34.783%2032.3944%2034.4924%2032.1198%2034.161%2031.9283C33.8297%2031.7368%2033.3837%2031.5202%2032.8229%2031.2783V29.2375C33.0778%2029.2476%2033.2919%2029.2753%2033.4652%2029.3206C33.6436%2029.366%2033.8246%2029.4239%2034.0081%2029.4945C34.1356%2029.5449%2034.2197%2029.5701%2034.2604%2029.5701C34.3624%2029.5701%2034.4695%2029.4995%2034.5816%2029.3584C34.6988%2029.2173%2034.7983%2029.0535%2034.8798%2028.8671C34.9614%2028.6756%2035.0022%2028.5194%2035.0022%2028.3985C35.0022%2028.2624%2034.9079%2028.1264%2034.7192%2027.9903C34.5357%2027.8543%2034.2757%2027.7384%2033.9393%2027.6426C33.6079%2027.5469%2033.2358%2027.4914%2032.8229%2027.4763V27.0606C32.8229%2026.9145%2032.7923%2026.8112%2032.7312%2026.7507C32.67%2026.6902%2032.5655%2026.66%2032.4176%2026.66C32.2953%2026.66%2032.2035%2026.6927%2032.1424%2026.7583C32.0812%2026.8187%2032.0506%2026.9195%2032.0506%2027.0606V27.4839C31.5561%2027.5393%2031.1024%2027.6728%2030.6895%2027.8845C30.2817%2028.0961%2029.9529%2028.3985%2029.7031%2028.7915C29.4585%2029.1795%2029.3361%2029.6557%2029.3361%2030.2201C29.3361%2030.8147%2029.4661%2031.2985%2029.7261%2031.6713C29.9912%2032.0392%2030.2996%2032.3189%2030.6513%2032.5103C31.0081%2032.6968%2031.4746%2032.8958%2032.0506%2033.1075V35.3221C31.7346%2035.3221%2031.444%2035.2793%2031.1789%2035.1936C30.9189%2035.108%2030.6513%2034.9971%2030.376%2034.8611C30.1823%2034.7603%2030.0549%2034.7099%2029.9937%2034.7099C29.902%2034.7099%2029.7873%2034.7804%2029.6496%2034.9215C29.512%2035.0576%2029.3922%2035.2214%2029.2902%2035.4128C29.1934%2035.6043%2029.1449%2035.7656%2029.1449%2035.8966C29.1449%2036.0528%2029.2596%2036.2191%2029.489%2036.3955C29.7235%2036.5718%2030.06%2036.7255%2030.4984%2036.8565C30.9419%2036.9825%2031.4593%2037.0556%2032.0506%2037.0757V37.6653C32.0506%2037.8064%2032.0837%2037.9097%2032.15%2037.9752ZM31.5001%2029.6154C31.602%2029.4793%2031.7855%2029.3786%2032.0506%2029.3131V30.9306C31.8212%2030.7996%2031.6453%2030.6635%2031.523%2030.5224C31.4058%2030.3813%2031.3471%2030.2151%2031.3471%2030.0236C31.3471%2029.8825%2031.3981%2029.7464%2031.5001%2029.6154ZM33.2511%2034.8611C33.1441%2034.9971%2033.0013%2035.1004%2032.8229%2035.171V33.4703C33.2154%2033.692%2033.4117%2033.9843%2033.4117%2034.3471C33.4117%2034.5537%2033.3582%2034.725%2033.2511%2034.8611ZM24.795%2050.31C24.795%2049.1226%2025.7687%2048.16%2026.9699%2048.16H53.07C54.2712%2048.16%2055.2449%2049.1226%2055.2449%2050.31C55.2449%2051.4974%2054.2712%2052.46%2053.07%2052.46H26.9699C25.7687%2052.46%2024.795%2051.4974%2024.795%2050.31ZM26.9699%2049.88C26.7297%2049.88%2026.535%2050.0725%2026.535%2050.31C26.535%2050.5475%2026.7297%2050.74%2026.9699%2050.74H53.07C53.3102%2050.74%2053.5049%2050.5475%2053.5049%2050.31C53.5049%2050.0725%2053.3102%2049.88%2053.07%2049.88H26.9699ZM51.7649%2025.8C51.7649%2020.1004%2056.4391%2015.48%2062.2049%2015.48C67.9708%2015.48%2072.6449%2020.1004%2072.6449%2025.8C72.6449%2031.4996%2067.9708%2036.12%2062.2049%2036.12C56.4391%2036.12%2051.7649%2031.4996%2051.7649%2025.8ZM60.0299%2020.21C60.0299%2019.0226%2061.0037%2018.06%2062.2049%2018.06C63.4062%2018.06%2064.3799%2019.0226%2064.3799%2020.21V25.37C64.3799%2026.5574%2063.4062%2027.52%2062.2049%2027.52C61.0037%2027.52%2060.0299%2026.5574%2060.0299%2025.37V20.21ZM62.2049%2019.78C61.9647%2019.78%2061.7699%2019.9725%2061.7699%2020.21V25.37C61.7699%2025.6075%2061.9647%2025.8%2062.2049%2025.8C62.4452%2025.8%2062.6399%2025.6075%2062.6399%2025.37V20.21C62.6399%2019.9725%2062.4452%2019.78%2062.2049%2019.78ZM62.2049%2033.54C61.0037%2033.54%2060.0299%2032.5774%2060.0299%2031.39C60.0299%2030.2026%2061.0037%2029.24%2062.2049%2029.24C63.4062%2029.24%2064.3799%2030.2026%2064.3799%2031.39C64.3799%2032.5774%2063.4062%2033.54%2062.2049%2033.54ZM61.7699%2031.39C61.7699%2031.6275%2061.9647%2031.82%2062.2049%2031.82C62.4452%2031.82%2062.6399%2031.6275%2062.6399%2031.39C62.6399%2031.1525%2062.4452%2030.96%2062.2049%2030.96C61.9647%2030.96%2061.7699%2031.1525%2061.7699%2031.39Z'%20fill='%23AFB5D9'/%3e%3c/svg%3e",Ca=a=>{const{closePrintModal:d,handleCurrentWindow:c,billIdToOpen:n,onBillHandled:y}=a,[w,l]=_.useState(),[T,N]=_.useState(""),[h,V]=_.useState(""),[g,k]=_.useState(),[O,W]=_.useState(),[D,A]=_.useState(1),[P,I]=_.useState([]),[R,Q]=_.useState(-1),[B,L]=_.useState(-1),[z,K]=_.useState(0),[ue,ce]=_.useState(0),[X,ee]=_.useState(!1),ve=_.useContext(It);if(!ve)throw new Error("Bills component must be used within an AppContext.Provider");const{patientIDs:de,setLoading:Ue,variable:pe}=ve,$=We=>K(We),fe=(We=pt[0])=>N(We),H=We=>V(We),De=We=>{k(We),H(We?.service_category??""),N(pt[1])},Me=(We,it)=>{Q(We),L(it)},Le=_.useCallback(async()=>{if(de?.patientRoleID)try{const We=await bl(Ie.dayjs().format("YYYY-MM-DD"),de.patientRoleID,!1,pe);W(We)}catch(We){console.error("Error in getPastDueAmount API Call:",We)}},[]);_.useEffect(()=>{Le()},[Le]);const xt=async()=>{const We=await Sl(de.patientRoleID,pe);ce(We?.wallet_balance||0)},ht=async()=>{Ue(!0);try{Ue(!0);const We=await yl("all",de.patientRoleID,1,10,pe);We&&(l(We),I(We?.bill_list)),Ue(!1)}catch{console.log("error in getBillsList API Call")}Ue(!1)},at=async We=>{let it=We;if(Ue(!0),it<=Math.ceil(w.total_pages)){if(it=We+1,it!==We){const Pt=await yl("all",de.patientRoleID,We,10,pe);if(Pt?.bill_list){const gt=[...P,...Pt.bill_list];I(gt)}}A(it)}Ue(!1)};return _.useEffect(()=>{ht()},[]),_.useEffect(()=>{xt()},[X]),_.useEffect(()=>{if(n&&P.length){const We=P.find(it=>it.order_id_str===n);We&&(De(We),y?.())}},[n,P]),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-h-[73.55vh] hfl-flex-row hfl-bg-White",children:[e.jsxRuntimeExports.jsxs("div",{className:`hfl-flex hfl-w-[938px] hfl-flex-col hfl-px-4 hfl-py-2 xxs:max-md:hfl-w-[750px] ${T===pt[7]?"hfl-opacity-30":""}`,children:[e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-max-h-[470px] hfl-w-full hfl-flex-col hfl-overflow-y-auto",children:e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-1 hfl-flex-col hfl-items-center hfl-gap-6 hfl-overflow-y-auto ",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-between hfl-self-stretch",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",className:"hfl-text-Gray-700",children:"Bills"}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-gap-2 ",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",className:"hfl-text-Blue_gray-600",children:"Total Due Amount :"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Semibold",type:"Text lg",className:"hfl-text-Error-500",children:["₹ ",O?.total_amount||0]})]}),e.jsxRuntimeExports.jsx("div",{className:"hfl-h-[30px] hfl-w-[2px] hfl-bg-Gray-200"}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-row hfl-items-center hfl-justify-center hfl-text-Gray-700",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",children:"Deposit Amount:"}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-center hfl-gap-1 hfl-rounded-lg hfl-bg-Gray-50 hfl-p-1",children:[e.jsxRuntimeExports.jsx("i",{className:"hx_rupee hfl-text-3 hfl-text-Success-500"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",className:" hfl-text-Success-500",children:ue}),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Secondary-Grey",size:"md",textField:"",icon:"Only",iconFile:"hx_add-circle hfl-text-4",className:"hfl-items-center hfl-justify-center",onClick:()=>fe(pt[7])})]})]})]})]}),w?.bill_list?.length>0?e.jsxRuntimeExports.jsx(ja,{billsData:P,handleRowClick:De,handleRightSegment:fe,getRowIndices:Me,getRefundAmt:$,closePrintModal:d}):e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-items-center hfl-justify-center hfl-gap-4",children:[e.jsxRuntimeExports.jsx("img",{className:"hfl-w-[80px] hfl-text-Blue_gray-500",src:wa,alt:"empty-bills"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text md",className:"hfl-items-center hfl-justify-center hfl-text-Gray-400",children:"No Past Bills Available"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text md",className:"hfl-text-Gray-500",children:["To create a new bill go to"," ",e.jsxRuntimeExports.jsx("p",{className:"hfl-inline hfl-cursor-pointer hfl-text-Blue-600 hfl-underline",onClick:()=>c(wt[2]),children:"Add Bills"})]})]})]})}),w?.bill_list?.length>0&&e.jsxRuntimeExports.jsx("div",{className:"hfl-px-6 hfl-py-2",children:e.jsxRuntimeExports.jsx(es,{currentPage:D,totalRecord:w?.total_records,currentTotal:D===Math.ceil(w?.total_records/20)?w?.total_records:D*20,handleLoadMore:at})})]}),e.jsxRuntimeExports.jsxs(Nl,{children:[T===pt[1]&&e.jsxRuntimeExports.jsx(Tl,{rightSegment:T,serviceDetails:g?.order_items??[],categorySummaryData:g,serviceItem:h,handleRightSegment:fe,getPastDueAmount:Le,getBillSummarydata:ht,closePrintModal:d,setRefreshWallet:ee,walletBalance:ue,bill_date:"",refreshBillsList:ht}),T===pt[6]&&e.jsxRuntimeExports.jsx(Ra,{refundAmt:z,bills:w,billsListIndex:R,orderItemsIndex:B,handleRightSegment:fe,getBillsList:ht}),T===pt[7]&&e.jsxRuntimeExports.jsx(Il,{depositAmount:ue,handleRightSegment:fe,rightSegment:T,setRefreshWallet:ee})]})]})},Ea=({childModalRef:a,children:d,hideBackDrop:c=!1,backdropClasses:n="",modalClasses:y="",closeOnClickOutside:w,clickOutsideHandler:l,position:T="hfl-inset-0"})=>(_.useEffect(()=>{if(!w)return;const N=h=>{a.current&&!a.current.contains(h.target)&&l()};return document.addEventListener("mousedown",N),()=>{document.removeEventListener("mousedown",N)}},[l,a,w]),e.jsxRuntimeExports.jsx("div",{className:`hfl-fixed ${T} hfl-z-50 hfl-flex hfl-items-center hfl-justify-center ${n} ${c?"":"hfl-bg-Gray-750 hfl-backdrop-blur-sm"}`,children:e.jsxRuntimeExports.jsx("div",{ref:a,className:`hfl-rounded-lg hfl-shadow-md hfl-bg-White ${y??""}`,children:d})})),Sa=({reference:a,closeModalHandler:d,payment_id:c,currentMode:n,transactionType:y,refreshPaymentData:w})=>{const{showToast:l,variable:T}=_.useContext(It)||{},[N,h]=_.useState({paymentMethod:n}),V=async()=>{const g=await Ln(c,N.paymentMethod,y,T);g.status?(l("Update Success",g.message,"Success",3e3),w?.()):l("Update Failed",g.message,"Error",3e3),d({show:!1,payment_id:"",mode:"",payment_type:""})};return e.jsxRuntimeExports.jsxs("div",{ref:a,className:"hfl-flex hfl-w-[400px] hfl-flex-col hfl-rounded-lg hfl-border-none",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-rounded-t-lg hfl-bg-gradient_primary_600_500_90 hfl-px-6 hfl-py-5 hfl-text-White hfl-shadow-sm",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Bold",type:"Text md",className:"hfl-text-White",children:"Please make required changes"})," "]}),e.jsxRuntimeExports.jsx("div",{className:"hfl-bg-White hfl-p-6",children:e.jsxRuntimeExports.jsx(p.Ap,{className:"hfl-w-[200px] hfl-text-0 hfl-text-Gray-800 ",value:{label:cr[N.paymentMethod]},options:Zr.map(g=>({label:g,value:g,className:"hfl-text-1 hfl-text-Gray-800"})),onChange:g=>{h(k=>({...k,paymentMethod:cr[g.value]}))},label:"Payment Method",labelClassName:"after:hfl-content-['*'] after:hfl-text-Error-600 after:hfl-ml-1 hfl-font-inter-2 hfl-font-inter",dropdownInputTextClassName:"hfl-text-1 hfl-text-Gray-600"})}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-row hfl-justify-end hfl-gap-[10px] hfl-rounded-b-lg hfl-border-t-1 hfl-border-Gray-100 hfl-bg-Gray-50 hfl-px-7 hfl-py-2",children:[e.jsxRuntimeExports.jsx(p.Ku,{textField:"Cancel",size:"sm",hierarchy:"Primary",onClick:()=>d({show:!1,payment_id:"",mode:"",payment_type:""}),className:"hfl-border-1 hfl-border-Blue-300 hfl-bg-Blue-50 hfl-text-Blue-600 hover:hfl-bg-Blue-600 hover:hfl-text-White"}),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Primary",size:"sm",textField:"Save",className:"hfl-bg-Blue-600",onClick:V})]})]})},Pa=({styles:a,data:d,handleDeleteRow:c,handleRightSegment:n,handleRowClick:y,getType:w,getTypeColor:l,refreshPaymentData:T})=>{const[N,h]=_.useState({show:!1,payment_id:"",mode:"",payment_type:""}),V=_.useRef(null),g=O=>{switch(O){case"1":return"Consultation";case"2":return"Other";case"3":return"Lab";default:return"Other"}},k=O=>{switch(O){case"1":return"hx_service-appointment-filled hfl-text-Primary-500";case"2":return"hx_service-other-filled hfl-text-Pink-500";case"3":return"hx_service-lab-filled hfl-text-Purple-600";default:return"hx_service-other-filled hfl-text-Pink-500"}};return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[d.length>0&&d.map((O,W)=>e.jsxRuntimeExports.jsx(_.Fragment,{children:e.jsxRuntimeExports.jsxs("tr",{className:"hfl-border-1",children:[e.jsxRuntimeExports.jsx("td",{className:`${a.td} `,children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",children:Ie.dayjs.utc(new Date(O.created_on)).format("YYYY-MM-DD / HH:mm")})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[70px]`,children:e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"-hfl-ml-1 ",children:O.order_id_str})})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[90px]`,children:e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex hfl-cursor-pointer hfl-text-Primary-600 hover:hfl-underline",onClick:()=>{y(O)},"data-qa":W+1+"-bill-amount",children:"₹"+O.paid_amount})})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[70px]`,children:e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center",children:[e.jsxRuntimeExports.jsx("i",{className:" hx_f_rupee hfl-flex "}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:` -hfl-ml-1 hfl-px-1 ${l(O.payment_refund)}`,children:w(O.payment_refund)})]})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-w-[90px]`,children:e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-between hfl-gap-2",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",onClick:()=>{},className:"-hfl-ml-1",children:cr[O.paid_mode]}),e.jsxRuntimeExports.jsx("span",{className:"hx_edit hfl-cursor-pointer hfl-text-Blue-600",onClick:()=>{h({show:!0,payment_id:O.order_payment_id,mode:O.paid_mode,payment_type:w(O.payment_refund).toLowerCase()})}})]})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[90px]`,children:e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center ",children:[e.jsxRuntimeExports.jsx("i",{className:`hfl-flex hfl-text-3 hfl-text-Error-500 ${k(O.service_category_id)}`}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"-hfl-ml-0 ",children:[" ",g(O?.service_category_id)]})]})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[50px]`,children:e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center",children:[e.jsxRuntimeExports.jsx("i",{className:" hx_f-rupee hfl-flex hfl-text-0"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"-hfl-ml-1",children:O.order_total})]})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[70px]`,title:O.details,children:e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"-hfl-ml-1 hfl-truncate",children:O.details})})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[70px]`,children:e.jsxRuntimeExports.jsx("i",{className:" hx_delete hfl-flex hfl-cursor-pointer hfl-text-2",onClick:D=>{D.stopPropagation(),n(),c(O,W)},"data-qa":W+1+"-delete-transaction"})})]},`${W}`)},W)),N.show&&e.jsxRuntimeExports.jsx(Ea,{childModalRef:V,backdropClasses:"",clickOutsideHandler:()=>{},closeOnClickOutside:!1,hideBackDrop:!1,modalClasses:"hfl-rounded-xlg hfl-mx-2 xsm:hfl-mx-6 md:hfl-mx-12 ",children:e.jsxRuntimeExports.jsx(Sa,{reference:V,closeModalHandler:h,payment_id:N.payment_id,currentMode:N.mode,transactionType:N.payment_type,refreshPaymentData:T})})]})},Na=({styles:a,data:d,handleRowClick:c,closePrintModal:n,patient_entity_id:y})=>{const{patientDetails:w,patientIDs:l,billPreferences:T,setShowPrintModal:N,showPrintModal:h}=_.useContext(It),V=async(g,k,O,W)=>{h?.visible&&n();const A=[w?.age&&typeof w?.age=="number"?`${w?.age}y`:w?.org_person_dob?hr(w?.org_person_dob):"",Jr[w?.gender]??"",w?.blood_group].filter(I=>I).join(", "),P={name:ar(w?.name)+(A?` (${A}) `:""),billDate:Ie.dayjs(g?.transaction_time).format("DD-MMM-YYYY"),mobileNumber:w?.phone_number,email:w?.email,billNumber:g?.bill_number,patientId:w?.org_person_bid_str,patientIdForEmail:l?.patientRoleID,billStatus:"PAID",address:[w?.address??"",w?.city??"",w?.pincode??""].filter(I=>I).join(", ")};N({printDataFrom:"patient_popup",visible:!0,whichPreview:k,printData:"",visitId:"",visit_date:"",visit_number:1,currentPrintTime:new Date().getTime(),printType:"bill_deposit_refund",details:{showPrintPreviewForBill:O,preferences:{...T?.print?.bill,...T?.org_details},depositRefundBillDetails:g,billPatientDetails:P,isWholeBill:!1,payloadDataforEmail:{orderDate:"",orderNumber:g?.bill_number,patient_user_id:y}},trackEventHandler:()=>{console.log(W)}})};return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:d.length>0&&d.map((g,k)=>e.jsxRuntimeExports.jsx(_.Fragment,{children:e.jsxRuntimeExports.jsxs("tr",{className:"hfl-border-1",children:[e.jsxRuntimeExports.jsx("td",{className:`${a.td} `,children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",children:Ie.dayjs.utc(new Date(g.transaction_time)).format("YYYY-MM-DD / HH:mm")})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[70px]`,children:e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"-hfl-ml-1 hfl-text-Primary-600",children:g.bill_number})})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[105px]`,children:e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center",children:[e.jsxRuntimeExports.jsx("i",{className:" hx_f-rupee hfl-flex hfl-text-0"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"-hfl-ml-1",children:g.bill_amount})]})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[115px]`,children:e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex hfl-cursor-pointer hover:hfl-underline",onClick:()=>{c(g)},"data-qa":k+1+"-bill-amount",children:"₹"+g.paid_amount}),e.jsxRuntimeExports.jsx("i",{className:" hx_print-filled hfl-cursor-pointer hfl-text-2 hfl-text-Gray-500",onClick:()=>V(g,"billPrintPreview",!1,g?.type==="DEPOSIT"?"DEPOSIT_BILL_PRINT":"REFUND_BILL_PRINT"),"data-qa":k+1+"-print-bill"})]})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-w-[90px]`,children:e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center",children:[e.jsxRuntimeExports.jsx("i",{className:" hfl-flex hfl-text-0"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"-hfl-ml-1",children:g.mode})]})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[90px]`,children:e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center ",children:[e.jsxRuntimeExports.jsx("img",{src:Ql(g.type)}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"-hfl-ml-0 ",children:[" ",g.type]})]})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[160px]`,title:g.details,children:e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"-hfl-ml-1 hfl-truncate",children:g.details})})})]},`${k}`)},k))})},Aa=a=>{const{data:d,setTableData:c,handleRightSegment:n,handleRowClick:y,activeTab:w,closePrintModal:l,patient_entity_id:T,refreshPaymentData:N}=a,{patientIDs:h,showToast:V,variable:g}=_.useContext(It)||{};Ie.dayjs.extend(Dl);const k=async(I,R)=>{let Q="";I.payment_refund==="P"?Q="payment":I.payment_refund==="R"&&(Q="refund");try{const B=await Dn(I.order_payment_id,Q,I.order_id,h?.patientRoleID||"",g);B.status&&(V("Success",B?.message,"Success",3e3),c(L=>{try{const z=[...L];return z.splice(R,1),z}catch(z){return console.error(`Error: ${z}`),L}}),N())}catch(B){console.error("Error deleting payment:",B)}},O=I=>{switch(I){case"P":return"Payment";case"R":return"Refund";case"D":return"Deposit";default:return""}},W=I=>{switch(I){case"DEPOSIT":case"P":return"hfl-bg-Success-50 hfl-text-Success-500";case"REFUND":case"R":return"hfl-bg-Error-50 hfl-text-Error-500";case"D":return"hfl-bg-Primary-50 hfl-text-Primary-500";default:return""}},D=_.useMemo(()=>w===pr[Rr.consultation_lab_other_services].key?[{label:"Date/Time",className:"focus:hfl-outline-none hfl-items-start hfl-w-[162px] hfl-border-Gray-200 hfl-border-1"},{label:"#Bill",className:"focus:hfl-outline-none hfl-items-start hfl-w-[100px] hfl-truncate hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Amount",className:"focus:hfl-outline-none hfl-items-start hfl-w-[90px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Type",className:"focus:hfl-outline-none hfl-items-start hfl-w-[90px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Mode",className:"focus:hfl-outline-none hfl-items-start hfl-w-[90px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Category",className:"focus:hfl-outline-none hfl-items-start hfl-w-[136px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Bill Amount",className:"focus:hfl-outline-none hfl-items-start hfl-w-[110px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Details",className:"focus:hfl-outline-none hfl-items-start hfl-w-[120px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:" ",className:"focus:hfl-outline-none hfl-items-start hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"}]:[{label:"Date/Time",className:"focus:hfl-outline-none hfl-items-start hfl-w-[162px] hfl-border-Gray-200 hfl-border-1 hfl-px-2 hfl-text-left"},{label:"#Bill",className:"focus:hfl-outline-none hfl-items-start hfl-w-[100px] hfl-truncate hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1 hfl-text-left"},{label:"Bill Amount",className:"focus:hfl-outline-none hfl-items-start hfl-w-[105px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1 hfl-text-left"},{label:"Total Paid",className:"focus:hfl-outline-none hfl-items-start hfl-w-[115px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1 hfl-text-left"},{label:"Mode",className:"focus:hfl-outline-none hfl-items-start hfl-w-[90px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1 hfl-text-left"},{label:"Category",className:"focus:hfl-outline-none hfl-items-start hfl-w-[136px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1 hfl-text-left"},{label:"Details",className:"focus:hfl-outline-none hfl-items-start hfl-w-[160px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1 hfl-text-left"}],[w]),A=({label:I,className:R})=>e.jsxRuntimeExports.jsx("th",{className:R,children:e.jsxRuntimeExports.jsxs(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-text-Gray-600",children:[" ",I]})}),P={table:"hfl-table-fixed hfl-rounded-lg hfl-shadow-md hfl-border-Gray-200 hfl-border-1 hfl-pb-8 ",th:"hfl-bg-Blue_gray-50",td:"hfl-px-2 hfl-h-[36px] hfl-align-top hfl-border-Gray-200 hfl-py-1.5 hfl-border-1 hfl-truncate hfl-text-Gray-500"};return e.jsxRuntimeExports.jsx("div",{className:"",children:e.jsxRuntimeExports.jsxs("table",{className:`${P.table}`,children:[e.jsxRuntimeExports.jsx("thead",{className:`${P.th}`,children:e.jsxRuntimeExports.jsx("tr",{children:D.map((I,R)=>e.jsxRuntimeExports.jsx(A,{label:I.label,className:I.className},R))})}),e.jsxRuntimeExports.jsx("tbody",{children:w===pr[Rr.consultation_lab_other_services].key?e.jsxRuntimeExports.jsx(Pa,{styles:P,data:d,handleDeleteRow:k,handleRightSegment:n,handleRowClick:y,getTypeColor:W,getType:O,refreshPaymentData:N}):e.jsxRuntimeExports.jsx(Na,{styles:P,data:d,handleRowClick:y,closePrintModal:l,patient_entity_id:T})})]})})},Da="data:image/svg+xml,%3csvg%20width='88'%20height='87'%20viewBox='0%200%2088%2087'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cellipse%20opacity='0.1'%20cx='44'%20cy='83.92'%20rx='43.5'%20ry='2.58'%20fill='%234E5BA6'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M12.6799%2017.3857C12.6799%2016.1344%2013.7061%2015.12%2014.972%2015.12C16.2379%2015.12%2017.2641%2016.1344%2017.2641%2017.3857V22.0468C17.2641%2023.2981%2016.2379%2024.3125%2014.972%2024.3125C13.7061%2024.3125%2012.6799%2023.2981%2012.6799%2022.0468V17.3857ZM14.972%2016.84C14.6671%2016.84%2014.4199%2017.0843%2014.4199%2017.3857V22.0468C14.4199%2022.3482%2014.6671%2022.5925%2014.972%2022.5925C15.2769%2022.5925%2015.5241%2022.3482%2015.5241%2022.0468V17.3857C15.5241%2017.0843%2015.2769%2016.84%2014.972%2016.84ZM23.1199%2026.3C23.1199%2023.9252%2025.0675%2022%2027.4699%2022H56.4199C55.1757%2023.464%2054.2776%2025.225%2053.8502%2027.16H23.1199V26.3ZM53.6005%2028.88H19.6399C17.2375%2028.88%2015.2899%2030.8052%2015.2899%2033.18V37.48L56.4199%2037.48C54.6412%2035.3872%2053.5699%2032.6872%2053.5699%2029.74C53.5699%2029.4508%2053.5802%2029.1641%2053.6005%2028.88ZM67.4899%2041.6581V58.98H69.2299C71.6324%2058.98%2073.5799%2057.0548%2073.5799%2054.68V38.9628C71.8823%2040.3727%2069.7897%2041.3329%2067.4899%2041.6581ZM75.3199%2037.1886V54.68C75.3199%2058.0047%2072.5933%2060.7%2069.2299%2060.7H67.4899V61.56C67.4899%2064.8848%2064.7633%2067.58%2061.3999%2067.58H19.6399C16.2765%2067.58%2013.5499%2064.8848%2013.5499%2061.56V33.18C13.5499%2029.8552%2016.2765%2027.16%2019.6399%2027.16H21.3799V26.3C21.3799%2022.9752%2024.1065%2020.28%2027.4699%2020.28H57.9199V20.5172C60.0371%2018.759%2062.7684%2017.7%2065.7499%2017.7C72.4768%2017.7%2077.9299%2023.0905%2077.9299%2029.74C77.9299%2032.5522%2076.9545%2035.1393%2075.3199%2037.1886ZM15.2899%2042.64L65.7499%2042.64V58.98V60.7V61.56C65.7499%2063.9348%2063.8024%2065.86%2061.3999%2065.86H19.6399C17.2375%2065.86%2015.2899%2063.9348%2015.2899%2061.56V42.64ZM73.262%2063.28C71.9961%2063.28%2070.9699%2064.2944%2070.9699%2065.5457V70.2068C70.9699%2071.4581%2071.9961%2072.4725%2073.262%2072.4725C74.5279%2072.4725%2075.5541%2071.4581%2075.5541%2070.2068V65.5457C75.5541%2064.2944%2074.5279%2063.28%2073.262%2063.28ZM72.7099%2065.5457C72.7099%2065.2443%2072.9571%2065%2073.262%2065C73.5669%2065%2073.8141%2065.2443%2073.8141%2065.5457V70.2068C73.8141%2070.5082%2073.5669%2070.7525%2073.262%2070.7525C72.9571%2070.7525%2072.7099%2070.5082%2072.7099%2070.2068V65.5457ZM55.3099%2029.74C55.3099%2024.0404%2059.9841%2019.42%2065.7499%2019.42C71.5158%2019.42%2076.1899%2024.0404%2076.1899%2029.74C76.1899%2035.4396%2071.5158%2040.06%2065.7499%2040.06C59.9841%2040.06%2055.3099%2035.4396%2055.3099%2029.74ZM63.5749%2024.15C63.5749%2022.9626%2064.5487%2022%2065.7499%2022C66.9511%2022%2067.9249%2022.9626%2067.9249%2024.15V29.31C67.9249%2030.4974%2066.9511%2031.46%2065.7499%2031.46C64.5487%2031.46%2063.5749%2030.4974%2063.5749%2029.31V24.15ZM65.7499%2023.72C65.5097%2023.72%2065.3149%2023.9125%2065.3149%2024.15V29.31C65.3149%2029.5475%2065.5097%2029.74%2065.7499%2029.74C65.9902%2029.74%2066.1849%2029.5475%2066.1849%2029.31V24.15C66.1849%2023.9125%2065.9902%2023.72%2065.7499%2023.72ZM65.7499%2037.48C64.5487%2037.48%2063.5749%2036.5174%2063.5749%2035.33C63.5749%2034.1426%2064.5487%2033.18%2065.7499%2033.18C66.9511%2033.18%2067.9249%2034.1426%2067.9249%2035.33C67.9249%2036.5174%2066.9511%2037.48%2065.7499%2037.48ZM65.3149%2035.33C65.3149%2035.5675%2065.5097%2035.76%2065.7499%2035.76C65.9902%2035.76%2066.1849%2035.5675%2066.1849%2035.33C66.1849%2035.0925%2065.9902%2034.9%2065.7499%2034.9C65.5097%2034.9%2065.3149%2035.0925%2065.3149%2035.33ZM35.7349%2050.38C34.5337%2050.38%2033.5599%2051.3426%2033.5599%2052.53C33.5599%2053.7174%2034.5337%2054.68%2035.7349%2054.68H59.2249C60.4262%2054.68%2061.3999%2053.7174%2061.3999%2052.53C61.3999%2051.3426%2060.4262%2050.38%2059.2249%2050.38H35.7349ZM35.2999%2052.53C35.2999%2052.2925%2035.4947%2052.1%2035.7349%2052.1H59.2249C59.4652%2052.1%2059.6599%2052.2925%2059.6599%2052.53C59.6599%2052.7675%2059.4652%2052.96%2059.2249%2052.96H35.7349C35.4947%2052.96%2035.2999%2052.7675%2035.2999%2052.53ZM24.4249%2056.4C26.5871%2056.4%2028.3399%2054.6673%2028.3399%2052.53C28.3399%2050.3927%2026.5871%2048.66%2024.4249%2048.66C22.2627%2048.66%2020.5099%2050.3927%2020.5099%2052.53C20.5099%2054.6673%2022.2627%2056.4%2024.4249%2056.4Z'%20fill='%23AFB5D9'/%3e%3c/svg%3e",Ta=({walletBalance:a,handleRightSegment:d,headerText:c})=>e.jsxRuntimeExports.jsxs("div",{className:"hfl-mt-2 hfl-flex hfl-w-full hfl-flex-row hfl-items-center hfl-justify-between hfl-text-Gray-700",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",children:c}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text lg",children:"Deposit Amount:"}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-center hfl-gap-1 hfl-rounded-lg hfl-bg-Gray-50 hfl-p-1",children:[e.jsxRuntimeExports.jsx("i",{className:"hx_rupee hfl-text-3 hfl-text-Success-500"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text lg",className:" hfl-text-Success-500",children:a}),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Secondary-Grey",size:"md",textField:"",icon:"Only",iconFile:"hx_add-circle hfl-text-4",className:"hfl-items-center hfl-justify-center",onClick:()=>d(pt[7])})]})]})]}),Ia=a=>{Ie.dayjs.extend(Dl);const{patientDetails:d,patientIDs:c,billPreferences:n,setShowPrintModal:y,showPrintModal:w}=_.useContext(It)||{},{handleRightSegment:l,closePrintModal:T,summaryData:N,patient_entity_id:h}=a,V=async(g,k)=>{w?.visible&&T();const W=[d?.age&&typeof d?.age=="number"?`${d?.age}y`:d?.org_person_dob?hr(d?.org_person_dob):"",Jr[d?.gender]??"",d?.blood_group].filter(A=>A).join(", "),D={name:ar(d?.name)+(W?` (${W}) `:""),billDate:Ie.dayjs(N?.transaction_time).format("DD-MMM-YYYY"),mobileNumber:d?.phone_number,email:d?.email,billNumber:N?.bill_number,patientId:d?.org_person_bid_str,patientIdForEmail:c?.patientRoleID,billStatus:"PAID",address:[d?.address??"",d?.city??"",d?.pincode??""].filter(A=>A).join(", ")};y?.({printDataFrom:"patient_popup",visible:!0,whichPreview:g,printData:"",visitId:"",visit_date:"",visit_number:1,currentPrintTime:new Date().getTime(),printType:"bill_deposit_refund",details:{showPrintPreviewForBill:k,preferences:{...n?.print?.bill,...n?.org_details},depositRefundBillDetails:N,billPatientDetails:D,isWholeBill:!1,payloadDataforEmail:{orderDate:"",orderNumber:N?.bill_number,patient_user_id:h}},trackEventHandler:()=>{}})};return e.jsxRuntimeExports.jsxs("div",{className:"hfl-relative hfl-h-full ",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-h-8 hfl-w-[330px] hfl-shrink-0 hfl-items-center hfl-gap-2 hfl-border-b-1 hfl-border-b-Gray-200 hfl-px-2",children:[e.jsxRuntimeExports.jsx("div",{className:"hx_arrow-left hfl-flex-shrink-0 hfl-cursor-pointer hfl-text-4",onClick:()=>l(pt[0])}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-flex hfl-items-center",children:"Bills Summary"})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-items-start hfl-px-3 hfl-py-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-justify-between hfl-self-stretch hfl-py-[7px] hfl-pr-7",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-[60%] hfl-gap-2",children:[e.jsxRuntimeExports.jsx("img",{src:Ql(N.type),alt:""}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:N.type==="DEPOSIT"?"Deposit":"Refund(Deposit)"})]}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹ ",N?.bill_amount]})]}),N.type==="DEPOSIT"&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-self-stretch hfl-py-[7px] hfl-pr-7",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-w-[60%] hfl-flex-1 hfl-text-Gray-800",children:"Total Billed Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-text-Gray-800",children:["₹ ",N?.bill_amount]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-self-stretch hfl-py-[7px] hfl-pr-7",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-w-[60%] hfl-flex-1 hfl-text-Gray-800",children:"Paid Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹ ",N?.paid_amount]})]})]}),N.type==="REFUND"&&e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-self-stretch hfl-py-[7px] hfl-pr-7",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-w-[60%] hfl-flex-1 hfl-text-Gray-800",children:"Deposit Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹ ",N?.opening_balance]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-self-stretch hfl-py-[7px] hfl-pr-7",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-w-[60%] hfl-flex-1 hfl-text-Gray-800",children:"Total Balance"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-text-Gray-800",children:["₹"," ",N.type==="DEPOSIT"?parseInt(N?.bill_amount)-parseInt(N?.paid_amount):N?.closing_balance]})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-absolute hfl-bottom-1 hfl-flex hfl-w-full hfl-items-start hfl-gap-2 hfl-px-1 hfl-pb-2",children:[e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Tertiary",size:"md",textField:"Print",icon:"Left",onClick:()=>V("billPrintPreview",!1),iconFile:"hx_print",className:" hfl-flex-1 hfl-items-center hfl-justify-center hfl-border hfl-border-Gray-300 hfl-bg-White hfl-text-Gray-700 hover:hfl-bg-Gray-100"}),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Tertiary",size:"md",textField:"Share",icon:"Left",onClick:()=>V("billSharePreview",!0),iconFile:"hx_share",className:" hfl-flex-1 hfl-items-center hfl-justify-center hfl-border hfl-border-Gray-300 hfl-bg-White hfl-text-Gray-700 hover:hfl-bg-Gray-100"})]})]})},Ba=({closePrintModal:a})=>{const[d,c]=_.useState(pr[Rr.consultation_lab_other_services].key),[n,y]=_.useState(null),[w,l]=_.useState(pt[5]),[T,N]=_.useState(""),[h,V]=_.useState(),[g,k]=_.useState([]),[O,W]=_.useState(1),[D,A]=_.useState(),{setLoading:P,patientIDs:I,variable:R}=_.useContext(It),[Q,B]=_.useState(0),[L,z]=_.useState(!1),K=_.useCallback(async()=>{try{if(P(!0),I?.patientRoleID){const $=await _l(I.patientRoleID,1,10,R);$&&(y($),k($.data))}P(!1)}catch{y(null),k([]),P(!1),console.log("error in getPaymentsList API Call")}},[I.patientRoleID,P,R]),ue=_.useCallback(async()=>{try{P(!0);const $=await jl(I?.patientRoleID||"",1,10,R);$&&(y($),k($?.wallet_transactions||[])),P(!1)}catch{y(null),k([]),P(!1),console.log("error in getDepositRefundList API Call")}},[I?.patientRoleID,P,R]),ce=($=pt[5])=>{l($)},X=$=>{N($)},ee=async $=>{if(V($),d===pr[Rr.consultation_lab_other_services].key){if(X(St[parseInt($?.service_category_id)-1]),l(pt[1]),$?.order_id){const fe=await de($.order_id);A(fe)}}else l(pt[8])},ve=async $=>{let fe=$;if(P(!0),fe<=Math.ceil(n?.total_records||0)){if(fe=$+1,fe!==$){let H,De;d==pr[Rr.deposit_refund].key?(H=await jl(I?.patientRoleID||"",fe,10,R),De=[...g,...H.wallet_transactions]):(H=await _l(I?.patientRoleID||"",fe,10,R),De=[...g,...H.data]),k(De)}W(fe)}P(!1)},de=async $=>{try{return await El($,I?.patientRoleID||"",["order_items"],R)}catch{console.log("Error in Loading Bill Details from Bill Id")}},Ue=_.useCallback(async()=>{const $=await Sl(I?.patientRoleID||"",R);B($?.wallet_balance||0)},[I?.patientRoleID,R]),pe=$=>{c($),ce(),a()};return _.useEffect(()=>{d==pr[Rr.deposit_refund].key?ue():K()},[d,ue,K]),_.useEffect(()=>{Ue(),d==pr[Rr.deposit_refund].key&&ue()},[d,Ue,ue,L]),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-h-[73.55vh] hfl-bg-White",children:[e.jsxRuntimeExports.jsxs("div",{className:`hfl-flex hfl-w-[938px] hfl-flex-col hfl-justify-start hfl-px-4 hfl-py-2 xxs:max-md:hfl-w-[750px] ${w===pt[7]?"hfl-opacity-30":""}`,children:[e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:Object.values(pr).map(($,fe)=>e.jsxRuntimeExports.jsx(p.bi,{variant:`${d===$.key?"Semibold":"Regular"}`,type:"Text md",className:`hfl-flex hfl-cursor-pointer hfl-items-center hfl-justify-center hfl-gap-0.5 hfl-px-[13px] hfl-py-2 ${d===$.key?"hfl-border-b-2 hfl-border-Primary-600 hfl-text-Primary-600":""}`,onClick:()=>pe($.key),children:$.label},fe))}),e.jsxRuntimeExports.jsx(Ta,{walletBalance:Q,handleRightSegment:ce,headerText:pr[d].label}),e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-max-h-[470px] hfl-w-full hfl-flex-col hfl-overflow-y-scroll"}),g?.length?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-flex-1 hfl-flex-col hfl-items-center hfl-gap-6 hfl-overflow-y-auto ",children:e.jsxRuntimeExports.jsx(Aa,{data:g,setTableData:k,handleRowClick:ee,handleRightSegment:ce,activeTab:d,closePrintModal:a,patient_entity_id:n?.entity_id||"",refreshPaymentData:K})}),e.jsxRuntimeExports.jsx("div",{className:"hfl-px-6 hfl-py-2",children:e.jsxRuntimeExports.jsx(es,{currentPage:O,totalRecord:n?.total_records||0,currentTotal:O===Math.ceil((n?.total_records||0)/10)?n?.total_records||0:O*10,handleLoadMore:ve})})]}):e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-items-center hfl-justify-center hfl-gap-4",children:[e.jsxRuntimeExports.jsx("img",{className:"hfl-w-[80px] hfl-text-Blue_gray-500",src:Da,alt:"empty-bills"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text md",className:"hfl-items-center hfl-justify-center hfl-text-Gray-400",children:"No Active or Past Payments for the Patient"})]})]}),e.jsxRuntimeExports.jsxs(Nl,{children:[w===pt[1]&&e.jsxRuntimeExports.jsx(Tl,{rightSegment:w,categorySummaryData:{...h,order_date:D?.order_date??""},serviceItem:T,handleRightSegment:ce,serviceDetails:D?.order_items??[],getBillSummarydata:K,closePrintModal:a,setRefreshWallet:z,walletBalance:Q,getPastDueAmount:()=>{},refreshBillsList:()=>{},bill_date:""}),w===pt[7]&&e.jsxRuntimeExports.jsx(Il,{depositAmount:Q,handleRightSegment:ce,rightSegment:w,setRefreshWallet:z}),w===pt[8]&&e.jsxRuntimeExports.jsx(Ia,{summaryData:{...h,order_date:D?.order_date??""},handleRightSegment:ce,closePrintModal:a,patient_entity_id:n?.entity_id||""})]})]})},Bl=()=>e.jsxRuntimeExports.jsx("div",{className:"hfl-inset-0 hfl-z-[100] hfl-flex hfl-h-full hfl-w-full hfl-items-center hfl-justify-center hfl-overflow-y-auto hfl-outline-none focus:hfl-outline-none",children:e.jsxRuntimeExports.jsx(p.Eu,{progress:10,spinnerMode:!0})}),en=({columns:a,data:d})=>{const{getTableProps:c,getTableBodyProps:n,headerGroups:y,rows:w,prepareRow:l}=Qr.useTable({columns:a,data:d}),T=h=>{const V=[];return h?.headers?.length&&h.headers.map(g=>{V.push(e.jsxRuntimeExports.jsx("th",{...g.getHeaderProps(),className:"hfl-rounded hfl-border-1 hfl-border-Gray-200 hfl-bg-Blue_gray-50 hfl-px-2 hfl-py-1 hfl-text-left",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-text-Gray-600",children:g.render("Header")})}))}),V},N=()=>{const h=[];return w.map((V,g)=>{l(V),h.push(e.jsxRuntimeExports.jsx("tr",{id:g.toString(),...V.getRowProps(),className:"hfl-bg-White hfl-group hfl-border-t-1 hfl-border-Gray-200",children:V.cells.map((k,O)=>e.jsxRuntimeExports.jsx("td",{"data-qa":g+1+"-"+(O+1),...k.getCellProps(),className:"hfl-relative hfl-border-1 hfl-border-Gray-200 hfl-px-2 hfl-text-left",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-[13px] hfl-text-Gray-500",children:k.render("Cell")})}))}))}),h};return e.jsxRuntimeExports.jsx("div",{className:"hfl-overflow-y-auto","data-qa":"lab-report-table",children:e.jsxRuntimeExports.jsxs("table",{...c(),className:"hfl-table-fixed hfl-rounded-lg hfl-border-1 hfl-border-Gray-200 hfl-pb-8 hfl-shadow-md",children:[e.jsxRuntimeExports.jsx("thead",{children:y.map(h=>e.jsxRuntimeExports.jsx("tr",{...h.getHeaderGroupProps(),className:"hfl-h-10 hfl-rounded-lg hfl-bg-Blue_gray-50 ",children:T(h)}))}),e.jsxRuntimeExports.jsx("tbody",{...n(),className:"hfl-rounded-",children:N()})]})})},Ga=a=>{const{visits:d=[],setPdfUrl:c,pdfUrl:n}=a,[y,w]=_.useState([]);return _.useEffect(()=>{w(Fa(d))},[]),e.jsxRuntimeExports.jsx("div",{children:y&&y.length&&y.map((l,T)=>l.reports.length>0&&l.reports.map((N,h)=>{const V=l.date||"No date available";N.label=`${new Date(V).toLocaleDateString()}${l.reports.length>1?` - ${h+1}`:""}`;const{lab_number:g,label:k,message:O=""}=N;return e.jsxRuntimeExports.jsx("div",{className:"hfl-relative hfl-mb-2 hfl-flex hfl-items-center hfl-justify-center",title:`${k} ${O?`(${O})`:""}
|
|
17
|
+
`,children:[h&&e.jsxRuntimeExports.jsxs("div",{className:"text:hfl-Gray-700 hfl-mb-3 hfl-w-[207px] hfl-rounded-lg hfl-bg-White hfl-p-3 hfl-shadow-lg",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-justify-between",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text sm",children:"Line Item Discount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Medium",type:"Text sm",children:["₹"," ",["1","2","3"].reduce((B,L)=>B+parseInt(h.bill_summary[L]?.order_item_sum_discount||"0"),0)]})]}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text sm",children:"Additional Discount"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",children:["1","2","3"].map(B=>e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-justify-between",children:[e.jsxRuntimeExports.jsxs("div",{children:[B==="1"&&"Consultations",B==="2"&&"Lab Services",B==="3"&&"Other Services"]}),"₹ ",h.bill_summary[B]?.order_discount||"0"]},B))})]}),e.jsxRuntimeExports.jsx("div",{className:"text:hfl-Gray-700 hfl-absolute hfl-bottom-2 hfl-left-1/2 hfl-h-3 hfl-w-3 hfl-translate-x-[-50%] hfl-rotate-45 hfl-bg-White"})]})]})]}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹"," - ",parseInt(h.bill_summary[1]?.order_item_sum_discount||"0")+parseInt(h.bill_summary[2]?.order_item_sum_discount||"0")+parseInt(h.bill_summary[3]?.order_item_sum_discount||"0")+parseInt(h.bill_summary[1]?.order_discount||"0")+parseInt(h.bill_summary[2]?.order_discount||"0")+parseInt(h.bill_summary[3]?.order_discount||"0")]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-inline-flex hfl-flex-1 hfl-items-center hfl-text-Gray-800 ",children:"Tax Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹"," ",parseInt(h.bill_summary[1]?.order_service_tax||"0")+parseInt(h.bill_summary[2]?.order_service_tax||"0")+parseInt(h.bill_summary[3]?.order_service_tax||"0")]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Final Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹"," ",parseInt(h.bill_summary[1]?.net_bill_amount||"0")+parseInt(h.bill_summary[2]?.net_bill_amount||"0")+parseInt(h.bill_summary[3]?.net_bill_amount||"0")]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Received Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹"," ",parseInt(h.bill_summary[1]?.order_paid_amount||"0")+parseInt(h.bill_summary[2]?.order_paid_amount||"0")+parseInt(h.bill_summary[3]?.order_paid_amount||"0")]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Refund Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹"," - ",parseInt(h.bill_summary[1]?.refund_amount||"0")+parseInt(h.bill_summary[2]?.refund_amount||"0")+parseInt(h.bill_summary[3]?.refund_amount||"0")]})]}),D&&e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px]",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Past Due Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹ ",N?.total_amount]}),e.jsxRuntimeExports.jsx("div",{className:"hx_close hfl-flex-shrink-0 hfl-cursor-pointer hfl-text-4",onClick:()=>Q()})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Total Balance"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Bold",type:"Text lg",className:"hfl-text-Gray-800",children:["₹"," ",(parseInt(h.bill_summary[1]?.balance_amount||"0")||0)+(parseInt(h.bill_summary[2]?.balance_amount||"0")||0)+(parseInt(h.bill_summary[3]?.balance_amount||"0")||0)+(D&&parseInt(N?.total_amount||"0")||0)]})]}),e.jsxRuntimeExports.jsx(Al,{isPayDue:D,rightSegment:c,pastDueData:N,showDiscount:w,showRefund:l,summaryData:h,date:d,getBillSummarydata:V,handleRightSegment:n,getPastDueAmount:g,refreshBillsList:k,deleteLastPaymemntMode:P,setDeleteLastPaymentMode:I,walletBalance:O,setRefreshWallet:W})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-px-2 hfl-pb-2",children:[e.jsxRuntimeExports.jsx(p.Ku,{"data-qa":"to-print",hierarchy:"Tertiary",size:"md",textField:"Print",disabled:!1,icon:"Left",onClick:()=>y([1,2,3],"billPrintPreview",!1),iconFile:"hx_print",className:" hfl-flex-1 hfl-items-center hfl-justify-center hfl-border hfl-border-Gray-300 hfl-bg-White hfl-text-Gray-700 hover:hfl-bg-Gray-100"}),e.jsxRuntimeExports.jsx(p.Ku,{"data-qa":"to-share",hierarchy:"Tertiary",size:"md",textField:"Share",icon:"Left",onClick:()=>y([1,2,3],"billSharePreview",!0),iconFile:"hx_share",className:" hfl-flex-1 hfl-items-center hfl-justify-center hfl-border hfl-border-Gray-300 hfl-bg-White hfl-text-Gray-700 hover:hfl-bg-Gray-100"})]})]})},oa=a=>{const{editedTableData:d,handleRightSegment:c,getBillSummarydata:n,order_date:y,editRowId:w,setTableData:l,refreshBillsList:T,handleRevertEdit:N}=a,{patientIDs:h,showToast:V,doctorListArr:g,billPreferences:k,formattedService:O,ppEventProps:W,variable:D}=_.useContext(It),[A,P]=_.useState(),I={bill_item_details:{doctor_name:D.window_var.doc_name_for_seg,referrer_doctor_role_id:D.window_var.doctor_role_id_for_seg,lab_owner_name:"",lab_owner_id:"",appointment_details:{appnt_id:"",doctor_role_id:"",appnt_date:"",appnt_time:"",appnt_duration:0,appnt_status:0},appnt_doctor_role_id:""}},[R,Q]=_.useState(()=>({...d,...I})),B=(K,ue)=>{let ce={};K==="labowner"?ce={lab_owner_name:ue.labOwnerName,lab_owner_id:ue.LabOwnerDocRoleID||""}:ce={doctor_name:ue.docName,referrer_doctor_role_id:ue.docRoleID},Q(X=>({...X,bill_item_details:{...X.bill_item_details,...ce}}))},L=async(K="")=>{try{const ue=await Nn(K,D);P(ue)}catch(ue){console.error("Error in getReferalDoctorList API Call:",ue)}};_.useEffect(()=>{L()},[]);const z=async()=>{if(d?.order_item_id)try{const K=await Cl(d?.order_item_id,h.patientRoleID,D);Q(ue=>{const ce=K.data;return{...ue,...sn,...ce,service_category:St[2],service_category_id:"3",order_item_service_tax_percentage:O?.[+ce.service_id]?.service_tax||0,bill_item_details:{...ue.bill_item_details,...ce.bill_item_details,appnt_doctor_role_id:"",referrer_doctor_role_id:""}}})}catch(K){console.error("Error fetching bill item data:",K)}};return _.useEffect(()=>{d&&Q({...R,...d})},[d]),_.useEffect(()=>{z()},[R.order_item_id]),e.jsxRuntimeExports.jsxs("div",{className:"hfl-relative hfl-h-full",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-h-8 hfl-shrink-0 hfl-items-center hfl-justify-between hfl-gap-2 hfl-border-b-1 hfl-border-b-Gray-200 hfl-px-2",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text md",className:"hfl-max-w-[300px] hfl-truncate",children:R?.service_name}),e.jsxRuntimeExports.jsx("div",{className:"hx_close hfl-flex-shrink-0 hfl-cursor-pointer hfl-text-4",onClick:()=>{c(),N()}})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-gap-[14px] hfl-px-3 hfl-py-4",children:[k?.billing?.enable_add_service_owner!=0&&e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(p.tj,{label:"Doctor Name",labelSize:"Text sm",labelColor:"hfl-text-Gray-800",input1value:"Dr.",input2value:R.bill_item_details.doctor_name,end_icon:"hx_down hfl-bg-White_20",inputProps:{disabled:!0},suffixInputProps:{placeholder:"Doctor Name"},className:"hfl-w-12 hfl-flex-none hfl-text-ellipsis hfl-bg-Gray-50 hfl-text-Gray-500",suffixClassName:" hfl-w-[220px] hfl-text-ellipsis hfl-bg-White_20",suffixDropdownClassName:"hfl-ml-12",widthSufixDrpdwn:"hfl-w-[250px]",suffixOptions:g?.doctor_list?.map(K=>({label:K.doctor_name,value:K.doctor_name,appnt_doctor_role_id:K.doctor_identifier})),handleSuffixValChange:K=>{B("",{docName:K,docRoleID:""})},onSuffixDropdownClick:K=>{B("",{docName:K.label,docRoleID:K.appnt_doctor_role_id})}})}),k?.billing?.enable_add_service_owner!=0&&e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(p.tj,{label:"Lab Owner (Referred By)",labelSize:"Text sm",labelColor:"hfl-text-Gray-800",end_icon:"hx_down hfl-bg-White_20",input2value:R.bill_item_details.lab_owner_name,inputProps:{disabled:!0},suffixInputProps:{placeholder:"Lab Owner (Referred By)"},className:"hfl-hidden hfl-w-12 hfl-text-ellipsis hfl-bg-Gray-50 hfl-text-Gray-500",suffixClassName:" hfl-border-l-0 hfl-w-[270px] hfl-text-ellipsis hfl-bg-White_20",widthSufixDrpdwn:"hfl-w-[305px]",suffixOptions:A?.referrals?.map(K=>({label:K.referralName,value:K.referralName,referralId:K.referralId})),onlySuffixDropdownItemsAllowed:!1,handleSuffixValChange:K=>{L(K),B("labowner",{labOwnerName:K,LabOwnerDocRoleID:""})},onSuffixDropdownClick:K=>{B("labowner",{labOwnerName:K.label,LabOwnerDocRoleID:K.referralId})}})}),e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Primary",size:"lg",textField:"Update",className:"hfl-flex hfl-h-9 hfl-w-full hfl-shrink-0 hfl-items-center hfl-justify-center hfl-gap-1 hfl-self-stretch hfl-rounded-md hfl-p-3",onClick:async()=>{const K=await Pl(R,V,h.patientRoleID,Ie.dayjs(y).format("YYYY-MM-DD"),W,St[2],D);R.bill_item_details.lab_owner_name&&An(R.bill_item_details.lab_owner_name,h?.patientRoleID||"",D),K&&(l(ue=>ue.map((ce,X)=>w==X.toString()?{...ce,order_item_id:K.order_item_id||R.order_item_id}:ce)),(K.order_item_id||R.order_item_id)&&(n(),c(),T(y)))}})})]}),e.jsxRuntimeExports.jsx("div",{className:"hfl-absolute hfl-bottom-4 hfl-left-2 hfl-w-full",children:e.jsxRuntimeExports.jsx(p.Ku,{className:"hfl-h-8 hfl-shrink-0 hfl-border-l-Gray-200 hfl-bg-White_20 hfl-text-Gray-500 hfl-shadow-md hover:hfl-bg-Gray-100",hierarchy:"Tertiary",size:"md",textField:"Go Back",icon:"Left",iconFile:"hx_arrow-left hfl-text-Gray-500",onClick:()=>{c(),N()}})})]})},ua="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='50'%20height='49'%20viewBox='0%200%2050%2049'%20fill='none'%3e%3cg%20opacity='0.3'%20clip-path='url(%23clip0_916_82588)'%3e%3cpath%20d='M48.2399%2011.218V38.5495C48.2399%2039.4022%2047.9011%2040.2201%2047.2981%2040.8231C46.6951%2041.4261%2045.8772%2041.7649%2045.0244%2041.7649H4.83118C3.97839%2041.7649%203.16052%2041.4261%202.55751%2040.8231C1.95449%2040.2201%201.61572%2039.4022%201.61572%2038.5495V11.218L2.41959%2010.4142H47.436L48.2399%2011.218Z'%20fill='%23F9FAFB'/%3e%3cpath%20d='M48.2399%208.00245V11.2179H1.61572V8.00245C1.61572%207.14965%201.95449%206.33179%202.55751%205.72877C3.16052%205.12576%203.97839%204.78699%204.83118%204.78699H45.0244C45.8772%204.78699%2046.6951%205.12576%2047.2981%205.72877C47.9011%206.33179%2048.2399%207.14965%2048.2399%208.00245Z'%20fill='%23D0D5DD'/%3e%3cpath%20d='M10.4572%203.17951C10.4572%202.29158%209.73735%201.57178%208.84943%201.57178C7.9615%201.57178%207.2417%202.29158%207.2417%203.17951V6.39497C7.2417%207.28289%207.9615%208.0027%208.84943%208.0027C9.73735%208.0027%2010.4572%207.28289%2010.4572%206.39497V3.17951Z'%20fill='%23F9FAFB'/%3e%3cpath%20d='M18.4967%203.17951C18.4967%202.29158%2017.7769%201.57178%2016.889%201.57178C16.0011%201.57178%2015.2812%202.29158%2015.2812%203.17951V6.39497C15.2812%207.28289%2016.0011%208.0027%2016.889%208.0027C17.7769%208.0027%2018.4967%207.28289%2018.4967%206.39497V3.17951Z'%20fill='%23F9FAFB'/%3e%3cpath%20d='M26.5348%203.17951C26.5348%202.29158%2025.815%201.57178%2024.9271%201.57178C24.0391%201.57178%2023.3193%202.29158%2023.3193%203.17951V6.39497C23.3193%207.28289%2024.0391%208.0027%2024.9271%208.0027C25.815%208.0027%2026.5348%207.28289%2026.5348%206.39497V3.17951Z'%20fill='%23F9FAFB'/%3e%3cpath%20d='M34.5734%203.17951C34.5734%202.29158%2033.8536%201.57178%2032.9656%201.57178C32.0777%201.57178%2031.3579%202.29158%2031.3579%203.17951V6.39497C31.3579%207.28289%2032.0777%208.0027%2032.9656%208.0027C33.8536%208.0027%2034.5734%207.28289%2034.5734%206.39497V3.17951Z'%20fill='%23F9FAFB'/%3e%3cpath%20d='M42.6124%203.17951C42.6124%202.29158%2041.8926%201.57178%2041.0047%201.57178C40.1168%201.57178%2039.397%202.29158%2039.397%203.17951V6.39497C39.397%207.28289%2040.1168%208.0027%2041.0047%208.0027C41.8926%208.0027%2042.6124%207.28289%2042.6124%206.39497V3.17951Z'%20fill='%23F9FAFB'/%3e%3cpath%20d='M24.928%2034.5299C29.8115%2034.5299%2033.7705%2030.571%2033.7705%2025.6874C33.7705%2020.8038%2029.8115%2016.8449%2024.928%2016.8449C20.0444%2016.8449%2016.0854%2020.8038%2016.0854%2025.6874C16.0854%2030.571%2020.0444%2034.5299%2024.928%2034.5299Z'%20fill='%23D0D5DD'/%3e%3cpath%20d='M29.7505%2024.0798H26.5351V20.8644C26.5351%2020.6512%2026.4504%2020.4467%2026.2996%2020.2959C26.1489%2020.1452%2025.9444%2020.0605%2025.7312%2020.0605H24.1235C23.9103%2020.0605%2023.7058%2020.1452%2023.5551%2020.2959C23.4043%2020.4467%2023.3196%2020.6512%2023.3196%2020.8644V24.0798H20.1042C19.891%2024.0798%2019.6865%2024.1645%2019.5357%2024.3153C19.385%2024.466%2019.3003%2024.6705%2019.3003%2024.8837V26.4914C19.3003%2026.7046%2019.385%2026.9091%2019.5357%2027.0598C19.6865%2027.2106%2019.891%2027.2953%2020.1042%2027.2953H23.3196V30.5107C23.3196%2030.7239%2023.4043%2030.9284%2023.5551%2031.0791C23.7058%2031.2299%2023.9103%2031.3146%2024.1235%2031.3146H25.7312C25.9444%2031.3146%2026.1489%2031.2299%2026.2996%2031.0791C26.4504%2030.9284%2026.5351%2030.7239%2026.5351%2030.5107V27.2953H29.7505C29.9637%2027.2953%2030.1682%2027.2106%2030.319%2027.0598C30.4697%2026.9091%2030.5544%2026.7046%2030.5544%2026.4914V24.8837C30.5544%2024.6705%2030.4697%2024.466%2030.319%2024.3153C30.1682%2024.1645%2029.9637%2024.0798%2029.7505%2024.0798Z'%20fill='white'/%3e%3cpath%20d='M13.6731%2048.1958C15.8929%2048.1958%2017.6925%2046.3963%2017.6925%2044.1765C17.6925%2041.9567%2015.8929%2040.1572%2013.6731%2040.1572C11.4533%2040.1572%209.65381%2041.9567%209.65381%2044.1765C9.65381%2046.3963%2011.4533%2048.1958%2013.6731%2048.1958Z'%20fill='%2398A2B3'/%3e%3cpath%20d='M45.0241%203.9834H43.4164V3.17954C43.4164%202.53994%2043.1623%201.92655%2042.71%201.47428C42.2578%201.02202%2041.6444%200.767944%2041.0048%200.767944C40.3652%200.767944%2039.7518%201.02202%2039.2995%201.47428C38.8472%201.92655%2038.5932%202.53994%2038.5932%203.17954V3.9834H35.3777V3.17954C35.3777%202.53994%2035.1236%201.92655%2034.6714%201.47428C34.2191%201.02202%2033.6057%200.767944%2032.9661%200.767944C32.3265%200.767944%2031.7131%201.02202%2031.2609%201.47428C30.8086%201.92655%2030.5545%202.53994%2030.5545%203.17954V3.9834H27.3391V3.17954C27.3391%202.53994%2027.085%201.92655%2026.6327%201.47428C26.1805%201.02202%2025.5671%200.767944%2024.9275%200.767944C24.2879%200.767944%2023.6745%201.02202%2023.2222%201.47428C22.7699%201.92655%2022.5159%202.53994%2022.5159%203.17954V3.9834H19.3004V3.17954C19.3004%202.53994%2019.0463%201.92655%2018.5941%201.47428C18.1418%201.02202%2017.5284%200.767944%2016.8888%200.767944C16.2492%200.767944%2015.6358%201.02202%2015.1836%201.47428C14.7313%201.92655%2014.4772%202.53994%2014.4772%203.17954V3.9834H11.2618V3.17954C11.2618%202.53994%2011.0077%201.92655%2010.5554%201.47428C10.1032%201.02202%209.48977%200.767944%208.85017%200.767944C8.21058%200.767944%207.59718%201.02202%207.14492%201.47428C6.69265%201.92655%206.43858%202.53994%206.43858%203.17954V3.9834H4.83085C3.76525%203.98468%202.74366%204.40855%201.99017%205.16205C1.23667%205.91554%200.8128%206.93713%200.811523%208.00273L0.811523%2038.5496C0.8128%2039.6152%201.23667%2040.6368%201.99017%2041.3903C2.74366%2042.1438%203.76525%2042.5676%204.83085%2042.5689H9.13152C8.80047%2043.5017%208.7644%2044.5137%209.02822%2045.4677C9.29203%2046.4217%209.84294%2047.2714%2010.6062%2047.9015C11.3695%2048.5317%2012.3081%2048.9117%2013.2948%2048.9902C14.2814%2049.0686%2015.2683%2048.8416%2016.1216%2048.3399C16.9748%2047.8382%2017.653%2047.0862%2018.0642%2046.1859C18.4754%2045.2856%2018.5996%2044.2805%2018.4201%2043.3072C18.2405%2042.3338%2017.7659%2041.4393%2017.0605%2040.7449C16.3552%2040.0506%2015.4533%2039.59%2014.4772%2039.4258V31.3148C14.4772%2030.6752%2014.2231%2030.0618%2013.7709%2029.6096C13.3186%2029.1573%2012.7052%2028.9032%2012.0656%2028.9032H10.8598C10.54%2028.9032%2010.2333%2028.7762%2010.0072%2028.55C9.78107%2028.3239%209.65404%2028.0172%209.65404%2027.6974C9.65404%2027.3776%209.78107%2027.0709%2010.0072%2026.8448C10.2333%2026.6187%2010.54%2026.4916%2010.8598%2026.4916H15.3221C15.5196%2028.9036%2016.6173%2031.153%2018.397%2032.793C20.1767%2034.4329%2022.5082%2035.3433%2024.9283%2035.3433C27.3483%2035.3433%2029.6799%2034.4329%2031.4596%2032.793C33.2393%2031.153%2034.3369%2028.9036%2034.5345%2026.4916H35.3777C35.5909%2026.4916%2035.7954%2026.5763%2035.9461%2026.7271C36.0969%2026.8778%2036.1816%2027.0823%2036.1816%2027.2955V32.5206C36.1816%2033.2668%2036.478%2033.9824%2037.0056%2034.5101C37.5333%2035.0377%2038.2489%2035.3341%2038.9951%2035.3341C39.7413%2035.3341%2040.4569%2035.0377%2040.9846%2034.5101C41.5122%2033.9824%2041.8086%2033.2668%2041.8086%2032.5206V24.8115C42.9313%2024.6208%2043.9503%2024.0394%2044.6858%2023.1701C45.4213%2022.3007%2045.8258%2021.1994%2045.8279%2020.0607V15.2375C45.8279%2014.8111%2045.6586%2014.4022%2045.3571%2014.1007C45.0555%2013.7992%2044.6466%2013.6298%2044.2202%2013.6298H43.4164C43.2032%2013.6298%2042.9987%2013.7145%2042.8479%2013.8652C42.6972%2014.016%2042.6125%2014.2204%2042.6125%2014.4336C42.6125%2014.6468%2042.6972%2014.8513%2042.8479%2015.0021C42.9987%2015.1528%2043.2032%2015.2375%2043.4164%2015.2375H44.2202V20.0607C44.2202%2020.9135%2043.8814%2021.7314%2043.2784%2022.3344C42.6754%2022.9374%2041.8576%2023.2762%2041.0048%2023.2762C40.152%2023.2762%2039.3341%2022.9374%2038.7311%2022.3344C38.1281%2021.7314%2037.7893%2020.9135%2037.7893%2020.0607V15.2375H38.5932C38.8064%2015.2375%2039.0108%2015.1528%2039.1616%2015.0021C39.3123%2014.8513%2039.397%2014.6468%2039.397%2014.4336C39.397%2014.2204%2039.3123%2014.016%2039.1616%2013.8652C39.0108%2013.7145%2038.8064%2013.6298%2038.5932%2013.6298H37.7893C37.3629%2013.6298%2036.954%2013.7992%2036.6525%2014.1007C36.351%2014.4022%2036.1816%2014.8111%2036.1816%2015.2375V20.0607C36.1837%2021.1994%2036.5882%2022.3007%2037.3237%2023.1701C38.0592%2024.0394%2039.0783%2024.6208%2040.2009%2024.8115V32.5206C40.2009%2032.8404%2040.0739%2033.1471%2039.8477%2033.3732C39.6216%2033.5994%2039.3149%2033.7264%2038.9951%2033.7264C38.6753%2033.7264%2038.3686%2033.5994%2038.1425%2033.3732C37.9163%2033.1471%2037.7893%2032.8404%2037.7893%2032.5206V27.2955C37.7893%2026.6559%2037.5352%2026.0425%2037.083%2025.5902C36.6307%2025.138%2036.0173%2024.8839%2035.3777%2024.8839H34.5328C34.3353%2022.4719%2033.2377%2020.2225%2031.458%2018.5825C29.6782%2016.9426%2027.3467%2016.0322%2024.9267%2016.0322C22.5066%2016.0322%2020.1751%2016.9426%2018.3954%2018.5825C16.6157%2020.2225%2015.518%2022.4719%2015.3205%2024.8839H10.8598C10.1136%2024.8839%209.39801%2025.1803%208.87037%2025.708C8.34273%2026.2356%208.04631%2026.9512%208.04631%2027.6974C8.04631%2028.4436%208.34273%2029.1592%208.87037%2029.6869C9.39801%2030.2145%2010.1136%2030.5109%2010.8598%2030.5109H12.0656C12.2788%2030.5109%2012.4833%2030.5956%2012.634%2030.7464C12.7848%2030.8971%2012.8695%2031.1016%2012.8695%2031.3148V39.4258C11.7956%2039.6088%2010.8152%2040.15%2010.0881%2040.9612H4.83085C4.19125%2040.9612%203.57785%2040.7071%203.12559%2040.2548C2.67333%2039.8026%202.41925%2039.1892%202.41925%2038.5496V12.0221H47.4357V38.5496C47.4357%2039.1892%2047.1816%2039.8026%2046.7293%2040.2548C46.2771%2040.7071%2045.6637%2040.9612%2045.0241%2040.9612H20.1043C19.8911%2040.9612%2019.6866%2041.0459%2019.5359%2041.1966C19.3851%2041.3474%2019.3004%2041.5519%2019.3004%2041.7651C19.3004%2041.9782%2019.3851%2042.1827%2019.5359%2042.3335C19.6866%2042.4842%2019.8911%2042.5689%2020.1043%2042.5689H45.0241C46.0897%2042.5676%2047.1113%2042.1438%2047.8648%2041.3903C48.6183%2040.6368%2049.0421%2039.6152%2049.0434%2038.5496V8.00273C49.0421%206.93713%2048.6183%205.91554%2047.8648%205.16205C47.1113%204.40855%2046.0897%203.98468%2045.0241%203.9834ZM24.9275%2017.6491C26.5174%2017.6491%2028.0715%2018.1206%2029.3935%2019.0039C30.7154%2019.8872%2031.7458%2021.1426%2032.3542%2022.6115C32.9626%2024.0804%2033.1218%2025.6967%2032.8117%2027.256C32.5015%2028.8154%2031.7359%2030.2477%2030.6116%2031.3719C29.4874%2032.4962%2028.0551%2033.2618%2026.4957%2033.5719C24.9364%2033.8821%2023.3201%2033.7229%2021.8512%2033.1145C20.3823%2032.5061%2019.1269%2031.4757%2018.2436%2030.1538C17.3603%2028.8318%2016.8888%2027.2776%2016.8888%2025.6878C16.8912%2023.5565%2017.7388%2021.5132%2019.2459%2020.0062C20.7529%2018.4991%2022.7962%2017.6514%2024.9275%2017.6491ZM13.6734%2040.9612C14.3093%2040.9612%2014.931%2041.1498%2015.4598%2041.5031C15.9886%2041.8564%2016.4007%2042.3586%2016.6441%2042.9461C16.8874%2043.5337%2016.9511%2044.1802%2016.827%2044.804C16.703%2045.4277%2016.3967%2046.0006%2015.947%2046.4503C15.4973%2046.9%2014.9244%2047.2063%2014.3007%2047.3303C13.6769%2047.4544%2013.0304%2047.3907%2012.4429%2047.1473C11.8553%2046.904%2011.3531%2046.4918%2010.9998%2045.9631C10.6465%2045.4343%2010.4579%2044.8126%2010.4579%2044.1766C10.4579%2043.3239%2010.7967%2042.506%2011.3997%2041.903C12.0027%2041.3%2012.8206%2040.9612%2013.6734%2040.9612ZM40.2009%203.17954C40.2009%202.96634%2040.2856%202.76187%2040.4363%202.61112C40.5871%202.46037%2040.7916%202.37567%2041.0048%202.37567C41.218%202.37567%2041.4224%202.46037%2041.5732%202.61112C41.7239%202.76187%2041.8086%202.96634%2041.8086%203.17954V6.395C41.8086%206.6082%2041.7239%206.81266%2041.5732%206.96342C41.4224%207.11417%2041.218%207.19886%2041.0048%207.19886C40.7916%207.19886%2040.5871%207.11417%2040.4363%206.96342C40.2856%206.81266%2040.2009%206.6082%2040.2009%206.395V3.17954ZM32.1622%203.17954C32.1622%202.96634%2032.2469%202.76187%2032.3977%202.61112C32.5484%202.46037%2032.7529%202.37567%2032.9661%202.37567C33.1793%202.37567%2033.3838%202.46037%2033.5345%202.61112C33.6853%202.76187%2033.77%202.96634%2033.77%203.17954V6.395C33.77%206.6082%2033.6853%206.81266%2033.5345%206.96342C33.3838%207.11417%2033.1793%207.19886%2032.9661%207.19886C32.7529%207.19886%2032.5484%207.11417%2032.3977%206.96342C32.2469%206.81266%2032.1622%206.6082%2032.1622%206.395V3.17954ZM24.1236%203.17954C24.1236%202.96634%2024.2083%202.76187%2024.359%202.61112C24.5098%202.46037%2024.7143%202.37567%2024.9275%202.37567C25.1407%202.37567%2025.3451%202.46037%2025.4959%202.61112C25.6466%202.76187%2025.7313%202.96634%2025.7313%203.17954V6.395C25.7313%206.6082%2025.6466%206.81266%2025.4959%206.96342C25.3451%207.11417%2025.1407%207.19886%2024.9275%207.19886C24.7143%207.19886%2024.5098%207.11417%2024.359%206.96342C24.2083%206.81266%2024.1236%206.6082%2024.1236%206.395V3.17954ZM16.085%203.17954C16.085%202.96634%2016.1696%202.76187%2016.3204%202.61112C16.4712%202.46037%2016.6756%202.37567%2016.8888%202.37567C17.102%202.37567%2017.3065%202.46037%2017.4572%202.61112C17.608%202.76187%2017.6927%202.96634%2017.6927%203.17954V6.395C17.6927%206.6082%2017.608%206.81266%2017.4572%206.96342C17.3065%207.11417%2017.102%207.19886%2016.8888%207.19886C16.6756%207.19886%2016.4712%207.11417%2016.3204%206.96342C16.1696%206.81266%2016.085%206.6082%2016.085%206.395V3.17954ZM8.04631%203.17954C8.04631%202.96634%208.131%202.76187%208.28175%202.61112C8.43251%202.46037%208.63697%202.37567%208.85017%202.37567C9.06337%202.37567%209.26783%202.46037%209.41859%202.61112C9.56934%202.76187%209.65404%202.96634%209.65404%203.17954V6.395C9.65404%206.6082%209.56934%206.81266%209.41859%206.96342C9.26783%207.11417%209.06337%207.19886%208.85017%207.19886C8.63697%207.19886%208.43251%207.11417%208.28175%206.96342C8.131%206.81266%208.04631%206.6082%208.04631%206.395V3.17954ZM2.41925%2010.4143V8.00273C2.41925%207.36313%202.67333%206.74973%203.12559%206.29747C3.57785%205.84521%204.19125%205.59113%204.83085%205.59113H6.43858V6.395C6.43858%207.03459%206.69265%207.64799%207.14492%208.10025C7.59718%208.55252%208.21058%208.80659%208.85017%208.80659C9.48977%208.80659%2010.1032%208.55252%2010.5554%208.10025C11.0077%207.64799%2011.2618%207.03459%2011.2618%206.395V5.59113H14.4772V6.395C14.4772%207.03459%2014.7313%207.64799%2015.1836%208.10025C15.6358%208.55252%2016.2492%208.80659%2016.8888%208.80659C17.5284%208.80659%2018.1418%208.55252%2018.5941%208.10025C19.0463%207.64799%2019.3004%207.03459%2019.3004%206.395V5.59113H22.5159V6.395C22.5159%207.03459%2022.7699%207.64799%2023.2222%208.10025C23.6745%208.55252%2024.2879%208.80659%2024.9275%208.80659C25.5671%208.80659%2026.1805%208.55252%2026.6327%208.10025C27.085%207.64799%2027.3391%207.03459%2027.3391%206.395V5.59113H30.5545V6.395C30.5545%207.03459%2030.8086%207.64799%2031.2609%208.10025C31.7131%208.55252%2032.3265%208.80659%2032.9661%208.80659C33.6057%208.80659%2034.2191%208.55252%2034.6714%208.10025C35.1236%207.64799%2035.3777%207.03459%2035.3777%206.395V5.59113H38.5932V6.395C38.5932%207.03459%2038.8472%207.64799%2039.2995%208.10025C39.7518%208.55252%2040.3652%208.80659%2041.0048%208.80659C41.6444%208.80659%2042.2578%208.55252%2042.71%208.10025C43.1623%207.64799%2043.4164%207.03459%2043.4164%206.395V5.59113H45.0241C45.6637%205.59113%2046.2771%205.84521%2046.7293%206.29747C47.1816%206.74973%2047.4357%207.36313%2047.4357%208.00273V10.4143H2.41925Z'%20fill='%2398A2B3'/%3e%3cpath%20d='M22.5154%2028.0995V30.5111C22.5154%2030.9375%2022.6848%2031.3465%2022.9863%2031.648C23.2878%2031.9495%2023.6968%2032.1189%2024.1231%2032.1189H25.7309C26.1573%2032.1189%2026.5662%2031.9495%2026.8677%2031.648C27.1692%2031.3465%2027.3386%2030.9375%2027.3386%2030.5111V28.0995H29.7502C30.1766%2028.0995%2030.5855%2027.9301%2030.887%2027.6286C31.1885%2027.3271%2031.3579%2026.9182%2031.3579%2026.4918V24.8841C31.3579%2024.4577%2031.1885%2024.0487%2030.887%2023.7472C30.5855%2023.4457%2030.1766%2023.2763%2029.7502%2023.2763H27.3386V20.8647C27.3386%2020.4384%2027.1692%2020.0294%2026.8677%2019.7279C26.5662%2019.4264%2026.1573%2019.257%2025.7309%2019.257H24.1231C23.6968%2019.257%2023.2878%2019.4264%2022.9863%2019.7279C22.6848%2020.0294%2022.5154%2020.4384%2022.5154%2020.8647V23.2763H20.1038C19.6774%2023.2763%2019.2685%2023.4457%2018.967%2023.7472C18.6655%2024.0487%2018.4961%2024.4577%2018.4961%2024.8841V26.4918C18.4961%2026.9182%2018.6655%2027.3271%2018.967%2027.6286C19.2685%2027.9301%2019.6774%2028.0995%2020.1038%2028.0995H22.5154ZM20.1038%2024.8841H23.3193C23.5325%2024.8841%2023.7369%2024.7994%2023.8877%2024.6486C24.0385%2024.4979%2024.1231%2024.2934%2024.1231%2024.0802V20.8647H25.7309V24.0802C25.7309%2024.2934%2025.8156%2024.4979%2025.9663%2024.6486C26.1171%2024.7994%2026.3215%2024.8841%2026.5347%2024.8841H29.7502V26.4918H26.5347C26.3215%2026.4918%2026.1171%2026.5765%2025.9663%2026.7272C25.8156%2026.878%2025.7309%2027.0825%2025.7309%2027.2957V30.5111H24.1231V27.2957C24.1231%2027.0825%2024.0385%2026.878%2023.8877%2026.7272C23.7369%2026.5765%2023.5325%2026.4918%2023.3193%2026.4918H20.1038V24.8841Z'%20fill='%2398A2B3'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_916_82588'%3e%3crect%20width='48.2319'%20height='48.2319'%20fill='white'%20transform='translate(0.811523%200.767883)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",ca=a=>{const{showToast:d,patientIDs:c,doctorListArr:n,patientDetails:y,billPreferences:w,formattedService:l,ppEventProps:T,variable:N}=_.useContext(It),{bill_date:h,handleRightSegment:V,getBillSummarydata:g,editedTableData:k,setTableData:O,editRowId:W,refreshBillsList:D,handleRevertEdit:A,checkAppointmentForBilling:P}=a,[I,R]=_.useState([]),Q=new Date().toLocaleString("en-US",{hour:"numeric",minute:"numeric",hour12:!0}),B=n?.doctor_list?.length===1?n?.doctor_list[0]:{doctor_name:"",doctor_identifier:""},L={...ql,appnt_doctor_name:window.role_id=="11"?window.doc_name_for_seg:B?.doctor_name,appnt_doctor_role_id:window.role_id=="11"?window.doctor_role_id_for_seg:B?.doctor_identifier,appnt_duration:+w?.print?.bill?.appnt_minute_slab,appnt_time_time:Q?.split(" ")[0]||"",appnt_time_format:Q?.split(" ")[1]||"",total_price:"",appnt_date:Ie.dayjs().format("YYYY-MM-DD"),appnt_service_id:k?.service_id||"",appnt_service_name:k?.service_name||"",...k},[z,K]=_.useState(L),[ue,ce]=_.useState(!1),X=async()=>{if(k?.order_item_id)try{const $=await Cl(k.order_item_id,c.patientRoleID,N),{created_on:fe,order_item_service_tax:H,service_id:De,bill_item_details:Me,order_item_id:Le,item_quantity:xt,order_unit_item_price:ht,order_item_price:at,order_item_discount:We,service_name:it}=$.data,{appointment_details:Pt,doctor_name:gt}=Me,{appnt_id:At,appnt_date:Gt=Ie.dayjs().format("YYYY-MM-DD"),appnt_time:G,appnt_status:Te,appnt_duration:Ze,doctor_role_id:se}=Pt,J=new Date("1970-01-01T"+G+"Z").toLocaleTimeString("en-US",{timeZone:"UTC",hour12:!0,hour:"numeric",minute:"numeric"}),U={appnt_time_time:"",appnt_time_format:""};J&&J!=="Invalid Date"&&(U.appnt_time_time=J?.split(" ")[0],U.appnt_time_format=J?.split(" ")[1]),K(ie=>({...ie,appnt_id:At,patient_role_id:c.patientRoleID,appnt_doctor_role_id:se,appnt_service_id:De,appnt_date:Gt,appnt_time:G,appnt_status:Te,appnt_duration:Ze,appnt_doctor_name:gt,appnt_service_name:it,appnt_mode:"inperson",order_item_id:Le,item_quantity:xt,order_unit_item_price:ht,order_item_price:at,order_item_discount:We,order_item_service_tax:""+Math.floor(+H),order_item_service_tax_percentage:l[+De]?.service_tax||0,total_price:"",appnt_created_on:fe,order_item_created_on:fe,...U}))}catch($){K(L),console.error("Error fetching bill item data:",$)}};_.useEffect(()=>{k&&K({...z,...k})},[k]),_.useEffect(()=>{X()},[z.order_item_id]);const[ee,ve]=_.useState(!1),de=($,fe)=>{K(H=>({...H,[$]:fe}))},Ue=async()=>{try{const $=await hn(k.service_id,Ie.dayjs(h).format("YYYY-MM-DD"),c.patientRoleID,N);if($?.appointments?.length)for(const fe of $.appointments){const H=new Date("1970-01-01T"+fe.appnt_time+"Z").toLocaleTimeString("en-US",{timeZone:"UTC",hour12:!0,hour:"numeric",minute:"numeric"});H&&H!=="Invalid Date"&&(fe.appnt_time_time=H?.split(" ")[0],fe.appnt_time_format=H?.split(" ")[1])}R($?.appointments)}catch{console.log("error in getAppointmentsList API Call")}};_.useEffect(()=>{Ue()},[k?.service_id]);const pe=z.appnt_date&&Ie.dayjs(z.appnt_date).format("YYYY-MM-DD")<Ie.dayjs().format("YYYY-MM-DD");return e.jsxRuntimeExports.jsxs("div",{className:"hfl-relative hfl-h-full",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-h-8 hfl-w-[340px] hfl-shrink-0 hfl-items-center hfl-justify-between hfl-gap-2 hfl-border-b-1 hfl-border-b-Gray-200 hfl-px-2",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text md",className:"hfl-truncate hfl-capitalize",title:k?.service_name||"",children:k?.service_name||""}),e.jsxRuntimeExports.jsx("div",{className:"hx_close hfl-flex-shrink-0 hfl-cursor-pointer hfl-text-4",onClick:()=>{V(),A()}})]}),I.length>0&&!ee&&e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-items-center hfl-gap-2.5 hfl-px-[13px] hfl-py-3",children:[I.map(($,fe)=>e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-full hfl-shrink-0 hfl-flex-col hfl-items-start hfl-gap-[5px] hfl-rounded-md hfl-border-Gray-200 hfl-bg-White_20 hfl-px-3 hfl-py-2 hfl-shadow-md hover:hfl-bg-Gray-100",onClick:()=>{ve(!0),K(H=>({...H,...$}))},children:[e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",children:["Consultation with ",$.appnt_doctor_name]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-gap-3",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text sm",children:`${$.appnt_time_time} ${$.appnt_time_format}`}),e.jsxRuntimeExports.jsx("div",{className:"hfl-h-[11px] hfl-w-[1px] hfl-bg-Gray-200"}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex",children:[e.jsxRuntimeExports.jsx("div",{className:"hx_inperson hfl-text-3"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",children:"In-Person"})]})]})]},fe)),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Secondary-Grey",size:"md",textField:"Create New Appointment",disabled:Ie.dayjs(h).format("YYYY-MM-DD")!==Ie.dayjs().format("YYYY-MM-DD"),className:"hfl-h-10 hfl-w-full hfl-justify-center hfl-bg-White_20 hfl-text-[13px] hover:hfl-bg-Gray-100",onClick:()=>{ve(!0),K(L)}})]}),(Ie.dayjs(h).format("YYYY-MM-DD")===Ie.dayjs().format("YYYY-MM-DD")&&I.length==0||ee)&&e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-full hfl-flex-col hfl-gap-4 hfl-px-3 hfl-py-4",children:[e.jsxRuntimeExports.jsx(p.tj,{label:"Doctor Name",labelSize:"Text sm",labelColor:"hfl-text-Gray-800",input1value:"Dr.",input2value:z.appnt_doctor_name,end_icon:"hx_down hfl-bg-White_20",inputProps:{disabled:!0},suffixInputProps:{placeholder:"Doctor Name"},className:"hfl-w-12 hfl-flex-none hfl-text-ellipsis hfl-bg-Gray-50 hfl-text-Gray-500",suffixClassName:`hfl-w-[220px] hfl-text-ellipsis hfl-bg-White_20 ${pe?" hfl-pointer-events-none":""}`,suffixDropdownClassName:"hfl-ml-12",widthSufixDrpdwn:"hfl-w-[250px]",suffixOptions:n?.doctor_list?.map($=>({label:$.doctor_name,value:$.doctor_name,appnt_doctor_role_id:$.doctor_identifier})),handleSuffixValChange:$=>{de("appnt_doctor_name",$),de("appnt_doctor_role_id","")},onSuffixDropdownClick:$=>{de("appnt_doctor_name",$.label),de("appnt_doctor_role_id",$.appnt_doctor_role_id)}}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-gap-1.5",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text sm",children:"Date & Time of Appointment"}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-gap-2",children:[pe?e.jsxRuntimeExports.jsx(p.Si,{className:"!hfl-h-[40px]",width:"120px",start_icon:"hx_calendar",inputProps:{value:z.appnt_date,disabled:!0}}):e.jsxRuntimeExports.jsx(p.ZC,{placeholder:"Today",width:"120px",height:"!hfl-h-[40px]",selectDate:new Date(Ie.dayjs(z.appnt_date).format("DD-MMM-YYYY")),dateVar:$=>{de("appnt_date",Ie.dayjs($).format("YYYY-MM-DD"))},isborderRequired:!0,minDate:new Date}),e.jsxRuntimeExports.jsx(p.tj,{className:` hfl-w-20 ${pe?" hfl-pointer-events-none":""}`,suffixClassName:` hfl-w-10 ${pe?" hfl-pointer-events-none":""}`,suffixDropdownClassName:"hfl-ml-[80px]",input1value:z?.appnt_time_time||"",input2value:z?.appnt_time_format||"",end_icon:"hx_down",inputProps:{placeholder:"10:00",onBlur:$=>{de("appnt_time_time",$.target.value)}},onlySuffixDropdownItemsAllowed:!0,suffixInputProps:{placeholder:"AM"},suffixOptions:[{label:"AM",value:"AM"},{label:"PM",value:"PM"}],onSuffixDropdownClick:$=>{de("appnt_time_format",$.value)}})]})]}),e.jsxRuntimeExports.jsx(p.Ap,{value:{label:Br.find($=>$.value==z.appnt_duration)?.label,value:z.appnt_duration},label:"Duration",className:`hfl-text-Gray-800 ${pe?" hfl-pointer-events-none":""}`,onChange:$=>{de("appnt_duration",$.value)},options:Br}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-gap-1.5",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text sm",children:"Type"}),e.jsxRuntimeExports.jsx(p.ju,{options:[{start_icon:"hx_inperson hfl-text-3",label:"In-Person",value:"inperson"}],disabled:!1,value:"inperson"})]}),window?.partner_service_enabled==="1"&&y?.insurance_details?.policy_id?.length&&e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-gap-1.5",children:e.jsxRuntimeExports.jsx(p.Oi,{size:"md",disabled:!1,isMarked:ue,text:"Partner Enabled",onClick:()=>ce($=>!$),"data-qa":"skip-billing"})}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2",children:[e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Tertiary",size:"md",textField:"Cancel",icon:"No",className:"hfl-flex-1 hfl-items-center hfl-justify-center hfl-border hfl-border-Gray-300 hfl-bg-White hfl-text-Gray-700 hover:hfl-bg-Gray-100",onClick:()=>{V(),ve(!1)}}),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Primary",size:"md",textField:z?.appnt_id?.length?"Update":"Create",icon:"No",onClick:async()=>{if(Ie.dayjs(h).format("YYYY-MM-DD")<Ie.dayjs().format("YYYY-MM-DD"))await Pl(z,d,c.patientRoleID,Ie.dayjs(h).format("YYYY-MM-DD"),T,St[0],N)&&V();else{const $=await $l(z,!1,d,y,c,T,ue,!0,N);$&&(O(fe=>fe.map((H,De)=>W==De.toString()?{...H,order_item_id:$.order_item_id||z.order_item_id}:H)),K(fe=>({...fe,order_item_id:$.order_item_id,appnt_id:$.appnt_id,order_id:$.order_id})),$.order_item_id&&$.appnt_id&&V())}g(),D(h),P()},className:"hfl-flex-1 hfl-items-center hfl-justify-center hfl-bg-Primary-600 hfl-text-White_20 hover:hfl-bg-Primary-800"})]})]}),Ie.dayjs(h).format("YYYY-MM-DD")!==Ie.dayjs().format("YYYY-MM-DD")&&I.length==0&&e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-items-center hfl-gap-[11px]",children:[e.jsxRuntimeExports.jsx("img",{className:"hfl-w-[58px] hfl-pb-4",src:ua,alt:"no-bills"}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-gap-1.5 hfl-text-Error-600",children:[e.jsxRuntimeExports.jsx("div",{className:"hx_error-filled hfl-h-5 hfl-w-5 "}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text sm",children:"There is no visit/prescription on this date."})]}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text sm",children:"Bill cannot be created without a visit"})]}),e.jsxRuntimeExports.jsx("div",{className:"hfl-sticky hfl-bottom-4 hfl-left-2 hfl-w-full",children:e.jsxRuntimeExports.jsx(p.Ku,{className:"hfl-h-8 hfl-shrink-0 hfl-border-l-Gray-200 hfl-bg-White_20 hfl-text-Gray-500 hfl-shadow-md hover:hfl-bg-Gray-100",hierarchy:"Tertiary",size:"md",textField:"Go Back",icon:"Left",iconFile:"hx_arrow-left hfl-text-Gray-500",onClick:()=>{ee?ve(!1):V(),A()}})})]})},da=a=>{const{handleRightSegment:d,editedTableData:c,getBillSummarydata:n,order_date:y,setTableData:w,editRowId:l,refreshBillsList:T,handleRevertEdit:N}=a,{patientIDs:h,showToast:V,doctorListArr:g,billPreferences:k,formattedService:O,ppEventProps:W,variable:D}=_.useContext(It)||{},A={bill_item_details:{appointment_details:{appnt_id:"",doctor_role_id:"",appnt_date:"",appnt_time:"",appnt_duration:0,appnt_status:0},doctor_name:D.window_var.doc_name_for_seg,referrer_doctor_role_id:D.window_var.doctor_role_id_for_seg,lab_owner_name:"",lab_owner_id:"",appnt_doctor_role_id:""}},[P,I]=_.useState({...c,...A}),R=_.useCallback(async()=>{if(c?.order_item_id)try{const B=await Cl(c.order_item_id,h?.patientRoleID||"",D);I({...c,...B.data,service_category:St[1],service_category_id:"2",order_item_service_tax_percentage:O?.[+B.data.service_id]?.service_tax||0,bill_item_details:{...A.bill_item_details,...B.data.bill_item_details,appointment_details:{appnt_id:"",doctor_role_id:"",appnt_date:"",appnt_time:"",appnt_duration:0,appnt_status:0},lab_owner_name:"",lab_owner_id:"0",appnt_doctor_role_id:"",referrer_doctor_role_id:""}})}catch(B){console.error("Error fetching bill item data:",B)}},[A.bill_item_details,c,O,h?.patientRoleID,D]);_.useEffect(()=>{c&&I(B=>({...B,...c}))},[c]),_.useEffect(()=>{R()},[R,P.order_item_id]);const Q=B=>{const L={...P,service_category:St[1],bill_item_details:{doctor_name:B.docName,appointment_details:null,lab_owner_name:"",lab_owner_id:"",referrer_doctor_role_id:B.docRoleID}};I(L)};return e.jsxRuntimeExports.jsxs("div",{className:"hfl-relative hfl-h-full",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-h-8 hfl-w-[330px] hfl-shrink-0 hfl-items-center hfl-justify-between hfl-gap-2 hfl-border-b-1 hfl-border-b-Gray-200 hfl-px-2",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text lg",children:P?.service_name}),e.jsxRuntimeExports.jsx("div",{className:"hx_close hfl-flex-shrink-0 hfl-cursor-pointer hfl-text-4",onClick:()=>{d(),N()}})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-gap-[14px] hfl-px-3 hfl-py-4",children:[k?.billing?.enable_add_service_owner!=0&&e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(p.tj,{label:"Doctor Name",labelSize:"Text sm",labelColor:"hfl-text-Gray-800",input1value:"Dr.",input2value:P.bill_item_details.doctor_name,end_icon:"hx_down hfl-bg-White_20",inputProps:{disabled:!0},suffixInputProps:{placeholder:"Doctor Name"},className:"hfl-w-12 hfl-flex-none hfl-text-ellipsis hfl-bg-Gray-50 hfl-text-Gray-500",suffixClassName:" hfl-w-[220px] hfl-text-ellipsis hfl-bg-White_20",suffixDropdownClassName:"hfl-ml-12",suffixOptions:g?.doctor_list?.map(B=>({label:B.doctor_name,value:B.doctor_name,appnt_doctor_role_id:B.doctor_identifier})),handleSuffixValChange:B=>{Q({docName:B,docRoleID:""})},onSuffixDropdownClick:B=>{Q({docName:B.label,docRoleID:B.appnt_doctor_role_id})}})}),e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Primary",size:"lg",textField:"Update",className:"hfl-flex hfl-h-9 hfl-w-full hfl-shrink-0 hfl-items-center hfl-justify-center hfl-gap-1 hfl-self-stretch hfl-rounded-md hfl-p-3",onClick:async()=>{const B=await Pl(P,V,h?.patientRoleID||"",Ie.dayjs(y).format("YYYY-MM-DD"),W,St[1],D);B&&(w(L=>L.map((z,K)=>l==K.toString()?{...z,order_item_id:B?.order_item_id||P.order_item_id}:z)),(B?.order_item_id||P.order_item_id)&&(n(),d(),T(y)))}})})]}),e.jsxRuntimeExports.jsx("div",{className:"hfl-absolute hfl-bottom-4 hfl-left-2 hfl-w-full",children:e.jsxRuntimeExports.jsx(p.Ku,{className:"hfl-h-8 hfl-shrink-0 hfl-border-l-Gray-200 hfl-bg-White_20 hfl-text-Gray-500 hfl-shadow-md hover:hfl-bg-Gray-100",hierarchy:"Tertiary",size:"md",textField:"Go Back",icon:"Left",iconFile:"hx_arrow-left hfl-text-Gray-500",onClick:()=>{d(),N()}})})]})};var Bs={exports:{}},fa=Bs.exports,Yl;function pa(){return Yl||(Yl=1,function(a,d){(function(c,n){a.exports=n()})(fa,function(){var c="minute",n=/[+-]\d\d(?::?\d\d)?/g,y=/([+-]|\d\d)/g;return function(w,l,T){var N=l.prototype;T.utc=function(D){var A={date:D,utc:!0,args:arguments};return new l(A)},N.utc=function(D){var A=T(this.toDate(),{locale:this.$L,utc:!0});return D?A.add(this.utcOffset(),c):A},N.local=function(){return T(this.toDate(),{locale:this.$L,utc:!1})};var h=N.parse;N.parse=function(D){D.utc&&(this.$u=!0),this.$utils().u(D.$offset)||(this.$offset=D.$offset),h.call(this,D)};var V=N.init;N.init=function(){if(this.$u){var D=this.$d;this.$y=D.getUTCFullYear(),this.$M=D.getUTCMonth(),this.$D=D.getUTCDate(),this.$W=D.getUTCDay(),this.$H=D.getUTCHours(),this.$m=D.getUTCMinutes(),this.$s=D.getUTCSeconds(),this.$ms=D.getUTCMilliseconds()}else V.call(this)};var g=N.utcOffset;N.utcOffset=function(D,A){var P=this.$utils().u;if(P(D))return this.$u?0:P(this.$offset)?g.call(this):this.$offset;if(typeof D=="string"&&(D=function(B){B===void 0&&(B="");var L=B.match(n);if(!L)return null;var z=(""+L[0]).match(y)||["-",0,0],K=z[0],ue=60*+z[1]+ +z[2];return ue===0?0:K==="+"?ue:-ue}(D),D===null))return this;var I=Math.abs(D)<=16?60*D:D;if(I===0)return this.utc(A);var R=this.clone();if(A)return R.$offset=I,R.$u=!1,R;var Q=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();return(R=this.local().add(I+Q,c)).$offset=I,R.$x.$localOffset=Q,R};var k=N.format;N.format=function(D){var A=D||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return k.call(this,A)},N.valueOf=function(){var D=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*D},N.isUTC=function(){return!!this.$u},N.toISOString=function(){return this.toDate().toISOString()},N.toString=function(){return this.toDate().toUTCString()};var O=N.toDate;N.toDate=function(D){return D==="s"&&this.$offset?T(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():O.call(this)};var W=N.diff;N.diff=function(D,A,P){if(D&&this.$u===D.$u)return W.call(this,D,A,P);var I=this.local(),R=T(D).local();return W.call(I,R,A,P)}}})}(Bs)),Bs.exports}var ha=pa();const Dl=p.getDefaultExportFromCjs(ha),Tl=a=>{Ie.dayjs.extend(Dl);const{categorySummaryData:d,serviceDetails:c,walletBalance:n,rightSegment:y,serviceItem:w,bill_date:l,handleRightSegment:T,getBillSummarydata:N,getPastDueAmount:h,refreshBillsList:V,closePrintModal:g,setRefreshWallet:k}=a,O=_.useContext(It);if(!O)throw new Error("ServiceLevelBillSummary must be used within an AppContext.Provider");const{patientDetails:W,patientIDs:D,billPreferences:A,setShowPrintModal:P,currentWindow:I,showPrintModal:R,variable:Q}=O,B=()=>{switch(w){case St[0]:return"Consultation Bill";case St[1]:return"Other Service Bill";case St[2]:return"Lab Service Bill";default:return`${w} Bill`}},L=async(z,K,ue)=>{if(R?.visible&&g(),!d)return;const ce=await Xl(d.order_id,D?.patientRoleID||"",Q),X=c.map(Le=>({serviceName:Le.service_name,price:+Le.order_unit_item_price,gst:+Le.order_item_service_tax,discount:+Le.order_item_discount,netPrice:+Le.net_amount,itemQty:+Le.item_quantity})),ee=+d.order_paid_amount,ve=+d.refund_amount,de=+d.balance_amount,Ue=+d.order_discount,pe=+d.order_item_sum_discount,$=+d.order_service_tax,fe={paymentStatus:ee-ve===0?"red":de===0?"green":"yellow",paymentMode:ce?.paymentModes?.length?ce.paymentModes.join(", "):"",billedAmount:+d.order_total,discountAmount:Ue+pe,gstAmount:$,cgstAmount:($/2).toFixed(2),sgstAmount:($/2).toFixed(2),finalAmount:+d.net_bill_amount,receivedAmount:ee,balanceAmount:de,refundAmount:ve},De=[W?.age&&typeof W.age=="number"?`${W.age}y`:W?.org_person_dob?hr(W.org_person_dob):"",W?.gender?Jr[W.gender]:"",W?.blood_group].filter(Boolean).join(", "),Me={name:`${ar(W?.name??"")}${De?` (${De})`:""}`,billDate:Ie.dayjs(d.order_date).format("DD-MMM-YYYY"),mobileNumber:W?.phone_number??"",email:W?.email??"",billNumber:d.order_id_str,patientId:W?.org_person_bid_str??"",patientIdForEmail:D?.patientRoleID??"",billStatus:de===0?"PAID":"UNPAID",address:[W?.address,W?.city,W?.pincode].filter(Boolean).join(", "),referredBy:ce?.lab_owner_name?ar(ce.lab_owner_name):W?.ref_doc_name?ar(W.ref_doc_name):"--"};P({printDataFrom:"patient_popup",visible:!0,whichPreview:z,printData:"",visitId:"",visit_date:"",visit_number:1,currentPrintTime:new Date().getTime(),printType:"bill",details:{showPrintPreviewForBill:K,preferences:{...A?.print?.bill,...A?.org_details},billSummaryDetails:fe,billServiceDetails:X,billPatientDetails:Me,isWholeBill:!1,payloadDataforEmail:{orderDate:"",orderNumber:d?.order_id}},trackEventHandler:()=>{console.log(ue)}})};return e.jsxRuntimeExports.jsxs("div",{className:"hfl-relative hfl-h-full ",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-h-8 hfl-w-[330px] hfl-shrink-0 hfl-items-center hfl-gap-2 hfl-border-b-1 hfl-border-b-Gray-200 hfl-px-2",children:[e.jsxRuntimeExports.jsx("div",{className:"hx_arrow-left hfl-flex-shrink-0 hfl-cursor-pointer hfl-text-4",onClick:()=>T(pt[0])}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-flex hfl-items-center",children:[B()," : ",e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",className:"hfl-text-Primary-600",children:d?.order_id_str})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-items-start hfl-px-3 hfl-py-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Gross Bill Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹ ",d?.order_total??0]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Discount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹"," - ",+(d?.order_discount||0)+ +(d?.order_item_sum_discount||0)]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Tax Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹ ",d?.order_service_tax]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Net Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-text-Gray-800",children:["₹ ",d?.net_bill_amount]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Collected Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹ ",d?.order_paid_amount]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Refund Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹"," - ",d?.refund_amount]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Net Paid Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Success-500",children:["₹ ",+(d?.order_paid_amount||0)-+(d?.refund_amount||0)]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-self-stretch hfl-py-[7px] hfl-pr-9",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:"Total Balance Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Warning-500 ",children:["₹ ",d?.balance_amount]})]}),e.jsxRuntimeExports.jsx(Al,{showDiscount:I!==wt[4],showRefund:I!==wt[4],rightSegment:y,summaryData:d,getBillSummarydata:N,handleRightSegment:T,serviceItem:w,getPastDueAmount:h,date:l,refreshBillsList:V,setRefreshWallet:k,walletBalance:n})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-gap-2 hfl-px-1 hfl-pb-2",children:[e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Tertiary",size:"md",textField:"Print",icon:"Left",onClick:()=>L("billPrintPreview",!1,"BILL_PRINT"),iconFile:"hx_print",className:" hfl-flex-1 hfl-items-center hfl-justify-center hfl-border hfl-border-Gray-300 hfl-bg-White hfl-text-Gray-700 hover:hfl-bg-Gray-100"}),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Tertiary",size:"md",textField:"Share",icon:"Left",onClick:()=>L("billSharePreview",!0,"BILL_SHARE"),iconFile:"hx_share",className:" hfl-flex-1 hfl-items-center hfl-justify-center hfl-border hfl-border-Gray-300 hfl-bg-White hfl-text-Gray-700 hover:hfl-bg-Gray-100"})]})]})},Il=({depositAmount:a,handleRightSegment:d,rightSegment:c,setRefreshWallet:n})=>e.jsxRuntimeExports.jsxs("div",{className:" hfl-flex hfl-flex-col",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-border-b hfl-border-Gray-200 hfl-py-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-full hfl-items-center hfl-px-1",children:[e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-gap-1"}),e.jsxRuntimeExports.jsx("i",{className:"hx_arrow-left hfl-cursor-pointer hfl-text-4 hfl-font-inter-2",onClick:()=>{d()}}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text md",className:"hfl-flex hfl-items-center",children:"Deposit Amount"})]}),e.jsxRuntimeExports.jsx("i",{className:"hx_close hfl-cursor-pointer hfl-text-right hfl-text-4 hfl-font-inter-2",onClick:()=>{d()}})]}),e.jsxRuntimeExports.jsxs("div",{className:`${a>0?"hfl-bg-Success-50":"hfl-bg-Warning-50"} hfl-m-3 hfl-flex hfl-flex-col hfl-items-center hfl-justify-center hfl-rounded-lg hfl-border hfl-border-Gray-200 hfl-px-2 hfl-py-3`,children:[e.jsxRuntimeExports.jsx("span",{className:`hfl-text-5 hfl-font-inter-3 ${a>0?"hfl-text-Success-600":"hfl-text-Gray-800"} `,children:"₹"+a}),e.jsxRuntimeExports.jsx("span",{className:"hfl-mt-[-8px] hfl-text-1 hfl-text-Gray-500",children:"Balance"})]}),e.jsxRuntimeExports.jsx("div",{className:"hfl-w-full hfl-px-3",children:e.jsxRuntimeExports.jsx(Al,{rightSegment:c,showDeposit:!0,showPayment:!1,showDiscount:!1,showDepositRefund:!0,showRefund:!1,handleRightSegment:d,walletBalance:a,setRefreshWallet:n})})]}),ma=({closePrintModal:a})=>{if(!_.useContext(It))throw new Error("AddBills component must be used within an PatientPopupContext.Provider");const{patientDetails:d,patientIDs:c,billPreferences:n,setShowPrintModal:y,showPrintModal:w,setLoading:l,showToast:T,variable:N}=_.useContext(It),[h,V]=_.useState(new Date),[g,k]=_.useState(),[O,W]=_.useState(pt[0]),[D,A]=_.useState([]),[P,I]=_.useState([]),[R,Q]=_.useState(""),[B,L]=_.useState(),[z,K]=_.useState(!1),[ue,ce]=_.useState(pl),[X,ee]=_.useState("-1"),[ve,de]=_.useState({bill_summary:{},status:!1,message:""}),[Ue,pe]=_.useState(!1),[$,fe]=_.useState(0),H=G=>{Q(G)},De=async G=>{l(!0);try{await ht(G),V(G)}catch(Te){console.error(Te)}l(!1)},Me=async()=>{try{const G=await dn(c.patientRoleID,Ie.dayjs(h).format("YYYY-MM-DD"),N);de(G)}catch(G){console.error("Error in getBillSummary API Call:",G)}},Le=()=>{ce(G=>P.length>+X&&+X>=0?[...G.slice(0,+X),{order_id:P[X].order_id,order_date:P[X].order_date,order_created_on:P[X].order_created_on,service_category:P[X].service_category,service_category_id:P[X].service_category_id,order_id_str:P[X].order_id_str,order_total:P[X].order_total,order_paid_amount:P[X].order_paid_amount,order_item_sum_discount:P[X].order_item_sum_discount,order_discount:P[X].order_discount,refund_amount:P[X].refund_amount,order_service_tax:P[X].order_service_tax,balance_amount:P[X].balance_amount,net_bill_amount:P[X].net_bill_amount,order_item_id:P[X].order_item_id,service_id:P[X]?.service_id,service_name:P[X].service_name,item_quantity:P[X].item_quantity,order_unit_item_price:P[X].order_unit_item_price,order_item_price:P[X].order_item_price,order_item_discount:P[X].order_item_discount,order_item_service_tax:""+Math.floor(P[X].order_item_service_tax),order_item_service_tax_percent:P[X].order_item_service_tax_percent,net_amount:P[X].net_amount,created_on:P[X].created_on},...G.slice(+X+1)]:G)},xt=async()=>{try{const G=await Gs(Ie.dayjs(h).format("YYYY-MM-DD"),c.patientRoleID,1,10,!0,N);K(G?.total_records>0)}catch{console.log("error in checkAppointmentForBilling API Call")}};_.useEffect(()=>{Me(),it(),window?.partner_service_enabled!=="1"&&xt()},[h]);const ht=async(G=Ie.dayjs().format("YYYY-MM-DD"))=>{l(!0);try{const Te=await yl(Ie.dayjs(G).format("YYYY-MM-DD"),c.patientRoleID,1,100,N);k(Te),ce(pl);const Ze=Te?.bill_list.flatMap(se=>{const{order_items:J,...U}=se;return J.map(ie=>({...U,...ie})).filter(ie=>Ie.dayjs(ie?.created_on).format("YYYY-MM-DD")===Ie.dayjs(new Date).format("YYYY-MM-DD"))});if(I(Ze),Te?.bill_list?.length){const se=Te?.bill_list.reduce((J,U)=>{const ie=U.order_items.filter(Be=>Ie.dayjs(Be?.created_on).isBefore(Ie.dayjs(new Date).format("YYYY-MM-DD"))).map(Be=>({...Be,service_category:U.service_category,service_category_id:U.service_category_id}));return[...J,...ie]},[]);A(se)}else ce(pl),A([])}catch{console.log("error in getBillsList API Call")}l(!1)};_.useEffect(()=>{ht()},[]);const at=async()=>{try{const G=await Sl(c.patientRoleID,N);fe(G?.wallet_balance||0)}catch(G){console.error("Failed to fetch wallet balance:",G)}};_.useEffect(()=>{at()},[Ue]);const We=_.useCallback(async()=>{try{const G=await bl(Ie.dayjs(h).format("YYYY-MM-DD"),c.patientRoleID,!1,N);L(G)}catch(G){console.error("Error in getPastDueAmount API Call:",G)}},[h,bl,c.patientRoleID]);_.useEffect(()=>{We()},[We]);const it=(G=pt[0])=>{W(G)},Pt=G=>{switch(G?.original?.service_category.toLowerCase()){case St[0].toLowerCase():it(pt[2]);break;case St[1].toLowerCase():it(pt[4]);break;case St[2].toLowerCase():it(pt[3]);break;default:it(pt[0]);break}},gt=(G,Te)=>Te.reduce((Ze,se)=>Ze+(parseInt(ve.bill_summary[se]?.[G]||"0")||0),0),At=(G,Te)=>Te.map(Ze=>ve.bill_summary[Ze]?.[G]).filter(Ze=>Ze),Gt=async(G,Te,Ze)=>{if(w?.visible&&a(),ve?.bill_summary&&Object.keys(ve?.bill_summary).length>0){const se=await zn(At("order_id",G),c?.patientRoleID,N),J=[...new Set(G.map(yt=>se.paymentsData.get(yt)).flat())].map(yt=>cr[yt]??void 0)?.filter(yt=>yt),U=gt("order_service_tax",G??[1,2,3]),ie={billedAmount:gt("order_total",G??[1,2,3]),gstAmount:U,cgstAmount:(U/2).toFixed(2),sgstAmount:(U/2).toFixed(2),discountAmount:gt("order_item_sum_discount",G??[1,2,3])+gt("order_discount",G??[1,2,3]),finalAmount:gt("net_bill_amount",G??[1,2,3]),receivedAmount:gt("order_paid_amount",G??[1,2,3]),balanceAmount:gt("balance_amount",G??[1,2,3]),refundAmount:gt("refund_amount",G??[1,2,3])},Se=[...ue,...D].filter(yt=>G.includes(parseInt(yt?.service_category_id))).map(yt=>({serviceName:yt.service_name,price:yt.order_unit_item_price,gst:Math.floor(yt.order_item_service_tax),discount:yt.order_item_discount,netPrice:yt.net_amount,itemQty:yt.item_quantity})),Qt=[d?.age&&typeof d?.age=="number"?`${d?.age}y`:d?.org_person_dob?hr(d?.org_person_dob):"",Jr[d?.gender]??"",d?.blood_group].filter(yt=>yt).join(", ");y({printDataFrom:"patient_popup",visible:!0,whichPreview:Te,printData:"",visitId:"",visit_date:"",visit_number:1,currentPrintTime:new Date().getTime(),printType:"bill",details:{showPrintPreviewForBill:Ze,preferences:{...n?.print?.bill,...n?.org_details,...n?.branch_details},billSummaryDetails:{...ie,paymentStatus:parseInt(ie?.receivedAmount||"0")-parseInt(ie?.refundAmount||"0")===0?"red":parseInt(ie?.balanceAmount||"0")===0?"green":"yellow",paymentMode:J?.join(", ")},billServiceDetails:Se,billPatientDetails:{name:ar(d?.name)+(Qt?` (${Qt}) `:""),billDate:Ie.dayjs(h).format("DD-MMM-YYYY"),mobileNumber:d?.phone_number,email:d?.email,billNumber:At("order_id_str",G)?.toString(),patientId:d?.org_person_bid_str,patientIdForEmail:c.patientRoleID,billStatus:parseInt(ie?.balanceAmount||"0")===0?"PAID":"UNPAID",address:[d?.address??"",d?.city??"",d?.pincode??""].filter(yt=>yt).join(", "),referredBy:se?.lab_owner_name?ar(se?.lab_owner_name):d?.ref_doc_name?ar(d?.ref_doc_name):"--"},isWholeBill:G.length===3,payloadDataforEmail:{orderDate:G.length===3?Ie.dayjs(h).format("YYYY-MM-DD"):"",orderNumber:At("order_id",G)?.join("_")}},trackEventHandler:yt=>{console.log("Bill Print Event",yt)}})}else T("Error","Please add a service to create bill","Error",3e3)};return e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex",children:[e.jsxRuntimeExports.jsx(aa,{tab:"add_bills",children:e.jsxRuntimeExports.jsxs("div",{className:`hfl-relative hfl-h-full hfl-overflow-auto ${O===pt[7]?"hfl-opacity-30":""}`,children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-ml-4 hfl-mr-1 hfl-flex hfl-flex-col hfl-gap-1 hfl-self-stretch",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-justify-between",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-gap-3",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",className:"hfl-text-Gray-700",children:"Bill Date :"}),e.jsxRuntimeExports.jsx("div",{"data-qa":"calendar",children:e.jsxRuntimeExports.jsx(p.ZC,{selectDate:new Date(Ie.dayjs(h).format("DD-MMM-YYYY")),dateVar:G=>{V(G),De(G)},maxDate:new Date})}),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Secondary-Grey",size:"md",textField:"Today",className:"hfl-h-10",onClick:()=>De(new Date),"data-qa":"today"})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-row hfl-items-center hfl-justify-center hfl-text-Gray-700",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",children:"Deposit Amount:"}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-center hfl-gap-1 hfl-rounded-lg hfl-bg-Gray-50 hfl-p-1",children:[e.jsxRuntimeExports.jsx("i",{className:"hx_rupee hfl-text-3 hfl-text-Success-500"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",className:" hfl-text-Success-500",children:$}),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Secondary-Grey",size:"md",textField:"",icon:"Only",iconFile:"hx_add-circle hfl-text-4",className:"hfl-items-center hfl-justify-center",onClick:()=>it(pt[7])})]})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"-hfl-gap-[1px] hfl-flex hfl-h-[590px] hfl-flex-col hfl-items-start",children:[e.jsxRuntimeExports.jsx(zl,{tableBodyData:P,tableData:ue,isDisabled:!1,addBillButton:!0,handleEditRow:Pt,handleRightSegment:it,setTableData:ce,setEditRowId:ee,getBillSummarydata:Me,refreshBillsList:ht}),D&&D?.length>0&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[" ",e.jsxRuntimeExports.jsxs(p.bi,{variant:"Semibold",type:"Text lg",className:"hfl-py-3 hfl-text-Gray-700",children:["Old Bill"," "]}),e.jsxRuntimeExports.jsx(zl,{tableBodyData:D,tableData:D,isDisabled:!0,addBillButton:!1,handleEditRow:Pt,handleRightSegment:it,setTableData:ce,setEditRowId:ee,getBillSummarydata:()=>{},refreshBillsList:()=>{}})]})]})]}),e.jsxRuntimeExports.jsx("div",{className:" mt-2 hfl-sticky hfl-bottom-0 hfl-w-full",children:z&&e.jsxRuntimeExports.jsx(na,{})})]})}),e.jsxRuntimeExports.jsxs(Nl,{tab:"add_bills",children:[O===pt[0]&&e.jsxRuntimeExports.jsx(ia,{summaryData:ve,date:h,rightSegment:O,handleRightSegment:it,billSummaryClicked:(G,Te,Ze)=>Gt(G,Te,Ze),showDiscount:!1,showRefund:!1,handleServiceItem:H,pastDueData:B,getBillSummarydata:Me,refreshBillsList:ht,getPastDueAmount:We,walletBalance:$,setRefreshWallet:pe}),O===pt[1]&&e.jsxRuntimeExports.jsx(Tl,{bill_date:h,rightSegment:O,serviceDetails:g?.bill_list.find(G=>G.service_category.toLowerCase()===R.toLowerCase())?.order_items??[],categorySummaryData:ve?.bill_summary[`${St.indexOf(R)+1}`],serviceItem:R,handleRightSegment:it,getBillSummarydata:Me,refreshBillsList:ht,getPastDueAmount:We,walletBalance:$,setRefreshWallet:pe,closePrintModal:a}),O===pt[2]&&e.jsxRuntimeExports.jsx(ca,{bill_date:h,handleRightSegment:it,getBillSummarydata:Me,editedTableData:ue?.[X],setTableData:ce,editRowId:X,handleRevertEdit:Le,refreshBillsList:ht,checkAppointmentForBilling:xt}),O===pt[4]&&e.jsxRuntimeExports.jsx(da,{order_date:h,handleRightSegment:it,getBillSummarydata:Me,editedTableData:ue?.[X],setTableData:ce,editRowId:X,refreshBillsList:ht,handleRevertEdit:Le}),O===pt[3]&&e.jsxRuntimeExports.jsx(oa,{order_date:h,handleRightSegment:it,editedTableData:ue?.[X],getBillSummarydata:Me,setTableData:ce,editRowId:X,refreshBillsList:ht,handleRevertEdit:Le}),O===pt[7]&&e.jsxRuntimeExports.jsx(Il,{depositAmount:$,handleRightSegment:it,rightSegment:O,setRefreshWallet:pe})]})]})},Rl=a=>{const{appointments:d,isDisabled:c,handleAppointData:n,leftNav:y,today:w}=a,l=_.useCallback(A=>{n(A)},[n]),T=_.useMemo(()=>[{Header:"Date",accessor:"appnt_date",Cell:({row:A})=>e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-w-[130px] hfl-items-center hfl-justify-center",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:` ${c?"":"hfl-rounded-sm hfl-bg-Success-50 hfl-px-2 hfl-text-Success-600"} `,children:Ie.dayjs(A?.original?.appnt_date).format("DD-MMM-YYYY")})})},{Header:"Time",accessor:"appnt_time",Cell:({row:A})=>e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:" ",children:A?.original?.appnt_time&&new Date("1970-01-01T"+A?.original?.appnt_time+"Z").toLocaleTimeString("en-US",{timeZone:"UTC",hour12:!0,hour:"numeric",minute:"numeric"})})},{Header:"Status",accessor:"appnt_status",Cell:({row:A})=>e.jsxRuntimeExports.jsx("div",{className:" hfl-flex hfl-w-[100px] hfl-items-center hfl-justify-center focus:hfl-outline-none",children:e.jsxRuntimeExports.jsx(p.bi,{className:" hfl-flex hfl-w-[100px] hfl-items-center focus:hfl-outline-none",variant:"Regular",type:"Text sm",children:vl.find(P=>P.value==A?.original?.appnt_status)?.text})})},{Header:"Doctor",accessor:"appnt_doctor_name",Cell:({row:A})=>e.jsxRuntimeExports.jsx(p.bi,{className:" hfl-flex hfl-w-[316px] hfl-items-center hfl-capitalize focus:hfl-outline-none",variant:"Regular",type:"Text sm",children:"Dr. "+A.original.appnt_doctor_name})},{Header:"Type",accessor:"order_unit_item_price",Cell:()=>e.jsxRuntimeExports.jsx(p.bi,{className:" hfl-flex hfl-w-[100px] hfl-items-center focus:hfl-outline-none",variant:"Regular",type:"Text sm",children:"In-Person"})},{Header:"Service",accessor:"appnt_service_name",Cell:({row:A})=>e.jsxRuntimeExports.jsx("div",{className:" [100px] hfl-flex hfl-items-center hfl-justify-center ",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex hfl-w-[116px] hfl-items-center hfl-capitalize",children:A.original.appnt_service_name})})},{Header:"Bill",accessor:"total_price",Cell:({row:A})=>A.original.order_item_id!=0||c||y!="today"?e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-center hfl-text-Error-500 ",children:[e.jsxRuntimeExports.jsx("i",{className:" hx_f-rupee"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex hfl-w-[106px] hfl-items-center",children:A.original.total_price})]}):e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Secondary",size:"sm",textField:"",icon:"Left",iconFile:"hx_rupee-bill-filled hfl-text-3",onClick:()=>{l(A.original)},children:"Add Bill"})},{Header:"",accessor:"edit",Cell:({row:A})=>e.jsxRuntimeExports.jsx("i",{className:` ${c?"hfl-text-White":""} ${y==="today"&&"hx_edit"} hfl-p-4 hfl-text-Primary-700 `,onClick:()=>{y==="today"&&l(A.original)},"data-qa":"edit-icon"})}],[l,c,y]),N=_.useMemo(()=>d||[],[d]),{getTableProps:h,getTableBodyProps:V,headerGroups:g,rows:k,prepareRow:O}=Qr.useTable({columns:T,data:N}),W=A=>{const P=[];return A?.headers?.length&&A.headers.map(I=>{P.push(e.jsxRuntimeExports.jsx("th",{...I.getHeaderProps(),className:"hfl-rounded hfl-border-1 hfl-border-Gray-200 hfl-bg-Blue_gray-50 hfl-px-2 hfl-py-1 hfl-text-left",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-text-Gray-600",children:I.render("Header")})}))}),P},D=()=>{const A=[];return k.map((P,I)=>{O(P),A.push(e.jsxRuntimeExports.jsx("tr",{"data-qa":I+1+"",...P.getRowProps(),className:`${P?.original?.appnt_status===1?"hfl-bg-Gray-50 hfl-text-Gray-400 hover:hfl-bg-White hover:hfl-text-Gray-500":"hfl-bg-White"} hfl-group hfl-h-9 hfl-w-full hfl-border-t-1 hfl-border-Gray-200 ${c?"hfl-bg-Gray-100":""}`,children:P.cells.map(R=>e.jsxRuntimeExports.jsx("td",{"data-qa":I+1+"-"+R.column.id,...R.getCellProps(),className:"hfl-relative hfl-border-1 hfl-border-Gray-200 hfl-px-2 hfl-text-left",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:`${P?.original?.appnt_status===1?"hfl-text-Gray-300 group-hover:hfl-text-Gray-500":"hfl-text-Gray-500"}`,children:R.render("Cell")})}))}))}),A};return e.jsxRuntimeExports.jsx("div",{className:`${c?" hfl-pointer-events-none":"hfl-cursor-pointer"} ${w?" hfl-h-[500px] hfl-overflow-y-scroll":""} `,children:d&&e.jsxRuntimeExports.jsxs("table",{...h(),className:"hfl-table-fixed hfl-rounded-lg hfl-border-1 hfl-border-Gray-200 hfl-pb-8 hfl-shadow-md",children:[e.jsxRuntimeExports.jsx("thead",{children:g.map(A=>e.jsxRuntimeExports.jsx("tr",{...A.getHeaderGroupProps(),className:"hfl-h-9 hfl-rounded-lg hfl-bg-Blue_gray-50 hfl-py-2",children:W(A)}))}),e.jsxRuntimeExports.jsx("tbody",{...V(),className:"hfl-rounded-lg hfl-border-1 hfl-border-Gray-200",children:D()})]})})},es=a=>{const{currentPage:d,totalRecord:c,handleLoadMore:n,isLoading:y=!1,currentTotal:w}=a;return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[!y&&e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-between",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text sm",className:"hfl-text-Gray-500",children:`1 — ${w} of ${c} results`}),w!==c?e.jsxRuntimeExports.jsx(p.Ku,{className:"hfl-text-Blue-^00 hfl-flex hfl-justify-center",hierarchy:"Link-Colour",size:"lg",textField:"Load more... ",onClick:()=>n(d)}):e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text sm",className:"hfl-text-Gray-500",children:"End of List"})]}),y&&e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center hfl-justify-center",children:e.jsxRuntimeExports.jsx(p.Eu,{size:"xxs",progress:10,spinnerMode:!0})})]})},xa=a=>{const{handleAddNewAppnt:d,handleAppointData:c,sortAppointments:n}=a,[y,w]=_.useState(),[l,T]=_.useState(1),[N,h]=_.useState([]),[V,g]=_.useState([]),[k,O]=_.useState(""),{patientIDs:W,setLoading:D,variable:A}=_.useContext(It),P=async I=>{let R=I;if(D(!0),R<=Math.ceil((y?.total_records||0)/10)){if(R=I+1,R!==I){const Q=await Gs("all",W?.patientRoleID||"",R,10,!1,A);h(B=>[...B,...Q.appointments.filter(L=>L.appnt_date>=Ie.dayjs(new Date).format("YYYY-MM-DD"))]),g(B=>[...B,...Q.appointments.filter(L=>L.appnt_date<Ie.dayjs(new Date).format("YYYY-MM-DD"))])}T(R)}D(!1)};return _.useEffect(()=>{D(!0);const I=async()=>{try{const R=await Gs("all",W?.patientRoleID||"",1,10,!1,A);R&&(w(R),h(R?.appointments?.filter(Q=>Q.appnt_date>=Ie.dayjs(new Date).format("YYYY-MM-DD"))),g(R?.appointments?.filter(Q=>Q.appnt_date<Ie.dayjs(new Date).format("YYYY-MM-DD")))),O(R?.appointments?.length?"":"No Appointment")}catch{console.log("error in getAppointmentsList API Call")}};D(!1),I()},[W?.patientRoleID,D,A]),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-max-h-[550px] hfl-w-full hfl-flex-col hfl-overflow-y-scroll",children:[N.length>0&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-full hfl-items-center hfl-justify-between hfl-px-3 hfl-py-2 ",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",className:"",children:"Upcoming Appointments"}),e.jsxRuntimeExports.jsx(p.Ku,{"data-qa":"new-appointment",hierarchy:"Primary",size:"md",className:"text",icon:"Left",iconFile:"hx_add-circle",textField:"New Appointment",onClick:d})]}),e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-px-4 ",children:e.jsxRuntimeExports.jsx(Rl,{appointments:n(N),handleAppointData:c})})]}),V.length>0&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",className:"hfl-w-full hfl-items-center hfl-px-3 hfl-py-2 hfl-pt-4 ",children:"Past Appointments"}),e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-px-4 hfl-pb-4 xxs:max-md:hfl-w-[885px] xxs:max-md:hfl-overflow-y","data-qa":"all-appoint-table",children:e.jsxRuntimeExports.jsx(Rl,{isDisabled:!0,appointments:V,handleAppointData:c})})]})]}),V.length>0||N.length>0?e.jsxRuntimeExports.jsx("div",{className:"hfl-px-6 hfl-py-2",children:e.jsxRuntimeExports.jsx(es,{currentPage:l,totalRecord:y?.total_records||0,currentTotal:l===Math.ceil((y?.total_records||0)/10)?y?.total_records||0:l*10,handleLoadMore:P})}):e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-h-full hfl-w-full hfl-items-center hfl-justify-center",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",children:k})})]})},ga=()=>{const{showToast:a,patientDetails:d,doctorListArr:c,serviceListArr:n,patientIDs:y,setLoading:w,billPreferences:l,docPreference:T,formattedService:N,ppEventProps:h,getAndSetServiceListArr:V,variable:g}=_.useContext(It),[k,O]=_.useState(g.window_var?.partner_service_enabled==="1"&&d?.insurance_details?.policy_id?.length?!0:l?.billing?.prepaid_consultation!=="1"),[W,D]=_.useState("today"),[A,P]=_.useState(!1),[I,R]=_.useState([]),Q=new Date().toLocaleString("en-US",{hour:"numeric",minute:"numeric",hour12:!0}),B=_.useMemo(()=>c?.doctor_list?.length===1?c.doctor_list[0]:{doctor_name:"",doctor_identifier:""},[c]),L=_.useMemo(()=>({...ql,deleted:!1,appnt_date:Ie.dayjs().format("YYYY-MM-DD"),appnt_doctor_name:g.window_var.role_id=="11"?g.window_var.doc_name_for_seg:B?.doctor_name,appnt_doctor_role_id:g.window_var.role_id=="11"?g.window_var.doctor_role_id_for_seg:B?.doctor_identifier,appnt_duration:l?.print?.bill?.appnt_minute_slab||"",appnt_time_time:Q?.split(" ")[0]||"",appnt_time_format:Q?.split(" ")[1]||"",total_price:"0",order_item_service_tax_percentage:0,order_item_service_tax:"0",item_quantity:"1",order_unit_item_price:"0",order_item_price:"0",order_id:"",order_date:"",order_created_on:"",service_category:"",service_category_id:"",order_id_str:"",order_total:"",order_paid_amount:"",order_item_sum_discount:"",order_discount:"",refund_amount:"",order_service_tax:"",balance_amount:"",net_bill_amount:"",service_id:"",service_name:"",order_item_service_tax_percent:"",created_on:"",net_amount:""}),[l?.print?.bill?.appnt_minute_slab,Q,B?.doctor_identifier,B?.doctor_name,g.window_var.doc_name_for_seg,g.window_var.doctor_role_id_for_seg,g.window_var.role_id]),[z,K]=_.useState(L),[ue,ce]=_.useState(!1);_.useEffect(()=>{O(g.window_var?.partner_service_enabled==="1"&&d?.insurance_details?.policy_id?!0:l?.billing?.prepaid_consultation!=="1")},[A,l,W,d,g.window_var?.partner_service_enabled]),_.useEffect(()=>{ce(G=>k&&G)},[k]),_.useEffect(()=>{if(!+z?.order_item_id&&!z?.order_unit_item_price){const G=N?.[z.appnt_service_id];G&&K(Te=>({...Te,order_unit_item_price:G.price.toString(),item_quantity:"1",order_item_discount:"0",order_item_service_tax_percentage:G?.service_tax||0}))}},[k,A,z.order_item_id,z.order_unit_item_price,z.appnt_service_id,N]);const X=_.useCallback(G=>{const{order_unit_item_price:Te=0,item_quantity:Ze=0,order_item_discount:se=0,appnt_service_id:J}=G;if(!J)return;let U=0;const ie=N?.[J]?.service_tax||0;let Be=0;if(Number(Te)>0&&Number(Ze)>0){const Se=Number(Te)*Number(Ze);U=Math.floor(Se*.01*ie),Be=Se+U-Number(se)}K(Se=>({...Se,order_item_service_tax:U.toString(),order_item_price:Be.toString()}))},[N]),ee=_.useMemo(()=>[{...z,order_item_service_tax:Math.floor(+z.order_item_service_tax).toString()}],[z]),ve=G=>{gt();const Te=new Date(`1970-01-01T${G.appnt_time}Z`).toLocaleTimeString("en-US",{timeZone:"UTC",hour12:!0,hour:"numeric",minute:"numeric"});K(Ze=>({...Ze,...G,appnt_time_time:Te?.split(" ")[0]??"",appnt_time_format:Te?.split(" ")[1]??"",order_item_service_tax_percentage:N?.[G.appnt_service_id]?.service_tax||0,order_item_price:G.total_price.toString(),deleted:!1}))},de=(G,Te)=>{if(G==="appnt_service_name"){const{appnt_service_name:Ze,appnt_service_id:se,order_item_discount:J,order_unit_item_price:U,item_quantity:ie,order_item_service_tax_percentage:Be}=Te,Se={...z,appnt_service_name:Ze,appnt_service_id:se,order_unit_item_price:U,item_quantity:ie,order_item_discount:J,order_item_service_tax_percentage:Be};K(Se),X(Se)}else G==="appnt_date"&&Te>Ie.dayjs().format("YYYY-MM-DD")&&(O(!0),k||a("Error","Cannot add bill for future appointments. Continue without billing?","Error",5e3)),K(Ze=>({...Ze,[G]:Te}))},Ue=()=>{O(G=>!G)},pe=()=>{ce(G=>!G)},$=(G,Te)=>{K(Ze=>({...Ze,[Te]:G}))};_.useEffect(()=>{X(z)},[z.order_unit_item_price,z.item_quantity,z.order_item_discount,X,z]);const fe=G=>[...G].sort((Te,Ze)=>new Date(Te.appnt_date).getTime()-new Date(Ze.appnt_date).getTime()),H=_.useMemo(()=>[{Header:"Unit Price",accessor:"order_unit_item_price",Cell:({row:G})=>e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-center",children:[e.jsxRuntimeExports.jsx("i",{className:" hx_f-rupee"}),T?.permissions?.edit_service_unit_price?e.jsxRuntimeExports.jsx("input",{type:"text",className:"hfl-flex hfl-w-[120px] hfl-items-center focus:hfl-outline-none",value:G?.original?.order_unit_item_price,onChange:Te=>$(Te.target.value,"order_unit_item_price")}):e.jsxRuntimeExports.jsx("input",{className:"hfl-pointer-events-none hfl-flex hfl-w-[120px] hfl-items-center focus:hfl-outline-none",value:G?.original?.order_unit_item_price})]})},{Header:"Qty",accessor:"item_quantity",Cell:({row:G})=>e.jsxRuntimeExports.jsx("input",{type:"text",className:"hfl-flex hfl-w-[74px] hfl-items-center focus:hfl-outline-none",value:G?.original?.item_quantity,onChange:Te=>$(Te.target.value,"item_quantity")})},{Header:"Discount",accessor:"order_item_discount",Cell:({row:G})=>e.jsxRuntimeExports.jsx("input",{type:"text",className:"hfl-flex hfl-w-[74px] hfl-items-center focus:hfl-outline-none",value:G?.original?.order_item_discount,onChange:Te=>$(Te.target.value,"order_item_discount")})},{Header:"GST in %",accessor:"order_item_service_tax_percentage",Cell:({row:G})=>{const Te=Number(G?.original?.appnt_service_id||"0");return e.jsxRuntimeExports.jsx("input",{className:"hfl-pointer-events-none hfl-flex hfl-w-[120px] hfl-items-center focus:hfl-outline-none",value:N?.[Te]?.service_tax||0,readOnly:!0})}},{Header:"GST In Rs",accessor:"order_item_service_tax",Cell:({row:G})=>e.jsxRuntimeExports.jsx("input",{className:"hfl-pointer-events-none hfl-flex hfl-w-[120px] hfl-items-center",value:G?.original?.order_item_service_tax,readOnly:!0})},{Header:"Net Price",accessor:"order_item_price",Cell:({row:G})=>e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-center hfl-text-Error-500 ",children:[e.jsxRuntimeExports.jsx("i",{className:" hx_f-rupee"}),e.jsxRuntimeExports.jsx("input",{type:"number",className:"hfl-pointer-events-none hfl-flex hfl-w-[120px] hfl-items-center",value:G?.original?.order_item_price,readOnly:!0})]})}],[T?.permissions?.edit_service_unit_price,N]),De=_.useMemo(()=>ee,[ee]),{getTableProps:Me,getTableBodyProps:Le,headerGroups:xt,rows:ht,prepareRow:at}=Qr.useTable({columns:H,data:De}),We=G=>{const Te=[];return G?.headers?.length&&G.headers.map(Ze=>{Te.push(e.jsxRuntimeExports.jsx("th",{...Ze.getHeaderProps(),className:"hfl-rounded hfl-border-1 hfl-border-Gray-200 hfl-bg-Blue_gray-50 hfl-px-2 hfl-py-1 hfl-text-left",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-text-Indigo-600",children:Ze.render("Header")})}))}),Te},it=()=>{const G=[];return ht.map((Te,Ze)=>{at(Te),G.push(e.jsxRuntimeExports.jsx("tr",{id:Ze.toString(),...Te.getRowProps(),className:`${Te?.original?.appnt_status===1?"hfl-bg-Gray-50 hfl-text-Gray-400 hover:hfl-bg-White hover:hfl-text-Gray-500":"hfl-bg-White"} hfl-group hfl-h-9 hfl-w-full hfl-border-t-1 hfl-border-Gray-200`,children:Te.cells.map(se=>e.jsxRuntimeExports.jsx("td",{"data-qa":Ze+1+"-"+se.column.id,...se.getCellProps(),className:"hfl-relative hfl-border-1 hfl-border-Gray-200 hfl-px-2 hfl-text-left",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:`${Te?.original?.appnt_status===1?"hfl-text-Gray-300 group-hover:hfl-text-Gray-500":"hfl-text-Gray-500"}`,children:se.render("Cell")})}))}))}),G},Pt=(G,Te,Ze)=>e.jsxRuntimeExports.jsxs("div",{className:`hfl-flex hfl-w-[60px] hfl-flex-col hfl-items-center hfl-rounded hfl-px-1 hfl-py-2 hfl-text-center ${W===G?"hfl-bg-Primary-50 hfl-text-Primary-600":""} hfl-cursor-pointer`,onClick:()=>D(G),"data-qa":G,children:[e.jsxRuntimeExports.jsx("div",{className:Te}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text sm",children:Ze})]},G),gt=_.useCallback(()=>{D("today"),K(L),P(!0)},[L]),At=_.useCallback(async()=>{w(!0);try{const G=await Gs(W=="today"?Ie.dayjs().format("YYYY-MM-DD"):"all",y?.patientRoleID||"",1,W=="today"?100:10,!1,g);R(G?.appointments?.filter(Te=>Te.appnt_date===Ie.dayjs().format("YYYY-MM-DD"))),G.appointments.length===0&>(),w(!1)}catch{w(!1),console.log("error in getAppointmentsList API Call")}},[gt,W,y?.patientRoleID,w,g]);_.useEffect(()=>{A||At()},[A,At]),_.useEffect(()=>{W==="today"&&At()},[At,W]);const Gt=async()=>{z.appnt_date>Ie.dayjs().format("YYYY-MM-DD")&&(O(!0),k||a("Error","Cannot add bill for future appointments. Continue without billing?","Error",5e3)),await $l(z,k||z.appnt_date>Ie.dayjs().format("YYYY-MM-DD"),a,d,y,h,ue,!1,g)&&P(!1)};return e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-h-[73.55vh] hfl-bg-White",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-gap-4 hfl-border-r-1 hfl-border-Gray-200 hfl-bg-Gray-50 hfl-px-1 hfl-py-2",children:[Pt("today","hx_calendar-add hfl-text-5","Today's Appts"),Pt("all","hx_calendar hfl-text-5","All Appts")]}),W==="today"&&e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-flex-1 hfl-flex-col hfl-items-center hfl-gap-6 hfl-overflow-y-auto",children:I.length<=0||A?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-gap-2 hfl-self-stretch hfl-bg-Gray-100 hfl-p-2",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",className:"hfl-flex-1",children:z.appnt_id.length?"Update Appointment":"New Appointment"}),e.jsxRuntimeExports.jsx("div",{className:"hx_close hfl-flex-shrink-0 hfl-cursor-pointer hfl-text-4",onClick:()=>{P(!1)},"data-qa":"close-new-ppointment"})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-item-center hfl-flex hfl-flex-col hfl-gap-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-[739px] hfl-flex-wrap hfl-content-start hfl-items-start hfl-gap-6",children:[e.jsxRuntimeExports.jsx(p.tj,{label:"Doctor Name",labelSize:"Text sm",labelColor:"hfl-text-Gray-800",input1value:"Dr.",input2value:z.appnt_doctor_name,end_icon:"hx_down hfl-bg-White_20",inputProps:{disabled:!0},suffixInputProps:{placeholder:"Doctor Name"},className:"hfl-relative hfl-w-12 hfl-flex-none hfl-text-ellipsis hfl-bg-Gray-50 hfl-text-Gray-500",suffixClassName:" hfl-w-[270px] hfl-text-ellipsis hfl-bg-White_20",suffixDropdownClassName:"hfl-ml-12",suffixOptions:c?.doctor_list?.map(G=>({label:G.doctor_name,value:G.doctor_name,appnt_doctor_role_id:G.doctor_identifier})),handleSuffixValChange:G=>{de("appnt_doctor_name",G),de("appnt_doctor_role_id","")},onSuffixDropdownClick:G=>{de("appnt_doctor_name",G.label),de("appnt_doctor_role_id",G.appnt_doctor_role_id)}}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-[350px] hfl-flex-col hfl-gap-1.5",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text sm",children:"Date & Time of Appointment"}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-gap-2 ",children:[e.jsxRuntimeExports.jsx(p.ZC,{placeholder:"Today",height:"!hfl-h-[40px]",selectDate:new Date(Ie.dayjs(z.appnt_date).format("DD-MMM-YYYY")),dateVar:G=>{de("appnt_date",Ie.dayjs(G).format("YYYY-MM-DD"))},isborderRequired:!0,minDate:new Date}),e.jsxRuntimeExports.jsx(p.tj,{className:"hfl-w-24",suffixClassName:"hfl-w-10 ",suffixDropdownClassName:"hfl-ml-[96px]",input1value:z?.appnt_time_time||"",input2value:z?.appnt_time_format||"",end_icon:"hx_down",classNamedoubleInput:"hfl-relative",inputProps:{placeholder:"10:00",onBlur:G=>{de("appnt_time_time",G.target.value)}},onlySuffixDropdownItemsAllowed:!0,suffixInputProps:{placeholder:"AM"},suffixOptions:[{label:"AM",value:"AM"},{label:"PM",value:"PM"}],onSuffixDropdownClick:G=>{de("appnt_time_format",G.value)}})]})]}),z.appnt_id.length>1&&z.order_item_id.length>1?e.jsxRuntimeExports.jsx(p.tj,{label:"Service",labelSize:"Text sm",labelColor:"hfl-text-Gray-800",end_icon:"hfl-bg-White_20",input2value:z.appnt_service_name,inputProps:{disabled:!0},widthSufixDrpdwn:"hfl-w-[350px]",suffixInputProps:{placeholder:"Service Name",disabled:!0},className:"hfl-hidden hfl-w-12 hfl-text-ellipsis hfl-bg-Gray-50 hfl-text-Gray-500 ",classNamedoubleInput:"hfl-relative",suffixClassName:" hfl-border-l-0 hfl-w-[318px] hfl-text-ellipsis hfl-bg-White_20"}):e.jsxRuntimeExports.jsx(p.tj,{label:"Service",labelSize:"Text sm",labelColor:"hfl-text-Gray-800",end_icon:"hx_down hfl-bg-White_20",input2value:z.appnt_service_name,inputProps:{disabled:!1},widthSufixDrpdwn:"hfl-w-[350px]",suffixInputProps:{placeholder:"Service Name",onClick:async()=>{n?.service_list?.length||V()}},className:"hfl-hidden hfl-w-12 hfl-text-ellipsis hfl-bg-Gray-50 hfl-text-Gray-500 ",classNamedoubleInput:"hfl-relative",suffixClassName:"hfl-border-l-0 hfl-w-[318px] hfl-text-ellipsis hfl-bg-White_20",suffixOptions:n?.service_list?.filter(G=>G.service_category==="Doctor consultation")?.map(G=>({label:G.service_name,value:G.service_name,appnt_service_id:G.service_identifier,order_unit_item_price:G.price,item_quantity:1,order_item_discount:G.order_item_discount||0,order_item_service_tax_percentage:G.service_tax,appnt_service_name:G.service_name})),handleSuffixValChange:G=>{de("appnt_service_name",{appnt_service_name:G})},onSuffixDropdownClick:G=>{de("appnt_service_name",G)}}),e.jsxRuntimeExports.jsx(p.Ap,{value:{label:Br.find(G=>G.value==Number(z.appnt_duration))?.label||"",value:z.appnt_duration},label:"Duration",className:"hfl-w-[350px] hfl-text-Gray-800",onChange:G=>{de("appnt_duration",G.value)},options:Br,"data-qa":"time picker"}),e.jsxRuntimeExports.jsx(p.Ap,{value:{label:vl.find(G=>G.value==z?.appnt_status)?.text||""},label:"Booking Status",className:"hfl-w-[350px] hfl-text-Gray-800",onChange:G=>{de("appnt_status",G.value)},options:vl.map(G=>({label:G.text,value:G.value})),"data-qa":"click-status"}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-[350px] hfl-flex-col hfl-gap-1.5",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text sm",children:"Type"}),e.jsxRuntimeExports.jsx(p.ju,{options:[{start_icon:"hx_inperson hfl-text-3",label:"In-Person",value:"inperson"}],disabled:!1,value:"inperson","data-qa":"data-type"})]}),g.window_var?.partner_service_enabled==="1"&&d?.insurance_details?.policy_id?.length&&e.jsxRuntimeExports.jsx(p.Oi,{size:"md",disabled:!1,isMarked:ue,text:"Partner Enabled",onClick:pe,"data-qa":"skip-billing"}),!+z?.order_item_id&&e.jsxRuntimeExports.jsx(p.Oi,{size:"md",disabled:!1,isMarked:k,text:"Skip Billing",onClick:Ue,"data-qa":"skip-billing"})]}),!k||+z?.order_item_id?e.jsxRuntimeExports.jsx("div",{className:`${+z?.appnt_id&&+z?.order_item_id?"hfl-pointer-events-none":""}`,children:e.jsxRuntimeExports.jsxs("table",{...Me(),className:"hfl-table-fixed hfl-rounded-lg hfl-border-1 hfl-border-Gray-200 hfl-pb-8 hfl-shadow-md",children:[e.jsxRuntimeExports.jsx("thead",{children:xt.map(G=>e.jsxRuntimeExports.jsx("tr",{...G.getHeaderGroupProps(),className:"hfl-h-10 hfl-rounded-lg hfl-bg-Blue_gray-50",children:We(G)}))}),e.jsxRuntimeExports.jsx("tbody",{...Le(),className:"hfl-rounded-lg hfl-border-1 hfl-border-Gray-200",children:it()})]})}):"",e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-justify-center hfl-gap-4",children:[e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Tertiary",size:"md",textField:"Cancel",icon:"No",className:"hfl-w-[150px] hfl-items-center hfl-justify-center hfl-border hfl-border-Gray-300 hfl-bg-White hfl-text-Gray-700 hover:hfl-bg-Gray-100",onClick:()=>{P(!1)},"data-qa":"cancel"}),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Primary",size:"md",textField:z.appnt_id.length?"Update Appointment":"Book Appointment",icon:"No",onClick:Gt,className:"hfl-w-[150px] hfl-items-center hfl-justify-center hfl-bg-Primary-600 hfl-text-White_20 hover:hfl-bg-Primary-800","data-qa":"book-appointment"})]})]})]}):e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-full hfl-flex-col",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-full hfl-items-center hfl-justify-between hfl-px-3 hfl-py-2",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",children:"Today’s Appointments"}),e.jsxRuntimeExports.jsx(p.Ku,{"data-qa":"new-appointment",hierarchy:"Primary",size:"md",className:"text",icon:"Left",iconFile:"hx_add-circle",textField:"New Appointment",onClick:gt})]}),e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-px-4 ","data-qa":"appointment-table",children:e.jsxRuntimeExports.jsx(Rl,{today:!0,leftNav:W,appointments:fe(I),handleAppointData:ve})})]})}),W==="all"&&e.jsxRuntimeExports.jsx(xa,{sortAppointments:fe,handleAddNewAppnt:gt,handleAppointData:ve})]})},va=({columns:a,data:d})=>{const{getTableProps:c,getTableBodyProps:n,headerGroups:y,rows:w,prepareRow:l}=Qr.useTable({columns:a,data:d}),T=h=>{const V=[];return h?.headers?.length&&h.headers.map(g=>{V.push(e.jsxRuntimeExports.jsx("th",{...g.getHeaderProps(),className:"hfl-rounded hfl-border-1 hfl-border-Gray-200 hfl-bg-Blue_gray-50 hfl-px-2 hfl-py-1 hfl-text-left",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-text-Gray-600",children:g.render("Header")})}))}),V},N=()=>{const h=[];return w.map((V,g)=>{l(V),h.push(e.jsxRuntimeExports.jsx("tr",{id:g.toString(),...V.getRowProps(),className:`${V.original.appnt_status===1?"hfl-bg-Gray-50 hfl-text-Gray-400 hover:hfl-bg-White hover:hfl-text-Gray-500":"hfl-bg-White"} hfl-group hfl-border-t-1 hfl-border-Gray-200`,children:V.cells.map((k,O)=>e.jsxRuntimeExports.jsx("td",{"data-qa":g+1+"-"+(O+1),...k.getCellProps(),className:"hfl-relative hfl-border-1 hfl-border-Gray-200 hfl-px-2 hfl-text-left",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:`hfl-text-[13px] ${V.original.appnt_status===1?"hfl-text-Gray-300 group-hover:hfl-text-Gray-500":"hfl-text-Gray-500"}`,children:k.render("Cell")})}))}))}),h};return e.jsxRuntimeExports.jsx("div",{className:"hfl-max-h-[55vh] hfl-overflow-y-auto xxs:max-md:hfl-overflow-x-auto hfl-overflow-x-hidden","data-qa":"past-visit-table",children:e.jsxRuntimeExports.jsxs("table",{...c(),className:"hfl-table-fixed hfl-rounded-lg hfl-border-1 hfl-border-Gray-200 hfl-pb-8 hfl-shadow-md",children:[e.jsxRuntimeExports.jsx("thead",{children:y.map(h=>e.jsxRuntimeExports.jsx("tr",{...h.getHeaderGroupProps(),className:"hfl-h-10 hfl-rounded-lg hfl-bg-Blue_gray-50 ",children:T(h)}))}),e.jsxRuntimeExports.jsx("tbody",{...n(),className:"hfl-rounded-",children:N()})]})})},ya="data:image/svg+xml,%3csvg%20width='87'%20height='86'%20viewBox='0%200%2087%2086'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cellipse%20opacity='0.1'%20cx='43.5'%20cy='83.42'%20rx='43.5'%20ry='2.58'%20fill='%234E5BA6'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M17.179%2014.1224C16.5958%2013.0118%2015.2122%2012.5787%2014.0887%2013.1552C12.9651%2013.7317%2012.5271%2015.0994%2013.1102%2016.21L15.2825%2020.347C15.8657%2021.4576%2017.2493%2021.8906%2018.3729%2021.3141C19.4964%2020.7377%2019.9345%2019.37%2019.3513%2018.2593L17.179%2014.1224ZM14.8903%2014.6818C15.1609%2014.543%2015.4942%2014.6473%2015.6346%2014.9148L17.8069%2019.0517C17.9474%2019.3193%2017.8419%2019.6487%2017.5712%2019.7875C17.3006%2019.9264%2016.9674%2019.8221%2016.8269%2019.5546L14.6546%2015.4176C14.5141%2015.1501%2014.6196%2014.8207%2014.8903%2014.6818ZM22.9352%2024.0112C20.0523%2024.0112%2017.7152%2026.3214%2017.7152%2029.1712V65.3801C17.7152%2068.2299%2020.0523%2070.5401%2022.9352%2070.5401H57.7352C60.6181%2070.5401%2062.9552%2068.2299%2062.9552%2065.3801V59.7953C59.3146%2057.7135%2056.8652%2053.8225%2056.8652%2049.366C56.8652%2044.9095%2059.3146%2041.0186%2062.9552%2038.9368V29.1712C62.9552%2026.3214%2060.6181%2024.0112%2057.7352%2024.0112H54.1652V25.3157C54.1652%2027.6905%2052.2177%2029.6157%2049.8152%2029.6157H32.5952C30.1928%2029.6157%2028.2452%2027.6905%2028.2452%2025.3157V24.0112H22.9352ZM64.6952%2038.1166V29.1712C64.6952%2025.3714%2061.5791%2022.2912%2057.7352%2022.2912H46.2996C45.7087%2020.0557%2043.6519%2018.406%2041.2052%2018.406C38.7586%2018.406%2036.7018%2020.0557%2036.1109%2022.2912H22.9352C19.0913%2022.2912%2015.9752%2025.3714%2015.9752%2029.1712V65.3801C15.9752%2069.1798%2019.0913%2072.2601%2022.9352%2072.2601H57.7352C61.5791%2072.2601%2064.6952%2069.1798%2064.6952%2065.3801V60.6155C66.0461%2061.1262%2067.5126%2061.406%2069.0452%2061.406C75.772%2061.406%2081.2252%2056.0155%2081.2252%2049.366C81.2252%2042.7165%2075.772%2037.326%2069.0452%2037.326C67.5126%2037.326%2066.0461%2037.6058%2064.6952%2038.1166ZM6.33244%2020.881C6.89862%2019.7618%208.27544%2019.3082%209.40766%2019.8679L13.625%2021.9526C14.7572%2022.5123%2015.2161%2023.8733%2014.6499%2024.9925C14.0837%2026.1117%2012.7069%2026.5652%2011.5747%2026.0056L7.35734%2023.9209C6.22512%2023.3612%205.76626%2022.0002%206.33244%2020.881ZM8.62943%2021.4063C8.35671%2021.2715%208.02508%2021.3807%207.8887%2021.6503C7.75233%2021.9199%207.86286%2022.2477%208.13557%2022.3825L12.3529%2024.4672C12.6256%2024.602%2012.9572%2024.4928%2013.0936%2024.2232C13.23%2023.9536%2013.1195%2023.6258%2012.8468%2023.491L8.62943%2021.4063ZM36.2851%2041.3145C36.2851%2040.127%2037.2589%2039.1645%2038.4601%2039.1645H53.2501C54.4513%2039.1645%2055.4251%2040.127%2055.4251%2041.3145C55.4251%2042.5019%2054.4513%2043.4645%2053.2501%2043.4645H38.4601C37.2589%2043.4645%2036.2851%2042.5019%2036.2851%2041.3145ZM38.4601%2049.2325C37.2589%2049.2325%2036.2851%2050.1951%2036.2851%2051.3825C36.2851%2052.5699%2037.2589%2053.5325%2038.4601%2053.5325H53.2501C54.4513%2053.5325%2055.4251%2052.5699%2055.4251%2051.3825C55.4251%2050.1951%2054.4513%2049.2325%2053.2501%2049.2325H38.4601ZM38.0251%2051.3825C38.0251%2051.145%2038.2199%2050.9525%2038.4601%2050.9525H53.2501C53.4903%2050.9525%2053.6851%2051.145%2053.6851%2051.3825C53.6851%2051.62%2053.4903%2051.8125%2053.2501%2051.8125H38.4601C38.2199%2051.8125%2038.0251%2051.62%2038.0251%2051.3825ZM36.2851%2061.9099C36.2851%2060.7225%2037.2589%2059.7599%2038.4601%2059.7599H53.2501C54.4513%2059.7599%2055.4251%2060.7225%2055.4251%2061.9099C55.4251%2063.0974%2054.4513%2064.0599%2053.2501%2064.0599H38.4601C37.2589%2064.0599%2036.2851%2063.0974%2036.2851%2061.9099ZM38.4601%2061.4799C38.2199%2061.4799%2038.0251%2061.6725%2038.0251%2061.9099C38.0251%2062.1474%2038.2199%2062.3399%2038.4601%2062.3399H53.2501C53.4903%2062.3399%2053.6851%2062.1474%2053.6851%2061.9099C53.6851%2061.6725%2053.4903%2061.4799%2053.2501%2061.4799H38.4601ZM26.5647%2040.5435C26.5647%2039.1186%2027.7333%2037.9635%2029.1747%2037.9635H30.5547C31.9962%2037.9635%2033.1647%2039.1186%2033.1647%2040.5435V41.9076C33.1647%2043.3325%2031.9962%2044.4876%2030.5547%2044.4876H29.1747C27.7333%2044.4876%2026.5647%2043.3325%2026.5647%2041.9076V40.5435ZM29.1747%2048.0315C27.7333%2048.0315%2026.5647%2049.1866%2026.5647%2050.6115V51.9757C26.5647%2053.4006%2027.7333%2054.5557%2029.1747%2054.5557H30.5547C31.9962%2054.5557%2033.1647%2053.4006%2033.1647%2051.9757V50.6115C33.1647%2049.1866%2031.9962%2048.0315%2030.5547%2048.0315H29.1747ZM28.3047%2050.6115C28.3047%2050.1366%2028.6942%2049.7515%2029.1747%2049.7515H30.5547C31.0352%2049.7515%2031.4247%2050.1366%2031.4247%2050.6115V51.9757C31.4247%2052.4506%2031.0352%2052.8357%2030.5547%2052.8357H29.1747C28.6942%2052.8357%2028.3047%2052.4506%2028.3047%2051.9757V50.6115ZM26.5647%2061.139C26.5647%2059.7141%2027.7333%2058.559%2029.1747%2058.559H30.5547C31.9962%2058.559%2033.1647%2059.7141%2033.1647%2061.139V62.5031C33.1647%2063.928%2031.9962%2065.0831%2030.5547%2065.0831H29.1747C27.7333%2065.0831%2026.5647%2063.928%2026.5647%2062.5031V61.139ZM29.1747%2060.279C28.6942%2060.279%2028.3047%2060.664%2028.3047%2061.139V62.5031C28.3047%2062.9781%2028.6942%2063.3631%2029.1747%2063.3631H30.5547C31.0352%2063.3631%2031.4247%2062.9781%2031.4247%2062.5031V61.139C31.4247%2060.664%2031.0352%2060.279%2030.5547%2060.279H29.1747ZM58.6052%2049.366C58.6052%2043.6665%2063.2793%2039.046%2069.0452%2039.046C74.811%2039.046%2079.4852%2043.6665%2079.4852%2049.366C79.4852%2055.0656%2074.811%2059.686%2069.0452%2059.686C63.2793%2059.686%2058.6052%2055.0656%2058.6052%2049.366ZM66.8702%2043.776C66.8702%2042.5886%2067.844%2041.626%2069.0452%2041.626C70.2464%2041.626%2071.2202%2042.5886%2071.2202%2043.776V48.936C71.2202%2050.1235%2070.2464%2051.086%2069.0452%2051.086C67.844%2051.086%2066.8702%2050.1235%2066.8702%2048.936V43.776ZM69.0452%2043.346C68.8049%2043.346%2068.6102%2043.5386%2068.6102%2043.776V48.936C68.6102%2049.1735%2068.8049%2049.366%2069.0452%2049.366C69.2854%2049.366%2069.4802%2049.1735%2069.4802%2048.936V43.776C69.4802%2043.5386%2069.2854%2043.346%2069.0452%2043.346ZM69.0452%2057.106C67.844%2057.106%2066.8702%2056.1435%2066.8702%2054.956C66.8702%2053.7686%2067.844%2052.806%2069.0452%2052.806C70.2464%2052.806%2071.2202%2053.7686%2071.2202%2054.956C71.2202%2056.1435%2070.2464%2057.106%2069.0452%2057.106ZM68.6102%2054.956C68.6102%2055.1935%2068.8049%2055.386%2069.0452%2055.386C69.2854%2055.386%2069.4802%2055.1935%2069.4802%2054.956C69.4802%2054.7186%2069.2854%2054.526%2069.0452%2054.526C68.8049%2054.526%2068.6102%2054.7186%2068.6102%2054.956Z'%20fill='%23AFB5D9'/%3e%3c/svg%3e",_a=({closePrintModal:a,setLatestMetaData:d,setInvestigationDropdown:c,setCustomTranslations:n,getVisitpadPreferenceHandler:y,updateVPPrefUsingDocPref:w})=>{const{patientIDs:l,setShowPrintModal:T,setEndConsultationClicked:N,preferences:h,variable:V,docPreference:g}=_.useContext(It),k=_.useMemo(()=>window.is_junior_doc==="1",[]),O=g?.permissions?.can_junior_print,[W,D]=_.useReducer((ee,ve)=>({...ee,...ve}),{currentPage:1,totalRecord:0,pastVisits:[],isVisitLoading:!1}),{pastVisits:A,currentPage:P,isVisitLoading:I,totalRecord:R}=W,Q=_.useCallback(async ee=>{if(l?.patientRoleID)try{D({isVisitLoading:!0});const ve=await bn(ln,ee,l.patientRoleID,V),de=ve?.visits??[];D({currentPage:ee,pastVisits:ee===1?de:[...A,...de],isVisitLoading:!1,totalRecord:+ve.total_visit_count})}catch(ve){console.error("Failed to fetch visits:",ve),D({isVisitLoading:!1})}},[l?.patientRoleID]),B=_.useCallback(async(ee,ve,de=!0)=>{if(l?.patientRoleID){a(),D({isVisitLoading:!0});try{const pe=(await vn(ee.original.visit_date,l.patientRoleID,ee.original.visit_id,V))?.visits?.[0];if(!pe)throw new Error("Visit details not found.");let $=null;const{doctor_id:fe="",doctor_role_id:H=""}=pe;V.window_var.doctor_role_id_for_seg!==H?$=await y({doc_id:fe,doc_rid:H}):h&&await w(h,h.printDefaultPrefIndex,H,!1),d(pe.latest_visit_metadata||{}),T({printDataFrom:"patient_popup",visible:!0,whichPreview:"offlinePrint",printData:"",visitId:pe.visit_id,visit_date:pe.visit_date,visit_number:R-ee.index,currentPrintTime:0,printType:"visit",details:pe,visitpadPref:$,appointmentInfo:{appnt_id:ee.original.appnt_id||"",appnt_type:ee.original.appnt_type||""},trackEventHandler:()=>{}}),N(de)}catch(Ue){console.error("Failed to prepare print data:",Ue)}finally{D({isVisitLoading:!1})}}},[a,y,V,l.patientRoleID,h,N,d,T,w,R]),L=_.useCallback(async()=>{try{const ee=await Fn(V),ve={};ee.transalation_records.forEach(de=>{ve[de.language]=de}),n(ve)}catch(ee){console.error("Failed to get custom translations:",ee)}},[n,V]),z=_.useCallback(async()=>{try{const ee=await Hn(V);if(ee?.test_ranges){const ve=ee.test_ranges.map(de=>({test_id:de.test_id,test_names:de.test_names,test_range_rule:de.test_range_rule,loinc_code:de?.loinc_code||"",test_range_text:de.test_range_text,test_units:de.test_units,value:de.test_names}));c(ve)}}catch(ee){console.error("Failed to get investigation test names:",ee)}},[c,V]);_.useEffect(()=>{Q(1),L(),z()},[L,z]);const K=_.useMemo(()=>({visit_date:"100px",doctor_name:"350px",appnt_type:"100px",service_name:"150px",view:"250px"}),[]),ue=_.useMemo(()=>[{Header:"Date",accessor:"visit_date",Cell:({row:ee})=>e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text [13px]",className:`hfl-text-Gray-600 hfl-w-[${K.visit_date}]`,children:ee.original.visit_date?Ie.dayjs(ee.original.visit_date).format("DD-MMM-YYYY"):"N/A"})},{Header:"Doctor",accessor:"doctor_name",Cell:({row:ee})=>e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text [13px]",className:`hfl-text-Gray-600 hfl-w-[${K.doctor_name}]`,children:["Dr. ",ee.original.doctor_name||"N/A"]})},{Header:"Type",accessor:"appnt_type",Cell:({row:ee})=>e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text [13px]",className:`hfl-text-Gray-600 hfl-w-[${K.appnt_type}]`,children:ee.original.appnt_type||"N/A"})},{Header:"Service",accessor:"service_name",Cell:({row:ee})=>e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text [13px]",className:`hfl-text-Gray-600 hfl-w-[${K.service_name}]`,children:ee.original.service_name||"N/A"})},{Header:"Prescription",id:"view",Cell:({row:ee})=>e.jsxRuntimeExports.jsxs("div",{className:"hfl-mx-2 hfl-my-1 hfl-flex hfl-gap-2",children:[e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Secondary-Grey",size:"sm",textField:"Print",iconFile:"hx_print",icon:"Left",onClick:()=>B(ee,"VISIT_PRINT",!1),className:"hfl-w-[74px]","data-qa":"to-print",disabled:k&&!O}),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Secondary-Grey",size:"sm",textField:"Share",iconFile:"hx_share",icon:"Left",onClick:()=>B(ee,"VISIT_SHARE",!0),className:"hfl-w-[74px]","data-qa":"to-share",disabled:k&&!O})]})}],[K,B,k,O]),ce=_.useMemo(()=>A?A.filter(ee=>!(ee.junior_doctor_role_ids||[]).includes(String(ee.last_modified_by_role_id))):[],[A]),X=async()=>{if(!l?.patientRoleID)return;let ee="../ipdv2/viewPatientsCase";if(V.window_var?.enable_ipd_v2!=="1"){ee="../ipd/viewPatientsCase.php";try{const ve=await wn(V,l.patientRoleID),{status:de=0,case_id:Ue=0}=ve,pe=new Date().toISOString().slice(0,10);ee=de&&Ue?`../ipd/viewPatientRecords.php?pid=${l.patientRoleID}&case_id=${Ue}`:`../ipd/viewAddPatientsCase.php?pid=${l.patientRoleID}&date=${pe}`}catch(ve){console.error("Failed to get IPD Case by PID:",ve)}}window.open(ee,"_blank")};return e.jsxRuntimeExports.jsxs("div",{className:"hfl-mx-[12%] hfl-h-[69vh] hfl-overflow-auto hfl-py-[20px]",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-between hfl-pb-2",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text md",className:"hfl-text-Gray-600",children:"Past Visits"}),V.window_var.ipd_module==="1"&&e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Primary",size:"sm",textField:"Go to IPD","data-qa":"go-to-ipd",className:"hfl-justify-center hfl-bg-Primary-600 hfl-text-White hover:hfl-bg-Primary-700",onClick:()=>{X()}})]}),ce?.length>0&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(va,{columns:ue,data:ce,columnWidth:K}),e.jsxRuntimeExports.jsx(es,{currentPage:P,totalRecord:R,handleLoadMore:()=>Q(P+1),isLoading:I,currentTotal:ce.length})]}),ce.length===0&&!I&&e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-h-[calc(100%_-_80px)] hfl-flex-col hfl-items-center hfl-justify-center hfl-gap-4",children:[e.jsxRuntimeExports.jsx("img",{className:"hfl-w-[80px] hfl-text-Blue_gray-500",src:ya,alt:"empty-bills"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text md",className:"hfl-items-center hfl-justify-center hfl-text-Gray-400",children:"There are no visits for the patient"})]})]})},ba=({fontBaseUrl:a})=>(ae.Font.register({family:"notoKannada",src:`${a}/fonts/NotoSansKannada.ttf`}),ae.Font.register({family:"notoKannadaBold",src:`${a}/fonts/NotoSansKannada-Bold.ttf`}),ae.Font.register({family:"notoHindi",src:`${a}/fonts/NotoSansHindi.ttf`}),ae.Font.register({family:"notoHindiBold",src:`${a}/fonts/NotoSansHindi-Bold.ttf`}),ae.Font.register({family:"notoUrdu",src:`${a}/fonts/Jameel-Nastaleeq.ttf`}),ae.Font.register({family:"notoUrduBold",src:`${a}/fonts/Jameel-Nastaleeq.ttf`}),ae.Font.register({family:"notoArabic",src:`${a}/fonts/NotoSansArabic.ttf`}),ae.Font.register({family:"notoArabicBold",src:`${a}/fonts/NotoSansArabic-Bold.ttf`}),ae.Font.register({family:"notoGujarati",src:`${a}/fonts/NotoSerifGujarati-Regular.ttf`}),ae.Font.register({family:"notoGujaratiBold",src:`${a}/fonts/NotoSerifGujarati-Bold.ttf`}),ae.Font.register({family:"notoMalayalam",src:`${a}/fonts/AnekMalayalam-Regular.ttf`}),ae.Font.register({family:"notoMalayalamBold",src:`${a}/fonts/AnekMalayalam-Bold.ttf`}),ae.Font.register({family:"notoOriya",src:`${a}/fonts/NotoSansOriya.ttf`}),ae.Font.register({family:"notoOriyaBold",src:`${a}/fonts/NotoSansOriya-Bold.ttf`}),ae.Font.register({family:"notoPunjabi",src:`${a}/fonts/MuktaMaheePunjabi-Regular.ttf`}),ae.Font.register({family:"notoPunjabiBold",src:`${a}/fonts/MuktaMaheePunjabi-Bold.ttf`}),ae.Font.register({family:"notoTamil",src:`${a}/fonts/NotoSansTamil.ttf`}),ae.Font.register({family:"notoTamilBold",src:`${a}/fonts/NotoSansTamil-Bold.ttf`}),ae.Font.register({family:"notoTelugu",src:`${a}/fonts/Noto-Sans-Telugu-Regular.ttf`}),ae.Font.register({family:"notoTeluguBold",src:`${a}/fonts/Noto-Sans-Telugu-Bold.ttf`}),ae.Font.register({family:"notoBengali",src:`${a}/fonts/NotoSerifBengali-Regular.ttf`}),ae.Font.register({family:"notoBengaliBold",src:`${a}/fonts/NotoSerifBengali-Bold.ttf`}),ae.Font.register({family:"Verdana",src:`${a}/fonts/Verdana.ttf`}),ae.Font.register({family:"Verdana-Bold",src:`${a}/fonts/Verdana-Bold.ttf`}),ae.Font.register({family:"Verdana-Italic",src:`${a}/fonts/Verdana-Italic.ttf`}),ae.Font.register({family:"Verdana-BoldItalic",src:`${a}/fonts/Verdana-Bold-Italic.ttf`}),ae.Font.register({family:"Arial",src:`${a}/fonts/Arial.ttf`}),ae.Font.register({family:"Arial-Bold",src:`${a}/fonts/Arial-Bold.ttf`}),ae.Font.register({family:"Arial-Italic",src:`${a}/fonts/Arial-Italic.ttf`}),ae.Font.register({family:"Arial-BoldItalic",src:`${a}/fonts/Arial-Bold-Italic.ttf`}),ae.Font.register({family:"Rupee",src:`${a}/fonts/Roboto-Regular.ttf`}),e.jsxRuntimeExports.jsx(ae.PDFViewer,{style:{display:"none"},children:e.jsxRuntimeExports.jsx(ae.Document,{children:e.jsxRuntimeExports.jsxs(ae.Page,{children:[e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoKannada"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoHindi"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoUrdu"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoArabic"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoGujarati"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoMalayalam"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoOriya"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoPunjabi"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoTamil"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoTelugu"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoBengali"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoKannadaBold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoHindiBold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoUrduBold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoArabicBold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoGujaratiBold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoMalayalamBold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoOriyaBold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoPunjabiBold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoTamilBold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoTeluguBold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"notoBengaliBold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"Verdana"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"Verdana-Bold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"Verdana-Italic"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"Verdana-BoldItalic"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"Arial"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"Arial-Bold"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"Arial-Italic"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"Arial-BoldItalic"},children:"load font"}),e.jsxRuntimeExports.jsx(ae.Text,{style:{fontFamily:"Rupee"},children:"load font"})]})})})),ja=a=>{const{billsData:d,handleRowClick:c,handleRightSegment:n,getRowIndices:y,getRefundAmt:w,closePrintModal:l}=a,{patientIDs:T,patientDetails:N,billPreferences:h,setShowPrintModal:V,showPrintModal:g,variable:k}=_.useContext(It)||{},O=({label:R,className:Q})=>e.jsxRuntimeExports.jsx("th",{className:Q,children:e.jsxRuntimeExports.jsxs(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-text-Gray-600",children:[" ",R]})}),W=R=>{switch(R){case St[0]:return"hx_service-appointment-filled hfl-text-Primary-500";case St[1]:return"hx_service-other-filled hfl-text-Pink-500";case St[2]:return"hx_service-lab-filled hfl-text-Purple-600";default:return"hx_service-other-filled hfl-text-Pink-500"}},D=R=>{switch(R){case St[0]:return"Consultation";case St[1]:return"Other";case St[2]:return"Lab";default:return"Other"}},A=async(R,Q,B)=>{if(g?.visible&&l(),R?.order_id){const L=await Xl(R?.order_id,T?.patientRoleID||"",k),z={finalAmount:R.net_bill_amount,billedAmount:R.order_total,gstAmount:R.order_service_tax,cgstAmount:(+R.order_service_tax/2).toFixed(2),sgstAmount:(+R.order_service_tax/2).toFixed(2),discountAmount:R.order_item_sum_discount,receivedAmount:R.order_paid_amount,refundAmount:R.refund_amount,balanceAmount:R.balance_amount,paymentMode:L?.paymentModes.length?L?.paymentModes.join(", "):"",paymentStatus:parseInt(R?.order_paid_amount||"0")-parseInt(R?.refund_amount||"0")===0?"red":parseInt(R?.balance_amount||"0")===0?"green":"yellow"},ue=[N?.age&&typeof N?.age=="number"?`${N?.age}y`:N?.org_person_dob?hr(N?.org_person_dob):"",Jr[N?.gender]??"",N?.blood_group].filter(ce=>ce).join(", ");V({printDataFrom:"patient_popup",visible:!0,whichPreview:Q,printData:"",visitId:"",visit_date:"",visit_number:1,currentPrintTime:new Date().getTime(),printType:"bill",details:{preferences:{...h?.print?.bill,...h?.org_details,...h?.branch_details},billSummaryDetails:z,billServiceDetails:R?.order_items?.map(ce=>({serviceName:ce.service_name,price:ce.order_unit_item_price,gst:Math.floor(+ce.order_item_service_tax),discount:ce.order_item_discount,netPrice:ce.net_amount,itemQty:ce.item_quantity})),billPatientDetails:{name:ar(N?.name)+(ue?` (${ue}) `:""),billDate:Ie.dayjs(R?.order_date).format("DD-MMM-YYYY"),mobileNumber:N?.phone_number,email:N?.email,billNumber:R.order_id_str,patientId:N?.org_person_bid_str,patientIdForEmail:T?.patientRoleID,billStatus:parseInt(R?.balance_amount||"0")===0?"PAID":"UNPAID",address:[N?.address??"",N?.city??"",N?.pincode??""].filter(ce=>ce).join(", "),referredBy:L?.lab_owner_name?ar(L?.lab_owner_name):N?.ref_doc_name?ar(N?.ref_doc_name):"--"},showPrintPreviewForBill:B,isWholeBill:!1,payloadDataforEmail:{orderDate:"",orderNumber:R?.order_id}},trackEventHandler:()=>{}})}},P={table:"hfl-table-fixed hfl-rounded-lg hfl-shadow-md hfl-border-Gray-200 hfl-border-1 hfl-pb-8 ",th:"hfl-bg-Blue_gray-50",td:"hfl-px-2 hfl-h-[36px] hfl-align-top hfl-border-Gray-200 hfl-py-1.5 hfl-border-1 hfl-truncate hfl-text-Gray-500",td_without_truncate:"hfl-px-2 hfl-h-[36px] hfl-align-top hfl-border-Gray-200 hfl-py-1.5 hfl-border-1 hfl-text-Gray-500"},I=[{label:"Date",className:"focus:hfl-outline-none hfl-items-start hfl-w-[120px] hfl-border-Gray-200 hfl-border-1"},{label:"#Bill",className:"focus:hfl-outline-none hfl-items-start hfl-w-[90px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Department",className:"focus:hfl-outline-none hfl-items-start hfl-w-[106px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Paid",className:"focus:hfl-outline-none hfl-items-start hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Due",className:"focus:hfl-outline-none hfl-items-start hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Billed",className:"focus:hfl-outline-none hfl-items-start hfl-truncate hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Discount",className:"focus:hfl-outline-none hfl-items-start hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Refund",className:"focus:hfl-outline-none hfl-items-start hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Service",className:"focus:hfl-outline-none hfl-items-center hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Price",className:"focus:hfl-outline-none hfl-items-center hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"GST",className:"focus:hfl-outline-none hfl-items-center hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"",className:"focus:hfl-outline-none hfl-items-center hfl-w-[36px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"}];return e.jsxRuntimeExports.jsx("div",{"data-qa":"bills-table",children:d.length>0&&e.jsxRuntimeExports.jsxs("table",{className:`${P.table} `,children:[e.jsxRuntimeExports.jsx("thead",{className:`${P.th}`,children:e.jsxRuntimeExports.jsx("tr",{children:I.map((R,Q)=>e.jsxRuntimeExports.jsx(O,{label:R.label,className:R.className},Q))})}),e.jsxRuntimeExports.jsx("tbody",{children:d.length>0&&d.map((R,Q)=>e.jsxRuntimeExports.jsx(_.Fragment,{children:R.order_items.map((B,L)=>e.jsxRuntimeExports.jsxs("tr",{className:"hfl-border-1",children:[L===0&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("td",{rowSpan:R.order_items.length,className:`${P.td}`,children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:`${Ie.dayjs(R.order_date).format("DD-MMM-YY")===Ie.dayjs(new Date).format("DD-MMM-YY")?"hfl-w-[80px] hfl-bg-Success-25 hfl-px-1 hfl-text-Success-500":""}`,children:Ie.dayjs(R.order_date).format("DD-MMM-YY")})}),e.jsxRuntimeExports.jsx("td",{rowSpan:R.order_items.length,className:`${P.td} hfl-w-[70px]`,children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",children:R.order_id_str})}),e.jsxRuntimeExports.jsx("td",{rowSpan:R.order_items.length,className:`${P.td} hfl-w-[70px]`,children:e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center",children:[e.jsxRuntimeExports.jsx("i",{className:` hfl-flex ${W(R.service_category)}`}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-truncate",children:[" ",D(R.service_category)]})]})}),e.jsxRuntimeExports.jsx("td",{rowSpan:R.order_items.length,className:`${P.td} hfl-w-[70px]`,children:e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",children:["₹ ",parseInt(R.order_paid_amount)-parseInt(R.refund_amount)]})})}),e.jsxRuntimeExports.jsx("td",{rowSpan:R.order_items.length,className:`${P.td} hfl-w-[70px]`,children:e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm","data-qa":Q+1+"-due-amount",children:["₹ ",R.balance_amount]})})}),e.jsxRuntimeExports.jsx("td",{rowSpan:R.order_items.length,className:`${P.td} hfl-w-[84px]`,children:e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-between",children:[e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:`${R.order_paid_amount===void 0||R.refund_amount===void 0||R.balance_amount===void 0||parseInt(R.order_paid_amount)-parseInt(R.refund_amount)===0?"hfl-text-Error-500":parseInt(R.balance_amount)===0?"hfl-text-Success-500":"hfl-text-Warning-500"} hfl-cursor-pointer`,onClick:()=>{c(R)},"data-qa":Q+1+"-total-bill",children:["₹ ",R.net_bill_amount]}),e.jsxRuntimeExports.jsx("i",{className:" hx_print-filled hfl-cursor-pointer hfl-text-2 hfl-text-Gray-500",onClick:()=>A(R,"billPrintPreview",!1),"data-qa":Q+1+"-print-bill"})]})}),e.jsxRuntimeExports.jsx("td",{rowSpan:R.order_items.length,className:`${P.td} hfl-w-[84px]`,children:e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",children:["₹ ",parseInt(R.order_discount)+parseInt(R.order_item_sum_discount)]})})}),e.jsxRuntimeExports.jsx("td",{rowSpan:R.order_items.length,className:`${P.td} hfl-max-w-[70px]`,children:e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",children:["₹ ",R.refund_amount]})})})]}),e.jsxRuntimeExports.jsx("td",{className:`${P.td} hfl-w-8 hfl-max-w-[96px]`,title:B.service_name,children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-truncate",children:B.service_name})}),e.jsxRuntimeExports.jsx("td",{className:`${P.td} hfl-max-w-[64px]`,children:e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",children:["₹ ",B.order_item_price]})})}),e.jsxRuntimeExports.jsx("td",{className:`${P.td} hfl-max-w-[46px]`,children:e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",children:["₹ ",B.order_item_service_tax]})})}),e.jsxRuntimeExports.jsx("td",{"data-qa":Q+1+"-"+(L+1)+"-delete-bill",className:`${P.td_without_truncate} hfl-max-w-[36px] hfl-cursor-pointer`,onClick:()=>{y(Q,L),n(pt[6]),parseInt(R.order_paid_amount)-parseInt(R.refund_amount)<=parseInt(R.net_bill_amount)-parseInt(R.order_items[L].net_amount)?w(0):w(parseInt(R.order_paid_amount)-parseInt(R.refund_amount))},children:e.jsxRuntimeExports.jsx("i",{className:"hx_delete hfl-text-Gray-500"})})]},`${Q}-${L}`))},Q))})]})})},Ra=a=>{const{refundAmt:d,handleRightSegment:c,bills:n,billsListIndex:y,orderItemsIndex:w,getBillsList:l}=a,{patientIDs:T,showToast:N,variable:h}=_.useContext(It)||{},[V,g]=_.useState("");return e.jsxRuntimeExports.jsxs("div",{className:"hfl-relative hfl-h-full hfl-bg-Error-25",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-h-8 hfl-shrink-0 hfl-items-center hfl-justify-between hfl-gap-2 hfl-border-b-1 hfl-border-b-Gray-200 hfl-px-2",children:[e.jsxRuntimeExports.jsxs(p.bi,{variant:"Medium",type:"Text lg",className:"hfl-flex",children:["Bill :",e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text lg",className:"hfl-flex hfl-text-Blue-600",children:n?.bill_list[y].order_id_str})]}),e.jsxRuntimeExports.jsx("div",{className:"hx_close hfl-flex-shrink-0 hfl-cursor-pointer hfl-text-4",onClick:()=>c("")})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-items-center hfl-gap-2.5 hfl-px-[13px] hfl-py-3",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-full hfl-shrink-0 hfl-flex-col hfl-items-start hfl-gap-[5px] hfl-rounded-md hfl-border-Gray-200 hfl-bg-White_20 hfl-px-3 hfl-py-2 hfl-shadow-md",children:[e.jsxRuntimeExports.jsxs(p.bi,{variant:"Semibold",type:"Text sm",children:["Service: ",n?.bill_list[y].order_items[w].service_name]}),d>0&&e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center hfl-gap-3",children:e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",children:["Refund of",e.jsxRuntimeExports.jsx("div",{className:"hfl-inline hfl-font-inter-2 hfl-text-Error-600",children:" ₹ "+d+" "}),"will be given to delete this item"]})})]}),e.jsxRuntimeExports.jsx("div",{className:"hfl-w-full",children:e.jsxRuntimeExports.jsx(p.bu,{className:"hfl-w-[100%]",rows:4,inputProps:{value:V,placeholder:"Enter Reason",onChange:k=>{g(k.target.value)}},isDynamicHeight:!0})}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-full hfl-items-start hfl-gap-2",children:[e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Tertiary",size:"md",textField:"Cancel",icon:"Left",iconFile:"hx_close",className:"hfl-flex-1 hfl-items-center hfl-justify-center hfl-border hfl-border-Gray-300 hfl-bg-White hfl-text-Gray-700 hover:hfl-bg-Gray-100",onClick:()=>{c("")}}),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Primary",size:"md",textField:"Delete",icon:"Left",iconFile:"hx_delete",onClick:async()=>{try{if(n?.bill_list?.[y].order_id){const k=await Ul(n?.bill_list?.[y].order_id,n?.bill_list?.[y].order_items[w].order_item_id,T?.patientRoleID||"",V,"0",h);k?(await l(),N?.("Success",k?.message,"Success",3e3),c("")):N?.("Error","Something went wrong please try again","Error",3e3)}}catch(k){console.error("Error in deleting bill item",k),N?.("Error",k?.data?.message||"Something went wrong please try again","Error",3e3)}},className:"hfl-flex-1 hfl-items-center hfl-justify-center hfl-bg-Primary-600 hfl-text-White_20 hover:hfl-bg-Primary-800"})]})]}),e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-flex-col hfl-gap-[14px] hfl-px-3 hfl-py-4"}),e.jsxRuntimeExports.jsx("div",{className:"hfl-absolute hfl-bottom-4 hfl-left-2 hfl-w-full",children:e.jsxRuntimeExports.jsx(p.Ku,{className:"hfl-h-8 hfl-shrink-0 hfl-border-l-Gray-200 hfl-bg-White_20 hfl-text-Gray-500 hfl-shadow-md hover:hfl-bg-Gray-100",hierarchy:"Tertiary",size:"md",textField:"Go Back",icon:"Left",iconFile:"hx_arrow-left hfl-text-Gray-500",onClick:()=>c("")})})]})},wa="data:image/svg+xml,%3csvg%20width='87'%20height='86'%20viewBox='0%200%2087%2086'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cellipse%20opacity='0.1'%20cx='43.5'%20cy='83.42'%20rx='43.5'%20ry='2.58'%20fill='%234E5BA6'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M33.6751%2018.92C34.2431%2016.9347%2036.0897%2015.48%2038.2799%2015.48H55.9277C54.4566%2016.3563%2053.188%2017.5313%2052.2081%2018.92H33.6751ZM51.1971%2020.64H25.6649C22.782%2020.64%2020.445%2022.9502%2020.445%2025.8V57.62H47.4149H47.8499C48.3304%2057.62%2048.7199%2058.005%2048.7199%2058.48V62.995C48.7199%2066.676%2051.7387%2069.66%2055.4624%2069.66C59.1862%2069.66%2062.2049%2066.676%2062.2049%2062.995V37.84C55.4781%2037.84%2050.0249%2032.4495%2050.0249%2025.8C50.0249%2023.9534%2050.4455%2022.2039%2051.1971%2020.64ZM63.9449%2037.7181V61.8486C66.4138%2061.4392%2068.2949%2059.3168%2068.2949%2056.76V36.2293C66.9805%2036.9809%2065.5108%2037.4967%2063.9449%2037.7181ZM70.0349%2035.0228V56.76C70.0349%2060.2756%2067.3674%2063.1753%2063.924%2063.5893C63.6156%2067.9429%2059.9451%2071.38%2055.4624%2071.38C55.3865%2071.38%2055.3108%2071.379%2055.2354%2071.377L55.2449%2071.38H23.925C19.1201%2071.38%2015.225%2067.5296%2015.225%2062.78V61.06C15.225%2059.1601%2016.783%2057.62%2018.705%2057.62V25.8C18.705%2022.0003%2021.821%2018.92%2025.6649%2018.92H31.8855C32.49%2015.9759%2035.1232%2013.76%2038.2799%2013.76H61.3349V13.7902C61.6223%2013.7702%2061.9124%2013.76%2062.2049%2013.76C68.9318%2013.76%2074.3849%2019.1505%2074.3849%2025.8C74.3849%2029.5023%2072.6945%2032.8142%2070.0349%2035.0228ZM10.44%2066.005C10.44%2065.6488%2010.7321%2065.36%2011.0925%2065.36C11.4528%2065.36%2011.745%2065.6488%2011.745%2066.005V66.22C11.745%2070.9696%2015.6401%2074.82%2020.445%2074.82H22.4459C22.7823%2074.82%2023.055%2075.0895%2023.055%2075.422C23.055%2075.7545%2022.7823%2076.024%2022.4459%2076.024H20.445C14.6698%2076.024%2010.44%2071.9104%2010.44%2066.22V66.005ZM11.0925%2063.64C9.77111%2063.64%208.69995%2064.6988%208.69995%2066.005V66.22C8.69995%2072.8786%2013.7274%2077.744%2020.445%2077.744H22.4459C23.7433%2077.744%2024.795%2076.7044%2024.795%2075.422C24.795%2074.1396%2023.7433%2073.1%2022.4459%2073.1H20.445C16.601%2073.1%2013.485%2070.0197%2013.485%2066.22V66.005C13.485%2064.6988%2012.4138%2063.64%2011.0925%2063.64ZM24.795%2043.43C24.795%2042.2426%2025.7687%2041.28%2026.9699%2041.28H40.0199C41.2212%2041.28%2042.195%2042.2426%2042.195%2043.43C42.195%2044.6174%2041.2212%2045.58%2040.0199%2045.58H26.9699C25.7687%2045.58%2024.795%2044.6174%2024.795%2043.43ZM26.9699%2043C26.7297%2043%2026.535%2043.1925%2026.535%2043.43C26.535%2043.6675%2026.7297%2043.86%2026.9699%2043.86H40.0199C40.2602%2043.86%2040.4549%2043.6675%2040.4549%2043.43C40.4549%2043.1925%2040.2602%2043%2040.0199%2043H26.9699ZM32.15%2037.9752C32.2163%2038.0407%2032.3208%2038.0735%2032.4635%2038.0735C32.5859%2038.0735%2032.6751%2038.0407%2032.7312%2037.9752C32.7923%2037.9097%2032.8229%2037.8064%2032.8229%2037.6653V37.0531C33.297%2037.0027%2033.7277%2036.8691%2034.1152%2036.6525C34.5026%2036.4307%2034.8135%2036.1082%2035.048%2035.685C35.2876%2035.2566%2035.4074%2034.7275%2035.4074%2034.0977C35.4074%2033.5534%2035.2825%2033.105%2035.0327%2032.7522C34.783%2032.3944%2034.4924%2032.1198%2034.161%2031.9283C33.8297%2031.7368%2033.3837%2031.5202%2032.8229%2031.2783V29.2375C33.0778%2029.2476%2033.2919%2029.2753%2033.4652%2029.3206C33.6436%2029.366%2033.8246%2029.4239%2034.0081%2029.4945C34.1356%2029.5449%2034.2197%2029.5701%2034.2604%2029.5701C34.3624%2029.5701%2034.4695%2029.4995%2034.5816%2029.3584C34.6988%2029.2173%2034.7983%2029.0535%2034.8798%2028.8671C34.9614%2028.6756%2035.0022%2028.5194%2035.0022%2028.3985C35.0022%2028.2624%2034.9079%2028.1264%2034.7192%2027.9903C34.5357%2027.8543%2034.2757%2027.7384%2033.9393%2027.6426C33.6079%2027.5469%2033.2358%2027.4914%2032.8229%2027.4763V27.0606C32.8229%2026.9145%2032.7923%2026.8112%2032.7312%2026.7507C32.67%2026.6902%2032.5655%2026.66%2032.4176%2026.66C32.2953%2026.66%2032.2035%2026.6927%2032.1424%2026.7583C32.0812%2026.8187%2032.0506%2026.9195%2032.0506%2027.0606V27.4839C31.5561%2027.5393%2031.1024%2027.6728%2030.6895%2027.8845C30.2817%2028.0961%2029.9529%2028.3985%2029.7031%2028.7915C29.4585%2029.1795%2029.3361%2029.6557%2029.3361%2030.2201C29.3361%2030.8147%2029.4661%2031.2985%2029.7261%2031.6713C29.9912%2032.0392%2030.2996%2032.3189%2030.6513%2032.5103C31.0081%2032.6968%2031.4746%2032.8958%2032.0506%2033.1075V35.3221C31.7346%2035.3221%2031.444%2035.2793%2031.1789%2035.1936C30.9189%2035.108%2030.6513%2034.9971%2030.376%2034.8611C30.1823%2034.7603%2030.0549%2034.7099%2029.9937%2034.7099C29.902%2034.7099%2029.7873%2034.7804%2029.6496%2034.9215C29.512%2035.0576%2029.3922%2035.2214%2029.2902%2035.4128C29.1934%2035.6043%2029.1449%2035.7656%2029.1449%2035.8966C29.1449%2036.0528%2029.2596%2036.2191%2029.489%2036.3955C29.7235%2036.5718%2030.06%2036.7255%2030.4984%2036.8565C30.9419%2036.9825%2031.4593%2037.0556%2032.0506%2037.0757V37.6653C32.0506%2037.8064%2032.0837%2037.9097%2032.15%2037.9752ZM31.5001%2029.6154C31.602%2029.4793%2031.7855%2029.3786%2032.0506%2029.3131V30.9306C31.8212%2030.7996%2031.6453%2030.6635%2031.523%2030.5224C31.4058%2030.3813%2031.3471%2030.2151%2031.3471%2030.0236C31.3471%2029.8825%2031.3981%2029.7464%2031.5001%2029.6154ZM33.2511%2034.8611C33.1441%2034.9971%2033.0013%2035.1004%2032.8229%2035.171V33.4703C33.2154%2033.692%2033.4117%2033.9843%2033.4117%2034.3471C33.4117%2034.5537%2033.3582%2034.725%2033.2511%2034.8611ZM24.795%2050.31C24.795%2049.1226%2025.7687%2048.16%2026.9699%2048.16H53.07C54.2712%2048.16%2055.2449%2049.1226%2055.2449%2050.31C55.2449%2051.4974%2054.2712%2052.46%2053.07%2052.46H26.9699C25.7687%2052.46%2024.795%2051.4974%2024.795%2050.31ZM26.9699%2049.88C26.7297%2049.88%2026.535%2050.0725%2026.535%2050.31C26.535%2050.5475%2026.7297%2050.74%2026.9699%2050.74H53.07C53.3102%2050.74%2053.5049%2050.5475%2053.5049%2050.31C53.5049%2050.0725%2053.3102%2049.88%2053.07%2049.88H26.9699ZM51.7649%2025.8C51.7649%2020.1004%2056.4391%2015.48%2062.2049%2015.48C67.9708%2015.48%2072.6449%2020.1004%2072.6449%2025.8C72.6449%2031.4996%2067.9708%2036.12%2062.2049%2036.12C56.4391%2036.12%2051.7649%2031.4996%2051.7649%2025.8ZM60.0299%2020.21C60.0299%2019.0226%2061.0037%2018.06%2062.2049%2018.06C63.4062%2018.06%2064.3799%2019.0226%2064.3799%2020.21V25.37C64.3799%2026.5574%2063.4062%2027.52%2062.2049%2027.52C61.0037%2027.52%2060.0299%2026.5574%2060.0299%2025.37V20.21ZM62.2049%2019.78C61.9647%2019.78%2061.7699%2019.9725%2061.7699%2020.21V25.37C61.7699%2025.6075%2061.9647%2025.8%2062.2049%2025.8C62.4452%2025.8%2062.6399%2025.6075%2062.6399%2025.37V20.21C62.6399%2019.9725%2062.4452%2019.78%2062.2049%2019.78ZM62.2049%2033.54C61.0037%2033.54%2060.0299%2032.5774%2060.0299%2031.39C60.0299%2030.2026%2061.0037%2029.24%2062.2049%2029.24C63.4062%2029.24%2064.3799%2030.2026%2064.3799%2031.39C64.3799%2032.5774%2063.4062%2033.54%2062.2049%2033.54ZM61.7699%2031.39C61.7699%2031.6275%2061.9647%2031.82%2062.2049%2031.82C62.4452%2031.82%2062.6399%2031.6275%2062.6399%2031.39C62.6399%2031.1525%2062.4452%2030.96%2062.2049%2030.96C61.9647%2030.96%2061.7699%2031.1525%2061.7699%2031.39Z'%20fill='%23AFB5D9'/%3e%3c/svg%3e",Ca=a=>{const{closePrintModal:d,handleCurrentWindow:c,billIdToOpen:n,onBillHandled:y}=a,[w,l]=_.useState(),[T,N]=_.useState(""),[h,V]=_.useState(""),[g,k]=_.useState(),[O,W]=_.useState(),[D,A]=_.useState(1),[P,I]=_.useState([]),[R,Q]=_.useState(-1),[B,L]=_.useState(-1),[z,K]=_.useState(0),[ue,ce]=_.useState(0),[X,ee]=_.useState(!1),ve=_.useContext(It);if(!ve)throw new Error("Bills component must be used within an AppContext.Provider");const{patientIDs:de,setLoading:Ue,variable:pe}=ve,$=We=>K(We),fe=(We=pt[0])=>N(We),H=We=>V(We),De=We=>{k(We),H(We?.service_category??""),N(pt[1])},Me=(We,it)=>{Q(We),L(it)},Le=_.useCallback(async()=>{if(de?.patientRoleID)try{const We=await bl(Ie.dayjs().format("YYYY-MM-DD"),de.patientRoleID,!1,pe);W(We)}catch(We){console.error("Error in getPastDueAmount API Call:",We)}},[]);_.useEffect(()=>{Le()},[Le]);const xt=async()=>{const We=await Sl(de.patientRoleID,pe);ce(We?.wallet_balance||0)},ht=async()=>{Ue(!0);try{Ue(!0);const We=await yl("all",de.patientRoleID,1,10,pe);We&&(l(We),I(We?.bill_list)),Ue(!1)}catch{console.log("error in getBillsList API Call")}Ue(!1)},at=async We=>{let it=We;if(Ue(!0),it<=Math.ceil(w.total_pages)){if(it=We+1,it!==We){const Pt=await yl("all",de.patientRoleID,We,10,pe);if(Pt?.bill_list){const gt=[...P,...Pt.bill_list];I(gt)}}A(it)}Ue(!1)};return _.useEffect(()=>{ht()},[]),_.useEffect(()=>{xt()},[X]),_.useEffect(()=>{if(n&&P.length){const We=P.find(it=>it.order_id_str===n);We&&(De(We),y?.())}},[n,P]),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-h-[73.55vh] hfl-flex-row hfl-bg-White",children:[e.jsxRuntimeExports.jsxs("div",{className:`hfl-flex hfl-w-[938px] hfl-flex-col hfl-px-4 hfl-py-2 xxs:max-md:hfl-w-[750px] ${T===pt[7]?"hfl-opacity-30":""}`,children:[e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-max-h-[470px] hfl-w-full hfl-flex-col hfl-overflow-y-auto",children:e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-1 hfl-flex-col hfl-items-center hfl-gap-6 hfl-overflow-y-auto ",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-between hfl-self-stretch",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",className:"hfl-text-Gray-700",children:"Bills"}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-gap-2 ",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",className:"hfl-text-Blue_gray-600",children:"Total Due Amount :"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Semibold",type:"Text lg",className:"hfl-text-Error-500",children:["₹ ",O?.total_amount||0]})]}),e.jsxRuntimeExports.jsx("div",{className:"hfl-h-[30px] hfl-w-[2px] hfl-bg-Gray-200"}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-row hfl-items-center hfl-justify-center hfl-text-Gray-700",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",children:"Deposit Amount:"}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-center hfl-gap-1 hfl-rounded-lg hfl-bg-Gray-50 hfl-p-1",children:[e.jsxRuntimeExports.jsx("i",{className:"hx_rupee hfl-text-3 hfl-text-Success-500"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",className:" hfl-text-Success-500",children:ue}),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Secondary-Grey",size:"md",textField:"",icon:"Only",iconFile:"hx_add-circle hfl-text-4",className:"hfl-items-center hfl-justify-center",onClick:()=>fe(pt[7])})]})]})]})]}),w?.bill_list?.length>0?e.jsxRuntimeExports.jsx(ja,{billsData:P,handleRowClick:De,handleRightSegment:fe,getRowIndices:Me,getRefundAmt:$,closePrintModal:d}):e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-items-center hfl-justify-center hfl-gap-4",children:[e.jsxRuntimeExports.jsx("img",{className:"hfl-w-[80px] hfl-text-Blue_gray-500",src:wa,alt:"empty-bills"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text md",className:"hfl-items-center hfl-justify-center hfl-text-Gray-400",children:"No Past Bills Available"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text md",className:"hfl-text-Gray-500",children:["To create a new bill go to"," ",e.jsxRuntimeExports.jsx("p",{className:"hfl-inline hfl-cursor-pointer hfl-text-Blue-600 hfl-underline",onClick:()=>c(wt[2]),children:"Add Bills"})]})]})]})}),w?.bill_list?.length>0&&e.jsxRuntimeExports.jsx("div",{className:"hfl-px-6 hfl-py-2",children:e.jsxRuntimeExports.jsx(es,{currentPage:D,totalRecord:w?.total_records,currentTotal:D===Math.ceil(w?.total_records/20)?w?.total_records:D*20,handleLoadMore:at})})]}),e.jsxRuntimeExports.jsxs(Nl,{children:[T===pt[1]&&e.jsxRuntimeExports.jsx(Tl,{rightSegment:T,serviceDetails:g?.order_items??[],categorySummaryData:g,serviceItem:h,handleRightSegment:fe,getPastDueAmount:Le,getBillSummarydata:ht,closePrintModal:d,setRefreshWallet:ee,walletBalance:ue,bill_date:"",refreshBillsList:ht}),T===pt[6]&&e.jsxRuntimeExports.jsx(Ra,{refundAmt:z,bills:w,billsListIndex:R,orderItemsIndex:B,handleRightSegment:fe,getBillsList:ht}),T===pt[7]&&e.jsxRuntimeExports.jsx(Il,{depositAmount:ue,handleRightSegment:fe,rightSegment:T,setRefreshWallet:ee})]})]})},Ea=({childModalRef:a,children:d,hideBackDrop:c=!1,backdropClasses:n="",modalClasses:y="",closeOnClickOutside:w,clickOutsideHandler:l,position:T="hfl-inset-0"})=>(_.useEffect(()=>{if(!w)return;const N=h=>{a.current&&!a.current.contains(h.target)&&l()};return document.addEventListener("mousedown",N),()=>{document.removeEventListener("mousedown",N)}},[l,a,w]),e.jsxRuntimeExports.jsx("div",{className:`hfl-fixed ${T} hfl-z-50 hfl-flex hfl-items-center hfl-justify-center ${n} ${c?"":"hfl-bg-Gray-750 hfl-backdrop-blur-sm"}`,children:e.jsxRuntimeExports.jsx("div",{ref:a,className:`hfl-rounded-lg hfl-shadow-md hfl-bg-White ${y??""}`,children:d})})),Sa=({reference:a,closeModalHandler:d,payment_id:c,currentMode:n,transactionType:y,refreshPaymentData:w})=>{const{showToast:l,variable:T}=_.useContext(It)||{},[N,h]=_.useState({paymentMethod:n}),V=async()=>{const g=await Ln(c,N.paymentMethod,y,T);g.status?(l("Update Success",g.message,"Success",3e3),w?.()):l("Update Failed",g.message,"Error",3e3),d({show:!1,payment_id:"",mode:"",payment_type:""})};return e.jsxRuntimeExports.jsxs("div",{ref:a,className:"hfl-flex hfl-w-[400px] hfl-flex-col hfl-rounded-lg hfl-border-none",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-rounded-t-lg hfl-bg-gradient_primary_600_500_90 hfl-px-6 hfl-py-5 hfl-text-White hfl-shadow-sm",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Bold",type:"Text md",className:"hfl-text-White",children:"Please make required changes"})," "]}),e.jsxRuntimeExports.jsx("div",{className:"hfl-bg-White hfl-p-6",children:e.jsxRuntimeExports.jsx(p.Ap,{className:"hfl-w-[200px] hfl-text-0 hfl-text-Gray-800 ",value:{label:cr[N.paymentMethod]},options:Zr.map(g=>({label:g,value:g,className:"hfl-text-1 hfl-text-Gray-800"})),onChange:g=>{h(k=>({...k,paymentMethod:cr[g.value]}))},label:"Payment Method",labelClassName:"after:hfl-content-['*'] after:hfl-text-Error-600 after:hfl-ml-1 hfl-font-inter-2 hfl-font-inter",dropdownInputTextClassName:"hfl-text-1 hfl-text-Gray-600"})}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-row hfl-justify-end hfl-gap-[10px] hfl-rounded-b-lg hfl-border-t-1 hfl-border-Gray-100 hfl-bg-Gray-50 hfl-px-7 hfl-py-2",children:[e.jsxRuntimeExports.jsx(p.Ku,{textField:"Cancel",size:"sm",hierarchy:"Primary",onClick:()=>d({show:!1,payment_id:"",mode:"",payment_type:""}),className:"hfl-border-1 hfl-border-Blue-300 hfl-bg-Blue-50 hfl-text-Blue-600 hover:hfl-bg-Blue-600 hover:hfl-text-White"}),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Primary",size:"sm",textField:"Save",className:"hfl-bg-Blue-600",onClick:V})]})]})},Pa=({styles:a,data:d,handleDeleteRow:c,handleRightSegment:n,handleRowClick:y,getType:w,getTypeColor:l,refreshPaymentData:T})=>{const[N,h]=_.useState({show:!1,payment_id:"",mode:"",payment_type:""}),V=_.useRef(null),g=O=>{switch(O){case"1":return"Consultation";case"2":return"Other";case"3":return"Lab";default:return"Other"}},k=O=>{switch(O){case"1":return"hx_service-appointment-filled hfl-text-Primary-500";case"2":return"hx_service-other-filled hfl-text-Pink-500";case"3":return"hx_service-lab-filled hfl-text-Purple-600";default:return"hx_service-other-filled hfl-text-Pink-500"}};return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[d.length>0&&d.map((O,W)=>e.jsxRuntimeExports.jsx(_.Fragment,{children:e.jsxRuntimeExports.jsxs("tr",{className:"hfl-border-1",children:[e.jsxRuntimeExports.jsx("td",{className:`${a.td} `,children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",children:Ie.dayjs.utc(new Date(O.created_on)).format("YYYY-MM-DD / HH:mm")})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[70px]`,children:e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"-hfl-ml-1 ",children:O.order_id_str})})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[90px]`,children:e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex hfl-cursor-pointer hfl-text-Primary-600 hover:hfl-underline",onClick:()=>{y(O)},"data-qa":W+1+"-bill-amount",children:"₹"+O.paid_amount})})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[70px]`,children:e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center",children:[e.jsxRuntimeExports.jsx("i",{className:" hx_f_rupee hfl-flex "}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:` -hfl-ml-1 hfl-px-1 ${l(O.payment_refund)}`,children:w(O.payment_refund)})]})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-w-[90px]`,children:e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-between hfl-gap-2",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",onClick:()=>{},className:"-hfl-ml-1",children:cr[O.paid_mode]}),e.jsxRuntimeExports.jsx("span",{className:"hx_edit hfl-cursor-pointer hfl-text-Blue-600",onClick:()=>{h({show:!0,payment_id:O.order_payment_id,mode:O.paid_mode,payment_type:w(O.payment_refund).toLowerCase()})}})]})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[90px]`,children:e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center ",children:[e.jsxRuntimeExports.jsx("i",{className:`hfl-flex hfl-text-3 hfl-text-Error-500 ${k(O.service_category_id)}`}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"-hfl-ml-0 ",children:[" ",g(O?.service_category_id)]})]})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[50px]`,children:e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center",children:[e.jsxRuntimeExports.jsx("i",{className:" hx_f-rupee hfl-flex hfl-text-0"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"-hfl-ml-1",children:O.order_total})]})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[70px]`,title:O.details,children:e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"-hfl-ml-1 hfl-truncate",children:O.details})})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[70px]`,children:e.jsxRuntimeExports.jsx("i",{className:" hx_delete hfl-flex hfl-cursor-pointer hfl-text-2",onClick:D=>{D.stopPropagation(),n(),c(O,W)},"data-qa":W+1+"-delete-transaction"})})]},`${W}`)},W)),N.show&&e.jsxRuntimeExports.jsx(Ea,{childModalRef:V,backdropClasses:"",clickOutsideHandler:()=>{},closeOnClickOutside:!1,hideBackDrop:!1,modalClasses:"hfl-rounded-xlg hfl-mx-2 xsm:hfl-mx-6 md:hfl-mx-12 ",children:e.jsxRuntimeExports.jsx(Sa,{reference:V,closeModalHandler:h,payment_id:N.payment_id,currentMode:N.mode,transactionType:N.payment_type,refreshPaymentData:T})})]})},Na=({styles:a,data:d,handleRowClick:c,closePrintModal:n,patient_entity_id:y})=>{const{patientDetails:w,patientIDs:l,billPreferences:T,setShowPrintModal:N,showPrintModal:h}=_.useContext(It),V=async(g,k,O,W)=>{h?.visible&&n();const A=[w?.age&&typeof w?.age=="number"?`${w?.age}y`:w?.org_person_dob?hr(w?.org_person_dob):"",Jr[w?.gender]??"",w?.blood_group].filter(I=>I).join(", "),P={name:ar(w?.name)+(A?` (${A}) `:""),billDate:Ie.dayjs(g?.transaction_time).format("DD-MMM-YYYY"),mobileNumber:w?.phone_number,email:w?.email,billNumber:g?.bill_number,patientId:w?.org_person_bid_str,patientIdForEmail:l?.patientRoleID,billStatus:"PAID",address:[w?.address??"",w?.city??"",w?.pincode??""].filter(I=>I).join(", ")};N({printDataFrom:"patient_popup",visible:!0,whichPreview:k,printData:"",visitId:"",visit_date:"",visit_number:1,currentPrintTime:new Date().getTime(),printType:"bill_deposit_refund",details:{showPrintPreviewForBill:O,preferences:{...T?.print?.bill,...T?.org_details},depositRefundBillDetails:g,billPatientDetails:P,isWholeBill:!1,payloadDataforEmail:{orderDate:"",orderNumber:g?.bill_number,patient_user_id:y}},trackEventHandler:()=>{console.log(W)}})};return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:d.length>0&&d.map((g,k)=>e.jsxRuntimeExports.jsx(_.Fragment,{children:e.jsxRuntimeExports.jsxs("tr",{className:"hfl-border-1",children:[e.jsxRuntimeExports.jsx("td",{className:`${a.td} `,children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",children:Ie.dayjs.utc(new Date(g.transaction_time)).format("YYYY-MM-DD / HH:mm")})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[70px]`,children:e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"-hfl-ml-1 hfl-text-Primary-600",children:g.bill_number})})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[105px]`,children:e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center",children:[e.jsxRuntimeExports.jsx("i",{className:" hx_f-rupee hfl-flex hfl-text-0"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"-hfl-ml-1",children:g.bill_amount})]})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[115px]`,children:e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex hfl-cursor-pointer hover:hfl-underline",onClick:()=>{c(g)},"data-qa":k+1+"-bill-amount",children:"₹"+g.paid_amount}),e.jsxRuntimeExports.jsx("i",{className:" hx_print-filled hfl-cursor-pointer hfl-text-2 hfl-text-Gray-500",onClick:()=>V(g,"billPrintPreview",!1,g?.type==="DEPOSIT"?"DEPOSIT_BILL_PRINT":"REFUND_BILL_PRINT"),"data-qa":k+1+"-print-bill"})]})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-w-[90px]`,children:e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center",children:[e.jsxRuntimeExports.jsx("i",{className:" hfl-flex hfl-text-0"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"-hfl-ml-1",children:g.mode})]})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[90px]`,children:e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center ",children:[e.jsxRuntimeExports.jsx("img",{src:Ql(g.type)}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"-hfl-ml-0 ",children:[" ",g.type]})]})}),e.jsxRuntimeExports.jsx("td",{className:`${a.td} hfl-max-w-[160px]`,title:g.details,children:e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"-hfl-ml-1 hfl-truncate",children:g.details})})})]},`${k}`)},k))})},Aa=a=>{const{data:d,setTableData:c,handleRightSegment:n,handleRowClick:y,activeTab:w,closePrintModal:l,patient_entity_id:T,refreshPaymentData:N}=a,{patientIDs:h,showToast:V,variable:g}=_.useContext(It)||{};Ie.dayjs.extend(Dl);const k=async(I,R)=>{let Q="";I.payment_refund==="P"?Q="payment":I.payment_refund==="R"&&(Q="refund");try{const B=await Dn(I.order_payment_id,Q,I.order_id,h?.patientRoleID||"",g);B.status&&(V("Success",B?.message,"Success",3e3),c(L=>{try{const z=[...L];return z.splice(R,1),z}catch(z){return console.error(`Error: ${z}`),L}}),N())}catch(B){console.error("Error deleting payment:",B)}},O=I=>{switch(I){case"P":return"Payment";case"R":return"Refund";case"D":return"Deposit";default:return""}},W=I=>{switch(I){case"DEPOSIT":case"P":return"hfl-bg-Success-50 hfl-text-Success-500";case"REFUND":case"R":return"hfl-bg-Error-50 hfl-text-Error-500";case"D":return"hfl-bg-Primary-50 hfl-text-Primary-500";default:return""}},D=_.useMemo(()=>w===pr[Rr.consultation_lab_other_services].key?[{label:"Date/Time",className:"focus:hfl-outline-none hfl-items-start hfl-w-[162px] hfl-border-Gray-200 hfl-border-1"},{label:"#Bill",className:"focus:hfl-outline-none hfl-items-start hfl-w-[100px] hfl-truncate hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Amount",className:"focus:hfl-outline-none hfl-items-start hfl-w-[90px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Type",className:"focus:hfl-outline-none hfl-items-start hfl-w-[90px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Mode",className:"focus:hfl-outline-none hfl-items-start hfl-w-[90px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Category",className:"focus:hfl-outline-none hfl-items-start hfl-w-[136px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Bill Amount",className:"focus:hfl-outline-none hfl-items-start hfl-w-[110px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:"Details",className:"focus:hfl-outline-none hfl-items-start hfl-w-[120px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"},{label:" ",className:"focus:hfl-outline-none hfl-items-start hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1"}]:[{label:"Date/Time",className:"focus:hfl-outline-none hfl-items-start hfl-w-[162px] hfl-border-Gray-200 hfl-border-1 hfl-px-2 hfl-text-left"},{label:"#Bill",className:"focus:hfl-outline-none hfl-items-start hfl-w-[100px] hfl-truncate hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1 hfl-text-left"},{label:"Bill Amount",className:"focus:hfl-outline-none hfl-items-start hfl-w-[105px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1 hfl-text-left"},{label:"Total Paid",className:"focus:hfl-outline-none hfl-items-start hfl-w-[115px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1 hfl-text-left"},{label:"Mode",className:"focus:hfl-outline-none hfl-items-start hfl-w-[90px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1 hfl-text-left"},{label:"Category",className:"focus:hfl-outline-none hfl-items-start hfl-w-[136px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1 hfl-text-left"},{label:"Details",className:"focus:hfl-outline-none hfl-items-start hfl-w-[160px] hfl-border-1 hfl-px-2 hfl-border-Gray-200 hfl-py-1 hfl-text-left"}],[w]),A=({label:I,className:R})=>e.jsxRuntimeExports.jsx("th",{className:R,children:e.jsxRuntimeExports.jsxs(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-text-Gray-600",children:[" ",I]})}),P={table:"hfl-table-fixed hfl-rounded-lg hfl-shadow-md hfl-border-Gray-200 hfl-border-1 hfl-pb-8 ",th:"hfl-bg-Blue_gray-50",td:"hfl-px-2 hfl-h-[36px] hfl-align-top hfl-border-Gray-200 hfl-py-1.5 hfl-border-1 hfl-truncate hfl-text-Gray-500"};return e.jsxRuntimeExports.jsx("div",{className:"",children:e.jsxRuntimeExports.jsxs("table",{className:`${P.table}`,children:[e.jsxRuntimeExports.jsx("thead",{className:`${P.th}`,children:e.jsxRuntimeExports.jsx("tr",{children:D.map((I,R)=>e.jsxRuntimeExports.jsx(A,{label:I.label,className:I.className},R))})}),e.jsxRuntimeExports.jsx("tbody",{children:w===pr[Rr.consultation_lab_other_services].key?e.jsxRuntimeExports.jsx(Pa,{styles:P,data:d,handleDeleteRow:k,handleRightSegment:n,handleRowClick:y,getTypeColor:W,getType:O,refreshPaymentData:N}):e.jsxRuntimeExports.jsx(Na,{styles:P,data:d,handleRowClick:y,closePrintModal:l,patient_entity_id:T})})]})})},Da="data:image/svg+xml,%3csvg%20width='88'%20height='87'%20viewBox='0%200%2088%2087'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cellipse%20opacity='0.1'%20cx='44'%20cy='83.92'%20rx='43.5'%20ry='2.58'%20fill='%234E5BA6'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M12.6799%2017.3857C12.6799%2016.1344%2013.7061%2015.12%2014.972%2015.12C16.2379%2015.12%2017.2641%2016.1344%2017.2641%2017.3857V22.0468C17.2641%2023.2981%2016.2379%2024.3125%2014.972%2024.3125C13.7061%2024.3125%2012.6799%2023.2981%2012.6799%2022.0468V17.3857ZM14.972%2016.84C14.6671%2016.84%2014.4199%2017.0843%2014.4199%2017.3857V22.0468C14.4199%2022.3482%2014.6671%2022.5925%2014.972%2022.5925C15.2769%2022.5925%2015.5241%2022.3482%2015.5241%2022.0468V17.3857C15.5241%2017.0843%2015.2769%2016.84%2014.972%2016.84ZM23.1199%2026.3C23.1199%2023.9252%2025.0675%2022%2027.4699%2022H56.4199C55.1757%2023.464%2054.2776%2025.225%2053.8502%2027.16H23.1199V26.3ZM53.6005%2028.88H19.6399C17.2375%2028.88%2015.2899%2030.8052%2015.2899%2033.18V37.48L56.4199%2037.48C54.6412%2035.3872%2053.5699%2032.6872%2053.5699%2029.74C53.5699%2029.4508%2053.5802%2029.1641%2053.6005%2028.88ZM67.4899%2041.6581V58.98H69.2299C71.6324%2058.98%2073.5799%2057.0548%2073.5799%2054.68V38.9628C71.8823%2040.3727%2069.7897%2041.3329%2067.4899%2041.6581ZM75.3199%2037.1886V54.68C75.3199%2058.0047%2072.5933%2060.7%2069.2299%2060.7H67.4899V61.56C67.4899%2064.8848%2064.7633%2067.58%2061.3999%2067.58H19.6399C16.2765%2067.58%2013.5499%2064.8848%2013.5499%2061.56V33.18C13.5499%2029.8552%2016.2765%2027.16%2019.6399%2027.16H21.3799V26.3C21.3799%2022.9752%2024.1065%2020.28%2027.4699%2020.28H57.9199V20.5172C60.0371%2018.759%2062.7684%2017.7%2065.7499%2017.7C72.4768%2017.7%2077.9299%2023.0905%2077.9299%2029.74C77.9299%2032.5522%2076.9545%2035.1393%2075.3199%2037.1886ZM15.2899%2042.64L65.7499%2042.64V58.98V60.7V61.56C65.7499%2063.9348%2063.8024%2065.86%2061.3999%2065.86H19.6399C17.2375%2065.86%2015.2899%2063.9348%2015.2899%2061.56V42.64ZM73.262%2063.28C71.9961%2063.28%2070.9699%2064.2944%2070.9699%2065.5457V70.2068C70.9699%2071.4581%2071.9961%2072.4725%2073.262%2072.4725C74.5279%2072.4725%2075.5541%2071.4581%2075.5541%2070.2068V65.5457C75.5541%2064.2944%2074.5279%2063.28%2073.262%2063.28ZM72.7099%2065.5457C72.7099%2065.2443%2072.9571%2065%2073.262%2065C73.5669%2065%2073.8141%2065.2443%2073.8141%2065.5457V70.2068C73.8141%2070.5082%2073.5669%2070.7525%2073.262%2070.7525C72.9571%2070.7525%2072.7099%2070.5082%2072.7099%2070.2068V65.5457ZM55.3099%2029.74C55.3099%2024.0404%2059.9841%2019.42%2065.7499%2019.42C71.5158%2019.42%2076.1899%2024.0404%2076.1899%2029.74C76.1899%2035.4396%2071.5158%2040.06%2065.7499%2040.06C59.9841%2040.06%2055.3099%2035.4396%2055.3099%2029.74ZM63.5749%2024.15C63.5749%2022.9626%2064.5487%2022%2065.7499%2022C66.9511%2022%2067.9249%2022.9626%2067.9249%2024.15V29.31C67.9249%2030.4974%2066.9511%2031.46%2065.7499%2031.46C64.5487%2031.46%2063.5749%2030.4974%2063.5749%2029.31V24.15ZM65.7499%2023.72C65.5097%2023.72%2065.3149%2023.9125%2065.3149%2024.15V29.31C65.3149%2029.5475%2065.5097%2029.74%2065.7499%2029.74C65.9902%2029.74%2066.1849%2029.5475%2066.1849%2029.31V24.15C66.1849%2023.9125%2065.9902%2023.72%2065.7499%2023.72ZM65.7499%2037.48C64.5487%2037.48%2063.5749%2036.5174%2063.5749%2035.33C63.5749%2034.1426%2064.5487%2033.18%2065.7499%2033.18C66.9511%2033.18%2067.9249%2034.1426%2067.9249%2035.33C67.9249%2036.5174%2066.9511%2037.48%2065.7499%2037.48ZM65.3149%2035.33C65.3149%2035.5675%2065.5097%2035.76%2065.7499%2035.76C65.9902%2035.76%2066.1849%2035.5675%2066.1849%2035.33C66.1849%2035.0925%2065.9902%2034.9%2065.7499%2034.9C65.5097%2034.9%2065.3149%2035.0925%2065.3149%2035.33ZM35.7349%2050.38C34.5337%2050.38%2033.5599%2051.3426%2033.5599%2052.53C33.5599%2053.7174%2034.5337%2054.68%2035.7349%2054.68H59.2249C60.4262%2054.68%2061.3999%2053.7174%2061.3999%2052.53C61.3999%2051.3426%2060.4262%2050.38%2059.2249%2050.38H35.7349ZM35.2999%2052.53C35.2999%2052.2925%2035.4947%2052.1%2035.7349%2052.1H59.2249C59.4652%2052.1%2059.6599%2052.2925%2059.6599%2052.53C59.6599%2052.7675%2059.4652%2052.96%2059.2249%2052.96H35.7349C35.4947%2052.96%2035.2999%2052.7675%2035.2999%2052.53ZM24.4249%2056.4C26.5871%2056.4%2028.3399%2054.6673%2028.3399%2052.53C28.3399%2050.3927%2026.5871%2048.66%2024.4249%2048.66C22.2627%2048.66%2020.5099%2050.3927%2020.5099%2052.53C20.5099%2054.6673%2022.2627%2056.4%2024.4249%2056.4Z'%20fill='%23AFB5D9'/%3e%3c/svg%3e",Ta=({walletBalance:a,handleRightSegment:d,headerText:c})=>e.jsxRuntimeExports.jsxs("div",{className:"hfl-mt-2 hfl-flex hfl-w-full hfl-flex-row hfl-items-center hfl-justify-between hfl-text-Gray-700",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text lg",children:c}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text lg",children:"Deposit Amount:"}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-center hfl-justify-center hfl-gap-1 hfl-rounded-lg hfl-bg-Gray-50 hfl-p-1",children:[e.jsxRuntimeExports.jsx("i",{className:"hx_rupee hfl-text-3 hfl-text-Success-500"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Medium",type:"Text lg",className:" hfl-text-Success-500",children:a}),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Secondary-Grey",size:"md",textField:"",icon:"Only",iconFile:"hx_add-circle hfl-text-4",className:"hfl-items-center hfl-justify-center",onClick:()=>d(pt[7])})]})]})]}),Ia=a=>{Ie.dayjs.extend(Dl);const{patientDetails:d,patientIDs:c,billPreferences:n,setShowPrintModal:y,showPrintModal:w}=_.useContext(It)||{},{handleRightSegment:l,closePrintModal:T,summaryData:N,patient_entity_id:h}=a,V=async(g,k)=>{w?.visible&&T();const W=[d?.age&&typeof d?.age=="number"?`${d?.age}y`:d?.org_person_dob?hr(d?.org_person_dob):"",Jr[d?.gender]??"",d?.blood_group].filter(A=>A).join(", "),D={name:ar(d?.name)+(W?` (${W}) `:""),billDate:Ie.dayjs(N?.transaction_time).format("DD-MMM-YYYY"),mobileNumber:d?.phone_number,email:d?.email,billNumber:N?.bill_number,patientId:d?.org_person_bid_str,patientIdForEmail:c?.patientRoleID,billStatus:"PAID",address:[d?.address??"",d?.city??"",d?.pincode??""].filter(A=>A).join(", ")};y?.({printDataFrom:"patient_popup",visible:!0,whichPreview:g,printData:"",visitId:"",visit_date:"",visit_number:1,currentPrintTime:new Date().getTime(),printType:"bill_deposit_refund",details:{showPrintPreviewForBill:k,preferences:{...n?.print?.bill,...n?.org_details},depositRefundBillDetails:N,billPatientDetails:D,isWholeBill:!1,payloadDataforEmail:{orderDate:"",orderNumber:N?.bill_number,patient_user_id:h}},trackEventHandler:()=>{}})};return e.jsxRuntimeExports.jsxs("div",{className:"hfl-relative hfl-h-full ",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-h-8 hfl-w-[330px] hfl-shrink-0 hfl-items-center hfl-gap-2 hfl-border-b-1 hfl-border-b-Gray-200 hfl-px-2",children:[e.jsxRuntimeExports.jsx("div",{className:"hx_arrow-left hfl-flex-shrink-0 hfl-cursor-pointer hfl-text-4",onClick:()=>l(pt[0])}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-flex hfl-items-center",children:"Bills Summary"})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-items-start hfl-px-3 hfl-py-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-justify-between hfl-self-stretch hfl-py-[7px] hfl-pr-7",children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-w-[60%] hfl-gap-2",children:[e.jsxRuntimeExports.jsx("img",{src:Ql(N.type),alt:""}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-flex-1 hfl-text-Gray-800",children:N.type==="DEPOSIT"?"Deposit":"Refund(Deposit)"})]}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹ ",N?.bill_amount]})]}),N.type==="DEPOSIT"&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-self-stretch hfl-py-[7px] hfl-pr-7",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-w-[60%] hfl-flex-1 hfl-text-Gray-800",children:"Total Billed Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-text-Gray-800",children:["₹ ",N?.bill_amount]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-self-stretch hfl-py-[7px] hfl-pr-7",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-w-[60%] hfl-flex-1 hfl-text-Gray-800",children:"Paid Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹ ",N?.paid_amount]})]})]}),N.type==="REFUND"&&e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-self-stretch hfl-py-[7px] hfl-pr-7",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-w-[60%] hfl-flex-1 hfl-text-Gray-800",children:"Deposit Amount"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-Gray-800",children:["₹ ",N?.opening_balance]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-items-start hfl-self-stretch hfl-py-[7px] hfl-pr-7",children:[e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-w-[60%] hfl-flex-1 hfl-text-Gray-800",children:"Total Balance"}),e.jsxRuntimeExports.jsxs(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-text-Gray-800",children:["₹"," ",N.type==="DEPOSIT"?parseInt(N?.bill_amount)-parseInt(N?.paid_amount):N?.closing_balance]})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"hfl-absolute hfl-bottom-1 hfl-flex hfl-w-full hfl-items-start hfl-gap-2 hfl-px-1 hfl-pb-2",children:[e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Tertiary",size:"md",textField:"Print",icon:"Left",onClick:()=>V("billPrintPreview",!1),iconFile:"hx_print",className:" hfl-flex-1 hfl-items-center hfl-justify-center hfl-border hfl-border-Gray-300 hfl-bg-White hfl-text-Gray-700 hover:hfl-bg-Gray-100"}),e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Tertiary",size:"md",textField:"Share",icon:"Left",onClick:()=>V("billSharePreview",!0),iconFile:"hx_share",className:" hfl-flex-1 hfl-items-center hfl-justify-center hfl-border hfl-border-Gray-300 hfl-bg-White hfl-text-Gray-700 hover:hfl-bg-Gray-100"})]})]})},Ba=({closePrintModal:a})=>{const[d,c]=_.useState(pr[Rr.consultation_lab_other_services].key),[n,y]=_.useState(null),[w,l]=_.useState(pt[5]),[T,N]=_.useState(""),[h,V]=_.useState(),[g,k]=_.useState([]),[O,W]=_.useState(1),[D,A]=_.useState(),{setLoading:P,patientIDs:I,variable:R}=_.useContext(It),[Q,B]=_.useState(0),[L,z]=_.useState(!1),K=_.useCallback(async()=>{try{if(P(!0),I?.patientRoleID){const $=await _l(I.patientRoleID,1,10,R);$&&(y($),k($.data))}P(!1)}catch{y(null),k([]),P(!1),console.log("error in getPaymentsList API Call")}},[I.patientRoleID,P,R]),ue=_.useCallback(async()=>{try{P(!0);const $=await jl(I?.patientRoleID||"",1,10,R);$&&(y($),k($?.wallet_transactions||[])),P(!1)}catch{y(null),k([]),P(!1),console.log("error in getDepositRefundList API Call")}},[I?.patientRoleID,P,R]),ce=($=pt[5])=>{l($)},X=$=>{N($)},ee=async $=>{if(V($),d===pr[Rr.consultation_lab_other_services].key){if(X(St[parseInt($?.service_category_id)-1]),l(pt[1]),$?.order_id){const fe=await de($.order_id);A(fe)}}else l(pt[8])},ve=async $=>{let fe=$;if(P(!0),fe<=Math.ceil(n?.total_records||0)){if(fe=$+1,fe!==$){let H,De;d==pr[Rr.deposit_refund].key?(H=await jl(I?.patientRoleID||"",fe,10,R),De=[...g,...H.wallet_transactions]):(H=await _l(I?.patientRoleID||"",fe,10,R),De=[...g,...H.data]),k(De)}W(fe)}P(!1)},de=async $=>{try{return await El($,I?.patientRoleID||"",["order_items"],R)}catch{console.log("Error in Loading Bill Details from Bill Id")}},Ue=_.useCallback(async()=>{const $=await Sl(I?.patientRoleID||"",R);B($?.wallet_balance||0)},[I?.patientRoleID,R]),pe=$=>{c($),ce(),a()};return _.useEffect(()=>{d==pr[Rr.deposit_refund].key?ue():K()},[d,ue,K]),_.useEffect(()=>{Ue(),d==pr[Rr.deposit_refund].key&&ue()},[d,Ue,ue,L]),e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-h-[73.55vh] hfl-bg-White",children:[e.jsxRuntimeExports.jsxs("div",{className:`hfl-flex hfl-w-[938px] hfl-flex-col hfl-justify-start hfl-px-4 hfl-py-2 xxs:max-md:hfl-w-[750px] ${w===pt[7]?"hfl-opacity-30":""}`,children:[e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-items-center",children:Object.values(pr).map(($,fe)=>e.jsxRuntimeExports.jsx(p.bi,{variant:`${d===$.key?"Semibold":"Regular"}`,type:"Text md",className:`hfl-flex hfl-cursor-pointer hfl-items-center hfl-justify-center hfl-gap-0.5 hfl-px-[13px] hfl-py-2 ${d===$.key?"hfl-border-b-2 hfl-border-Primary-600 hfl-text-Primary-600":""}`,onClick:()=>pe($.key),children:$.label},fe))}),e.jsxRuntimeExports.jsx(Ta,{walletBalance:Q,handleRightSegment:ce,headerText:pr[d].label}),e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-max-h-[470px] hfl-w-full hfl-flex-col hfl-overflow-y-scroll"}),g?.length?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{className:"hfl-flex hfl-flex-1 hfl-flex-col hfl-items-center hfl-gap-6 hfl-overflow-y-auto ",children:e.jsxRuntimeExports.jsx(Aa,{data:g,setTableData:k,handleRowClick:ee,handleRightSegment:ce,activeTab:d,closePrintModal:a,patient_entity_id:n?.entity_id||"",refreshPaymentData:K})}),e.jsxRuntimeExports.jsx("div",{className:"hfl-px-6 hfl-py-2",children:e.jsxRuntimeExports.jsx(es,{currentPage:O,totalRecord:n?.total_records||0,currentTotal:O===Math.ceil((n?.total_records||0)/10)?n?.total_records||0:O*10,handleLoadMore:ve})})]}):e.jsxRuntimeExports.jsxs("div",{className:"hfl-flex hfl-flex-col hfl-items-center hfl-justify-center hfl-gap-4",children:[e.jsxRuntimeExports.jsx("img",{className:"hfl-w-[80px] hfl-text-Blue_gray-500",src:Da,alt:"empty-bills"}),e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text md",className:"hfl-items-center hfl-justify-center hfl-text-Gray-400",children:"No Active or Past Payments for the Patient"})]})]}),e.jsxRuntimeExports.jsxs(Nl,{children:[w===pt[1]&&e.jsxRuntimeExports.jsx(Tl,{rightSegment:w,categorySummaryData:{...h,order_date:D?.order_date??""},serviceItem:T,handleRightSegment:ce,serviceDetails:D?.order_items??[],getBillSummarydata:K,closePrintModal:a,setRefreshWallet:z,walletBalance:Q,getPastDueAmount:()=>{},refreshBillsList:()=>{},bill_date:""}),w===pt[7]&&e.jsxRuntimeExports.jsx(Il,{depositAmount:Q,handleRightSegment:ce,rightSegment:w,setRefreshWallet:z}),w===pt[8]&&e.jsxRuntimeExports.jsx(Ia,{summaryData:{...h,order_date:D?.order_date??""},handleRightSegment:ce,closePrintModal:a,patient_entity_id:n?.entity_id||""})]})]})},Bl=()=>e.jsxRuntimeExports.jsx("div",{className:"hfl-inset-0 hfl-z-[100] hfl-flex hfl-h-full hfl-w-full hfl-items-center hfl-justify-center hfl-overflow-y-auto hfl-outline-none focus:hfl-outline-none",children:e.jsxRuntimeExports.jsx(p.Eu,{progress:10,spinnerMode:!0})}),en=({columns:a,data:d})=>{const{getTableProps:c,getTableBodyProps:n,headerGroups:y,rows:w,prepareRow:l}=Qr.useTable({columns:a,data:d}),T=h=>{const V=[];return h?.headers?.length&&h.headers.map(g=>{V.push(e.jsxRuntimeExports.jsx("th",{...g.getHeaderProps(),className:"hfl-rounded hfl-border-1 hfl-border-Gray-200 hfl-bg-Blue_gray-50 hfl-px-2 hfl-py-1 hfl-text-left",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Semibold",type:"Text sm",className:"hfl-text-Gray-600",children:g.render("Header")})}))}),V},N=()=>{const h=[];return w.map((V,g)=>{l(V),h.push(e.jsxRuntimeExports.jsx("tr",{id:g.toString(),...V.getRowProps(),className:"hfl-bg-White hfl-group hfl-border-t-1 hfl-border-Gray-200",children:V.cells.map((k,O)=>e.jsxRuntimeExports.jsx("td",{"data-qa":g+1+"-"+(O+1),...k.getCellProps(),className:"hfl-relative hfl-border-1 hfl-border-Gray-200 hfl-px-2 hfl-text-left",children:e.jsxRuntimeExports.jsx(p.bi,{variant:"Regular",type:"Text sm",className:"hfl-text-[13px] hfl-text-Gray-500",children:k.render("Cell")})}))}))}),h};return e.jsxRuntimeExports.jsx("div",{className:"hfl-overflow-y-auto","data-qa":"lab-report-table",children:e.jsxRuntimeExports.jsxs("table",{...c(),className:"hfl-table-fixed hfl-rounded-lg hfl-border-1 hfl-border-Gray-200 hfl-pb-8 hfl-shadow-md",children:[e.jsxRuntimeExports.jsx("thead",{children:y.map(h=>e.jsxRuntimeExports.jsx("tr",{...h.getHeaderGroupProps(),className:"hfl-h-10 hfl-rounded-lg hfl-bg-Blue_gray-50 ",children:T(h)}))}),e.jsxRuntimeExports.jsx("tbody",{...n(),className:"hfl-rounded-",children:N()})]})})},Ga=a=>{const{visits:d=[],setPdfUrl:c,pdfUrl:n}=a,[y,w]=_.useState([]);return _.useEffect(()=>{w(Fa(d))},[]),e.jsxRuntimeExports.jsx("div",{children:y&&y.length&&y.map((l,T)=>l.reports.length>0&&l.reports.map((N,h)=>{const V=l.date||"No date available";N.label=`${new Date(V).toLocaleDateString()}${l.reports.length>1?` - ${h+1}`:""}`;const{lab_number:g,label:k,message:O=""}=N;return e.jsxRuntimeExports.jsx("div",{className:"hfl-relative hfl-mb-2 hfl-flex hfl-items-center hfl-justify-center",title:`${k} ${O?`(${O})`:""}
|
|
18
18
|
${g}`,children:e.jsxRuntimeExports.jsx(p.Ku,{hierarchy:"Secondary",size:"lg",textField:`${k} ${O?`(${O})`:""}
|
|
19
19
|
${g}`,textFieldClassName:"hfl-w-full hfl-line-clamp-2",onClick:()=>c(N),className:`
|
|
20
20
|
hfl-w-full
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { P as r } from "./PediatricsCalculatorTable-DxMhP_4g.js";
|
|
2
|
-
import { P as e } from "./PatientPopupContainer-
|
|
2
|
+
import { P as e } from "./PatientPopupContainer-BVIoIg2M.js";
|
|
3
3
|
import { A as i } from "./Attachments-DA_XzmWs.js";
|
|
4
4
|
import { P } from "./PatientAddEdit-B_5MAHTe.js";
|
|
5
5
|
import { S as m } from "./SearchPatients-JEwoj-ri.js";
|