extract-clinical-entities-to-fhir
它能做什么
这项技能从合成或已去标识化的文本中提取临床实体,并将其映射为 FHIR R4 资源,例如 Condition 或 Observation。适合需要从本地临床文本生成结构化 FHIR 输出的开发者,编码只能来自经批准的来源。
适用场景
- ✓当智能体需要把临床文本转换为 FHIR Condition 或 Observation 资源的时候。
- ✓当你希望把实体提取与临床编码决定分开处理的时候。
- ✓当源文本是合成数据,或已经完成去标识化的时候。
技能链接
https://github.com/maziyarpanahi/openmed/blob/master/skills/extract-clinical-entities-to-fhir/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请从这份合成记录中提取诊断,并把每个诊断转换为 Bundle 中的一个 FHIR Condition。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会运行实体提取,只保留置信度高于阈值且属于已接受标签的实体,将每个实体映射到资源类型,然后组装 Bundle。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Extract clinical entities to FHIR
Separate extraction from clinical coding. OpenMed finds spans and supplies the mechanical FHIR builders; the application decides which resource type and status are clinically appropriate.
Procedure
- Keep the source synthetic, or de-identify it inside the trusted boundary before extraction.
- Run
openmed.analyze_textwith the task-appropriate clinical model. - Filter predictions by label and confidence; preserve offsets in a PHI-safe audit record.
- Map each accepted span to the correct FHIR resource type.
- Add terminology codes only from a user-approved mapping or terminology service. Never invent a code.
- Assemble resources with
to_bundleand validate against the target profile.
Runnable synthetic example
Install the model runtime first with python -m pip install "openmed[hf]".
import json
from openmed import analyze_text
from openmed.clinical.exporters.fhir import to_bundle
note = "Assessment: type 2 diabetes mellitus is stable on metformin."
result = analyze_text(
note,
model_name="disease_detection_superclinical",
confidence_threshold=0.5,
)
resources = [{"resourceType": "Patient", "id": "synthetic-patient"}]
for index, entity in enumerate(result.entities, start=1):
if entity.label.upper() not in {"CONDITION", "DIAGNOSIS", "DISEASE"}:
continue
resources.append(
{
"resourceType": "Condition",
"id": f"condition-{index}",
"clinicalStatus": {
"coding": [
{
"system": (
"http://terminology.hl7.org/CodeSystem/"
"condition-clinical"
),
"code": "active",
}
]
},
"verificationStatus": {
"coding": [
{
"system": (
"http://terminology.hl7.org/CodeSystem/"
"condition-ver-status"
),
"code": "confirmed",
}
]
},
# A text-only CodeableConcept is preferable to an invented code.
"code": {"text": entity.text},
"subject": {"reference": "Patient/synthetic-patient"},
}
)
if len(resources) == 1:
raise RuntimeError("No condition spans met the label and confidence rules")
bundle = to_bundle(resources, doc_id="synthetic-note-001")
print(json.dumps(bundle, indent=2))
Safety checks
- Do not put raw identifiers, source text, or reversible mappings in logs,
OperationOutcome.diagnostics, or trace metadata. - Keep a patient identity service separate from extracted clinical facts.
- Preserve negation, temporality, and experiencer context before asserting a resource as active or confirmed.
- Use a text-only
CodeableConceptwhen no approved code is available. - Validate the Bundle against the receiver's FHIR and profile requirements.
- Do not bundle restricted terminologies; use the user's licensed service.
Repository example
Read and run the redaction-to-FHIR walkthrough for an offline-friendly pipeline with deterministic extraction.
常见问题
它会自行添加 ICD-10 之类的编码吗?
不会。编码只能来自你批准的映射,或来自术语服务。
允许使用哪些文本?
指引要求使用合成文本,或在可信边界内、提取之前已完成去标识化的文本。
它会检查输出结果吗?
指引要求根据目标配置文件(profile)验证资源。
详情
作者的原始描述
Extract clinical entities from synthetic or already de-identified text with OpenMed and map them into deterministic FHIR R4 resources and a Bundle. Use when an agent must turn local clinical NER output into Conditions, MedicationStatements, Observations, or other FHIR resources without inventing terminology codes.
repo: maziyarpanahi/openmed
热度
- GitHub 星标
- 5.8k
- 排名
- #14698
- 许可证
- 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扫描已去标识化的临床文本,查找残留的标识符,例如社会安全号、银行卡号、电子邮件地址和日期,若仍有残留则阻止发布。