segmenting-clinical-sections
できること
このスキルは、医療ノートを病歴、服薬、計画などの名前付きの部分に分ける方法をエージェントに教えます。後の読み取りの手順が、ある語が過去の病歴か、現在の問題かを区別できるようにします。
使う場面
- ✓長い臨床ノートや退院サマリーがあり、各セクションを別々に扱いたいとき。
- ✓機密性の高いセクション、たとえば社会歴に、より厳しいプライバシーのルールが必要なとき。
- ✓セクションの見出しを、標準のLOINCの文書コードに対応づける必要があるとき。
スキルのリンク
https://github.com/maziyarpanahi/openmed/blob/master/skills/segmenting-clinical-sections/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“退院サマリーを、服薬と計画がそれぞれ見られるように、セクションに分けてもらえますか?”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、ノートの中のHPIやALLERGIESなどのセクションの見出しを見つけ、各見出しの下のテキストをまとめます。その後の分析は、そのセクションを文脈として使います。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Segmenting clinical sections
A clinical note is not flat text — it is a sequence of named sections (Chief Complaint, HPI, Past Medical History, Medications, Allergies, Assessment & Plan). The same phrase means different things in different sections: "diabetes" in PMH is historical context, "diabetes" in Assessment & Plan is an active problem, and "penicillin" under Allergies is an adverse-reaction flag, not a current medication. Splitting the note into canonical sections before NER or de-identification gives every downstream OpenMed step the context it needs to be more precise — and lets you process sensitive sections under stricter policies.
When to use
- You have a free-text note, H&P, progress note, or discharge summary and are
about to run NER (
extracting-clinical-entities) or de-identification. - The user wants section detection, header parsing, LOINC section mapping, or per-section processing (e.g. "redact the Social History section harder").
- Downstream NER is over- or under-firing because it can't tell historical PMH mentions from active A&P problems.
Quick start
import re
import openmed
# Synthetic note.
note = """CHIEF COMPLAINT: chest pain.
HPI: 54M with 2 hours of substernal pressure.
PAST MEDICAL HISTORY: type 2 diabetes, prior MI 2019.
MEDICATIONS: metformin 500 mg BID.
ALLERGIES: penicillin (rash).
ASSESSMENT AND PLAN: acute coronary syndrome; start aspirin, admit."""
# Map common header variants -> canonical section + LOINC document-section code.
SECTION_MAP = {
"chief complaint": ("Chief Complaint", "10154-3"),
"hpi": ("History of Present Illness", "10164-2"),
"history of present illness": ("History of Present Illness", "10164-2"),
"past medical history": ("Past Medical History", "11348-0"),
"medications": ("Medications", "10160-0"),
"allergies": ("Allergies", "48765-2"),
"assessment and plan": ("Assessment and Plan", "51847-2"),
}
HEADER_RE = re.compile(r"^(?P<h>[A-Z][A-Za-z /&]+):", re.MULTILINE)
# Split note into (canonical_label, loinc, body) chunks at each header.
chunks, matches = [], list(HEADER_RE.finditer(note))
for i, m in enumerate(matches):
raw = m.group("h").strip().lower()
label, loinc = SECTION_MAP.get(raw, (m.group("h").strip(), None))
body_start = m.end()
body_end = matches[i + 1].start() if i + 1 < len(matches) else len(note)
chunks.append({"section": label, "loinc": loinc,
"text": note[body_start:body_end].strip()})
# Run NER per section — pass the section label downstream as context.
for c in chunks:
ents = openmed.analyze_text(c["text"], model_name="disease_detection_superclinical",
output_format="dict")
c["entities"] = ents
Each chunk now carries its canonical section label and LOINC code, so downstream context resolution can treat PMH findings as historical and A&P findings as active.
Workflow
- Detect section headers. Use header heuristics: a line that is a known header phrase, often uppercase, ending in a colon, at line start. Maintain a synonym map (HPI ↔ History of Present Illness, PMH ↔ Past Medical History, A&P ↔ Assessment and Plan) so variants normalize to one canonical label.
- Normalize to canonical labels and LOINC codes. Map each detected header to
a canonical section name and a LOINC document-section code (e.g. HPI →
10164-2, PMH →11348-0, Medications →10160-0, Allergies →48765-2, A&P →51847-2). Unknown headers keep their literal text and a null code. - Chunk the note into
(section, loinc, body)spans between consecutive headers, preserving original character offsets if you need to map results back. - Process per section. Run
analyze_text/deidentifyon each chunk and carry the section label forward. This is where precision is won: section-aware negation (PMH = historical) and section-specific de-id policy (Social History / Family History often warrant stricter redaction). - Reassemble with provenance. Tag each downstream entity with its source section so the problem-list and context layers can use it.
Hand-off to / from OpenMed
- To
extracting-clinical-entities: feed each section chunk intoopenmed.analyze_textand attach the section label to every entity — section context measurably sharpens entity precision and downstream status assignment. - To
deidentifying-clinical-text: runopenmed.deidentifyper
よくある質問
なぜセクションが重要なのですか?
同じ語でも、病歴と計画では意味が違うことがあるため、セクションが誤りを防ぎます。
名前の匿名化の前に実行しますか?
はい。スキルは、各セクションを正しいルールで処理できるよう、先にセクションに分けるよう勧めています。
どの見出しを知っていますか?
主訴、HPI、PMH、服薬、アレルギー、評価と計画などの標準の臨床の見出しを扱います。
詳細
作者による元の説明
Split a clinical note into canonical sections (Chief Complaint, HPI, PMH, Medications, Allergies, Assessment & Plan, etc.) before running OpenMed NER or de-identification, so section context sharpens downstream precision. Use when the user has a free-text note or discharge summary and wants section-aware processing, header detection, mapping headers to LOINC document-section codes, or per-section NER/de-id. Covers heuristic header detection, normalization to canonical section labels, LOINC/SecTag framing, and why a finding in PMH is historical while the same finding in A&P is active. Hand-off:
repo: maziyarpanahi/openmed
人気
- GitHubのスター
- 5.8k
- ランキング
- #14732
- ライセンス
- 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エージェントが、匿名化済みの臨床テキストに残っている識別子(SSN、カード番号、メール、日付など)をスキャンし、残っていれば公開を止めます。
似ているスキル
gitcrawl
394k保存されたGitHubのイシューとプルリクエストのアーカイブを検索し、重複をまとめ、GitHub上の現在の状態を確認するようエージェントを支援します。
slacrawl
394kローカルのSlackアーカイブ内のメッセージを検索して件数を数え、アーカイブの新しさを確認し、必要に応じて更新するようエージェントを支援します。
goplaces
394kGoogle Placesを使って、場所を検索し、詳細や口コミを取得し、場所の名前を解決するようエージェントを支援します。スクリプト用にJSON出力もできます。