Parsing Trial Eligibility logo

Parsing Trial Eligibility

CommunityPopular
maziyarpanahi
parsing-trial-eligibility

Parses free-text clinical-trial eligibility criteria into structured inclusion and exclusion logic, then matches them against patient facts that OpenMed extracted. Use when the user wants to turn a ClinicalTrials.gov eligibility block into machine-readable rules, screen a synthetic patient for trial fit, or explain why a patient does or does not meet criteria. Trigger keywords: eligibility criteria, inclusion, exclusion, trial matching, patient screening, criteria parsing, eligibilityModule, age/sex gates. Pairs after OpenMed and after searching-clinicaltrials: consume the eligibilityModule text from a study, structure it, and match against conditions, medications, labs, and demographics from openmed.analyze_text. Decision-support only — never autonomous enrollment.

Overview

Publishermaziyarpanahi
Repositoryopenmed
Skill nameparsing-trial-eligibility
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 Trial Eligibility 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-trial-eligibility .claude/skills/parsing-trial-eligibility
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Parsing Trial Eligibility 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 Trial Eligibility 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 Trial Eligibility 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 trial eligibility & matching patients

A ClinicalTrials.gov study exposes its eligibility as a single free-text block (protocolSection.eligibilityModule.eligibilityCriteria) plus a few typed fields (sex, minimumAge, maximumAge, healthyVolunteers). This skill turns that prose into structured inclusion / exclusion criteria and matches each rule against patient facts that OpenMed extracted — producing an explainable eligible | ineligible | unknown verdict per criterion.

This is decision support, not enrollment. The output is a candidate list and a rationale for a clinician to review, never an automated eligibility decision.

When to use

  • You pulled a study with searching-clinicaltrials and need its eligibility as machine-readable rules.
  • You have a (synthetic) patient profile and want to screen it against one or many trials, with a per-criterion reason.
  • You want to highlight which patient facts are missing to decide a criterion.

Quick start

The typed gates are deterministic — apply them first. The free-text criteria need parsing into bullet-level inclusion/exclusion items.

python
# Study from ClinicalTrials.gov v2 (see searching-clinicaltrials)
elig = study["protocolSection"]["eligibilityModule"]

raw = elig["eligibilityCriteria"]            # free text, often markdown bullets
sex = elig.get("sex", "ALL")                 # ALL | FEMALE | MALE
min_age = elig.get("minimumAge")             # e.g. "18 Years"
max_age = elig.get("maximumAge")             # e.g. "75 Years"
healthy_ok = elig.get("healthyVolunteers")   # bool

def split_criteria(text: str) -> dict[str, list[str]]:
    """Split the prose into inclusion / exclusion bullet lists."""
    sections, current = {"inclusion": [], "exclusion": []}, None
    for line in text.splitlines():
        low = line.strip().lower()
        if "inclusion criteria" in low:
            current = "inclusion"; continue
        if "exclusion criteria" in low:
            current = "exclusion"; continue
        bullet = line.strip(" -*•\t")
        if bullet and current:
            sections[current].append(bullet)
    return sections

criteria = split_criteria(raw)

Each bullet is a candidate rule. Structure it into a comparable predicate: condition present/absent, lab threshold, age/sex, prior-therapy, performance status (e.g. ECOG ≤ 2), pregnancy status, etc.

python
from dataclasses import dataclass

@dataclass
class Criterion:
    kind: str            # "condition" | "lab" | "age" | "sex" | "medication" | "other"
    polarity: str        # "include" | "exclude"
    text: str            # original bullet
    target: str | None   # e.g. "ECOG", "diabetes", "metformin"
    op: str | None = None  # "<=", ">=", "==", "present", "absent"
    value: float | str | None = None

Matching against OpenMed-extracted patient facts

Build the patient profile from openmed.analyze_text outputs plus structured demographics, then evaluate each criterion to a three-valued result.

python
patient = {
    "age": 61, "sex": "FEMALE",
    "conditions": {"type 2 diabetes", "hypertension"},   # OpenMed Disease spans
    "medications": {"metformin", "lisinopril"},          # OpenMed Pharmaceutical
    "labs": {"hba1c": 8.1, "ecog": 1},                   # from a labs extractor
}

def evaluate(c: Criterion, p: dict) -> str:
    if c.kind == "sex" and c.target:
        return "pass" if p["sex"] == c.target or c.target == "ALL" else "fail"
    if c.kind == "condition" and c.target:
        has = c.target.lower() in {x.lower() for x in p["conditions"]}
        ok = has if c.polarity == "include" else not has
        return "pass" if ok else "fail"
    if c.kind == "lab" and c.target and c.target.lower() in p["labs"]:
        v = p["labs"][c.target.lower()]
        cmp = {"<=": v <= c.value, ">=": v >= c.value, "==": v == c.value}
        return "pass" if cmp.get(c.op, False) else "fail"
    return "unknown"   # fact not present → needs human review, never assume pass

Aggregate: a patient is a candidate only if every inclusion criterion is pass (or unknown, flagged) and every exclusion criterion is not fail. Surface the unknown items prominently — missing data is the most common reason a real screen needs a human.

Workflow

  1. Apply the typed gates (sex, minimumAge, maximumAge) — cheap, exact.
  2. Split the free text into inclusion / exclusion bullets.
  3. Structure each bullet into a Criterion (kind, polarity, target, op, value). NER on the bullet via openmed.analyze_text finds the condition / drug / lab targets; numeric thresholds come from a regex/units pass.
  4. Evaluate each criterion against the OpenMed-derived patient profile to pass | fail | unknown.
  5. Report a verdict with a per-criterion rationale and an explicit list of unknown facts that block a confident decision.

Hand-off to / from OpenMed

  • From OpenMed (patient side). Run openmed.analyze_text over the patient note to populate conditions (Disease), medications (Pharmaceutical), and oncology context; normalize via coding-icd10 / normalizing-rxnorm so comparisons are code-based, not string-based.
  • From OpenMed (trial side). Run openmed.analyze_text over each eligibility bullet to identify the condition / drug / lab the rule references, improving target extraction beyond keyword spotting.
  • From searching-clinicaltrials. Studies arrive with their eligibilityModule already populated — this skill is the next stage.
  • Keep everything local: matching runs on-device against the patient profile; no PHI leaves the process. Examples here use a synthetic patient.

Edge cases & gotchas

  • Three-valued logic is mandatory. Treating unknown as pass enrolls ineligible patients; treating it as fail drops eligible ones. Surface it.
  • Negation & temporality. "No prior chemotherapy" vs "prior chemotherapy" flips polarity; "active infection" vs "history of infection" differs in time. Use openmed.clinical (see resolving-clinical-context) so negated/historical mentions are not counted as present.
  • Units & ranges. "Creatinine clearance ≥ 60 mL/min", "platelets > 100,000/µL" — normalize units before comparing; LOINC grounding (mapping-loinc) helps.
  • Compound bullets. One sentence may carry several predicates ("age 18-75 and ECOG 0-1"). Split into atomic criteria.
  • Inconsistent headings. Some studies omit explicit "Inclusion/Exclusion" labels or use "Key Inclusion Criteria". Default unlabeled bullets to inclusion and flag for review.
  • Not a medical device. Output is a ranked candidate list with rationale for a clinician — never an autonomous enrollment or exclusion decision.

Standards & references

Frequently asked questions

What does the Parsing Trial Eligibility AI skill do?

Parses free-text clinical-trial eligibility criteria into structured inclusion and exclusion logic, then matches them against patient facts that OpenMed extracted. Use when the user wants to turn a ClinicalTrials.gov eligibility block into machine-readable rules, screen a synthetic patient for trial fit, or explain why a patient does or does not meet criteria. Trigger keywords: eligibility criteria, inclusion, exclusion, trial matching, patient screening, criteria parsing, eligibilityModule, age/sex gates. Pairs after OpenMed and after searching-clinicaltrials: consume the eligibilityModule...

Why use Parsing Trial Eligibility on TypingMind?

Because you install it once and use it with any model. Parsing Trial Eligibility 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 Trial Eligibility in TypingMind?

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

Which AI models can use Parsing Trial Eligibility?

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 Trial Eligibility?

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

Is the Parsing Trial Eligibility 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 👇