PageSourceSearch

https://app.psychreport.ai/assets/PlatformAdminExtractionQuality-izkPBPMA.js

js psychreport.ai collected 2026-10-05 14:12:55 UTC 11,582 bytes, 1 lines download raw bytes

1import{r as x,b as N,j as e,a4 as se,C as S,g as w,h as R,K as k,i as I,am as O,ac as te,ad as re,ae,af as ne,ag as Q,$ as ie,O as T,k as E,aa as le,a5 as de,a6 as ce,a7 as oe,a_ as xe,a0 as he,a1 as me}from"./index-CREIb8fj.js";import{P as ue}from"./PlatformAdminLayout-0BKUGoe8.js";import{T as D,a as $,b as h,c as t,d as F,e as r}from"./table-BGjdk8zt.js";import{R as _}from"./refresh-cw-ClL51j_X.js";import"./file-search-BoaqwTyV.js";import"./sparkles-Bk-ewvgy.js";import"./megaphone-BaHBaP_d.js";import"./chart-line-agkrZ7IK.js";import"./key-D7TQOEg-.js";const je=[{value:"score",label:"Score"},{value:"percentile",label:"Percentile"},{value:"ci",label:"Confidence Interval"},{value:"age_equivalent",label:"Age Equivalent"},{value:"grade_equivalent",label:"Grade Equivalent"},{value:"descriptor",label:"Descriptor"}],A="No correction events yet — data accumulates as practitioners save extracted scores.";function y(i){return i===null?"—":`${(i*100).toFixed(1)}%`}function pe(i){if(!i)return;const u=new Date(`${i}T00:00:00.000Z`);if(!Number.isNaN(u.getTime()))return u.toISOString()}function Re(){const[i,u]=x.useState("all"),[L,B]=x.useState(""),[d,H]=x.useState("correctionRate"),[f,P]=x.useState("desc"),[n,V]=x.useState(null),q=pe(L),v=new URLSearchParams;i!=="all"&&v.set("fieldClass",i),q&&v.set("since",q);const U=v.toString(),M=`/api/platform-admin/extraction-quality/ranking${U?`?${U}`:""}`,{data:j,isLoading:Y,isError:G,refetch:Z}=N({queryKey:[M]}),C=n?`/api/platform-admin/extraction-quality/drilldown?slug=${encodeURIComponent(n.slug)}&versionId=${encodeURIComponent(n.versionId)}`:null,{data:b,isLoading:z,isError:J}=N({queryKey:C?[C]:["extraction-quality-drilldown-disabled"],enabled:!!C}),{data:c,isLoading:W,isError:X,refetch:ee}=N({queryKey:["/api/platform-admin/extraction-quality/descriptor-candidates"]}),K=x.useMemo(()=>[...(j==null?void 0:j.assessments)??[]].sort((o,m)=>{let l=0;return d==="assessmentSlug"?l=o.assessmentSlug.localeCompare(m.assessmentSlug):d==="correctionRate"?o.correctionRate===null&&m.correctionRate===null?l=0:o.correctionRate===null?l=1:m.correctionRate===null?l=-1:l=o.correctionRate-m.correctionRate:l=o[d]-m[d],f==="asc"?l:-l}),[j,d,f]),p=s=>{d===s?P(a=>a==="asc"?"desc":"asc"):(H(s),P("desc"))},g=({column:s})=>d!==s?e.jsx(xe,{className:"h-3.5 w-3.5 inline ml-1 text-gray-400"}):f==="asc"?e.jsx(he,{className:"h-3.5 w-3.5 inline ml-1"}):e.jsx(me,{className:"h-3.5 w-3.5 inline ml-1"});return e.jsx(ue,{children:e.jsx(se,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900","data-testid":"text-page-title",children:"Extraction Quality"}),e.jsx("p",{className:"text-gray-500 mt-2",children:"Read-only review of practitioner accept/correct/clear behavior at score save, aggregated per assessment and field. This surface recommends; nothing here mutates catalog data."})]}),e.jsxs(S,{children:[e.jsxs(w,{children:[e.jsx(R,{children:"Correction Rate Ranking"}),e.jsx(k,{children:"Assessments ranked by correction rate (corrected + cleared + replaced, over accepted + corrected + cleared + replaced). Unconfirmed events are tracked separately and excluded from the rate."})]}),e.jsxs(I,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(O,{children:"Field class"}),e.jsxs(te,{value:i,onValueChange:u,children:[e.jsx(re,{"data-testid":"select-field-class-filter",children:e.jsx(ae,{})}),e.jsxs(ne,{children:[e.jsx(Q,{value:"all",children:"All field classes"}),je.map(s=>e.jsx(Q,{value:s.value,children:s.label},s.value))]})]})]}),e.jsxs("div",{children:[e.jsx(O,{children:"Since"}),e.jsx(ie,{type:"date",value:L,onChange:s=>B(s.target.value),"data-testid":"input-since-filter"})]})]}),Y?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(_,{className:"h-8 w-8 animate-spin text-gray-400"})}):G?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(T,{className:"h-8 w-8 text-red-500 mb-4"}),e.jsx("p",{className:"text-gray-900 font-medium mb-2",children:"Failed to load ranking"}),e.jsx("button",{type:"button",className:"text-sm text-blue-600 underline",onClick:()=>Z(),"data-testid":"button-retry-ranking",children:"Retry"})]}):K.length===0?e.jsx("p",{className:"text-gray-500 py-8 text-center","data-testid":"text-ranking-empty",children:A}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(D,{children:[e.jsx($,{children:e.jsxs(h,{children:[e.jsxs(t,{className:"cursor-pointer select-none",onClick:()=>p("assessmentSlug"),"data-testid":"col-sort-slug",children:["Assessment",e.jsx(g,{column:"assessmentSlug"})]}),e.jsxs(t,{className:"cursor-pointer select-none",onClick:()=>p("totalEvents"),"data-testid":"col-sort-total",children:["Total events",e.jsx(g,{column:"totalEvents"})]}),e.jsxs(t,{className:"cursor-pointer select-none",onClick:()=>p("unconfirmedCount"),"data-testid":"col-sort-unconfirmed",children:["Unconfirmed",e.jsx(g,{column:"unconfirmedCount"})]}),e.jsxs(t,{className:"cursor-pointer select-none",onClick:()=>p("correctionRate"),"data-testid":"col-sort-rate",children:["Correction rate",e.jsx(g,{column:"correctionRate"})]}),e.jsx(t,{children:"Field-class breakdown"}),e.jsx(t,{children:"Versions (click to drill down)"})]})}),e.jsx(F,{children:K.map(s=>e.jsxs(h,{"data-testid":`row-assessment-${s.assessmentSlug}`,children:[e.jsx(r,{className:"font-medium",children:s.assessmentSlug}),e.jsx(r,{children:s.totalEvents}),e.jsx(r,{children:s.unconfirmedCount}),e.jsx(r,{children:y(s.correctionRate)}),e.jsx(r,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:s.fieldClassBreakdown.map(a=>e.jsxs(E,{variant:"outline",title:`${a.total} events`,children:[a.fieldClass,": ",y(a.correctionRate)]},a.fieldClass))})}),e.jsx(r,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:s.versions.map(a=>e.jsxs("button",{type:"button",disabled:!a.versionId,onClick:()=>a.versionId&&V({slug:s.assessmentSlug,versionId:a.versionId}),className:le("text-xs px-2 py-1 rounded border",(n==null?void 0:n.slug)===s.assessmentSlug&&(n==null?void 0:n.versionId)===a.versionId?"bg-blue-600 text-white border-blue-600":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50",!a.versionId&&"opacity-50 cursor-not-allowed"),"data-testid":`button-version-${s.assessmentSlug}-${a.versionId??"unknown"}`,children:[a.versionId?a.versionId.slice(0,8):"unknown"," (",y(a.correctionRate),")"]},a.versionId??"unknown"))})})]},s.assessmentSlug))})]})})]})]}),n&&e.jsxs(S,{children:[e.jsxs(w,{children:[e.jsxs(R,{children:["Drill-down: ",n.slug," (",n.versionId.slice(0,8),")"]}),e.jsx(k,{children:"Per-field breakdown of correction categories, direction, and rater."})]}),e.jsx(I,{children:z?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(_,{className:"h-8 w-8 animate-spin text-gray-400"})}):J?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(T,{className:"h-8 w-8 text-red-500 mb-4"}),e.jsx("p",{className:"text-gray-900 font-medium",children:"Failed to load drill-down"})]}):!b||b.fields.length===0?e.jsx("p",{className:"text-gray-500 py-8 text-center","data-testid":"text-drilldown-empty",children:A}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(D,{children:[e.jsx($,{children:e.jsxs(h,{children:[e.jsx(t,{children:"Field key"}),e.jsx(t,{children:"Field class"}),e.jsx(t,{children:"Total"}),e.jsx(t,{children:"Accepted"}),e.jsx(t,{children:"Corrected"}),e.jsx(t,{children:"Cleared"}),e.jsx(t,{children:"Filled blank"}),e.jsx(t,{children:"Replaced"}),e.jsx(t,{children:"Unconfirmed"}),e.jsx(t,{children:"Direction (higher/lower)"}),e.jsx(t,{children:"By rater"})]})}),e.jsx(F,{children:b.fields.map(s=>e.jsxs(h,{"data-testid":`row-field-${s.fieldKey}`,children:[e.jsx(r,{className:"font-medium",children:s.fieldKey}),e.jsx(r,{children:s.fieldClass}),e.jsx(r,{children:s.total}),e.jsx(r,{children:s.byCategory.accepted??0}),e.jsx(r,{children:s.byCategory.corrected??0}),e.jsx(r,{children:s.byCategory.cleared??0}),e.jsx(r,{children:s.byCategory.filled_blank??0}),e.jsx(r,{children:s.byCategory.replaced??0}),e.jsx(r,{children:s.byCategory.unconfirmed??0}),e.jsxs(r,{children:[s.correctedDirection.higher," / ",s.correctedDirection.lower]}),e.jsx(r,{children:Object.entries(s.byRater).length===0?"—":Object.entries(s.byRater).map(([a,o])=>`${a}: ${o}`).join(", ")})]},s.fieldKey))})]})})})]}),e.jsxs(S,{children:[e.jsxs(w,{children:[e.jsx(R,{children:"Descriptor Hallucination Candidates"}),e.jsxs(k,{children:["Versions where descriptor corrections (cleared + replaced, over accepted + cleared + replaced) meet the detector threshold",c?` (rate ≥ ${(c.thresholds.rate*100).toFixed(0)}%, ≥ ${c.thresholds.minExtractions} distinct extractions, ≥ ${c.thresholds.minDescriptorEvents} descriptor events)`:"",". This list is a recommendation only — flipping"," ",e.jsx("code",{className:"text-xs bg-gray-100 px-1 rounded",children:"assessment_versions.no_printed_descriptors"}
1)," ","is a manual change applied via a numbered seed SQL file in"," ",e.jsx("code",{className:"text-xs bg-gray-100 px-1 rounded",children:"docs/New_SQL_For_Mike/"}),", never automatically from this page."]})]}),e.jsx(I,{children:W?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(_,{className:"h-8 w-8 animate-spin text-gray-400"})}):X?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(T,{className:"h-8 w-8 text-red-500 mb-4"}),e.jsx("p",{className:"text-gray-900 font-medium mb-2",children:"Failed to load descriptor candidates"}),e.jsx("button",{type:"button",className:"text-sm text-blue-600 underline",onClick:()=>ee(),"data-testid":"button-retry-candidates",children:"Retry"})]}):!c||c.candidates.length===0?e.jsx("p",{className:"text-gray-500 py-8 text-center","data-testid":"text-candidates-empty",children:A}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(D,{children:[e.jsx($,{children:e.jsxs(h,{children:[e.jsx(t,{children:"Assessment / version"}),e.jsx(t,{children:"Current no_printed_descriptors"}),e.jsx(t,{children:"Rate"}),e.jsx(t,{children:"Accepted"}),e.jsx(t,{children:"Cleared"}),e.jsx(t,{children:"Replaced"}),e.jsx(t,{children:e.jsxs(de,{children:[e.jsx(ce,{asChild:!0,children:e.jsx("span",{className:"underline decoration-dotted cursor-help",children:"Unconfirmed"})}),e.jsx(oe,{children:"Extracted but never confirmed — not counted in the rate."})]})}),e.jsx(t,{children:"Distinct extractions"}),e.jsx(t,{children:"Candidate"})]})}),e.jsx(F,{children:c.candidates.map(s=>e.jsxs(h,{"data-testid":`row-candidate-${s.versionId??s.assessmentSlug}`,children:[e.jsxs(r,{className:"font-medium",children:[s.displayName??s.assessmentSlug,e.jsx("div",{className:"text-xs text-gray-500",children:s.assessmentSlug})]}),e.jsxs(r,{children:[s.noPrintedDescriptors===null?"—":s.noPrintedDescriptors?"true":"false",s.alreadyFlagged&&e.jsx(E,{variant:"secondary",className:"ml-2",children:"Already flagged"})]}),e.jsx(r,{children:y(s.rate)}),e.jsx(r,{children:s.acceptedCount}),e.jsx(r,{children:s.clearedCount}),e.jsx(r,{children:s.replacedCount}),e.jsx(r,{children:s.unconfirmedCount}),e.jsx(r,{children:s.distinctExtractions}),e.jsx(r,{children:s.isCandidate?e.jsx(E,{variant:"destructive",children:"Candidate"}):e.jsx("span",{className:"text-gray-400 text-sm",children:"—"})})]},s.versionId??s.assessmentSlug))})]})})})]})]})})})}export{Re as PlatformAdminExtractionQuality};

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.