extracting-lab-tables
What it does
This skill turns laboratory result tables from PDFs, scans, photos and spreadsheets into clean structured rows. It is for teams who need lab values as data rather than as images.
When to use it
- ✓When a lab report is a scanned image, photo or PDF page and you need the results as rows.
- ✓When a lab export is a CSV and its columns must be identified as value, unit, range or flag.
- ✓When lab rows must be prepared for code mapping and a FHIR Observation.
Skill link
https://github.com/maziyarpanahi/openmed/blob/master/skills/extracting-lab-tables/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Turn this scanned CBC lab report into rows with the test name, value, unit, reference range and abnormal flag.”
5 new skills a week. 1 minute to read.
How it works
The agent reads the table on the device with text recognition, rebuilds the grid of rows and columns, redacts any patient details in the table, and returns clean rows.
Technical content (original SKILL.md)
Original text by the author, straight from 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
FAQ
Does it code the tests to LOINC?
No. Coding to LOINC and unit normalization come in a later step.
Does it keep patient details?
No. It redacts any patient details embedded in the table before returning the rows.
Which abnormal flags does it recognize?
It looks for flags such as high, low and critical in the table.
Details
Original description by the author
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
Popularity
- GitHub stars
- 5.8k
- Ranking position
- #14701
- License
- Apache-2.0
- Updated
- 11/2/2026
Comments
- …
More skills from this repository
annotating-variants
5.8kHelps your agent predict what a genetic variant does, convert HGVS names to genome positions and attach population frequencies, using free public annotators.
ask-openmed
5.8kHelps your agent pick the right OpenMed workflow for a clinical text request, starting with a privacy check whenever patient data may be present.
assembling-fhir-bundles
5.8kPackages several FHIR health records into one transaction Bundle ready to send to an EHR, with the internal references linked correctly.
auditing-deid-leakage
5.8kScans de-identified clinical text for leftover identifiers such as SSNs, card numbers, emails and dates, and blocks release if any remain.
Similar skills
gitcrawl
394kLets your agent search a saved archive of GitHub issues and pull requests, group duplicates, and check their current status on GitHub.
slacrawl
394kLets your agent search and count messages in a local Slack archive, check how fresh that archive is, and refresh it when needed.
goplaces
394kHelps your agent search for places, get their details and reviews, and resolve place names using Google Places, with JSON output for scripts.