annotating-variants
Annotates VCF variants and normalizes HGVS nomenclature with public, license-free annotators…
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
$ npx -y skills add maziyarpanahi/openmed --skill resolving-clinical-context --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/resolving-clinical-contextContext preview
The summary Claude sees to decide when to auto-load this skill.
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
name: resolving-clinical-context 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." license: Apache-2.0 metadata: project: OpenMed category: clinical-nlp pairs: after version: "1.0"
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.
problem-list building, or analytics.
family-history vs. patient, historical vs. active, or hedged/uncertain findings.
and need the upstream signal.
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)`resolve_span_context` returns a `ClinicalContextResult(negation, temporality, certainty)`. For a downstream-grounding-shaped record use `assert_context_axes`, which returns a `ClinicalAssertion` with a `.to_dict()` that omits unset axes.
1. **Get entities and their context window.** From `analyze_text`, take each entity's surface text and the surrounding sentence (or the whole short note) as the modifier window. The ConText helpers accept a string, a span mapping with a `text`-like key, or any object exposing `.text`, plus optional `modifier_hits`. 2. **Resolve negation** with `resolve_negation(span, window)` → `AFFIRMED` or `NEGATED`. It uses a NegEx/ConText cue lexicon ("denies," "no evidence of," "without," "negative for"), masks **pseudo-negation** ("not ruled out," "cannot be excluded") so those don't refute the concept, and counts true cues with even/odd parity so double-negation is deterministic. 3. **Resolve temporality** with `resolve_temporality(span, window)` → `RECENT` (default), `HISTORICAL` ("history of," "h/o," "s/p," "resolved," "PMH"), or `HYPOTHETICAL` ("if," "should," "in case of"). A conditional span is treated as hypothetical even if a historical cue is also present. 4. **Resolve uncertainty** with `resolve_uncertainty(span, window)` → `CERTAIN` or `UNCERTAIN` ("concern for," "suspicious for," "rule out," "probable," "vs," "r/o"). Uncertain spans are **flagged, not dropped**. 5. **Apply the axes downstream.** Drop or refute `NEGATED` spans; route `HISTORICAL` to inactive/resolved status; do not record `HYPOTHETICAL` spans as present; mark `UNCERTAIN` spans provisional. Use the constants, not string literals, so a vocabulary change doesn't silently break comparisons.
Disease/Finding entities. Without context resolution, every mention — including negated and historical ones — would be (wrongly) treated as present.
resolve_temporality, resolve_uncertainty, resolve_span_context, assert_context_axes, ClinicalAssertion` and the `NEGATED/AFFIRMED`, `HISTORICAL/RECENT/HYPOTHETICAL`, `CERTAIN/UNCERTAIN` constants.
`ClinicalContextResult` so active vs. resolved vs. historical is decided correctly and negated mentions are excluded.
`temporality=historical` → inactive/resolved `clinicalStatus`; `certainty=uncertain` → `verificationStatus=provisional`. The layer emits the axis; it does not build the FHIR record.
document — a negation cue three sentences away should not flip an affirmed finding. Segment first (`segmenting-clinical-sections`) for long notes.
affirmed-but-uncertain, not negated. The negation layer masks these cues; the u
Local-first healthcare AI: clinical NER and HIPAA PII de-identification on hardware you control. 2,200+ medical models, 35 model-backed PII languages, and Python, MLX, Android and browser runtimes. Apache-2.0 SDK.
Repo: maziyarpanahi/openmed
Annotates VCF variants and normalizes HGVS nomenclature with public, license-free annotators…
Choose the first OpenMed workflow skill for an intake, privacy, extraction, exchange, or…
Package multiple FHIR R4 resources produced from OpenMed output into a single valid…
Adversarially scan already-de-identified clinical text for residual identifiers and emit a…
Produce a signed, reproducible, no-PHI audit trail for an OpenMed de-identification run via…
Generates and verifies 21 CFR Part 11-style audit trails — who/what/when, electronic…