1import{a7 as E,b as h,r as I,j as e,L as A,x as b,ao as B,z as H,N as z,h as L,M as Q,l as K}from"./index-Df108JlE.js";import{P as Y}from"./printer-D36GaD_b.js";const C=a=>a!=null?`$${Math.round(a/1e3).toLocaleString()}K`:"â",U=a=>a!=null?`$${(a/1e6).toFixed(1)}M`:"â",j=a=>a!=null?Number(a).toLocaleString():"â",D=a=>a==null?"â":a>=365?`${(a/365).toFixed(1)}y`:a>=30?`${Math.round(a/30)}mo`:`${Math.round(a)}d`,q=[{code:"S_041_01_OBS_RATE",label:"Self-Care at Expected",dir:"higher"},{code:"S_042_02_OBS_RATE",label:"Mobility at Expected",dir:"higher"},{code:"S_024_06_OBS_RATE",label:"Self-Care Improvement",dir:"higher"},{code:"S_025_06_OBS_RATE",label:"Mobility Improvement",dir:"higher"},{code:"S_005_02_DTC_RS_RATE",label:"Discharge to Community",dir:"higher"},{code:"S_004_01_PPR_PD_RSRR",label:"Readmission Rate",dir:"lower"},{code:"S_038_02_OBS_RATE",label:"Falls w/ Major Injury",dir:"lower"},{code:"S_039_01_HAI_RS_RATE",label:"Healthcare Infections",dir:"lower"}];function S({value:a,label:c}){const m=parseInt(a)||0;return e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[[1,2,3,4,5].map(x=>e.jsx("div",{style:{width:8,height:8,borderRadius:1,backgroundColor:x<=m?"#0284c7":"#e2e8f0",border:"1px solid #94a3b8"}},x)),e.jsx("span",{className:"text-[10px] font-bold text-slate-800 ml-1",children:m||"â"})]}),e.jsx("p",{className:"text-[7px] text-slate-500 uppercase",children:c})]})}function l({label:a,value:c,sub:m,good:x}){return e.jsxs("div",{className:"py-1 border-b border-slate-100 last:border-0 flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-slate-500",children:a}),e.jsxs("div",{className:"text-right",children:[e.jsx("span",{className:`text-[11px] font-semibold ${x===!0?"text-emerald-600":x===!1?"text-red-500":"text-slate-800"}`,children:c}),m&&e.jsx("span",{className:"text-[9px] text-slate-400 ml-1.5",children:m})]})]})}function p({title:a,children:c}){return e.jsxs("div",{children:[e.jsx("h2",{className:"text-[9px] font-bold text-slate-800 uppercase tracking-wider border-b border-slate-400 pb-0.5 mb-1.5",children:a}),c]})}function J(){const{ccn:a}=E(),{data:c,isLoading:m}=h({queryKey:["facility",a],queryFn:()=>B(a)}),{data:x}=h({queryKey:["report-fin",a],queryFn:()=>H(a),enabled:!!c}),{data:g}=h({queryKey:["report-qrp",a,c?.state],queryFn:()=>z({state:c?.state}),enabled:!!c?.state}),{data:M}=h({queryKey:["report-staff",a],queryFn:()=>L(a),enabled:!!c}),{data:f}=h({queryKey:["report-comp",a],queryFn:()=>Q(a,{radius_miles:15}),enabled:!!c}),{data:w}=h({queryKey:["report-tenure",a],queryFn:()=>K(a),enabled:!!c});if(I.useEffect(()=>{if(!c)return;const s=document.title;return document.title=`${c.provider_name} â Facility Report`,()=>{document.title=s}},[c]),m)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx(A,{size:24,className:"animate-spin text-slate-400"})});if(!c)return e.jsx("div",{className:"min-h-screen flex items-center justify-center text-slate-500",children:"Facility not found."});const t=c,n=x?.latest,$=g?.facilities?.find(s=>s.ccn===a),_=M,v=s=>{const d=(x?.benchmarks||[]).find(i=>i.metric===s);return d?{rank:d.state_rank,total:d.n_facilities}:null},R={};g?.facilities&&$&&q.forEach(s=>{const r=g.facilities.filter(i=>i.measures?.[s.code]!=null).map(i=>({ccn:i.ccn,val:i.measures[s.code]}));r.sort((i,u)=>s.dir==="higher"?u.val-i.val:i.val-u.val);const d=r.findIndex(i=>i.ccn===a);d>=0&&(R[s.code]={rank:d+1,total:r.length})});const N=s=>s?`#${s.rank}/${s.total}`:"",F=_?.agency_pct!=null?_.agency_pct:null,P=_?.roles||[];return e.jsxs("div",{className:"max-w-[850px] mx-auto px-3 py-3 bg-white min-h-screen text-[10px]",style:{border:"1px solid #cbd5e1"},children:[e.jsxs("div",{className:"no-print flex items-center justify-between mb-2",children:[e.jsx("a",{href:`/facility/${a}`,className:"text-xs text-sky-600 hover:underline",children:"â Back to facility"}),e.jsxs("button",{onClick:()=>window.print(),className:"flex items-center gap-2 bg-sky-600 hover:bg-sky-700 text-white px-4 py-2 rounded-lg text-xs font-medium",children:[e.jsx(Y,{size:13})," Print / Save as PDF"]})]}),e.jsxs("div",{className:"flex items-center justify-between border-b border-slate-900 pb-1 mb-2",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-sm font-bold text-slate-900 leading-tight",children:t.provider_name}),e.jsxs("p",{className:"text-[9px] text-slate-600",children:[t.provider_address," · ",t.citytown,", ",t.state," ",t.zip_code," · CCN: ",a," ",t.chain_name?`· ${t.chain_name}`:""]})]}),e.jsxs("div",{className:"text-right flex-shrink-0",children:[e.jsx("p",{className:"text-[8px] text-slate-500 font-medium",children:new Date().toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx("p",{className:"text-[7px] text-sky-600",children:"snf-insights.com"})]})]}),e.jsxs("div",{className:"flex items-center justify-between mb-3 px-3 py-1.5 rounded",style:{backgroundColor:"#f8fafc",border:"1px solid #e2e8f0"},children:[e.jsx(S,{value:t.overall_rating,label:"Overall"}),e.jsx(S,{value:t.health_inspection_rating,label:"Health"}),e.jsx(S,{value:t.staffing_rating,label:"Staffing"}),e.jsx(S,{value:t.qm_rating,label:"Quality"}),e.jsxs("div",{className:"text-center border-l border-slate-200 pl-4",children:[e.jsx("p",{className:"text-sm font-bold text-slate-800",children:j(t.number_of_certified_beds)}),e.jsx("p",{className:"text-[8px] text-slate-500 uppercase",children:"Beds"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm font-bold text-slate-800",children:j(t.average_number_of_residents_per_day)}),e.jsx("p",{className:"text-[8px] text-slate-500 uppercase",children:"ADC"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm font-bold text-slate-800",children:b((()=>{const s=parseFloat(t.number_of_certified_beds),r=parseFloat(t.average_number_of_residents_per_day);return s>0&&r?r/s*100:null})())}),e.jsx("p",{className:"text-[8px] text-slate-500 uppercase",children:"Occupancy"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-3",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs(p,{title:"Staffing",children:[e.jsx(l,{label:"Total Nursing HPRD",value:t.reported_total_nurse_hprd||"â"}),e.jsx(l,{label:"RN HPRD",value:t.reported_rn_hprd||"â"}),e.jsx(l,{label:"Nursing Turnover",value:t.total_nursing_staff_turnover?`${t.total_nursing_staff_turnover}%`:"â",good:t.total_nursing_staff_turnover?Number(t.total_nursing_staff_turnover)<50:void 0}),e.jsx(l,{label:"Admin Turnover",value:t.administrator_turnover||"â"}),F!=null&&e.jsx(l,{label:"Agency %",value:`${F.toFixed(1)}%`,good:F<15}),_?.admin_tenure_days!=null&&e.jsx(l,{label:"Admin Tenure",value:D(_.admin_tenure_days),good:_.admin_tenure_days>365}),_?.don_tenure_days!=null&&e.jsx(l,{label:"DON Tenure",value:D(_.don_tenure_days),good:_.don_tenure_days>365})]}),P.length>0&&e.jsx(p,{title:"Workforce by Role",children:P.map(s=>e.jsxs("div",{className:"flex items-center justify-between py-0.5",children:[e.jsx("span",{className:"text-[10px] text-slate-500",children:s.role}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-16 rounded-full h-1.5",style:{backgroundColor:"#e2e8f0"},children:e.jsx("div",{className:"h-1.5 rounded-full",style:{width:`${Math.min(100,s.employee_pct||0)}%`,backgroundColor:"#0284c7"}})}),e.jsx("span",{className:"text-[9px] text-slate-600 w-8 text-right",children:s.count||"â"})]})]},s.role))})]}),e.jsx("div",{className:"space-y-3",children:e.jsx(p,{title:`Financial${n?.fy_year?` (FY${n.fy_year})`:""}`,children:n?e.jsxs(e.Fragment,{children:[e.jsx(l,{label:"Net Revenue",value:U(n.net_revenue_after_medicare),sub:N(v("net_revenue_ppd"))}),e.jsx(l,{label:"Op Income",value:C(n.net_income),good:n.net_income>0}),e.jsx(l,{label:"Op Margin",value:b(n.operating_margin_pct),sub:N(v("operating_margin_pct")),good:n.operating_margin_pct>0}),e.jsx(l,{label:"EBITDAR",value:C(n.ebitdar),good:n.ebitdar>0}),e.jsx(l,{label:"EBITDAR Margin",value:b(n.ebitdar_margin_pct)}),e.jsx(l,{label:"Rev PPD",value:n.net_revenue_ppd?`$${n.net_revenue_ppd.toFixed(0)}`:"â",sub:N(v("net_revenue_ppd"))}),e.jsx(l,{label:"Exp PPD",value:n.cost_per_day?`$${n.cost_per_day.toFixed(0)}`:"â",sub:N(v("cost_per_day"))}),!n.balance_sheet_suppressed&&n.dso_days&&e.jsx(l,{label:"DSO",value:n.dso_days>=150?">150 days":`${n.dso_days.toFixed(0)} days`})]}):e.jsx("p",{className:"text-[9px] text-slate-400 italic",children:"No cost report data"})})}),e.jsx("div",{className:"space-y-3",children:e.jsx(p,{title:"Quality Outcomes (SNF QRP)",children:$?q.map(s=>{const r=$.measures?.[s.code],d=g?.measures?.find(k=>k.code===s.code)?.national_median,i=R[s.code],u=r!=null&&d!=null&&(s.dir==="higher"?r>
1=d:r<=d);return e.jsx(l,{label:s.label,value:r!=null?`${r.toFixed(1)}%`:"â",sub:i?`#${i.rank}/${i.total} in ${t.state}`:"",good:r!=null?u:void 0},s.code)}):e.jsx("p",{className:"text-[9px] text-slate-400 italic",children:"No QRP data"})})})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",marginBottom:"8px"},children:[e.jsx("div",{style:{flex:1},children:e.jsxs(p,{title:"Regulatory & Compliance",children:[e.jsx(l,{label:"Total Fines",value:t.total_amount_of_fines_in_dollars?`$${Number(t.total_amount_of_fines_in_dollars).toLocaleString()}`:"$0"}),e.jsx(l,{label:"Last Survey",value:t.rating_cycle_1_standard_survey_health_date||"â"}),e.jsx(l,{label:"Special Focus",value:t.special_focus_status||"None"}),e.jsx(l,{label:"Case Mix Index",value:t.nursing_casemix_index_ratio||"â"})]})}),n&&(n.medicare_day_pct||n.medicaid_day_pct)&&e.jsx("div",{style:{flex:1},children:e.jsxs(p,{title:"Payer Mix (Patient Days)",children:[e.jsx("div",{className:"space-y-1",children:[{label:"Medicare",pct:n.medicare_day_pct,color:"#0284c7"},{label:"Medicaid",pct:n.medicaid_day_pct,color:"#64748b"},{label:"Other",pct:n.other_day_pct,color:"#cbd5e1"}].map(s=>s.pct>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[8px] text-slate-500 w-12",children:s.label}),e.jsx("div",{className:"flex-1 rounded-full h-1.5",style:{backgroundColor:"#e2e8f0"},children:e.jsx("div",{className:"h-1.5 rounded-full",style:{width:`${s.pct}%`,backgroundColor:s.color}})}),e.jsxs("span",{className:"text-[8px] font-medium text-slate-600 w-8 text-right",children:[s.pct.toFixed(0),"%"]})]},s.label))}),n.medicare_alos&&e.jsx(l,{label:"Medicare ALOS",value:`${n.medicare_alos} days`}),n.total_days&&e.jsx(l,{label:"Total Patient Days",value:j(n.total_days)})]})}),e.jsx("div",{style:{flex:1},children:e.jsxs(p,{title:"Claims-Based Quality",children:[e.jsx(l,{label:"SS Rehospitalization",value:t.qm_short_stay_rehospitalization!=null?`${t.qm_short_stay_rehospitalization}%`:"â",good:t.qm_short_stay_rehospitalization!=null?t.qm_short_stay_rehospitalization<22:void 0}),e.jsx(l,{label:"SS ED Visits",value:t.qm_short_stay_ed_visits!=null?`${t.qm_short_stay_ed_visits}%`:"â",good:t.qm_short_stay_ed_visits!=null?t.qm_short_stay_ed_visits<12:void 0}),e.jsx(l,{label:"LS Hospitalizations",value:t.qm_long_stay_hospitalizations!=null?`${t.qm_long_stay_hospitalizations}%`:"â"}),e.jsx(l,{label:"LS ED Visits",value:t.qm_long_stay_ed_visits!=null?`${t.qm_long_stay_ed_visits}%`:"â"})]})})]}),f?.competitors?.length>0&&e.jsxs("div",{className:"mb-2",children:[e.jsxs("h2",{className:"text-[9px] font-bold text-slate-800 uppercase tracking-wider border-b border-slate-400 pb-0.5 mb-1.5",children:["Nearby Competitors (within 15 miles) â ",f.competitors.length," facilities"]}),e.jsxs("table",{className:"w-full text-[9px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-200",children:[e.jsx("th",{scope:"col",className:"text-left py-0.5 font-semibold text-slate-500",children:"Facility"}),e.jsx("th",{scope:"col",className:"text-left py-0.5 font-semibold text-slate-500",children:"City"}),e.jsx("th",{scope:"col",className:"text-center py-0.5 font-semibold text-slate-500",children:"Stars"}),e.jsx("th",{scope:"col",className:"text-right py-0.5 font-semibold text-slate-500",children:"Beds"}),e.jsx("th",{scope:"col",className:"text-right py-0.5 font-semibold text-slate-500",children:"Occ%"}),e.jsx("th",{scope:"col",className:"text-right py-0.5 font-semibold text-slate-500",children:"HPRD"}),e.jsx("th",{scope:"col",className:"text-right py-0.5 font-semibold text-slate-500",children:"Miles"})]})}),e.jsx("tbody",{children:f.competitors.slice(0,10).map((s,r)=>e.jsxs("tr",{className:"border-b border-slate-50",children:[e.jsx("td",{className:"py-0.5 text-slate-700 truncate max-w-[180px]",children:s.provider_name}),e.jsx("td",{className:"py-0.5 text-slate-500",children:s.citytown}),e.jsx("td",{className:"py-0.5 text-center font-semibold",children:s.overall_rating||"â"}),e.jsx("td",{className:"py-0.5 text-right",children:s.number_of_certified_beds||"â"}),e.jsx("td",{className:"py-0.5 text-right",children:s.occupancy_pct?`${s.occupancy_pct.toFixed(0)}%`:"â"}),e.jsx("td",{className:"py-0.5 text-right",children:s.total_nurse_hprd?s.total_nurse_hprd.toFixed(2):"â"}),e.jsx("td",{className:"py-0.5 text-right text-slate-400",children:s.distance_miles?.toFixed(1)})]},r))})]})]}),f?.competitors?.length>0&&(()=>{const s=f.competitors,r=s.filter(o=>o.overall_rating).reduce((o,y)=>o+parseInt(y.overall_rating),0)/s.filter(o=>o.overall_rating).length,d=s.filter(o=>o.occupancy_pct).reduce((o,y)=>o+y.occupancy_pct,0)/s.filter(o=>o.occupancy_pct).length,i=s.filter(o=>o.total_nurse_hprd).reduce((o,y)=>o+y.total_nurse_hprd,0)/s.filter(o=>o.total_nurse_hprd).length,u=parseInt(t.overall_rating)||0,k=parseFloat(t.number_of_certified_beds)||0,T=parseFloat(t.average_number_of_residents_per_day)||0,O=k>0?T/k*100:0;return e.jsxs("div",{className:"mb-3 py-2 px-3 rounded",style:{backgroundColor:"#f8fafc",border:"1px solid #e2e8f0"},children:[e.jsx("h2",{className:"text-[9px] font-bold text-slate-700 uppercase tracking-wider mb-1",children:"Market Position Summary"}),e.jsxs("p",{className:"text-[10px] text-slate-600 leading-relaxed",children:["This facility is rated ",e.jsxs("strong",{children:[u," stars"]})," vs. a market average of ",e.jsxs("strong",{children:[r.toFixed(1)," stars"]})," within 15 miles.",u>r?" It outperforms the local market on overall quality.":u<r?" It underperforms the local market on overall quality.":" It is in line with the local market."," ","Occupancy is ",e.jsx("strong",{children:b(O)})," vs. market average ",e.jsx("strong",{children:b(d)}),"."," ","Average nursing HPRD in the market is ",e.jsx("strong",{children:i.toFixed(2)}),"."," ","There are ",e.jsxs("strong",{children:[s.length," competing facilities"]})," within a 15-mile radius."]})]})})(),w?.distributions?.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("h2",{className:"text-[9px] font-bold text-slate-800 uppercase tracking-wider border-b border-slate-400 pb-0.5 mb-1.5",children:"Staff Tenure Distribution"}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:w.distributions.filter(s=>["rn","lpn","cna"].includes(s.role_group)).map(s=>{const r=s.buckets.reduce((i,u)=>i+u.count,0);if(!r)return null;const d=[{label:"< 90d",count:s.buckets[0]?.count||0},{label:"90dâ1yr",count:(s.buckets[1]?.count||0)+(s.buckets[2]?.count||0)},{label:"1â2yr",count:s.buckets[3]?.count||0},{label:"2+ yr",count:(s.buckets[4]?.count||0)+(s.buckets[5]?.count||0)}].map(i=>({...i,pct:r>0?i.count/r*100:0}));return e.jsxs("div",{children:[e.jsxs("p",{className:"text-[9px] font-semibold text-slate-600 uppercase mb-1",children:[s.role_group.toUpperCase()," (",r,")"]}),e.jsx("div",{className:"space-y-0.5",children:d.map(i=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-[8px] text-slate-500
1w-12 text-right",children:i.label}),e.jsx("div",{className:"flex-1 rounded-full h-1.5",style:{backgroundColor:"#e2e8f0"},children:e.jsx("div",{className:"h-1.5 rounded-full",style:{width:`${i.pct}%`,backgroundColor:"#0284c7"}})}),e.jsxs("span",{className:"text-[8px] text-slate-500 w-10 text-right",children:[i.pct.toFixed(0),"%"]})]},i.label))})]},s.role_group)})})]}),x?.benchmarks?.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("h2",{className:"text-[9px] font-bold text-slate-800 uppercase tracking-wider border-b border-slate-400 pb-0.5 mb-1.5",children:["State Rankings â ",t.state," (",x.benchmarks[0]?.n_facilities," facilities)"]}),e.jsx("div",{className:"grid grid-cols-3 gap-x-6 gap-y-0.5",children:x.benchmarks.filter(s=>s.state_rank&&s.n_facilities).map(s=>{const r=Math.round((1-s.state_rank/s.n_facilities)*100);return e.jsxs("div",{className:"flex items-center justify-between py-0.5",children:[e.jsx("span",{className:"text-[9px] text-slate-500 truncate",children:s.label}),e.jsxs("span",{style:{color:r>=75?"#059669":r<=25?"#ef4444":"#334155"},className:"text-[9px] font-semibold",children:["#",s.state_rank,"/",s.n_facilities]})]},s.metric)})})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",marginBottom:"8px"},children:[t.county_name&&e.jsx("div",{style:{flex:1},children:e.jsxs(p,{title:`County Demographics â ${t.county_name}, ${t.state}`,children:[t.county_total_pop!=null&&e.jsx(l,{label:"Population",value:j(t.county_total_pop),sub:t.county_rank_total_pop&&t.state_county_count?`#${t.county_rank_total_pop}/${t.state_county_count}`:""}),t.county_pop_65_plus!=null&&e.jsx(l,{label:"Population 65+",value:j(t.county_pop_65_plus),sub:t.county_rank_pct_65&&t.state_county_count?`#${t.county_rank_pct_65}/${t.state_county_count}`:t.county_pct_65_plus!=null?`${t.county_pct_65_plus.toFixed(1)}%`:""}),t.county_median_hhi!=null&&e.jsx(l,{label:"Median HH Income",value:`$${Number(t.county_median_hhi).toLocaleString()}`,sub:t.county_rank_median_hhi&&t.state_county_count?`#${t.county_rank_median_hhi}/${t.state_county_count}`:""}),t.ma_penetration!=null&&e.jsx(l,{label:"MA Penetration",value:`${t.ma_penetration.toFixed(1)}%`,sub:t.ma_rank_penetration&&t.ma_state_county_count?`#${t.ma_rank_penetration}/${t.ma_state_county_count}`:""})]})}),e.jsx("div",{style:{flex:1},children:e.jsxs(p,{title:"Facility Profile",children:[e.jsx(l,{label:"Ownership",value:t.ownership_type||"â"}),e.jsx(l,{label:"Provider Type",value:t.provider_type||"â"}),t.continuing_care_retirement_community==="Y"&&e.jsx(l,{label:"CCRC",value:"Yes"}),t.provider_resides_in_hospital==="Y"&&e.jsx(l,{label:"Hospital-Based",value:"Yes"}),t.provider_changed_ownership_in_last_12_months==="Y"&&e.jsx(l,{label:"Ownership Change (12mo)",value:"Yes",good:!1}),t.number_of_facilities_in_chain&&e.jsx(l,{label:"Chain Size",value:`${t.number_of_facilities_in_chain} facilities`})]})})]}),e.jsxs("div",{className:"border-t border-slate-300 pt-2 flex items-center justify-between text-[8px] text-slate-400",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-slate-500",children:"SNF Insights â Facility Intelligence Report"}),e.jsx("p",{children:"Data from CMS Provider Data, HCRIS Cost Reports, PBJ Staffing, SNF QRP, and Health Deficiencies. Not independently verified."})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{children:"snf-insights.com"}),e.jsx("p",{children:new Date().toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})})]})]})]})}export{J as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.