# Extracting Lab Tables

Detects and extracts tabular laboratory panels from PDFs, scans, and images into...

- Repository: https://github.com/maziyarpanahi/openmed (5755 stars)
- Category: Documents
- License: Apache-2.0
- Last updated: 2026-10-31
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add maziyarpanahi/openmed --skill extracting-lab-tables -g -a claude-code -y`
Codex: `npx skills add maziyarpanahi/openmed --skill extracting-lab-tables -g -a codex -y`
Cursor: `npx skills add maziyarpanahi/openmed --skill extracting-lab-tables -g -a cursor -y`
Gemini CLI: `npx skills add maziyarpanahi/openmed --skill extracting-lab-tables -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add maziyarpanahi/openmed`

## Description

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, read_table), de-identify embedded PHI with openmed.deidentify, then hand structured rows to LOINC/UCUM mapping and openmed.clinical lab flagging. Image/CSV/TSV intake is supported; PDF/DOCX raise UnsupportedDocumentError, render those to images or text first.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# 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

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