Inspiration

My grandfather owns and runs SP , a pharmaceutical company in Chennai, India. Growing up, I heard him talk about medicines all the time, and what stuck with me was the names. The same medicine could go by a chemical name, a generic name and several brand names, and he knew them all.

When I started looking into medication errors, I realised those names are exactly where things go wrong. A doctor writes "Augmentin" in one part of a note and "allergic to PCN" in another. A pharmacist knows that Augmentin contains amoxicillin and PCN means penicillin, so this patient should not get it. A tired reader skimming a rushed note might not connect the two. WHO estimates medication errors cost about US$42 billion a year, and most documentation tools check billing completeness, not medication safety inside the note.

So I set out to build something that reads a clinical note the way someone like my grandfather would: knowing that different names can mean the same drug, and catching the conflict before the note is signed. And because this is about patient safety, I made one rule non-negotiable: the AI can help read the note, but it must never be able to make a dangerous note look safe.

What it does

You paste a clinical note and get three things back:

  • A structured SOAP note (Subjective, Objective, Assessment, Plan)
  • Safety flags: drug and allergy conflicts, out of range doses, missing vitals, and missing or unrecognized allergy documentation. Every flag shows the exact evidence that triggered it.
  • An action checklist in priority order, for example "HOLD amoxicillin. Confirm the penicillin allergy and its reaction with the patient."

It understands shorthand and brand names (PCN is penicillin, Augmentin is amoxicillin, Lasix is furosemide), catches unit slips like 5000 mg of metformin, and can find an allergy hidden in the patient history even when there is no allergy line.

How I built it

Python and FastAPI, with a plain HTML and JavaScript interface. The core idea is the LLM reads, the rules decide:

  • An extractor turns free text into structured fields. It runs as regex, as an LLM (Groq openai/gpt-oss-120b or Google Gemini), or hybrid (both).
  • In hybrid mode the rules see the union of what regex and the LLM found. The LLM can add a finding but can never remove one. A test runs the whole safety suite against an LLM that returns nothing, and it still passes.
  • Every flag comes from deterministic Python rules over a small reference table where every entry is sourced (DailyMed drug labels, AAAAI, ACR, AHA).
  • Failures are loud. If the LLM fails, the screen says so. It never shows a silent all clear.

I also made clinically informed choices: a penicillin allergy does not block cephalosporins and an "iodine allergy" does not block contrast, because both are myths, and codeine to hydrocodone is a "review", not a hard stop.

Challenges I ran into

  • Real notes broke my regex in ways synthetic notes never did: brand names, salt names like "metoprolol tartrate", "1 gm", "pulse was 94", dash separated medication lists, and allergy lists on the line below the heading. Each one became a fix plus a regression test (97 tests now).
  • The free Groq model is a reasoning model. On long notes it spent its whole output budget thinking and returned nothing, which showed up as a confusing JSON error. I found the cause with a probe script and fixed it by lowering reasoning effort and raising the token limit.
  • My test suite was secretly calling the live LLM and burned my whole daily quota. Tests now run offline by default in about 15 seconds.
  • While re-checking my labels I found one of my own label errors, copied from a buggy extraction. I corrected it and re-scored.

Accomplishments that I'm proud of

I hand-labeled 25 real, de-identified notes from MTSamples (allergies, medications with doses, which vitals are present) and re-checked every label on a second pass. I kept 10 notes hidden until the very end to get a fair test.

Held-out: 10 unseen notes Regex Hybrid
Allergies (precision / recall) 88 / 100 88 / 100
Medications (precision / recall) 68 / 61 76 / 100
Safety flags (precision / recall) 91 / 91 91 / 91

On notes it had never seen, the LLM raised medication recall from 61% to 100%. I'm also proud of the safety design: the AI can make the tool smarter, but it can never make it less safe.

What I learned

Testing on real data is a different job from testing on data you made up. A held-out set is the only fair way to compare two approaches, and a 100% score on notes you tuned on means very little. I also learned that in healthcare, being honest about what your tool can't do matters as much as what it can.

What's next for Clinical Note Auditor

  • A larger evaluation with more notes and more than one labeler
  • More sourced drugs, and kidney function based dosing
  • A pre-sign check built into the EHR note editor, so errors are caught before the note is saved

Limitations: small sample (25 notes, one labeler). The dose table covers 7 drugs and the allergy table 7 classes, because every entry must be sourced. It misses drugs with no mg dose, counts supplements as medications, and can't tell a past or planned dose from a current one. Research prototype on de-identified data. Not a medical device and not clinically validated. Built with AI coding assistance; the problem choice, labeling and evaluation are my own.

Built With

Share this project:

Updates

Submission history