agentleFS
ashfulcraashfulcra/fulcra-tools/skills/fulcra-lab-results/SKILL.md

fulcra-lab-results

Skill10 starsChanged 3 months agoMITView on GitHub

Parse a lab-report PDF (LabCorp, Quest, hospital labs — any provider) into one canonical Fulcra data track per marker (LDL-C, HbA1c, TSH, ferritin, …). You read the PDF; the fulcra-labs engine normalizes units, validates, and ingests. Verify-before-ingest: nothing is written without passing validation or explicit operator confirmation. Use when the operator says 'parse my labs', 'import my LabCorp/Quest results', or hands over a lab-report PDF.

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read the PDF and produce the extraction schema (below).

    line 58
  2. Very specific:

    Exactly as printed: No unit conversion, no rounding, no inferring a missing unit.

    line 63
  3. Very specific:

    Collection date, not report date: When both appear, collected_at is the *specimen collection* date/time (often "Collected:" / "Date …

    line 66
  4. Very specific:

    Write each pass to its own JSON file (e.g.

    line 70
  5. Distinctive:

    Always dry-run first — it validates and prints a verdict per row without writing anything:

    line 86
  6. Very specific:

    Medical data stays local: Only the numeric values the operator confirms go to Fulcra.

    line 129

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

fulcra-lab-results — lab-report PDFs into per-marker Fulcra tracks

Turn a lab-report PDF into structured, queryable history in the operator's own Fulcra account: one canonical data track per marker (Total Cholesterol, LDL-C, HbA1c, TSH, ferritin, …), regardless of which lab produced the report. Over time, every LDL-C result — LabCorp in March, Quest in September, a hospital draw in between — lands on the same track, so it reads as one time series.

The split: model extracts, code verifies

This is the load-bearing idea. You (the model) do exactly one thing the code can't: read the PDF and transcribe what's printed. Everything else — resolving "CHOL" to total-cholesterol, converting 5.5 mmol/L to 99.1 mg/dL, sanity-checking the value, computing the idempotent id, writing to Fulcra — is done by the deterministic fulcra-labs engine. Do NOT convert units, round, infer a missing unit, or "fix" a value yourself. Transcribe exactly what's on the page; let the engine do the rest.

This pipeline is verify-before-ingest — the deliberate opposite of the media plugins' over-capture. Lab data is medical PII, so a wrong value is worse than a missing one. Nothing reaches Fulcra unless it passes validation (ok) or the operator explicitly confirms a flagged row.

Invocation. The engine is the fulcra-labs console script. From the fulcra-tools repo run it with uv run fulcra-labs <command>; once installed as a tool, just fulcra-labs <command>. All commands take --json for a machine envelope. Run fulcra-labs markers to see the registry.


Where to start

Stateless — no probes. Each PDF is a fresh, operator-gated transaction; there is no cross-session journey to resume into. The intermediate files (pass_a.json, pass_b.json, agreed.json) are ephemeral local scratch, and re-running any step on the same file is a server-side no-op (deterministic source ids), so an interrupted run simply restarts from Intake with the same PDF. The only prerequisites — an authed fulcra account and the fulcra-labs engine — are covered under Invocation above.


The flow

1. Intake

The operator provides one or more PDF paths (or points at a folder). Save any chat-attached PDF to a local path first. Confirm the file(s) you'll work on.

Coming later — portal fetch. A future browser-agent step will pull the PDF straight from the LabCorp / Quest patient portal. For now the operator downloads the PDF themselves and hands you the path. Don't attempt to log into a lab portal.

2. Extract the PDF — TWICE, independently

Read the PDF and produce the extraction schema (below). Then read it again from scratch — a second, independent pass; do not copy the first pass's numbers. Two independent transcriptions that agree are the model-side guard that pairs with the code-side validation.

Transcription rules (both passes):

  • Exactly as printed. No unit conversion, no rounding, no inferring a missing unit. If the unit column is blank, unit_raw is null — never guess it.
  • One row per analyte.
  • Collection date, not report date. When both appear, collected_at is the specimen collection date/time (often "Collected:" / "Date collected"). Capture the report date separately as report_date.
  • Capture the reference range and any H/L/A flag verbatim if present (reference_range_raw, flag_raw).

Write each pass to its own JSON file (e.g. pass_a.json, pass_b.json). Schema and detailed rules: references/extraction-schema.md.

3. Cross-check the two passes

uv run fulcra-labs check pass_a.json pass_b.json --out agreed.json --json

Rows that agree on (marker, value, unit) go into agreed.json (an ingest-ready extraction). Disagreements are listed. For each disagreement, re-read the PDF a third time for just that row and resolve it; if it's still ambiguous, show the operator the exact text and ask. Add any resolved rows into agreed.json. Do not ingest a row the two passes disagreed on until it's resolved.

4. Validate (dry run), confirm, then ingest

Always dry-run first — it validates and prints a verdict per row without writing anything:

uv run fulcra-labs ingest agreed.json --source-doc report.pdf --dry-run --json

Each row gets a verdict:

  • ok — resolved, unit accepted, value plausible → auto-ingestable.
  • review — needs an operator call: unresolved/ambiguous marker, missing or unknown unit, implausible value (a classic unit-mixup catch), or an in-batch duplicate. Reasons are attached.
  • reject — malformed: non-numeric value, no/parse-failed collection date, future or pre-1990 date. Never ingestable.

Show the operator the verdict table. Walk through every review and reject row with its reason. Then get explicit confirmation before the real write. Only after they confirm:

uv run fulcra-labs ingest agreed.json --source-doc report.pdf

To push a specific reviewed row through (e.g. an implausible-but-real value the operator vouches for), pass its marker key: --yes-reviewed ldl-c,ferritin. Never blanket-confirm review rows on the operator's behalf.

The engine resolves-or-creates each marker's track on first use (idempotently), then writes each ok row. Re-running is safe: the deterministic source id makes a re-ingest a server-side no-op.

5. Report back

Summarize: markers ingested, tracks newly created vs adopted, the review/reject queue (with reasons and what you did about each), and any in-run dedupe skips. Point the operator at Context Web to browse the tracks. Use fulcra-labs status to show per-track observation counts.


Safety rules

  • Never guess a unit. A blank unit is null; the engine holds it for review. Guessing a unit is the single most dangerous error this pipeline can make.
  • Never convert or round in extraction. Transcribe as printed; the engine converts.
  • Never ingest a review or reject row without explicit operator confirmation (and even then only review rows, via --yes-reviewed). reject rows never ingest.
  • Medical data stays local. Only the numeric values the operator confirms go to Fulcra. Source PDFs are archived to ~/.config/fulcra-labs/documents/ on this machine only — never uploaded.
  • Don't soft-delete tracks. Fulcra has no per-event delete; cleanup is an operator decision.
  • Collection date is the event time, not the report date.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.