Clinical Documentation Assistant
Overview
This skill enables an OpenClaw agent to connect to any FHIR R4-compliant EHR, retrieve structured patient data, and generate high-quality clinical documentation drafts. It covers the most time-consuming document types in outpatient and inpatient settings.
Supported document types:
- - SOAP notes (Subjective / Objective / Assessment / Plan)
- Referral letters (specialist, imaging, therapy)
- Prior authorization requests (insurance)
- Discharge summaries
- Care plan narratives
- Patient-facing after-visit summaries
Supported FHIR backends:
- - Epic (SMART on FHIR)
- Cerner (Millennium)
- Azure Health Data Services
- HAPI FHIR (public sandbox for testing)
- Any R4-compliant server
⚠️ Clinical Disclaimer: All output is a documentation draft intended to be reviewed, edited, and signed by a licensed clinician. This skill does not provide clinical advice, diagnoses, or prescriptions.
🔒 Privacy / PHI Warning: FHIR data is fetched into the agent's context for the session only and is not written to disk by this skill. If you use the hosted backend (CLINICAL_DOC_API_URL), patient context is transmitted to that server — only use a backend you control in a HIPAA-eligible environment. Do not use a third-party hosted backend with real patient data unless a BAA is in place. For development and testing, always use FHIR_SANDBOX_MODE=true with synthetic data only.
Quick Start (Sandbox Mode — No EHR Needed)
Set FHIR_SANDBOX_MODE=true to use the public HAPI R4 sandbox. No credentials required. Ideal for testing and development.
CODEBLOCK0
Then ask your agent:
"Pull patient John Smith from the FHIR sandbox and draft a SOAP note for today's hypertension follow-up."
Authentication
This skill uses SMART on FHIR (OAuth2) for EHR connections. Set up once per environment.
Step 1 — Register your app with your EHR
Each EHR has its own developer portal:
- - Epic: https://fhir.epic.com → create a non-production app → note Client ID
- Cerner: https://code.cerner.com → register app → note Client ID + Secret
- Azure AHDS: Azure Portal → FHIR service → Authentication
Step 2 — Set environment variables
CODEBLOCK1
Step 3 — Test the connection
Ask the agent:
"Check my FHIR connection status."
The agent will attempt a token fetch and a GET /metadata call, then report back.
FHIR Data Retrieval
The agent fetches only the resources needed for the requested document. All calls are read-only GET requests.
Patient lookup
CODEBLOCK2
Internally calls:
CODEBLOCK3
Condition list
CODEBLOCK4
Calls:
CODEBLOCK5
Medication list
CODEBLOCK6
Calls:
CODEBLOCK7
Recent vitals
CODEBLOCK8
Calls:
CODEBLOCK9
Lab results
CODEBLOCK10
Calls:
CODEBLOCK11
Encounter history
CODEBLOCK12
Calls:
GET /Encounter?patient=[id]&date=ge2025-09-01&_sort=-date
Document Generation
Once patient data is retrieved, ask the agent to generate any document type.
SOAP Note
Trigger phrases:
- - "Draft a SOAP note for today's visit"
- "Write a SOAP note for this patient's diabetes follow-up"
- "Generate a clinical note — chief complaint is chest pain"
What the agent does:
- 1. Retrieves active conditions, current meds, recent vitals, and relevant labs
- Asks you for any additional subjective information (chief complaint, HPI)
- Structures the note into S / O / A / P sections
- Flags any data gaps (missing vitals, no recent labs)
Example output structure:
CODEBLOCK14
Referral Letter
Trigger phrases:
- - "Write a referral to cardiology for this patient"
- "Draft a referral letter to Dr. Chen for physical therapy"
- "Generate an imaging referral for MRI of the lumbar spine"
What the agent does:
- 1. Pulls relevant conditions, meds, and recent encounter notes
- Asks for referring provider name, specialty, and clinical question
- Formats a professional referral letter with clinical context
Example:
CODEBLOCK15
Prior Authorization Request
Trigger phrases:
- - "Draft a prior auth for [medication/procedure]"
- "Generate a prior authorization for Humira for this patient"
- "Write a PA request for MRI lumbar spine — payer is BlueCross"
What the agent does:
- 1. Retrieves diagnosis codes (ICD-10) from active conditions
- Looks up the requested item's typical HCPCS/CPT code
- Generates a structured PA narrative with clinical justification
- Lists supporting labs or imaging that strengthen the case
Key fields generated:
- - Member ID (from input)
- Requesting provider NPI (from input)
- Diagnosis codes (from FHIR Condition resources)
- Requested service + procedure/drug code
- Clinical justification narrative
- Supporting documentation checklist
Discharge Summary
Trigger phrases:
- - "Generate a discharge summary for this patient"
- "Draft a hospital discharge note — patient is going home today"
What the agent does:
- 1. Pulls the current/recent encounter, active conditions, procedures, and meds
- Asks for admission diagnosis, hospital course summary, and discharge instructions
- Formats a complete discharge summary with follow-up plan
After-Visit Summary (Patient-Facing)
Trigger phrases:
- - "Write a patient-friendly after-visit summary"
- "Generate an AVS in plain language for this patient"
What the agent does:
- 1. Translates clinical note content into plain English (8th-grade reading level)
- Lists medications with plain-language instructions
- Includes follow-up appointments and warning signs to watch for
Manual Mode (No FHIR Connection)
If no EHR is connected, the agent will prompt you to provide patient data manually. Useful for small practices, telehealth, or demos.
Ask: "Draft a SOAP note — I'll provide the patient data manually."
The agent will ask for:
- - Chief complaint and HPI
- Vitals
- Active conditions and medications
- Assessment and plan outline
Hosted Backend (Credit-Based Generation)
For high-volume use or team deployments, a managed API backend handles generation, audit logging, and HIPAA-aligned data handling.
Set these variables to enable:
CODEBLOCK16
When set, document generation routes through the hosted backend instead of the local LLM. Credits are deducted per document generated. Visit [your site] to purchase credits and manage your account.
Hosted backend advantages:
- - Audit log of every document draft (for compliance)
- No patient data stored — stateless processing
- Team accounts with per-provider usage tracking
- 99.9% uptime SLA
Data Privacy & HIPAA Considerations
- - Local mode: Patient data is fetched into the agent's context for the duration of the session only. No data is written to disk by this skill.
- Hosted mode: Requests are processed statelessly. No PHI is retained after response delivery. Review the hosted backend's BAA before use in production.
- Audit trail: Clinicians should save final signed documents in their EHR per their organization's policies. This skill generates drafts only.
- De-identification: For development and testing, use
FHIR_SANDBOX_MODE=true with synthetic data only.
🔒 Before using with real patient data, ensure your deployment satisfies your organization's HIPAA security requirements and that a Business Associate Agreement (BAA) is in place with any third-party service.
Troubleshooting
"FHIR connection failed: 401 Unauthorized"
- - Token may have expired. The skill auto-refreshes tokens, but check that
FHIR_CLIENT_SECRET is current. - Confirm your app registration is approved and not in sandbox-only mode.
"Patient not found"
- - Try searching by MRN instead of name (name matching varies by EHR).
- Check that your app has
Patient.read and Patient.search scopes granted.
"Missing vitals / labs in output"
- - The patient may not have recent observations in the EHR.
- The agent will flag missing data sections in the draft and prompt you to fill them in manually.
"SMART on FHIR scopes error"
- - Ensure your registered app includes these scopes:
INLINECODE8
Sandbox mode not working
- - Public HAPI sandbox: INLINECODE9
- Confirm
FHIR_SANDBOX_MODE=true is set and FHIR_BASE_URL is unset or points to the sandbox.
Example Workflows
Full outpatient visit workflow
CODEBLOCK17
Quick prior auth
User: "Generate a prior auth for Ozempic for this patient — payer is Aetna."
Agent: [Pulls active conditions, labs (HbA1c), current meds]
"Draft PA narrative ready. Diagnosis: T2DM (E11.9). Supporting:
HbA1c 8.4% (2026-02-01), inadequate response to Metformin 2000mg.
Do you want to add any additional clinical notes before I finalize?"
Version History
| Version | Date | Changes |
|---|
| 1.0.4 | 2026-03-29 | Fixed misleading ANTHROPICAPIKEY comment; clarified patientcontext is forwarded to Anthropic when backend is used; added CORS production warning. |
| 1.0.3 |
2026-03-29 | Fixed env var declarations (moved optional vars out of requiredEnv); added ANTHROPICAPI_KEY to optionalEnv with context; added PHI/privacy warning. |
| 1.0.0 | 2026-03-29 | Initial release. SOAP, referral, prior auth, discharge, AVS. SMART on FHIR auth. Sandbox mode. |
Questions or issues? Open a GitHub issue or reach out via the OpenClaw Discord.
临床文档助手
概述
该技能使OpenClaw代理能够连接到任何符合FHIR R4标准的电子健康记录系统,检索结构化患者数据,并生成高质量的临床文档草稿。它涵盖了门诊和住院场景中最耗时的文档类型。
支持的文档类型:
- - SOAP记录(主观/客观/评估/计划)
- 转诊信函(专科、影像、治疗)
- 预授权申请(保险)
- 出院小结
- 护理计划叙述
- 面向患者的就诊后摘要
支持的FHIR后端:
- - Epic(基于FHIR的SMART)
- Cerner(Millennium)
- Azure健康数据服务
- HAPI FHIR(公共测试沙盒)
- 任何符合R4标准的服务器
⚠️ 临床免责声明: 所有输出均为文档草稿,需由持证临床医生审阅、编辑和签署。本技能不提供临床建议、诊断或处方。
🔒 隐私/受保护健康信息警告: FHIR数据仅在会话期间提取到代理的上下文中,本技能不会将其写入磁盘。如果您使用托管后端(CLINICALDOCAPIURL),患者上下文将传输到该服务器——请仅在符合HIPAA要求的环境中使用您控制的后端。除非已签署业务伙伴协议,否则请勿将真实患者数据与第三方托管后端一起使用。 对于开发和测试,请始终使用FHIRSANDBOX_MODE=true并仅使用合成数据。
快速入门(沙盒模式——无需电子健康记录系统)
设置FHIRSANDBOXMODE=true以使用公共HAPI R4沙盒。无需凭据。非常适合测试和开发。
bash
export FHIRSANDBOXMODE=true
然后向您的代理提问:
从FHIR沙盒中提取患者John Smith,并为今天的高血压随访起草一份SOAP记录。
身份验证
本技能使用基于FHIR的SMART(OAuth2)进行电子健康记录系统连接。每个环境只需设置一次。
第1步——在您的电子健康记录系统中注册应用
每个电子健康记录系统都有其开发者门户:
- - Epic: https://fhir.epic.com → 创建非生产应用 → 记录客户端ID
- Cerner: https://code.cerner.com → 注册应用 → 记录客户端ID + 密钥
- Azure AHDS: Azure门户 → FHIR服务 → 身份验证
第2步——设置环境变量
bash
export FHIRBASEURL=https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4
export FHIRCLIENTID=your-client-id
export FHIRCLIENTSECRET=your-client-secret
export FHIRTOKENURL=https://fhir.epic.com/interconnect-fhir-oauth/oauth2/token
第3步——测试连接
向代理提问:
检查我的FHIR连接状态。
代理将尝试获取令牌并调用GET /metadata,然后报告结果。
FHIR数据检索
代理仅提取所请求文档所需的资源。所有调用均为只读GET请求。
患者查找
查找名为[name]出生于[DOB]的患者
查找MRN为1234567的患者
搜索姓氏为Rodriguez的患者
内部调用:
GET /Patient?name=Rodriguez&birthdate=1975-04-12
GET /Patient/[id]
病情列表
该患者有哪些活动性病情?
调用:
GET /Condition?patient=[id]&clinical-status=active
用药列表
提取患者[id]的当前用药
调用:
GET /MedicationRequest?patient=[id]&status=active
近期生命体征
获取该患者最近的生命体征数据
调用:
GET /Observation?patient=[id]&category=vital-signs&sort=-date&count=10
实验室结果
提取近期实验室结果——重点关注HbA1c和基础代谢面板
调用:
GET /Observation?patient=[id]&category=laboratory&sort=-date&count=20
就诊历史
显示过去6个月的就诊记录
调用:
GET /Encounter?patient=[id]&date=ge2025-09-01&_sort=-date
文档生成
一旦检索到患者数据,即可要求代理生成任何文档类型。
SOAP记录
触发短语:
- - 为今天的就诊起草一份SOAP记录
- 为该患者的糖尿病随访写一份SOAP记录
- 生成一份临床记录——主诉为胸痛
代理执行的操作:
- 1. 检索活动性病情、当前用药、近期生命体征和相关实验室结果
- 询问您任何额外的主观信息(主诉、现病史)
- 将记录结构化为S/O/A/P部分
- 标记任何数据缺失(缺少生命体征、无近期实验室结果)
示例输出结构:
主观:
患者为58岁男性,因常规糖尿病随访就诊。
自述自药物调整以来精力有所改善。无低血糖发作。
否认胸痛、气短或下肢水肿。
客观:
生命体征(2026-03-15):血压132/78,心率72,体重198磅,BMI 29.4
HbA1c(2026-02-10):7.2%(较11月的7.9%下降)
当前用药:二甲双胍1000mg每日两次,赖诺普利10mg每日一次
评估:
- 1. 2型糖尿病——改善中,已达目标
- 高血压——已控制
计划:
- 1. 继续当前治疗方案
- 3个月后复查HbA1c
- 已安排年度眼科转诊
- 3个月后或如有问题提前复诊
转诊信函
触发短语:
- - 为该患者写一份转诊至心内科的信函
- 起草一份转诊至陈医生进行物理治疗的信函
- 生成一份腰椎MRI影像转诊
代理执行的操作:
- 1. 提取相关病情、用药和近期就诊记录
- 询问转诊医生姓名、专科和临床问题
- 格式化一份包含临床背景的专业转诊信函
示例:
[日期]
事由:[患者姓名],出生日期[日期],MRN[编号]
尊敬的[专科医生]医生:
我特此将上述患者转诊至您处进行心内科评估。
[患者]为64岁女性,有高血压和高脂血症病史,
近6周出现劳力性呼吸困难。近期心电图显示非特异性ST段改变。
尚未进行超声心动图检查。
当前用药:氨氯地平5mg,阿托伐他汀40mg,阿司匹林81mg。
感谢您的评估和建议。
此致
[转诊医生]
预授权申请
触发短语:
- - 为[药物/操作]起草一份预授权申请
- 为该患者生成一份Humira的预授权申请
- 写一份腰椎MRI的预授权申请——保险公司为BlueCross
代理执行的操作:
- 1. 从活动性病情中检索诊断代码(ICD-10)
- 查找所请求项目的典型HCPCS/CPT代码
- 生成结构化的预授权叙述,包含临床理由
- 列出支持该病例的实验室或影像结果
生成的关键字段:
- - 会员ID(来自输入)
- 申请医生NPI(来自输入)
- 诊断代码(来自FHIR Condition资源)
- 所请求的服务+操作/药物代码
- 临床理由叙述
- 支持性文档清单
出院小结
触发短语:
- - 为该患者生成一份出院小结
- 起草一份出院记录——患者今天出院回家
代理执行的操作:
- 1. 提取当前/近期就诊、活动性病情、操作和用药
- 询问入院诊断、住院过程总结和出院指导
- 格式化一份包含随访计划的完整出院小结
就诊后摘要(面向患者)
触发短语:
- - 为该患者写一份通俗易懂的就诊后摘要
- 用通俗语言为该患者生成一份就诊后摘要
代理执行的操作:
- 1. 将临床记录内容翻译成通俗英语(八年级阅读水平)
- 列出用药及通俗语言说明
- 包含随访预约和需注意的警示信号
手动模式(无FHIR连接)
如果未连接电子健康记录系统,代理将提示您手动提供患者数据。适用于小型诊所、远程医疗或演示。
提问:起草一份SOAP记录——我将手动提供患者数据。
代理将要求提供:
- - 主诉和现病史
- 生命体征
- 活动性病情和用药
- 评估和计划大纲
托管后端(基于积分的生成)
对于高使用量或团队部署,托管API后端负责生成、审计日志和符合HIPAA要求的数据处理。
设置