1import{r,b as G,g as H,h as M,j as e,aE as K,aw as W,l as N,M as v,N as y,m as b,t as L,I as w,c as S,B as C,$ as z,ay as Y,a5 as Q,ar as J,L as X}from"./index-Ojn8dnb4.js";import{S as Z}from"./skeleton-BD64H99-.js";import{S as _,a as ee,b as te,c as se,d as A}from"./select-ClkkhIG3.js";import{C as re}from"./checkbox-B9anf0Td.js";import{I as ae}from"./info-CPft80qG.js";import{D as ie}from"./download-CUUKpo-F.js";import"./chevron-up-Dm1YbDE-.js";const le=["AL","AK","AZ","AR","CA","CO","CT","DE","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY","DC"],o=n=>(n??0).toLocaleString("en-US"),ne=n=>(n??0).toLocaleString("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0});function pe(){const n=(()=>{try{return new URLSearchParams(window.location.search).get("q")?.trim()||""}catch{return""}})(),[p,E]=r.useState(n),[m,I]=r.useState(n),[g,D]=r.useState(new Set),[P,B]=r.useState(20),[c,U]=r.useState("all"),[x,R]=r.useState("");r.useEffect(()=>{const t=setTimeout(()=>I(p.trim()),350);return()=>clearTimeout(t)},[p]);const{data:l,isFetching:j}=G({queryKey:["/api/hcp/drug-codes/search",m],enabled:m.length>=2,queryFn:async()=>(await M("GET",`/api/hcp/drug-codes/search?q=${encodeURIComponent(m)}`)).json()});r.useEffect(()=>{l?.drugs&&D(new Set(l.drugs.slice(0,12).map(t=>t.key)))},[l]);const u=r.useMemo(()=>{const t=new Map(l?.drugs.map(a=>[a.key,a.generic])??[]);return Array.from(new Set(Array.from(g).map(a=>t.get(a)).filter(Boolean)))},[g,l]),h=H({mutationFn:async()=>(await M("POST","/api/hcp/drug-cohort",{generics:u,minClaims:P,state:c==="all"?void 0:c,providerType:x.trim()||void 0})).json()}),s=h.data,F=r.useCallback(t=>{D(a=>{const d=new Set(a);return d.has(t)?d.delete(t):d.add(t),d})},[]),V=u.length>0&&!h.isPending,$=r.useCallback(()=>{if(!s?.providers?.length)return;const t=s.providers.filter(i=>!i.locked),a=["NPI","Name","Provider Type","City","State","Total Claims","Beneficiaries","Total Drug Cost","Drugs"],d=t.map(i=>[i.npi,i.name,i.providerType||"",i.city||"",i.state||"",i.totalClaims,i.totalBeneficiaries??"",i.totalCost,i.drugsBilled].map(q=>`"${String(q).replace(/"/g,'""')}"`).join(",")),O=new Blob([[a.join(","),...d].join(` 2`)],{type:"text/csv"}),k=URL.createObjectURL(O),f=document.createElement("a");f.href=k,f.download=`drug-cohort-${Date.now()}.csv`,f.click(),URL.revokeObjectURL(k)},[s]),T=r.useMemo(()=>s?.resolvedDrugs?.length?s.resolvedDrugs:null,[s]);return e.jsxs("div",{className:"max-w-6xl mx-auto px-4 py-6 space-y-6",children:[e.jsxs(K,{children:[e.jsx("title",{children:"Drug & Prescriber Volume Search | Nopp"}),e.jsx("meta",{name:"description",content:"Find healthcare providers by the drugs they prescribe to Medicare Part D patients. Search by brand, generic, or drug class with a minimum prescription-volume threshold."})]}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2","data-testid":"heading-drug-search",children:[e.jsx(W,{className:"h-6 w-6 text-violet-500"}),"Drug & Prescriber Volume Search"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Find providers by what they actually prescribe to Medicare Part D â by brand, generic, or class. Searching a brand like âEliquisâ finds every prescriber of its molecule."})]}),e.jsxs(N,{children:[e.jsx(v,{children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 rounded-full bg-violet-500 text-white text-xs",children:"1"}),"Pick the drug(s)"]})}),e.jsxs(b,{className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(L,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(w,{value:p,onChange:t=>E(t.target.value),placeholder:'e.g. "Eliquis", "apixaban", "blood thinner", "GLP-1", or "Ozempic"',className:"pl-9","data-testid":"input-drug-term"})]}),m.length>=2&&e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[e.jsx(ae,{className:"h-3.5 w-3.5"}),"Typo-tolerant. Tick the drugs that match what you mean â the cohort is built at the generic (molecule) level."]}),j&&e.jsx("div",{className:"space-y-2",children:[0,1,2].map(t=>e.jsx(Z,{className:"h-12 w-full"},t))}),!j&&l?.drugs?.length===0&&m.length>=2&&e.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center","data-testid":"text-no-drugs",children:"No matching drugs. Try a brand, generic name, or a class like âstatinâ or âblood thinnerâ."}),!j&&(l?.drugs?.length??0)>0&&e.jsx("div",{className:"border rounded-lg divide-y max-h-80 overflow-auto","data-testid":"list-drugs",children:l.drugs.map(t=>e.jsxs("label",{className:"flex items-start gap-3 p-3 hover:bg-muted/40 cursor-pointer","data-testid":`drug-row-${t.key}`,children:[e.jsx(re,{checked:g.has(t.key),onCheckedChange:()=>F(t.key),"data-testid":`checkbox-drug-${t.key}`}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-semibold",children:t.brand}),!t.isGeneric&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",t.generic,")"]}),t.isGeneric&&e.jsx(S,{variant:"secondary",className:"text-[10px]",children:"Generic"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[o(t.providerCount)," prescribers · ",o(t.totalClaims)," claims"]})]})})]},t.key))})]})]}),e.jsxs(N,{children:[e.jsx(v,{children:e.jsxs(y,{className:"text-base flex items-center gap-2",children:[e.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 rounded-full bg-violet-500 text-white text-xs",children:"2"}),"Set the threshold & filters"]})}),e.jsxs(b,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Minimum claims (Part D)"}),e.jsx(w,{type:"number",min:1,value:P,onChange:t=>B(Math.max(1,parseInt(t.target.value,10)||1)),"data-testid":"input-min-claims"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"State (optional)"}),e.jsxs(_,{value:c,onValueChange:U,children:[e.jsx(ee,{"data-testid":"select-state",children:e.jsx(te,{placeholder:"All states"})}),e.jsxs(se,{children:[e.jsx(A,{value:"all",children:"All states"}),le.map(t=>e.jsx(A,{value:t,children:t},t))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Provider type (optional)"}),e.jsx(w,{value:x,onChange:t=>R(t.target.value),placeholder:'e.g. "Cardiology"',"data-testid":"input-provider-type"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(C,{onClick:()=>h.mutate(),disabled:!V,"data-testid":"button-find-prescribers",children:[h.isPending?e.jsx(z,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(L,{className:"h-4 w-4 mr-2"}),"Find prescribers"]}
2),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[u.length," molecule",u.length===1?"":"s"," selected"]})]})]})]}),h.isError&&e.jsx("div",{className:"text-sm text-destructive","data-testid":"text-cohort-error",children:"Something went wrong running the search. Please try again."}),s&&e.jsxs(N,{children:[e.jsxs(v,{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2",children:[e.jsx(y,{className:"text-base",children:"Results"}),!s.paywall&&s.providers.length>0&&e.jsxs(C,{variant:"outline",size:"sm",onClick:$,"data-testid":"button-export-csv",children:[e.jsx(ie,{className:"h-4 w-4 mr-2"})," Export CSV"]})]}),e.jsxs(b,{className:"space-y-4",children:[T&&e.jsxs("div",{className:"rounded-lg border bg-muted/30 p-3 text-xs space-y-1","data-testid":"box-resolved-drugs",children:[e.jsxs("div",{className:"font-medium text-foreground/80",children:["Providers with ⥠",o(s.minClaims)," total Part D claims across:"]}),(c!=="all"||x.trim())&&e.jsxs("div",{className:"flex flex-wrap gap-1.5 pt-0.5","data-testid":"box-active-filters",children:[c!=="all"&&e.jsxs(S,{variant:"outline",className:"text-[10px]",children:["State: ",c]}),x.trim()&&e.jsxs(S,{variant:"outline",className:"text-[10px]",children:["Type: ",x.trim()]})]}),e.jsx("ul",{className:"space-y-0.5",children:T.map(t=>e.jsxs("li",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-semibold text-foreground/80",children:t.generic}),t.brands.length>0&&e.jsxs("span",{children:[" â ",t.brands.join(", ")]})]},t.generic))})]}),!s.hasData&&e.jsx("div",{className:"text-sm text-muted-foreground py-6 text-center","data-testid":"text-no-prescribers",children:"No prescribers met that threshold. Try lowering the minimum or widening the drugs/state."}),s.hasData&&e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm min-w-[680px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-xs text-muted-foreground border-b",children:[e.jsx("th",{className:"py-2 pr-3",children:"Provider"}),e.jsx("th",{className:"py-2 pr-3",children:"Type"}),e.jsx("th",{className:"py-2 pr-3",children:"Location"}),e.jsx("th",{className:"py-2 pr-3 text-right",children:"Claims"}),e.jsx("th",{className:"py-2 pr-3 text-right",children:"Benes (sum)"}),e.jsx("th",{className:"py-2 pr-3 text-right",children:"Drug Cost"}),e.jsx("th",{className:"py-2 pr-3 text-right",children:"Drugs"})]})}),e.jsx("tbody",{children:s.providers.map((t,a)=>e.jsxs("tr",{className:"border-b last:border-0","data-testid":`row-prescriber-${t.npi||a}`,children:[e.jsx("td",{className:"py-2 pr-3",children:t.locked?e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground blur-[3px] select-none",children:[e.jsx(Y,{className:"h-3.5 w-3.5"})," Provider name hidden"]}):e.jsxs(Q,{href:`/npi/${t.npi}`,className:"text-violet-500 hover:underline inline-flex items-center gap-1","data-testid":`link-prescriber-${t.npi}`,children:[t.name||t.npi,e.jsx(J,{className:"h-3 w-3"})]})}),e.jsx("td",{className:"py-2 pr-3 text-muted-foreground",children:t.providerType||"â"}),e.jsx("td",{className:"py-2 pr-3 text-muted-foreground",children:[t.city,t.state].filter(Boolean).join(", ")||"â"}),e.jsx("td",{className:"py-2 pr-3 text-right font-semibold",children:o(t.totalClaims)}),e.jsx("td",{className:"py-2 pr-3 text-right",children:t.totalBeneficiaries!=null?o(t.totalBeneficiaries):"â"}),e.jsx("td",{className:"py-2 pr-3 text-right",children:ne(t.totalCost)}),e.jsx("td",{className:"py-2 pr-3 text-right",children:o(t.drugsBilled)})]},t.npi||`locked-${a}`))})]})}),s.paywall&&s.hasData&&e.jsxs("div",{className:"rounded-lg border border-violet-500/30 bg-violet-500/5 p-4 flex items-center justify-between gap-4","data-testid":"box-paywall",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(X,{className:"h-4 w-4 text-violet-500"}),"Provider names are hidden on the free plan. Upgrade to HCP Pro to see the full cohort, export to CSV, and open each profile."]}),e.jsx(C,{asChild:!0,size:"sm","data-testid":"button-upgrade-pro",children:e.jsx("a",{href:"/hc
2p-pro",children:"Upgrade"})})]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground pt-2 border-t",children:["Source: CMS Medicare Part D (Prescribers, by Provider & Drug). Counts reflect",e.jsx("strong",{children:" Medicare Part D only"})," and exclude commercial, cash, and Medicaid prescriptions. CMS suppresses claim counts under 11 per provider-drug. Cohorts are summed at the generic (molecule) level. âBenes (sum)â adds each drugâs beneficiary count and may exceed unique patients when a provider prescribes several selected molecules."]})]})]})]})}export{pe 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.