
Resolving Clinical Context
Assign negation, temporality, and uncertainty (the ConText axes) to clinical entities...
Install
npx skills add maziyarpanahi/openmed --skill resolving-clinical-context -g -a claude-code -y- Repository
- maziyarpanahi/openmed5.8k
- Category
- Engineering
- Updated
- 4d ago
- License
- Apache-2.0
- Context cost
- Mediumabout 1,544 tokens
- Runs scripts
- No, instructions only
What it does
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.
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/clinicalStatusand need the upstream signal.
Quick start
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)
