# Resolving Clinical Context

Assign negation, temporality, and uncertainty (the ConText axes) to clinical entities...

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

## Install

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

## Description

Assign negation, temporality, and uncertainty (the ConText axes) to clinical entities extracted by OpenMed, so \"denies chest pain\" is not counted as chest pain and \"history of MI\" is not counted as an active MI. Use after NER when the user needs assertion status, negation detection, family-history / hypothetical / historical flags, or ConText/NegEx-style classification before grounding entities to FHIR or a problem list. Covers openmed.clinical.resolve_negation / resolve_temporality / resolve_uncertainty / resolve_span_context / assert_context_axes, ClinicalAssertion, and the AFFIRMED/NEGATED, RECENT/HISTORICAL/HYPOTHETICAL, CERTAIN/UNCERTAIN constants. Pairs after extracting-clinical-entities.

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

# Resolving clinical context

NER finds *that* a condition was mentioned; it does not tell you whether the
patient **has** it. "Patient denies chest pain," "history of MI," and "rule out
PE" all surface entities that must **not** be recorded as active, present
findings. OpenMed's `openmed.clinical` ConText layer assigns three deterministic
axes to each span, **negation**, **temporality**, **uncertainty**, turning raw
mentions into clinically faithful assertions before they reach a problem list or
FHIR Condition.

## When to use

- Immediately after `extracting-clinical-entities`, before grounding,
  problem-list building, or analytics.
- The user asks for assertion status, negation handling, "is this affirmed?",
  family-history vs. patient, historical vs. active, or hedged/uncertain findings.
- You are about to map entities to FHIR `verificationStatus` /`clinicalStatus`
  and need the upstream signal.

## Quick start

```python
import openmed
from openmed.clinical import (
    resolve_span_context, assert_context_axes,
    NEGATED, HISTORICAL, HYPOTHETICAL, UNCERTAIN,
)

note = "Patient denies chest pain. History of MI. Concern for PE; rule out DVT."

# 1) Extract entities (registry key, HF id, or local path).
ents = openmed.analyze_text(note, model_name="disease_detection_superclinical",
                            output_format="dict")

# 2) Assign ConText axes per entity. Pass the span text plus a window of cues.
for e in ents:
    span = e["word"]                      # entity surface text
    window = note                         # full sentence/note as modifier context
    ctx = resolve_span_context(span, window)
    print(span, "->", ctx.negation, ctx.temporality, ctx.certainty)

# "chest pain" -> negated   recent      certain     (do NOT record as present)
# "MI"         -> affirmed  historical  certain     (past, not active)
# "PE"         -> affirmed  recent      uncertain   (hedged; flag, don't drop)
```

The rest: https://github.com/maziyarpanahi/openmed/blob/HEAD/skills/resolving-clinical-context/SKILL.md
