Inspiration
A discharge summary condenses a whole hospital stay into one document, assembled from many notes that sometimes disagree. Writing one by hand takes a long time, and a generic AI summary can't be trusted unless every statement links back to the note it came from. We wanted a draft a clinician could check claim by claim.
What it does
DischargeCopilot reads a patient's hospitalization notes and drafts a discharge summary. Every claim in it cites the source passage it came from. When notes contradict each other (for example, two different doses for the same drug), it stops and asks the clinician which is right instead of guessing. After that, the clinician can:
- open any citation to see the original passage
- ask questions about the case and get answers that cite the notes
- describe a correction in plain words, then review the AI's revised wording side by side with the original and accept or reject it
- approve the draft and export it as a Word document
The backend is API-first: the review UI is one client, and the same API could sit behind an EHR plugin.
How we built it
- Backend: Python with FastAPI. Two LangGraph workflows do the AI work:
- The load graph extracts clinical events from each note in parallel, checks the notes for conflicts, pauses for the clinician to resolve them, then drafts the summary one section at a time, in parallel.
- The review graph answers case questions by classifying the question, retrieving relevant passages, and answering only from those passages.
- Model: OpenAI with structured outputs, so the model returns typed data the backend can validate rather than free text.
- Grounding check: every quote the model cites must appear word for word in its source passage. Anything that fails is dropped.
- Frontend: React 19, TypeScript, Vite and Tailwind. Draft sections and answers stream in as they're generated.
- Export: python-docx for the Word output.
- Data: three synthetic patient cases. No real patient data was used.
Challenges we ran into
- Processing a lot of text quickly: each case is several notes, and a full load means dozens of model calls that all had to finish within a 120-second limit. Running them one after another was too slow, so we restructured the pipeline:
- notes are extracted in parallel
- summary sections are drafted in parallel
- each model call gets its own short timeout
- failed notes are retried without redrafting the whole summary
- results stream to the UI as they arrive, so the clinician isn't staring at a spinner
- Made-up citations: the model sometimes cites passages that don't say what it claims. We added the word-for-word quote check and drop anything that fails.
- Conflicting notes: the pipeline has to pause partway through for a clinician's input and then pick up where it stopped.
- Keeping the AI in bounds: the question-answering prompt has to keep the model from adding medical knowledge the notes don't state.
Accomplishments that we're proud of
- Every claim in the draft traces back to an exact passage in the notes.
- The clinician stays in control: conflicts are resolved by a person, corrections need explicit approval, and approval and export are blocked while any correction is undecided.
- The full workflow runs live against the model, from loading a case through to a Word document.
- The project has a substantial test suite on both backend and frontend.
What we learned
One theme the code supports: an AI tool can only be trusted in a clinical workflow if what it writes can be checked against the source.
What's next for DischargeCopilot
- Batch processing: generate summaries one patient at a time, or in bulk filtered by date range, physician/provider, and/or medical insurance.
- White label: let hospitals and vendors ship it under their own brand.
- Voice interaction: clinicians ask questions and dictate corrections by voice.
- EHR plugin: package the API as an EHR plugin while keeping the standalone UI.
- Plugin store: a marketplace of automations for healthcare professionals, built on the same API.
- Validate on real (de-identified) clinical data with clinicians, and add the security and compliance work needed for clinical use.
Log in or sign up for Devpost to join the conversation.