top of page

AI Discharge Summary Drafter with Python and OpenAI

11 minutes ago
7 min read





A patient is ready to go home. Before they can leave, someone has to pull together everything that happened during the stay, the visit notes, the medication changes, the follow-up plan, into one discharge summary. That summary then has to be explained again, in plain language, so the patient actually understands what to do once they are home.


Today, that means a clinician sitting down at the busiest point of the day to write it all out by hand, twice, once for the chart and once for the patient. The patient waits on it, and the clinician's time goes into typing instead of care.


What if a single click could draft that summary for you, in both voices, with every statement pointing back to exactly where it came from?


That is exactly what the AI Discharge Summary Drafter does. In this post, we walk through what it is, how it works, and what each step of the process looks like.






The Requirement


Imagine a hospital reaches out with a very specific need:


"Every discharge needs a summary that pulls together the visit notes, the medication list, and the follow-up instructions. Our clinicians do not have time to write this by hand at the end of every shift, and the patient still needs it explained in plain language. We want a draft ready for review, not another blank page."



Breaking that down the way we would in a client meeting, the application needs to:


  • Read three sources: the visit notes, the discharge medication list, and the follow-up instructions.


  • Draft one summary from all three, covering the diagnosis, the presentation, the hospital course, the condition at discharge, and the medications.


  • Write it in two voices: one for the clinician, in clinical language, and one for the patient, in plain language that says the same thing.


  • Trace every statement back to its source, so nothing in the draft is unverifiable.


  • Cross-check the three sources against each other, and flag anything that does not line up, such as a dose that differs between the medication list and the instruction sheet.


  • Never release a draft without a clinician's review. A new draft is never approved by default.


If your hospital needs a draft ready before the clinician even opens the chart, this is for you.






Tech Stack


The application runs on three things:


  • Python for the backend logic, the source handling, and the drafting rules.

  • OpenAI to read the sources and draft the summary in both voices.

  • HTML, CSS, and JavaScript for the interface, the tabs, the tables, and the draft views.






POC Overview


The AI Discharge Summary Drafter takes three inputs: the visit notes, the discharge medication list, and the follow-up instructions.


It reads all three, and drafts the discharge summary automatically using an OpenAI language model. The output is one draft written for two readers, the clinician and the patient, with every statement traceable to the source it came from.


In simple words, a patient's records go in, and a discharge summary draft comes out, ready for a clinician to review and approve.






Features


The whole process takes only a few steps.




Step 1: Open the Patients Page


The patients page lists every discharge waiting for a summary. It can be sorted by patient name, admitted date, discharged date, or status, searched by name, record number, or diagnosis, and filtered to Not started, In review, Ready to approve, or Approved.



The Patients page: every discharge waiting for a summary, with sorting, search, and status filters




Filtering the list down to a single status





Step 2: Open a Patient


Opening a patient shows the encounter summary, the diagnosis, and a single Draft discharge summary button. Nothing has been generated yet, so the status reads Not started.


Opening a patient: the encounter summary and the Draft discharge summary button





Step 3: Review the Three Sources


Below the summary sit the three sources the draft will be built from: the visit notes, the medications, and the follow-up instructions. Every line carries its own ID, N1 for a note, M1 for a medication, F1 for a follow-up instruction, and the medication table shows the dose and whether each medicine is new, changed, continued, or stopped.







Step 4: Draft the Summary


One click drafts the summary. The application reads the visit notes, reconciles the medication list, checks the follow-up instructions, cross-checks the three sources for conflicts, and writes both versions of the summary.





Step 5: Read the Draft, in Two Voices


The clinician version reads the way a clinician expects. The patient version says the same thing in plain language, so the patient actually understands what happened and what to do next. Clicking any source tag jumps to the exact line it came from and highlights it.






Step 6: Clear the Clinician Review


A new draft always starts at In review, never at approved. The clinician review panel lists the specific items to check, such as a dose that does not match between the medication list and the instruction sheet, or a lab result still pending at discharge. Each one has to be marked reviewed.







Step 7: Approve the Draft


Only once every item is reviewed does the status move to Ready to approve, and the Approve draft button releases the summary to the patient. The status is carried straight back to the patients list, so the whole ward is visible at a glance.







Advantages


  • Clinician time back. A draft replaces writing the summary from scratch at the end of a shift.

  • Two voices from one draft. The clinical version and the plain language version are written together, so they never drift apart.

  • Traceable, not just plausible. Every statement carries a source tag, so a clinician can verify it in seconds instead of re-reading the whole chart.

  • Built-in cross-checking. Dose mismatches and pending results are surfaced automatically, instead of relying on someone to notice them.

  • Nothing ships without review. A draft cannot reach the patient until a clinician has cleared every flagged item and approved it.






Limitations


This is a proof of concept, and it is important to be clear about its current scope:


  • Three sources. The draft is built from visit notes, the medication list, and follow-up instructions. Other chart sections are not yet included.


  • Cross-checking is rule-based. It catches the conflicts it is built to look for, such as dose mismatches and pending results, not every possible inconsistency.


  • A clinician review is still required. The application drafts and flags, it does not approve itself, by design.


None of these is a permanent limit, and each can be addressed in a custom build.






Future Scope of Improvements


The current version is a foundation. Natural next steps include:


  • More source types, such as vitals, lab trends, and imaging reports, folded into the same drafting pipeline.


  • Direct electronic health record integration, so sources are pulled in automatically instead of being prepared by hand.


  • Ward-level dashboards, tracking how many drafts are in review, ready to approve, or approved across an entire hospital.


  • Multi-language patient drafts, so the plain language version can be generated in the patient's own language.


  • Structured discharge coding support, suggesting diagnosis and procedure codes alongside the narrative summary.


  • Audit history, recording who reviewed, edited, and approved each draft, and when.






Use Cases


  • Hospital wards can give the discharging clinician a draft to review, instead of a blank page at the end of a shift.


  • Patient communication teams can hand every patient a plain language version of the same summary, written for them to actually follow.


  • Clinical documentation teams can draft consistently structured summaries across every ward, in one house style.


  • Quality and audit teams get a summary where every statement carries its source, so it can be checked against the record it came from.


  • Specialty clinics can draft visit summaries and care plans from the same notes, medications, and follow-up structure.


  • Care transitions can send the receiving team and the family the same reviewed summary, in the voice each one needs.






Who This Is For


  • Hospitals and clinics that discharge patients every day and need a summary for each one

  • Clinical documentation and quality teams responsible for discharge paperwork

  • Care coordination teams handling transitions between wards, facilities, or home care

  • Patient experience teams who want every patient to leave with instructions they can actually follow

  • Any healthcare organization with structured visit notes, medication lists, and follow-up plans, and a need to summarize them consistently






Frequently Asked Questions




What is a discharge summary?


A discharge summary is a document written at the end of a hospital stay that explains why the patient was admitted, what happened during the stay, and what to do after leaving.




What does the AI Discharge Summary Drafter actually draft?


It drafts one summary from three sources, the visit notes, the discharge medication list, and the follow-up instructions, covering the diagnosis, the presentation, the hospital course, the condition at discharge, and the medications.




Why are there two versions of the draft?

One is written for the clinician, in clinical language, and one is written for the patient, in plain language. Both come from the same sources, so they always agree with each other.




How do I know a statement in the draft is accurate?


Every statement carries a source tag. Clicking it jumps straight to the exact note or medication line it came from and highlights it.




Does the application approve its own drafts?


No. A new draft always starts at In review. A clinician has to clear every flagged item before the status moves to Ready to approve, and only a clinician can approve it.




What kind of issues does it flag for review?


Issues such as a medication dose that differs between the medication list and the instruction sheet, or a lab result that was still pending at the time of discharge.




Who builds this, and how do I get in touch?


This application is built by Codersarts, which delivers custom clinical documentation applications for hospitals and clinics. Reach out at contact@codersarts.com or visit www.codersarts.com.






Call to Action


If you want this built for your organization, Codersarts delivers custom clinical documentation applications, including:


  • The drafting pipeline, the source citations, and the clinician review workflow, all built for your wards

  • Architecture consulting for scale, supporting many wards and many clinicians at once

  • Integration with your existing electronic health record


It is simple to start. No long onboarding, just a discovery call to talk through your wards and your discharge workflow.


Book a discovery call to get started. Reach out at contact@codersarts.com or visit www.codersarts.com.






Exploring AI Resources


If you found this blog helpful, explore AI resources from CodersArts AI to see how organizations are applying these systems to real world applications.









Comments


bottom of page