Shubhambhandari commited on
Commit
f19a9b8
·
verified ·
1 Parent(s): f0ba50a

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.jsx +13 -13
  2. frontend_index.html +83 -0
app.jsx CHANGED
@@ -1,8 +1,8 @@
1
- /* Pathify — pathologist/intern app (single-file React).
2
  Main flow is ONE guided path: upload a case -> see the whole-slide overview and
3
  verdict -> zoom into the flagged patches -> confirm the read (which also teaches
4
  the model). The batch worklists live under a secondary "Review queue" tab.
5
- Pathify never changes a sign-out and never diagnoses. */
6
  const {useState, useEffect, useCallback} = React;
7
 
8
  const POST = (u, b) => fetch(u, {method:"POST", headers:{"Content-Type":"application/json"}, body:JSON.stringify(b)}).then(r=>r.json());
@@ -146,7 +146,7 @@ function GuidedFlow() {
146
  </Step>
147
 
148
  {res && <>
149
- <Step n="2" title="Pathify's read">
150
  <div className="card" style={{borderLeft:"4px solid "+verdictColor(res.combined.read),marginTop:0}}>
151
  <div style={{fontSize:18,fontWeight:600}}>{readPill(res.combined.read)} <span style={{fontSize:13,color:"var(--muted)",fontWeight:400}}>combined verdict · {(100*res.combined.confidence).toFixed(0)}% · {res.combined.agree?"model + stain agree":"needs review"}</span></div>
152
  <div style={{fontSize:13,color:"var(--muted)",marginTop:6}}>{res.combined.note}</div>
@@ -187,8 +187,8 @@ function GuidedFlow() {
187
  <button className="btn amend" style={{marginLeft:8}} onClick={()=>confirmRead("tumor")}>This is tumour (cancer)</button>
188
  </> : <>
189
  <div style={{fontSize:14}}>You marked {readPill(decision.label)}. {decision.matched
190
- ? <span style={{color:"var(--ok,#34d399)"}}>Pathify agreed, no discrepancy.</span>
191
- : <span style={{color:"var(--warn,#f59e0b)"}}>This differs from Pathify's read, exactly the kind of case worth a second look. Your correction now trains it.</span>}</div>
192
  {decision.saving && <div style={{fontSize:12,color:"var(--muted)",marginTop:8}}>Saving and updating the model…</div>}
193
  {decision.learned && <div style={{fontSize:12,color:"var(--ok,#34d399)",marginTop:8}}>Saved and folded into the model{decision.auroc?` (val AUROC ${decision.auroc})`:""}. It will use this from the next case on.</div>}
194
  {!decision.saving && !decision.learned && stats && (stats.normal<3||stats.tumor<3) &&
@@ -343,7 +343,7 @@ function ReviewQueue() {
343
  <button className={"tab"+(q==="patches"?" active":"")} onClick={()=>setQ("patches")}>Patches</button>
344
  <button className={"tab"+(q==="slides"?" active":"")} onClick={()=>setQ("slides")}>Whole slides</button>
345
  </div>
346
- <div style={{fontSize:12,color:"var(--muted)",marginBottom:10}}>Demo review queues: a batch of already signed-out cases; Pathify lists only the ones it disagrees with.</div>
347
  {q==="patches" ? <PatchesView/> : <SlidesView/>}
348
  </>;
349
  }
@@ -368,7 +368,7 @@ function ReportCheck() {
368
  if(!res || res.error) return null;
369
  const a=res.cat;
370
  if(!patho) return <div className="card" style={{borderLeft:"4px solid #6b7280"}}><b>Read only.</b> Pick or type the pathologist's conclusion to compare.</div>;
371
- if(a==="uncertain") return <div className="card" style={{borderLeft:"4px solid var(--warn,#f59e0b)"}}><b>Pathify is not sure.</b> Add more report text or confirm with the pathologist.</div>;
372
  if(a==="nondiag"||patho==="nondiag"){
373
  const both=a==="nondiag"&&patho==="nondiag";
374
  return <div className="card" style={{borderLeft:"4px solid "+(both?"var(--ok,#34d399)":"var(--warn,#f59e0b)")}}>
@@ -377,7 +377,7 @@ function ReportCheck() {
377
  const gap=Math.abs(CATS[a].rank-CATS[patho].rank);
378
  const col=gap===0?"var(--ok,#34d399)":gap===1?"var(--warn,#f59e0b)":"var(--tumor,#f87171)";
379
  return <div className="card" style={{borderLeft:"4px solid "+col}}>
380
- <div style={{marginBottom:6}}>Pathologist {catPill(patho)} &nbsp;vs&nbsp; Pathify {catPill(a)}</div>
381
  {gap===0 ? <><b>Matches.</b> No discrepancy, safe to proceed.</>
382
  : gap===1 ? <><b>Borderline difference.</b> Worth a quick confirm with the pathologist.</>
383
  : <><b>Clear discrepancy, second look needed.</b> Take it back to the pathologist before sign-out. Do not change the read yourself.</>}</div>;
@@ -396,7 +396,7 @@ function ReportCheck() {
396
  <div style={{fontSize:12,color:"var(--muted)",margin:"10px 0 4px"}}>or type it in their words</div>
397
  <input style={FIELD} value={free} onChange={e=>{setFree(e.target.value); setConcl(null);}}
398
  placeholder='e.g. "atypical glandular cells, cannot exclude malignancy"'/>
399
- {free.trim() && <div style={{fontSize:13,color:"var(--muted)",marginTop:6}}>Pathify reads your text as {catPill(classifyReport(free).cat)}</div>}
400
  </Step>
401
  <Step n="3" title="Check">
402
  <button className="btn primary" onClick={run}>Run report check</button>
@@ -404,7 +404,7 @@ function ReportCheck() {
404
  </Step>
405
  {res && !res.error && <>
406
  <div className="card">
407
- <div style={{fontSize:15,fontWeight:600,marginBottom:6}}>Pathify's independent read: {catPill(res.cat)} <span style={{fontSize:13,color:"var(--muted)",fontWeight:400}}>· {(100*res.conf).toFixed(0)}%</span></div>
408
  <div style={{fontSize:12,color:"var(--muted)",marginBottom:6}}>Reading the words in the report (not the tissue). Terms it weighted:</div>
409
  <div>{res.terms.slice().sort((a,b)=>b.w-a.w).map((t,i)=>{const c=t.side==="mal"?CATS.malignant:t.side==="ben"?CATS.benign:t.side==="nd"?CATS.nondiag:CATS.atypical;
410
  return <span key={i} style={{background:c.bg,color:c.fg,fontSize:12,padding:"3px 9px",borderRadius:999,margin:"4px 6px 0 0",display:"inline-block"}}>{t.label} +{(+t.w).toFixed(1)}</span>;})}
@@ -455,11 +455,11 @@ function App() {
455
  const Tab = ({id, label}) => <button className={"tab"+(mode===id?" active":"")} onClick={()=>setMode(id)}>{label}</button>;
456
  return <div className="wrap">
457
  <header>
458
- <h1>Pathify · second-reader QA</h1>
459
  <div className="sub">An AI safety-net for the pathology sign-out. Quality assurance, not diagnosis.</div>
460
  </header>
461
  <div className="banner">
462
- <b>Assist, not replace.</b> Pathify gives an independent second read and flags anything worth a second look. You decide the outcome; it never changes a sign-out.
463
  </div>
464
  <div className="tabs">
465
  <Tab id="analyze" label="Analyze a case"/>
@@ -470,7 +470,7 @@ function App() {
470
  {mode==="analyze" ? <GuidedFlow/> : mode==="report" ? <ReportCheck/> : mode==="review" ? <ReviewQueue/> : <ModelInfoView/>}
471
  <div className="foot">
472
  Every decision is appended to a local audit log (<span className="mono">audit_log.jsonl</span>).
473
- Data never leaves this machine. Pathify outputs re-check recommendations only; it does not diagnose.
474
  </div>
475
  </div>;
476
  }
 
1
+ /* PathoAI — pathologist/intern app (single-file React).
2
  Main flow is ONE guided path: upload a case -> see the whole-slide overview and
3
  verdict -> zoom into the flagged patches -> confirm the read (which also teaches
4
  the model). The batch worklists live under a secondary "Review queue" tab.
5
+ PathoAI never changes a sign-out and never diagnoses. */
6
  const {useState, useEffect, useCallback} = React;
7
 
8
  const POST = (u, b) => fetch(u, {method:"POST", headers:{"Content-Type":"application/json"}, body:JSON.stringify(b)}).then(r=>r.json());
 
146
  </Step>
147
 
148
  {res && <>
149
+ <Step n="2" title="PathoAI's read">
150
  <div className="card" style={{borderLeft:"4px solid "+verdictColor(res.combined.read),marginTop:0}}>
151
  <div style={{fontSize:18,fontWeight:600}}>{readPill(res.combined.read)} <span style={{fontSize:13,color:"var(--muted)",fontWeight:400}}>combined verdict · {(100*res.combined.confidence).toFixed(0)}% · {res.combined.agree?"model + stain agree":"needs review"}</span></div>
152
  <div style={{fontSize:13,color:"var(--muted)",marginTop:6}}>{res.combined.note}</div>
 
187
  <button className="btn amend" style={{marginLeft:8}} onClick={()=>confirmRead("tumor")}>This is tumour (cancer)</button>
188
  </> : <>
189
  <div style={{fontSize:14}}>You marked {readPill(decision.label)}. {decision.matched
190
+ ? <span style={{color:"var(--ok,#34d399)"}}>PathoAI agreed, no discrepancy.</span>
191
+ : <span style={{color:"var(--warn,#f59e0b)"}}>This differs from PathoAI's read, exactly the kind of case worth a second look. Your correction now trains it.</span>}</div>
192
  {decision.saving && <div style={{fontSize:12,color:"var(--muted)",marginTop:8}}>Saving and updating the model…</div>}
193
  {decision.learned && <div style={{fontSize:12,color:"var(--ok,#34d399)",marginTop:8}}>Saved and folded into the model{decision.auroc?` (val AUROC ${decision.auroc})`:""}. It will use this from the next case on.</div>}
194
  {!decision.saving && !decision.learned && stats && (stats.normal<3||stats.tumor<3) &&
 
343
  <button className={"tab"+(q==="patches"?" active":"")} onClick={()=>setQ("patches")}>Patches</button>
344
  <button className={"tab"+(q==="slides"?" active":"")} onClick={()=>setQ("slides")}>Whole slides</button>
345
  </div>
346
+ <div style={{fontSize:12,color:"var(--muted)",marginBottom:10}}>Demo review queues: a batch of already signed-out cases; PathoAI lists only the ones it disagrees with.</div>
347
  {q==="patches" ? <PatchesView/> : <SlidesView/>}
348
  </>;
349
  }
 
368
  if(!res || res.error) return null;
369
  const a=res.cat;
370
  if(!patho) return <div className="card" style={{borderLeft:"4px solid #6b7280"}}><b>Read only.</b> Pick or type the pathologist's conclusion to compare.</div>;
371
+ if(a==="uncertain") return <div className="card" style={{borderLeft:"4px solid var(--warn,#f59e0b)"}}><b>PathoAI is not sure.</b> Add more report text or confirm with the pathologist.</div>;
372
  if(a==="nondiag"||patho==="nondiag"){
373
  const both=a==="nondiag"&&patho==="nondiag";
374
  return <div className="card" style={{borderLeft:"4px solid "+(both?"var(--ok,#34d399)":"var(--warn,#f59e0b)")}}>
 
377
  const gap=Math.abs(CATS[a].rank-CATS[patho].rank);
378
  const col=gap===0?"var(--ok,#34d399)":gap===1?"var(--warn,#f59e0b)":"var(--tumor,#f87171)";
379
  return <div className="card" style={{borderLeft:"4px solid "+col}}>
380
+ <div style={{marginBottom:6}}>Pathologist {catPill(patho)} &nbsp;vs&nbsp; PathoAI {catPill(a)}</div>
381
  {gap===0 ? <><b>Matches.</b> No discrepancy, safe to proceed.</>
382
  : gap===1 ? <><b>Borderline difference.</b> Worth a quick confirm with the pathologist.</>
383
  : <><b>Clear discrepancy, second look needed.</b> Take it back to the pathologist before sign-out. Do not change the read yourself.</>}</div>;
 
396
  <div style={{fontSize:12,color:"var(--muted)",margin:"10px 0 4px"}}>or type it in their words</div>
397
  <input style={FIELD} value={free} onChange={e=>{setFree(e.target.value); setConcl(null);}}
398
  placeholder='e.g. "atypical glandular cells, cannot exclude malignancy"'/>
399
+ {free.trim() && <div style={{fontSize:13,color:"var(--muted)",marginTop:6}}>PathoAI reads your text as {catPill(classifyReport(free).cat)}</div>}
400
  </Step>
401
  <Step n="3" title="Check">
402
  <button className="btn primary" onClick={run}>Run report check</button>
 
404
  </Step>
405
  {res && !res.error && <>
406
  <div className="card">
407
+ <div style={{fontSize:15,fontWeight:600,marginBottom:6}}>PathoAI's independent read: {catPill(res.cat)} <span style={{fontSize:13,color:"var(--muted)",fontWeight:400}}>· {(100*res.conf).toFixed(0)}%</span></div>
408
  <div style={{fontSize:12,color:"var(--muted)",marginBottom:6}}>Reading the words in the report (not the tissue). Terms it weighted:</div>
409
  <div>{res.terms.slice().sort((a,b)=>b.w-a.w).map((t,i)=>{const c=t.side==="mal"?CATS.malignant:t.side==="ben"?CATS.benign:t.side==="nd"?CATS.nondiag:CATS.atypical;
410
  return <span key={i} style={{background:c.bg,color:c.fg,fontSize:12,padding:"3px 9px",borderRadius:999,margin:"4px 6px 0 0",display:"inline-block"}}>{t.label} +{(+t.w).toFixed(1)}</span>;})}
 
455
  const Tab = ({id, label}) => <button className={"tab"+(mode===id?" active":"")} onClick={()=>setMode(id)}>{label}</button>;
456
  return <div className="wrap">
457
  <header>
458
+ <h1>PathoAI · second-reader QA</h1>
459
  <div className="sub">An AI safety-net for the pathology sign-out. Quality assurance, not diagnosis.</div>
460
  </header>
461
  <div className="banner">
462
+ <b>Assist, not replace.</b> PathoAI gives an independent second read and flags anything worth a second look. You decide the outcome; it never changes a sign-out.
463
  </div>
464
  <div className="tabs">
465
  <Tab id="analyze" label="Analyze a case"/>
 
470
  {mode==="analyze" ? <GuidedFlow/> : mode==="report" ? <ReportCheck/> : mode==="review" ? <ReviewQueue/> : <ModelInfoView/>}
471
  <div className="foot">
472
  Every decision is appended to a local audit log (<span className="mono">audit_log.jsonl</span>).
473
+ Data never leaves this machine. PathoAI outputs re-check recommendations only; it does not diagnose.
474
  </div>
475
  </div>;
476
  }
frontend_index.html ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>PathoAI · second-reader QA</title>
7
+ <!--
8
+ React + Babel are loaded from a CDN for convenience. For an AIR-GAPPED / on-prem
9
+ deploy with no internet, run ./frontend/vendor_offline.sh once to download
10
+ react, react-dom and babel into ./frontend/vendor/, then switch the three <script>
11
+ srcs below to ./vendor/... . Nothing else changes.
12
+ -->
13
+ <script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
14
+ <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
15
+ <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
16
+ <style>
17
+ :root{
18
+ --bg:#0f1419; --panel:#161c24; --panel2:#1c242e; --line:#2a343f;
19
+ --text:#e6edf3; --muted:#8b98a5; --accent:#2dd4bf; --accent2:#38bdf8;
20
+ --warn:#f59e0b; --danger:#f87171; --ok:#34d399;
21
+ }
22
+ *{box-sizing:border-box}
23
+ body{margin:0;background:var(--bg);color:var(--text);
24
+ font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;}
25
+ a{color:var(--accent2)}
26
+ .wrap{max-width:1120px;margin:0 auto;padding:24px}
27
+ header h1{margin:0;font-size:20px;letter-spacing:.2px}
28
+ header .sub{color:var(--muted);font-size:13px;margin-top:2px}
29
+ .banner{margin:14px 0 20px;padding:10px 14px;border:1px solid var(--line);
30
+ border-left:3px solid var(--accent);background:var(--panel);border-radius:8px;
31
+ font-size:13px;color:var(--muted)}
32
+ .banner b{color:var(--text)}
33
+ .cards{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;margin-bottom:16px}
34
+ .card{background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:14px}
35
+ .card .k{color:var(--muted);font-size:12px;text-transform:uppercase;letter-spacing:.4px}
36
+ .card .v{font-size:24px;font-weight:600;margin-top:6px}
37
+ .card .v small{font-size:13px;color:var(--muted);font-weight:400}
38
+ .controls{display:flex;align-items:center;gap:16px;background:var(--panel);
39
+ border:1px solid var(--line);border-radius:10px;padding:14px;margin-bottom:16px;flex-wrap:wrap}
40
+ .controls label{font-size:13px;color:var(--muted)}
41
+ .controls input[type=range]{accent-color:var(--accent);width:220px;vertical-align:middle}
42
+ .pill{font-size:12px;padding:3px 8px;border-radius:999px;border:1px solid var(--line)}
43
+ .pill.tumor{color:#fca5a5;border-color:#5b2b2b;background:#2a1414}
44
+ .pill.normal{color:#a7f3d0;border-color:#1f4d3d;background:#0f241d}
45
+ table{width:100%;border-collapse:collapse;background:var(--panel);
46
+ border:1px solid var(--line);border-radius:10px;overflow:hidden}
47
+ th,td{padding:10px 12px;text-align:left;font-size:13px;border-bottom:1px solid var(--line)}
48
+ th{color:var(--muted);font-weight:500;text-transform:uppercase;font-size:11px;letter-spacing:.5px}
49
+ tr:last-child td{border-bottom:none}
50
+ tr.done{opacity:.5}
51
+ .mono{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px}
52
+ .thumb{width:52px;height:52px;border-radius:6px;border:1px solid var(--line);cursor:pointer;object-fit:cover}
53
+ .confbar{height:6px;background:var(--panel2);border-radius:3px;overflow:hidden;width:90px}
54
+ .confbar>span{display:block;height:100%;background:linear-gradient(90deg,var(--accent),var(--accent2))}
55
+ .btn{font-size:12px;padding:6px 10px;border-radius:7px;border:1px solid var(--line);
56
+ background:var(--panel2);color:var(--text);cursor:pointer}
57
+ .btn:hover{border-color:var(--accent)}
58
+ .btn.amend{border-color:#7a4a12;color:#fcd34d}
59
+ .btn.confirm{border-color:#1f4d3d;color:#a7f3d0}
60
+ .tag{font-size:11px;padding:2px 8px;border-radius:999px}
61
+ .tag.confirm_signout{background:#0f241d;color:#a7f3d0}
62
+ .tag.amend{background:#2a1c0a;color:#fcd34d}
63
+ .empty{padding:40px;text-align:center;color:var(--muted)}
64
+ .modal{position:fixed;inset:0;background:rgba(0,0,0,.6);display:flex;align-items:center;justify-content:center;z-index:20}
65
+ .modal .box{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:20px;max-width:420px;width:90%}
66
+ .modal img{width:100%;image-rendering:pixelated;border-radius:8px;border:1px solid var(--line)}
67
+ .foot{color:var(--muted);font-size:12px;margin-top:22px;line-height:1.6}
68
+ .tabs{display:flex;gap:8px;margin-bottom:16px}
69
+ .tab{background:var(--panel);border:1px solid var(--line);color:var(--muted);
70
+ padding:8px 14px;border-radius:8px;font-size:13px;cursor:pointer}
71
+ .tab.active{color:var(--text);border-color:var(--accent);background:var(--panel2)}
72
+ .slidegrid{display:grid;grid-template-columns:repeat(2,1fr);gap:14px}
73
+ .slidecard{background:var(--panel);border:1px solid var(--line);border-radius:12px;overflow:hidden}
74
+ .slidecard.done{opacity:.55}
75
+ .slidecard .heat{width:100%;display:block;cursor:pointer;image-rendering:pixelated;border-bottom:1px solid var(--line)}
76
+ .scbody{padding:12px 14px}
77
+ </style>
78
+ </head>
79
+ <body>
80
+ <div id="root"></div>
81
+ <script type="text/babel" src="/app.jsx"></script>
82
+ </body>
83
+ </html>