scaffolding-smart-on-fhir
它能做什么
这项技能教智能体如何搭建一个在医院电子健康记录内部打开的网页应用。内容涵盖安全登录步骤,以及应用所请求的权限。
适用场景
- ✓当团队想要一个可以从 Epic 或 Oracle Health 内部打开的临床工具的时候。
- ✓当开发者需要为 EHR 启动配置带 PKCE 的 OAuth 登录流程的时候。
- ✓当项目计划通过 FHIR 获取临床记录,并在本地设备上处理的时候。
技能链接
https://github.com/maziyarpanahi/openmed/blob/master/skills/scaffolding-smart-on-fhir/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我搭建一个能从我们 Epic 病历内部打开的应用,并安全地读取患者的临床记录。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会设置启动请求、服务器设置的发现、登录交换和权限范围。获取记录之后,应用便可以在本地处理它们。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Scaffolding SMART on FHIR
To put an OpenMed-powered tool inside a clinician's EHR (Epic, Cerner/Oracle Health), you build a SMART on FHIR app: a web app the EHR launches with an OAuth2 flow, granting scoped, time-limited access to the patient's FHIR data. The app fetches the clinical notes, then runs OpenMed on-device (de-id + NER) — so PHI is processed locally and only de-identified output, if anything, leaves the browser/host.
When to use
Reach for this when the deliverable is a clinician-facing app embedded in an
EHR, or a standalone app authorizing against an EHR's FHIR endpoint. Triggers:
"SMART on FHIR", "EHR launch", "OAuth2 scopes", "Epic/Cerner app",
"embed OpenMed in the chart". For pulling notes at cohort scale (no UI), use
exporting-bulk-fhir instead.
Two launch flows
- EHR launch — clinician clicks your app in the chart. The EHR opens your
launch_uri?iss=<fhir-base>&launch=<opaque>; you complete OAuth2 and inherit the current patient/encounter context. - Standalone launch — user opens your app directly; it discovers the FHIR server and runs OAuth2, and the user/EHR picks the patient.
Both use SMART App Launch v2: OAuth2 authorization code flow with PKCE
(required in v2), discovered via .well-known/smart-configuration.
Quick start: the launch sequence
1. EHR launch URL:
GET https://app.example/launch?iss=https://ehr.example/fhir&launch=abc123
2. Discover endpoints:
GET https://ehr.example/fhir/.well-known/smart-configuration
-> { "authorization_endpoint": ".../authorize",
"token_endpoint": ".../token",
"code_challenge_methods_supported": ["S256"],
"capabilities": ["launch-ehr","client-public","context-ehr-patient", ...] }
3. Redirect the browser to authorize (PKCE + the launch token):
GET .../authorize?
response_type=code&
client_id=YOUR_CLIENT_ID&
redirect_uri=https://app.example/callback&
scope=launch openid fhirUser patient/DocumentReference.rs patient/Patient.r&
state=RANDOM&
aud=https://ehr.example/fhir&
launch=abc123&
code_challenge=BASE64URL(SHA256(verifier))&
code_challenge_method=S256
4. Callback -> exchange code for token:
POST .../token
grant_type=authorization_code&code=...&redirect_uri=...&
client_id=...&code_verifier=ORIGINAL_VERIFIER
-> { "access_token": "...", "token_type": "Bearer", "expires_in": 3600,
"scope": "patient/DocumentReference.rs ...",
"patient": "Patient-123", "encounter": "Encounter-9",
"id_token": "..." }
5. Call FHIR with the token:
GET https://ehr.example/fhir/DocumentReference?patient=Patient-123&type=clinical-note
Authorization: Bearer <access_token>
The token response carries the launch context (patient, sometimes
encounter, and in v2 a fhirContext array). Use patient to scope every
subsequent query.
Scopes you actually need
SMART v2 scopes are <level>/<Resource>.<permissions> where permissions are a
subset of c r u d s (create/read/update/delete/search) — .rs = read +
search. Request the minimum:
| Scope | Why |
|---|---|
launch |
EHR launch context (omit for standalone; use launch/patient) |
openid fhirUser |
Identify the launching user |
patient/Patient.r |
The in-context patient demographics |
patient/DocumentReference.rs |
Read + search the patient's clinical notes |
patient/Condition.rs |
(optional) reconcile against existing problems |
offline_access |
(optional) refresh token for background work |
Prefer patient/… (current-patient) over user/… (everything the user can see)
to keep the blast radius small. Granular v2 scopes (.rs) are stricter than the
v1 .read/.write forms — use them.
Where OpenMed runs
Notes arrive as DocumentReference → content.attachment (often base64 or a
url to a Binary). Decode, then process locally:
import base64, openmed
note_b64 = document_reference["content"][0]["attachment"]["data"]
note = base64.b64decode(note_b64).decode("utf-8")
# De-identify on-device before anything else touches it
deid = openmed.deidentify(note, method="replace", policy="hipaa_safe_harbor")
# Clinical NER on the (de-identified or raw, per your IRB) text
entities = openmed.analyze_text(deid.text, model_name="disease_detection_superclinical")
# -> render highlights in the SMART app UI, or export FHIR (exporting-to-fhir)
OpenMed models run on
常见问题
它也适用于独立应用吗?
适用。这项技能同时涵盖从病历内启动的 EHR 启动和独立启动。
什么是 PKCE?
它是一种更安全的登录步骤,这项技能说明 SMART App Launch v2 中要求使用它。
它指明了哪些 EHR?
它把 Epic 以及 Cerner 或 Oracle Health 列为目标系统。
详情
作者的原始描述
Scaffold a SMART-on-FHIR app (SMART App Launch v2 — EHR launch and standalone launch, OAuth2 PKCE, scopes, token handling, fhirContext) so an OpenMed-powered tool can run inside Epic or Cerner/Oracle Health. Covers the .well-known/smart-configuration discovery, authorize/token sequence, scopes like patient/DocumentReference.rs and launch/patient, and fetching clinical notes the app then de-identifies and runs NER on locally with OpenMed. Use when the user wants to embed OpenMed inside an EHR, mentions SMART on FHIR, OAuth2 launch, scopes, Epic/Cerner app, or clinician-facing FHIR app. Pairs ad
repo: maziyarpanahi/openmed
热度
- GitHub 星标
- 5.8k
- 排名
- #14730
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
annotating-variants
5.8k帮你的智能体预测基因变异的作用,把 HGVS 名称转换为基因组位置,并使用免费的公共注释工具添加人群频率。
ask-openmed
5.8k帮你的智能体为临床文本请求选择合适的 OpenMed 工作流程,并在可能涉及患者数据时,先进行隐私检查。
assembling-fhir-bundles
5.8k把多份 FHIR 健康记录打包成一个事务 Bundle,可直接发送给 EHR 系统,并正确链接其中的内部引用。
auditing-deid-leakage
5.8k扫描已去标识化的临床文本,查找残留的标识符,例如社会安全号、银行卡号、电子邮件地址和日期,若仍有残留则阻止发布。