Automated soap note generator

From aipoch/medical-research-skills · View interactive version

Automated soap note generator is an AI agent skill from the GitHub repository aipoch/medical-research-skills. Generate structured SOAP notes from clinical narratives, transcripts, or existing notes; use when the user needs de-identified clinical documentation organized into Subjective, Objective, Assessment, and Plan sections, with clear assumptions and review points.

How to use this skill

Skill file

Source: https://github.com/aipoch/medical-research-skills

Automated SOAP Note Generator

Quick Check

Use this command to verify that the packaged script entry point can be parsed before deeper execution.

python -m py_compile scripts/main.py

Audit-Ready Commands

Use these concrete commands for validation. They are intentionally self-contained and avoid placeholder paths.

python -m py_compile scripts/main.py
python scripts/main.py --help
python scripts/main.py --input "Audit validation sample with explicit symptoms, history, assessment, and next-step plan." --patient-id P12345 --provider "Dr. Smith" --format json

Workflow

  1. Confirm the user objective, required inputs, and non-negotiable constraints before doing detailed work.
  2. Validate that the request matches the documented scope and stop early if the task would require unsupported assumptions.
  3. Use the packaged script path or the documented reasoning path with only the inputs that are actually available.
  4. Return a structured result that separates assumptions, deliverables, risks, and unresolved items.
  5. If execution fails or inputs are incomplete, switch to the fallback path and state exactly what blocked full completion.

Overview

AI-powered clinical documentation tool that converts unstructured clinical input into professionally formatted SOAP notes compliant with medical documentation standards.

Key Capabilities:

When to Use

Core Capabilities

1. Input Processing and Preprocessing

Handle various input formats and prepare for NLP analysis:

from scripts.soap_generator import SOAPNoteGenerator

generator = SOAPNoteGenerator()

# Process text input
soap_note = generator.generate(
    input_text="Patient presents with 2-day history of chest pain, radiating to left arm...",
    patient_id="P12345",
    encounter_date="2026-01-15",
    provider="Dr. Smith"
)

# Process from audio transcript
soap_note = generator.generate_from_transcript(
    transcript_path="consultation_transcript.txt",
    patient_id="P12345"
)

Input Preprocessing Steps:

  1. Text Cleaning: Remove filler words ("um", "uh"), timestamps, speaker labels
  2. Sentence Segmentation: Split into clinically meaningful segments
  3. Normalization: Standardize abbreviations and medical shorthand
  4. Encoding Detection: Handle various file formats (UTF-8, ASCII, etc.)

Parameters:

| Parameter | Type | Required | Description | Default |

|-----------|------|----------|-------------|---------|

| input_text | str | Yes* | Raw clinical text or dictation | None |

| transcript_path | str | Yes* | Path to transcript file | None |

| patient_id | str | No | Patient identifier (MUST be de-identified for testing) | None |

| encounter_date | str | No | Date in ISO 8601 format (YYYY-MM-DD) | Current date |

| provider | str | No | Healthcare provider name | None |

| specialty | str | No | Medical specialty context | "general" |

| verbose | bool | No | Include confidence scores | False |

*Either input_text or transcript_path required

Best Practices:

2. Medical Named Entity Recognition (NER)

Identify and extract medical concepts from unstructured text:

# Extract entities with context
entities = generator.extract_medical_entities(
    "Patient has history of hypertension and diabetes, 
     currently taking lisinopril 10mg daily and metformin 500mg BID"
)

# Returns structured entities:
# {
#   "diagnoses": ["hypertension", "diabetes mellitus"],
#   "medications": [
#     {"name": "lisinopril", "dose": "10mg", "frequency": "daily"},
#     {"name": "metformin", "dose": "500mg", "frequency": "BID"}
#   ]
# }

Entity Types Recognized:

| Category | Examples | Notes |

|----------|----------|-------|

| Diagnoses | diabetes, hypertension, pneumonia | ICD-10 compatible where possible |

| Symptoms | chest pain, headache, nausea | Includes severity modifiers |

| Medications | metformin, lisinopril, aspirin | Extracts dose, route, frequency |

| Procedures | ECG, CT scan, blood draw | Includes body site |

| Anatomy | left arm, chest, abdomen | Laterality and location |

| Lab Values | glucose 120, BP 140/90 | Units and reference ranges |

| Temporal | yesterday, 3 days ago, chronic | Normalized to relative dates |

Common Issues and Solutions:

Issue: Missed medications

Issue: Ambiguous abbreviations

Issue: Misspelled drug names

3. SOAP Section Classification

Automatically categorize sentences into appropriate SOAP sections:

# Classify content into SOAP sections
classified = generator.classify_soap_sections(
    "Patient reports chest pain for 2 days. Physical exam shows BP 140/90. 
     Likely angina. Schedule stress test and start aspirin 81mg daily."
)

# Output structure:
# {
#   "Subjective": ["Patient reports chest pain for 2 days"],
#   "Objective": ["Physical exam shows BP 140/90"],
#   "Assessment": ["Likely angina"],
#   "Plan": ["Schedule stress test", "start aspirin 81mg daily"]
# }

Classification Rules:

| Section | Content Type | Examples |

|---------|--------------|----------|

| S - Subjective | Patient-reported information | "Patient states...", "Patient reports...", "Complains of..." |

| O - Objective | Observable/measurable findings | Vital signs, physical exam, lab results, imaging |

| A - Assessment | Clinical interpretation | Diagnosis, differential, clinical impression |

| P - Plan | Actions to be taken | Medications, procedures, follow-up, patient education |

Multi-label Handling:

Some sentences span multiple sections (e.g., "Patient reports chest pain [S], which was sharp and 8/10 [S], with ECG showing ST elevation [O]")

Best Practices:

4. Temporal Information Extraction

Parse and normalize timeline information:

# Extract temporal relationships
timeline = generator.extract_temporal_info(
    "Patient had chest pain starting 3 days ago, worsening since yesterday. 
     Had similar episode 2 months ago that resolved with rest."
)

# Returns:
# {
#   "onset": "3 days ago",
#   "progression": "worsening",
#   "previous_episodes": [
#     {"time": "2 months ago", "resolution": "with rest"}
#   ]
# }

Temporal Elements Extracted:

Normalization:

Converts relative dates to standardized format:

5. Negation and Uncertainty Detection

Critical for accurate medical documentation:

# Detect negations and uncertainties
analysis = generator.analyze_certainty(
    "Patient denies chest pain. No shortness of breath. 
     Possibly had fever yesterday but not sure."
)

# Identifies:
# - "denies chest pain" → Negative finding (important!)
# - "No shortness of breath" → Negative finding
# - "Possibly had fever" → Uncertain finding (flag for verification)

Detection Categories:

| Type | Cues | Action |

|------|------|--------|

| Negation | denies, no, without, absent | Mark as negative finding |

| Uncertainty | possibly, maybe, uncertain, ? | Flag for physician review |

| Hypothetical | if, would, could | Note as conditional |

| Family History | family history of, mother had | Separate from patient findings |

⚠️ Critical:

Negation errors are high-risk (e.g., missing "denies" → documenting symptom they don't have)

6. Structured SOAP Generation

Produce final formatted output:

# Generate complete SOAP note
soap_output = generator.generate_soap_document(
    structured_data=classified,
    format="markdown",  # Options: markdown, json, hl7, text
    include_metadata=True
)

Output Format:

# SOAP Note

**Patient ID:** P12345  
**Date:** 2026-01-15  
**Provider:** Dr. Smith

## Subjective
Patient reports [extracted symptoms with duration]. History of [chronic conditions]. 
Currently taking [medications]. Patient denies [negative findings].

## Objective
**Vital Signs:** [BP, HR, RR, Temp, O2Sat]  
**Physical Examination:** [Exam findings by system]  
**Laboratory/Data:** [Relevant results]

## Assessment
[Primary diagnosis/differential]  
[Clinical reasoning summary]

## Plan
1. [Action item 1]
2. [Action item 2]
3. [Follow-up instructions]

---
*Generated by AI. REQUIRES PHYSICIAN REVIEW before entry into patient record.*

Export Formats:

| Format | Use Case | Notes |

|--------|----------|-------|

| Markdown | Human review, documentation | Default, readable |

| JSON | System integration, research | Structured data |

| HL7 FHIR | EHR integration | Healthcare standard |

| Plain Text | Simple documentation | Minimal formatting |

| CSV | Data analysis, research | Tabular data export |

Limitations

Parameters

| Parameter | Type | Default | Required | Description |

|-----------|------|---------|----------|-------------|

| --input, -i | string | - | No | Input clinical text directly |

| --input-file, -f | string | - | No | Path to input text file |

| --output, -o | string | - | No | Output file path |

| --patient-id, -p | string | - | No | Patient identifier |

| --provider | string | - | No | Healthcare provider name |

| --format | string | markdown | No | Output format (markdown, json) |

Usage

Basic Usage

# Generate SOAP from text
python scripts/main.py --input "Patient reports chest pain..." --output note.md

# From file
python scripts/main.py --input-file consultation.txt --patient-id P12345 --provider "Dr. Smith"

# JSON output
python scripts/main.py --input-file notes.txt --format json --output note.json

Output Requirements

Every final response should make these items explicit when they are relevant:

Error Handling

Input Validation

This skill accepts requests that match the documented purpose of automated-soap-note-generator and include enough context to complete the workflow safely.

Do not continue the workflow when the request is out of scope, missing a critical input, or would require unsupported assumptions. Instead respond:

automated-soap-note-generator only handles its documented workflow. Please provide the missing required inputs or switch to a more suitable skill.

Response Template

Use the following fixed structure for non-trivial requests:

  1. Objective
  2. Inputs Received
  3. Assumptions
  4. Workflow
  5. Deliverable
  6. Risks and Limits
  7. Next Checks

If the request is simple, you may compress the structure, but still keep assumptions and limits explicit when they affect correctness.

When Not to Use

Required Inputs

| Field | Required | Format/Source | Example | If Missing |

|---|---|---|---|---|

| User task description | Yes | Text | Research question, writing goal, analysis objective | Stop and ask user to provide |

| Primary input material | Depends on task | Text, file path, ID, table, or literature | PMID, PDF, CSV, DOCX, keywords, etc. | Specify which material type is missing |

| Output preference | No | Text | Language, format, target journal, template | Use skill default format |

Output Contract

Failure Handling

User Checkpoints

Quick Validation

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.