import{l as r,m as o,n as g,p as c,t as s,q as p}from"./index-C9vqJYWU.js";const i={getPatientAgingReport:async t=>{const{data:e}=await r.get(o.PATIENT_AGING,{params:t});return e.data},getPatientAgingDetail:async(t,e)=>{const{data:a}=await r.get(`${o.PATIENT_AGING}${t}/`,{params:e});return a.data},exportPatientAgingReport:async(t,e)=>{const{data:a}=await r.get(`${o.PATIENT_AGING}export/`,{params:{...e,format:t},responseType:"blob"});return a}},A=t=>g({queryKey:["patientAging",JSON.stringify(t)],queryFn:()=>i.getPatientAgingReport(t),staleTime:60*1e3}),d=(t,e)=>g({queryKey:["patientAging","patient",t,JSON.stringify(e)],queryFn:()=>i.getPatientAgingDetail(t,e),enabled:!!t,staleTime:60*1e3}),y=()=>c({mutationFn:({format:t,filters:e})=>i.exportPatientAgingReport(t,e),onSuccess:(t,e)=>{const a=window.URL.createObjectURL(t),n=document.createElement("a");n.href=a,n.download=`patient-aging-report.${e.format}`,document.body.appendChild(n),n.click(),document.body.removeChild(n),window.URL.revokeObjectURL(a),s.success("Report exported successfully")},onError:t=>{s.error(p(t))}});export{A as a,y as b,d as u};
