Inspiration
For some major operations, the hospital you choose changes your chance of surviving them, and the people choosing are rarely told.
The largest recent study I found followed 1,049,069 elective high-risk operations on Medicare patients in 2016 to 2018. Thirty-day mortality was 8.1% at low-volume hospitals and 5.5% at hospitals meeting the Leapfrog volume standard (adjusted odds ratio 0.67). The figure that stayed with me is the next one: for 79.8% of the operations done at a low-volume hospital, a hospital that met the standard was in the patient's own insurance network, a median of 29 miles from home. (Kalata et al., JAMA Surgery 2024, PMID 38150228.) The share done at low-volume hospitals ranged from 1.5% of carotid endarterectomies to 65.0% of oesophagectomies, so the stakes depend heavily on the operation.
For the pancreas, the gap is clearer. Across 516,392 Medicare cancer resections, risk-adjusted mortality after pancreatic resection was 3.8% at hospitals meeting the standard and 5.7% at those that did not. (Sheetz et al., JAMA Surgery 2019, PMID 31411663.)
The same paper found no significant difference for oesophageal, lung or rectal resection. That finding is as important as the headline, and I built the product around it. Volume is a weak proxy on its own. In a later analysis, the Leapfrog thresholds had a positive predictive value of only 24% to 26% for picking out poor-performing hospitals (J Am Coll Surg 2020, PMID 32335321), and once a study design was tightened, the gap in pancreatectomy mortality by surgeon volume shrank from 7.9% vs 5.2% to 7.8% vs 7.2% (JAMA Netw Open 2022, PMID 35267034). Even among surgeons who met the volume bar, 90-day oesophagectomy mortality ranged from 3.5% to 9.3% (Cancer 2021, PMID 34292582).
England shows the other side. It centralised oesophago-gastric cancer surgery from 2001. The 2026 national audit found 90-day survival of 96.7% after curative surgery and no centre that was a mortality outlier. Yet 30-day readmission still ranged from 7% to 29% across centres, and stays over 15 days from 11% to 40%. The audit itself says second-opinion review "may be beneficial" in borderline cases.
The law already treats this as a patient's business. In Johnson ex rel. Adler v. Kokemoor (Wisconsin Supreme Court, 1996, 199 Wis. 2d 615), a neurosurgeon asked how many operations like hers he had done said "dozens." The plaintiff's evidence was that he had done two basilar bifurcation aneurysm operations. She was left an incomplete quadriplegic. The court held that the surgeon's limited experience, the comparative morbidity and mortality of experienced and inexperienced surgeons, and the availability of a more experienced centre were material to informed consent. Her experts said she should have been referred to a tertiary centre "such as the Mayo Clinic, only 90 miles away." Those are three questions a patient can ask: how many have you done, how do your results compare, and is there a centre nearby that does more. The opinion states no award amount and I do not cite one. Andersen v. Khanna (Iowa, 2018) and Montgomery v Lanarkshire [2015] UKSC 11 are in the app for the US and UK standards.
Nobody sits with a patient in the weeks between "you need an operation" and the operation and does this homework. I wanted that to be a private assistant that belongs to the patient.
What it does
Second Opinion keeps a patient's case and checks the public data against it. It takes the clinic letter, works out which operation is proposed and which dataset applies, shows the hospitals in that dataset, says what the numbers can and cannot tell the patient, and writes the questions to take to the surgeon. It does not recommend a hospital, and it never says an operation is safe.
The app ships with three example patients. The patients and their letters are written examples. The hospital figures in every table are real public data.
- A Whipple in Ohio (US). Five Ohio hospitals have a visible Medicare count for the pancreas and liver DRG group in 2024: Cleveland Clinic 56, Riverside Methodist 52, UH Cleveland 17, Toledo 14, University of Cincinnati 12. The patient's own hospital is not in the file, and the app says that means fewer than 11 Medicare fee-for-service cases in 2024, which is "unknown, ask," not proof of low volume. The highest-volume hospital, Cleveland Clinic, is marked "Worse Than the National Value" on the CMS safety composite (PSI-90), while all five are "No Different" on failure-to-rescue (PSI-04). Volume and safety disagree, so the app shows both and picks no winner. For this operation it rates volume as weighing heavily, with the Kalata and Sheetz evidence beside it and the counter-evidence next to that.
- A hip replacement in Nottingham (UK). Nottingham City Hospital did 2,132 procedures in 2025 and is flagged for hip 5-year revision and total knee 10-year revision. Nearby units are not flagged. No unit in England is a 90-day mortality outlier for hips. The app's verdict: volume is not the signal for this operation, and a revision flag is not a mortality flag.
- Oesophagectomy in England. The audit table covers 2019 to 2022. The app declines to turn the adjusted mortality column into a league table, because the audit says every centre was within the expected range for 90-day mortality. It points to readmission, length of stay and the audit's second-opinion line instead. This is the case where the honest answer is that mortality will not separate the centres.
Memory is the point of the Personal AI track. Each case file holds the diagnosis, the proposed operation and its mapped dataset, the hospital named, the insurance network, how far the patient will travel, the consultation date, every message, and a dated journal of what the agent did. Every item is stored with an embedding. When the patient writes back, the agent recalls the relevant earlier turns instead of starting cold. I restarted the server mid-build and the case was still there.
How I built it
Backend. FastAPI. Case files and memory are in SQLite. Static assessments for the three example cases are precomputed and cached, so a visitor can open every screen without spending tokens. "Run it," a new message and memory search call the models live, capped at 60 live calls per process so a public URL cannot drain the credit.
Frontend. React and Vite, built into the backend's static folder. The layout is a left sidebar, a coloured masthead and metric cards. Views are Overview, Case, Hospitals, Safety, Decision and Journal.
Models, all on Nebius Token Factory through one OpenAI-compatible base URL:
| Tier | Job |
|---|---|
| Nemotron 3 Nano | Reads the letter and maps the operation to a dataset. Classification, low reasoning effort. |
| Nemotron 3.5 Lightning | The tool-calling step: it chooses which dataset to open. |
| Nemotron 3 Super | Writes the plain-language reading of the table, and replies to new messages using recalled memory. |
| Nemotron 3 Ultra | The one judgment: does volume decide for this operation, what must not be concluded, what to ask next. |
| Qwen3-Embedding-8B | Embeds every memory item for recall. It is the only embedding model in the catalogue, and it is not an NVIDIA model. |
Decisions that mattered:
- A model never emits a statistic. The data layer owns every number. The system prompt tells each model not to invent figures, not to name a safest hospital, and not to show Leapfrog ratings. Evidence figures live in one module, copied from saved abstracts, and the court holdings live in another, quoted from the saved opinions.
- The dataset mapping stays authoritative in code. In the cached Whipple run, Nano labelled the letter as UK and picked the oesophago-gastric dataset. The case file's mapping decides which dataset opens, and the model's output is shown alongside it. Left alone, the classifier would have shown a patient the wrong country's data.
- Missing is not low. CMS suppresses cells under 11. A hospital absent from the file is treated as "unknown, ask" in the prompt and in the caveat text on screen.
- Reasoning models need a larger token budget. A small max_tokens returns empty because the budget goes to hidden thinking. I set reasoning effort low for mapping and higher for the Ultra judgment.
- Leapfrog results are not shown. Their terms forbid republishing. The app states the published thresholds and links out.
Data. CMS Complications and Deaths and Medicare Inpatient by Provider and DRG (public domain), National Joint Registry transparency data (OGL), NOGCA 2023 data tables (CC BY).
What makes it agentic
| Perception | Decision | Action |
|---|---|---|
| A clinic letter naming an operation and a hospital | Which procedure and dataset apply; Lightning picks the tool | Opens the matching public table and builds the comparison |
| A hospital missing from the table | Suppressed under 11 cases, or genuinely low? Unknown | Says "ask," and writes the question for the surgeon |
| The table plus the studies on that operation | Does volume decide here (pancreas: yes; hip, oesophagus in England: no or weakly) | States the verdict with the evidence and what not to conclude |
| A new message from the patient | What does the case file already know that bears on it | Recalls past turns by embedding and answers from them |
| Each action | What the next session should know | Writes a dated finding to the journal, stored with an embedding |
Accomplishments
- Memory survives a server restart. I killed the process and brought the case back with its history intact.
- The agent gives three different answers for three operations, including "volume is not the signal" for hips and oesophagectomy, rather than one scare story.
- Every figure on screen traces to a saved source. The Kalata and Sheetz numbers are copied from the abstracts. The court facts are quoted from the opinion text, and no damages figure appears.
- Leapfrog stays out because its terms forbid republishing, and the app still says how to look a hospital up.
- Deployed on AWS App Runner and tested end to end on the live URL.
What's next
- Act without being asked. The research plan has the agent re-check when CMS refreshes Care Compare each quarter or the NJR and NOGCA publish each year, diff the case file and message the patient, then send a one-page brief before the consultation date. The memory and journal it needs exist. The scheduler and messaging channel do not yet.
- Read the real letter. Photo-to-text with a vision model (no Nemotron reads images on Nebius Token Factory), then Nemotron for everything after.
- Hospital-published volumes. Many hospitals publish their own case counts and surgeon pages, which no open dataset has. That would fill the main gap below.
- Verified UK choice wording. The NHS right-to-choose wording is not yet checked against the Constitution, so the app does not quote it.
Log in or sign up for Devpost to join the conversation.