Chuyển đến nội dung
Skillpedia
Phân tích và bảng tính5.8k · #14701

extracting-lab-tables

Skill này làm gì

Skill này chuyển bảng kết quả xét nghiệm từ PDF, bản quét, ảnh và bảng tính thành các dòng có cấu trúc gọn gàng. Dành cho các nhóm cần giá trị xét nghiệm dưới dạng dữ liệu thay vì hình ảnh.

Khi nào nên dùng

  • ✓Khi báo cáo xét nghiệm là bản quét, ảnh chụp hoặc trang PDF và bạn cần kết quả dưới dạng dòng.
  • ✓Khi bản xuất xét nghiệm là tệp CSV và các cột phải được nhận diện là giá trị, đơn vị, khoảng hoặc cờ.
  • ✓Khi các dòng xét nghiệm phải được chuẩn bị để ánh xạ mã và tạo FHIR Observation.

Liên kết skill

https://github.com/maziyarpanahi/openmed/blob/master/skills/extracting-lab-tables/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/maziyarpanahi/openmed/blob/master/skills/extracting-lab-tables/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Hãy chuyển báo cáo CBC quét này thành các dòng có tên xét nghiệm, giá trị, đơn vị, khoảng tham chiếu và cờ bất thường.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent đọc bảng trên thiết bị bằng nhận dạng văn bản, dựng lại lưới hàng và cột, khử nhận dạng mọi chi tiết bệnh nhân có trong bảng, rồi trả về các dòng sạch.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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=...) → an OcrResult whose .words are OcrWord(text, bbox, confidence, page) and .text is the joined string. OcrResult.to_document() bridges each word (with its pixel bbox) into an ExtractedDocument so detected PHI can project back to the source location.
  • read_table(...) → a TableView (headers, rows, delimiter, has_header, columns) for delimited text; classify_columns(...) labels each column; redact_table(...) → a RedactedTable with a PHI-safe manifest.

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

  1. Detect the source type. CSV/TSV → read_table. Image/scan → ocr(). PDF/DOCX are not directly parseable (they raise UnsupportedDocumentError); render PDF pages to images first, or extract their text layer, then OCR.
  2. OCR with positions. ocr() returns OcrWords carrying bbox and page. Keep the boxes — they let you cluster words into rows/columns and project PHI redaction back to pixels.
  3. Reconstruct the grid. Cluster words by their bbox y 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.
  4. Identify the lab columns. Map headers to roles: test name, value, unit, reference range, flag. For delimited input, classify_columns tags PHI columns (name/MRN/DOB) so redact_table masks them.
  5. 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 through openmed.deidentify before the rows leave the device.
  6. Emit structured rows {test, value, unit, ref_range, flag} per result and hand off to LOINC/UCUM coding and parsing-lab-values.

Hand-off to / from OpenMed

Câu hỏi thường gặp

Nó có mã hóa xét nghiệm sang LOINC không?

Không. Mã hóa LOINC và chuẩn hóa đơn vị được thực hiện ở bước sau.

Nó có giữ lại chi tiết bệnh nhân không?

Không. Nó khử nhận dạng mọi chi tiết bệnh nhân nhúng trong bảng trước khi trả về các dòng.

Nó nhận diện những cờ bất thường nào?

Nó tìm các cờ như cao, thấp và nguy kịch trong bảng.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
5.8k
Vị trí xếp hạng
#14701
Giấy phép
Apache-2.0
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự