Parsing Lab Values logo

Parsing Lab Values

CommunityPopular
maziyarpanahi
parsing-lab-values

Parse laboratory values and reference ranges from clinical text and flag results as low, normal, high, or critical with OpenMed. Use when the user needs to interpret lab results, compute abnormal flags, parse reference ranges like "135-145" or "<5", honor an originating-lab flag (H/L/critical), or turn extracted lab entities into structured high/low/critical signals. Covers openmed.clinical.parse_reference_range, derive_abnormal_flag, ReferenceRange, and AbnormalFlag, with UCUM/LOINC framing. Unit-agnostic — it does not convert units. Pairs after extracting-clinical-entities (lab entities from analyze_text).

Overview

Publishermaziyarpanahi
Repositoryopenmed
Skill nameparsing-lab-values
Stars
5.3K
Forks
677
Bundled files
Instructions only
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by maziyarpanahi on GitHub. Read the source before you install it.

Installation

Install the Parsing Lab Values AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/maziyarpanahi/openmed.git /tmp/openmed
mkdir -p .claude/skills
cp -r /tmp/openmed/skills/parsing-lab-values .claude/skills/parsing-lab-values
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Parsing Lab Values in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Parsing Lab Values on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Parsing Lab Values is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Parsing lab values

Lab results in clinical text arrive as a value, a unit, and a reference range ("Sodium 132 mmol/L (135–145)"). To act on them you need a structured abnormal flag — is 132 low, normal, high, or critical? OpenMed's openmed.clinical lab helpers parse the reference range deterministically and derive the flag, honoring any explicit flag the originating lab already supplied. The helpers are unit-agnostic by design: they compare numbers within a stated range and never convert units, so a mmol/L value is never silently compared against a mg/dL range.

When to use

  • After extracting-clinical-entities surfaces lab/measurement entities and you need to classify each as low / normal / high / critical.
  • The user asks to parse reference ranges, flag abnormal labs, build a flagged labs table, or interpret values like <5, >=10, 0.5 - 1.2.
  • You have an originating-lab flag (H, L, C, HH) and want it honored over a derived comparison.

Quick start

python
from openmed.clinical import (
    parse_reference_range, derive_abnormal_flag, LAB_FLAG_ADVISORY,
)

# Closed range
rng = parse_reference_range("135-145")
# -> {"low": 135.0, "high": 145.0, "low_inclusive": True, "high_inclusive": True}

derive_abnormal_flag(132, rng)            # "low"
derive_abnormal_flag(140, "135-145")      # "normal"  (raw range string accepted)
derive_abnormal_flag(150, "135 to 145")   # "high"

# One-sided bounds
derive_abnormal_flag(7, parse_reference_range("<5"))    # "high" (above the cap)
derive_abnormal_flag(3, parse_reference_range(">=10"))  # "low"

# Honor the lab's own explicit flag (takes precedence over derived comparison)
derive_abnormal_flag(132, "135-145", explicit_flag="C")   # "critical"
derive_abnormal_flag(132, "135-145", explicit_flag="HH")  # "critical"

# Unparseable / non-numeric inputs fail safe rather than guessing
derive_abnormal_flag("pending", "135-145")  # "unknown"
derive_abnormal_flag(132, "see report")     # "unknown"

print(LAB_FLAG_ADVISORY)  # surface this disclaimer with derived flags

AbnormalFlag is one of "low" | "normal" | "high" | "critical" | "unknown". ReferenceRange is a typed mapping of low, high, low_inclusive, high_inclusive.

Workflow

  1. Get value + range + (optional) lab flag from extracted lab entities. The value should be numeric; the range may be a raw string or a parsed mapping.
  2. Parse the reference range with parse_reference_range. It handles closed ranges ("135-145", "0.5 - 1.2", "135 to 145", en/em dashes) and one-sided bounds ("<5", "<=5", ">10", ">=10"). Contradictory or unparseable ranges return empty bounds rather than a guess — by design.
  3. Derive the flag with derive_abnormal_flag(value, range, explicit_flag=). Resolution order: an explicit lab flag wins first (H/HIGH, L/LOW, C/CRIT/CRITICAL, HH/LL → critical, N/NORMAL); an unknown explicit flag returns "unknown" instead of being silently ignored. With no explicit flag, it compares the numeric value against the parsed bounds, respecting inclusive vs. exclusive edges.
  4. Handle "unknown" explicitly. Non-numeric values, empty/unparseable ranges, or unrecognized explicit flags yield "unknown". Treat it as "needs review," not "normal."
  5. Attach the advisory. Surface LAB_FLAG_ADVISORY wherever derived flags are shown — derived flags are heuristic and do not replace the originating laboratory's own diagnostic flagging.

Hand-off to / from OpenMed

  • From extracting-clinical-entities: analyze_text lab/measurement entities give you the value text, unit, and often the reference range; this skill turns them into structured flags. Parse the numeric value out of the entity surface before calling derive_abnormal_flag.
  • OpenMed calls: from openmed.clinical import parse_reference_range, derive_abnormal_flag, ReferenceRange, AbnormalFlag, LAB_FLAG_ADVISORY.
  • To reconciling-problem-lists / FHIR grounding: a critical/high/low flag becomes a FHIR Observation.interpretation code (HL7 v3 ObservationInterpretation: H, L, HH, LL, N). Ground the LOINC code and UCUM unit out-of-process; OpenMed emits the flag, not the terminology binding.

Edge cases & gotchas

  • Unit-agnostic — convert before comparing. The helpers ignore units entirely. If the value and the range are in different units (mg/dL vs mmol/L), the flag is wrong. Normalize units before calling, or only compare value and range that share a unit.
  • Inclusive vs. exclusive edges. "<5" makes 5 the high bound exclusive; a value of exactly 5 flags high. parse_reference_range records high_inclusive=False for < and True for <= — respect it.
  • Critical needs an explicit flag. Derived comparison yields only low/normal/ high. "critical" comes from the lab's explicit flag (C, HH, LL); the helpers do not infer critical thresholds beyond the reference range.
  • Empty bounds are intentional. A range with both bounds missing returns "unknown" from derive_abnormal_flag, not "normal". Don't treat unknown as in-range.
  • Local-first, advisory-only. Runs on-device; flags are decision support, not a diagnosis. Always carry LAB_FLAG_ADVISORY.

Standards & references

Frequently asked questions

What does the Parsing Lab Values AI skill do?

Parse laboratory values and reference ranges from clinical text and flag results as low, normal, high, or critical with OpenMed. Use when the user needs to interpret lab results, compute abnormal flags, parse reference ranges like "135-145" or "<5", honor an originating-lab flag (H/L/critical), or turn extracted lab entities into structured high/low/critical signals. Covers openmed.clinical.parse_reference_range, derive_abnormal_flag, ReferenceRange, and AbnormalFlag, with UCUM/LOINC framing. Unit-agnostic — it does not convert units. Pairs after extracting-clinical-entities (lab entities f...

Why use Parsing Lab Values on TypingMind?

Because you install it once and use it with any model. Parsing Lab Values is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Parsing Lab Values in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/maziyarpanahi/openmed/tree/master/skills/parsing-lab-values. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Parsing Lab Values?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Parsing Lab Values?

As many as you like. As long as a model supports skills, you can use Parsing Lab Values with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Parsing Lab Values AI skill free?

Yes. It is published on GitHub by maziyarpanahi under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇