import{u as _,a as f,e as j,r as n,j as e,B as y,A as b,C as N,b as C,c as P,d as D}from"./index-Cc987VYg.js";import{P as v}from"./page-header-CrLb0v5J.js";import{u as S}from"./use-payer-aging-yxwg8Le_.js";import{I as K}from"./input-DPNG9e3H.js";import{L as A,a as z}from"./label-npsA0UlW.js";import{D as k}from"./data-table-DE8WuOG4.js";import{f as r,a as g}from"./format-xRPgypNS.js";import"./command-G4m7hi6O.js";import"./separator-D14BnWPe.js";const B=[{accessorKey:"claim_number",header:"Claim Number"},{accessorKey:"payer_claim_number",header:"Payer Claim #",cell:({row:a})=>a.original.payer_claim_number||"-"},{accessorKey:"claim_date",header:"Claim Date",cell:({row:a})=>g(a.original.claim_date)},{accessorKey:"submitted_date",header:"Submitted Date",cell:({row:a})=>a.original.submitted_date?g(a.original.submitted_date):"-"},{accessorKey:"patient_name",header:"Patient Name"},{accessorKey:"days_outstanding",header:"Days Outstanding",cell:({row:a})=>{const s=a.original.days_outstanding;return e.jsx("span",{className:s>90?"text-red-600 font-semibold":"",children:s})}},{accessorKey:"aging_bucket",header:"Aging Bucket",cell:({row:a})=>{const s=a.original.aging_bucket,l={current:"text-green-600","31-60":"text-yellow-600","61-90":"text-orange-600","91-120":"text-red-600","121+":"text-red-700 font-bold"};return e.jsx("span",{className:l[s]||"",children:s})}},{accessorKey:"total_charge_amount",header:"Total Charges",cell:({row:a})=>r(a.original.total_charge_amount||a.original.original_amount)},{accessorKey:"paid_amount",header:"Paid Amount",cell:({row:a})=>r(a.original.paid_amount)},{accessorKey:"adjustment_amount",header:"Adjustments",cell:({row:a})=>r(a.original.adjustment_amount||0)},{accessorKey:"balance_due",header:"Balance Due",cell:({row:a})=>e.jsx("span",{className:"font-semibold",children:r(a.original.balance_due)})}];function $(){const{payerId:a}=_(),s=f(),{preferences:l,getDefaultPageSize:c}=j(),[d,x]=n.useState(new Date().toISOString().split("T")[0]),[p,m]=n.useState(1),[o,u]=n.useState(c());n.useEffect(()=>{u(c()),m(1)},[l?.items_per_page,c]);const{data:t,isLoading:h}=S(a,{as_of_date:d,page:p,page_size:o});return h?e.jsx("div",{className:"flex items-center justify-center h-96",children:e.jsx(A,{className:"h-8 w-8 animate-spin"})}):t?e.jsxs("div",{className:"space-y-6",children:[e.jsx(v,{title:`Payer Aging Detail: ${t.payer_name}`,description:`Payer Code: ${t.payer_code}`}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>s(-1),children:[e.jsx(b,{className:"h-4 w-4 mr-2"}),"Back to Report"]}),e.jsxs("div",{className:"w-64",children:[e.jsx(z,{children:"As of Date"}),e.jsx(K,{type:"date",value:d,onChange:i=>x(i.target.value)})]})]}),e.jsxs(N,{children:[e.jsx(C,{children:e.jsx(P,{children:"Summary"})}),e.jsx(D,{children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Payer Name"}),e.jsx("p",{className:"text-lg font-semibold",children:t.payer_name})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Outstanding"}),e.jsx("p",{className:"text-lg font-semibold",children:r(t.total_outstanding)})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h2",{className:"text-xl font-semibold",children:["Claim Details (",t.claims.length," claims)"]}),e.jsx(k,{columns:B,data:t.claims,searchableColumns:[{id:"claim_number",title:"Claim Number"},{id:"patient_name",title:"Patient Name"}],pageCount:Math.ceil((t.count||t.claims.length)/o),defaultPageSize:o,onPaginationChange:i=>{m(i.pageIndex+1),u(i.pageSize)}})]})]}):e.jsx("div",{children:"No data available"})}export{$ as PayerAgingDetailPage};
