extracting-lab-tables
できること
このスキルは、PDF、スキャン、写真、スプレッドシートの検査結果の表を、きれいな構造化された行に変換します。検査値を画像ではなくデータとして扱いたいチーム向けです。
使う場面
- ✓検査レポートがスキャン画像、写真、またはPDFのページで、結果を行として取り出す必要があるとき。
- ✓検査のCSVの列が、値、単位、基準範囲、フラグのどれかを特定する必要があるとき。
- ✓検査の行を、コードへの対応づけとFHIRのObservationに備えて準備するとき。
スキルのリンク
https://github.com/maziyarpanahi/openmed/blob/master/skills/extracting-lab-tables/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“このスキャンされたCBCの検査レポートを、検査名、値、単位、基準範囲、異常のフラグを含む行にしてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、端末上の文字認識で表を読み、行と列のグリッドを組み直し、表に埋め込まれた患者の詳細を伏せてから、きれいな行を返します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Extracting lab tables from documents and scans
Lab results arrive as tables: a column of test names, a value column, units, a reference range, and an abnormal flag (H/L/Crit). To use them downstream you must recover that grid from a PDF, scan, or spreadsheet into clean rows — then code each test to LOINC, normalize units with UCUM, and flag abnormals.
This skill is the intake step: it OCRs/parses the table on-device with
openmed.multimodal, de-identifies any embedded PHI, and emits structured rows.
It pairs before OpenMed's clinical helpers — the LOINC/UCUM coding and the
high/low/critical flag are downstream (see parsing-lab-values).
When to use
- You have a lab report as a scanned image / photo / PDF page and need the panel as rows, not pixels.
- The source is a CSV/TSV export and you need columns classified (which is the value, the unit, the range, the flag) and PHI columns redacted.
- You need machine-readable rows to feed LOINC mapping and a FHIR
Observation/DiagnosticReport.
What OpenMed gives you here
openmed.multimodal ships the intake primitives (no heavy deps at import; the
OCR backend loads lazily):
openmed.multimodal.ocr.ocr(image, engine=...)→ anOcrResultwhose.wordsareOcrWord(text, bbox, confidence, page)and.textis the joined string.OcrResult.to_document()bridges each word (with its pixel bbox) into anExtractedDocumentso detected PHI can project back to the source location.read_table(...)→ aTableView(headers,rows,delimiter,has_header,columns) for delimited text;classify_columns(...)labels each column;redact_table(...)→ aRedactedTablewith a PHI-safemanifest.
Engines: Tesseract (pip install "openmed[multimodal]" + the system binary) or
PaddleOCR (pip install "openmed[ocr-paddle]"). ocr() auto-selects the first
installed backend.
Quick start
from openmed.multimodal.ocr import ocr
from openmed.multimodal import read_table, classify_columns, redact_table
# A) Scanned / image lab report -> words with pixel boxes.
result = ocr("cbc_report.png") # OcrResult
for w in result.words[:5]:
print(repr(w.text), w.bbox, round(w.confidence, 2), "p", w.page)
doc = result.to_document() # ExtractedDocument; bbox preserved
# B) Delimited lab export (CSV/TSV) -> classified, PHI-redacted rows.
csv_text = (
"PatientName,Test,Value,Unit,RefRange,Flag\n"
"Jane Roe,Hemoglobin,9.1,g/dL,12.0-15.5,L\n"
"Jane Roe,Glucose,148,mg/dL,70-99,H\n"
)
view = read_table(csv_text) # TableView
view = classify_columns(view) # tag PHI vs data columns
redacted = redact_table(view) # RedactedTable: PatientName redacted
for row in redacted.rows:
print(row) # name column masked; lab data intact
for col in redacted.manifest: # PHI-safe per-column audit manifest
print(col["column_name"], col["assigned_class"], col["action"])
For an OCR'd (image) table, you reconstruct the grid yourself from word boxes (next section) — OCR yields positioned words, not a delimited table.
Workflow
- Detect the source type. CSV/TSV →
read_table. Image/scan →ocr(). PDF/DOCX are not directly parseable (they raiseUnsupportedDocumentError); render PDF pages to images first, or extract their text layer, then OCR. - OCR with positions.
ocr()returnsOcrWords carryingbboxandpage. Keep the boxes — they let you cluster words into rows/columns and project PHI redaction back to pixels. - Reconstruct the grid. Cluster words by their
bboxy into rows, by x into columns. The header row names the columns; align body cells to those x bands. Confidence (OcrWord.confidence) flags shaky cells for review. - Identify the lab columns. Map headers to roles: test name, value,
unit, reference range, flag. For delimited input,
classify_columnstags PHI columns (name/MRN/DOB) soredact_tablemasks them. - De-identify embedded PHI. Patient name/MRN often sit in the table header or
a leading column. Redact those columns (
redact_table) and run free-text cells throughopenmed.deidentifybefore the rows leave the device. - Emit structured rows
{test, value, unit, ref_range, flag}per result and hand off to LOINC/UCUM coding andparsing-lab-values.
Hand-off to / from OpenMed
よくある質問
検査項目をLOINCにコード化しますか?
いいえ。LOINCへのコード化と単位の正規化は、後の段階で行います。
患者の情報は残りますか?
いいえ。表に埋め込まれた患者の詳細は、行を返す前に伏せられます。
どの異常のフラグを認識しますか?
表にある高い、低い、重篤などのフラグを認識します。
詳細
作者による元の説明
Detects and extracts tabular laboratory panels from PDFs, scans, and images into structured rows ready for OpenMed and FHIR. Use when the user has a CBC, CMP, lipid panel, or other lab report as a scanned image / PDF / spreadsheet and needs the test name, value, unit, reference range, and abnormal flag as clean rows. Trigger keywords: lab table extraction, lab panel, OCR labs, table detection, layout analysis, header detection, reference range column, abnormal flag column, LOINC, UCUM, CBC, CMP, structured labs. Pairs before OpenMed: OCR/parse the table on-device (openmed.multimodal.ocr.ocr, r
repo: maziyarpanahi/openmed
人気
- GitHubのスター
- 5.8k
- ランキング
- #14701
- ライセンス
- 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出力もできます。