LLMs generate structured SOAP notes when the application asks the model for one field per section and rejects any draft that fails the schema. The result is still a draft note for the clinician to sign. A problem written in Assessment does not become a coded problem-list entry until the clinician adds it.
Product and engineering leads building AI note drafting into a clinical app will find the schema, the checks after it, the review screen, draft storage and pre-launch tests.
How do LLMs generate structured SOAP notes?
LLMs generate structured SOAP notes when the application requests a JSON object with Subjective, Objective, Assessment and Plan fields, enforces that shape with a schema on the model call and checks it again in code. Agnotic Technologies treats the result as a preliminary note for the clinician to edit and sign, never as coded chart data.
Drafting SOAP notes with an LLM?
We enforce the schema, check it again in code, and store a draft the clinician signs.
OpenAI's Structured Outputs constrains completed, non-refusal model output to the JSON Schema you supply. The application still has to handle refusals, incomplete responses and API errors, and validate business rules the schema does not express.
- Schema: four required string fields, one per SOAP section, plus the encounter id and note type.
- No extra free fields: the model cannot invent a fifth section.
- Refusal and truncation: treated as no draft, not as an empty note.
- Business rules in code: for example, Plan may not be empty when Assessment names a new problem.
OpenAI states that Structured Outputs does not prevent all model mistakes: the model may still make mistakes within the values of the JSON object.
What should the app check after the schema passes?
After the schema passes, the app should still check the values, because a valid object can hold a wrong statement. Agnotic runs checks that compare the draft with the source of the visit before the clinician sees it.
| Check | What fails it | What happens |
|---|---|---|
| Section present | A required section is empty | Draft rejected, model called again or clinician writes it |
| Grounding | Objective cites a vital or result not in the visit data | Line flagged for the clinician |
| Medication names | A drug in Plan is not in the visit or the medication list | Line flagged for the clinician |
| Length | The model stopped at its token limit | No draft shown. Retried with a shorter input |
These checks catch drafts that fit the schema but not the visit. They do not replace the clinician's review.
Is a structured SOAP note the same as coded chart data?
No. A structured note is still a note. The Assessment field may name a diagnosis, but the problem list, orders and medication list change only when the clinician enters them.
A FHIR Composition has a required status of preliminary, final, amended or entered-in-error, a type coded with LOINC where possible, and an attester recording who attested it and when.
- Store the draft as a note document with status preliminary, typed with a LOINC note code.
- Mark it final only after the clinician signs. That signature is the attester.
- Do not write a Condition, order or prescription from the Assessment or Plan text.
- Keep the model, prompt version and schema version with the draft for review.
What should the JSON schema for a SOAP note contain?
The JSON schema for a SOAP note should contain the four section fields, the identifiers that tie the draft to one visit, and nothing the model can use to wander. Every field is required, and additional properties are switched off.
| Field | Type | Rule |
|---|---|---|
| encounterId | String, copied from the request | Must match the visit the clinician opened |
| noteType | String from a fixed list | Progress note, consult note or another type the site uses |
| subjective | Text or a list of statements | Patient-reported history, in the patient's terms where possible |
| objective | Text or a list of statements | Findings, vitals and results that exist in the visit data |
| assessment | Text or a list of statements | Impressions as discussed in the visit, no new diagnoses |
| plan | Text or a list of statements | Follow-up, advice and orders as discussed, not orders placed |
Copy encounterId from your own request rather than trusting the model to repeat it. If the two values differ, the draft belongs to no visit and is discarded.
Should each section be one block of text or a list of statements?
A list of short statements per section is easier to check, because each statement can be compared with the visit data on its own. One block of text reads more like a typed note but can hide an unsupported sentence inside a paragraph.
| Question | One text block | List of statements |
|---|---|---|
| Grounding checks | Run on the whole paragraph | Run per statement, so a flag points at one line |
| Clinician editing | Familiar, like a typed note | Needs a display that joins statements into prose |
| Filing in the EHR | Pastes straight into a note field | Joined into text before it is filed |
Agnotic often recommends statements, joined into prose for display, so the checks stay precise and the clinician still reads a normal note.
How should the app handle a refusal, a cut-off reply or an API error?
The app should treat each of those as a failed attempt with its own log entry, and show the clinician a clear message instead of a partial note. None of them should reach the review screen looking like a finished draft.
- Step 1, read the response status first: a refusal or an incomplete status ends the attempt before any parsing.
- Step 2, parse and validate the object against the same schema version the request named.
- Step 3, on a timeout or server error, retry once with the same input, then stop.
- Step 4, on a second failure, tell the clinician the draft is unavailable and leave the note editor empty.
What should the clinician see when reviewing the draft?
The clinician should see the draft in the note editor with every flagged line marked and the reason beside it. Nothing is filed until the clinician has read it and chosen to sign.
- Flags inline: an unsupported vital or an unknown drug is highlighted where it appears, not listed on a separate tab.
- Source on demand: the clinician can open the visit data a statement was checked against.
- Both versions kept: the draft as generated and the signed version are stored, so edits can be reviewed later.
- Three clear actions: sign, edit then sign, or discard the draft and write the note by hand.
If the review screen makes discarding awkward, clinicians will sign drafts they meant to reject. Discard should take no more effort than signing.
Recording the model, prompt and schema behind each draft
Record the model name and version, the prompt version, the schema version and the generation time against the draft itself. A FHIR Provenance record is one standard way to link that information to the note.
In FHIR R4, the Provenance resource tracks the activity that created, revised, deleted or signed a version of a resource, with the agents and entities involved. It points at its target with a reference that is usually version specific, and separate activities on one target get separate Provenance records.
- Target: the preliminary note, by its version-specific reference.
- Agent: the software that generated the draft, recorded as a device or application.
- Entity: the visit data the draft was built from, by reference rather than copied in.
- Second record: signing is its own activity, pointing at the final version and naming the clinician.
What are the common mistakes when LLMs generate SOAP notes?
The common mistakes when LLMs generate SOAP notes sit at the edges of the schema: content that fits a field but belongs in another, and values that are valid text but wrong for this visit.
- Section drift: a symptom the patient reported lands in Objective because the model treated it as a finding.
- Invented normals: Objective describes a normal exam of a body system nobody examined.
- Plan as action: the draft says a drug was prescribed when it was only discussed.
- Stale context: text from an earlier visit in the input appears as if it happened today.
- Silent schema change: someone edits the schema without bumping its version, and older drafts stop validating.
A worked example: a hypertension follow-up visit
A worked example: a primary care clinic drafts notes for routine blood pressure follow-ups. The request carries the encounter id, the vitals recorded at check-in, the current medication list and the visit transcript.
The model returns four statement lists. The grounding check passes the blood pressure reading, because it matches the recorded vitals. It flags a heart rate in Objective that appears nowhere in the visit data.
Plan says to raise the dose of a drug already on the medication list, so the medication check passes. The clinician deletes the heart rate line, enters the dose change as an order in the EHR and signs. The note is filed as final, and the order exists only because the clinician placed it.
How do you test the schema and the checks before go-live?
Test with a fixed set of de-identified visits whose correct notes a clinician has already written, and run every schema, prompt or model change against that set before it ships.
- Schema tests: objects with a missing section, an extra field or a wrong type are all rejected.
- Check tests: visits seeded with a vital or drug absent from the source get that line flagged.
- Failure tests: a simulated refusal, cut-off reply and timeout each produce no draft on screen.
- Regression runs: new drafts are compared with the reference notes, and a clinician reads the differences.
Who owns the schema, the prompt and the checks?
Ownership should be split so that clinical content and software behavior each have a named person. When a draft is wrong, the team needs to know quickly whether the prompt, the schema or a check failed.
| Part | Owner | A change needs |
|---|---|---|
| Schema and versioning | Engineering | A version bump and a passing test run |
| Prompt wording | Engineering with a clinical lead | The clinical lead's review of regression output |
| Grounding and medication checks | Engineering | Seeded test cases for each new rule |
| Note types and section rules | Clinical lead | Agreement with the sites using the template |
What does structured SOAP drafting mean for your build plan?
Structured SOAP drafting adds three pieces of work beyond the model call: a versioned schema, a set of checks against the visit data, and a review screen clinicians will actually use. Plan all three from the start, because the model call is the smallest part of the build.
- Start with one note type and one specialty, so the schema and section rules stay small.
- Agree the reference visits, and the clinician who reviews regression output, before the first prompt is written.
- Decide where the preliminary note is stored and how signing marks it final in your EHR or document store.
- Leave room for the review screen: inline flags, source lookup and a discard action as easy as signing.
How does Agnotic build structured SOAP note drafting?
Agnotic builds the model request, the schema, the checks that run after it, the review screen, the storage of the preliminary note and the record of who signed it. The model is one component inside that flow, and the clinician's signature is what makes a note final.
Schema, checks, then a signed note
The model fills sections. The clinician decides what goes on the chart.
Related reading on Agnotic
AI clinical documentation, and ambient listening.


