Agent Skillsmaziyarpanahi/openmed › resolving-clinical-context

resolving-clinical-context

GitHub

为临床文本中的实体解析否定、时间性和不确定性状态,区分现症与既往史,辅助FHIR映射。

skills/resolving-clinical-context/SKILL.md maziyarpanahi/openmed

Trigger Scenarios

需要判断疾病是否确诊或排除 提取临床实体后需标注断言状态

Install

npx skills add maziyarpanahi/openmed --skill resolving-clinical-context -g -y
More Options

Use without installing

npx skills use maziyarpanahi/openmed@resolving-clinical-context

指定 Agent (Claude Code)

npx skills add maziyarpanahi/openmed --skill resolving-clinical-context -a claude-code -g -y

安装 repo 全部 skill

npx skills add maziyarpanahi/openmed --all -g -y

预览 repo 内 skill

npx skills add maziyarpanahi/openmed --list

SKILL.md

Frontmatter
{
    "name": "resolving-clinical-context",
    "license": "Apache-2.0",
    "metadata": {
        "pairs": "after",
        "project": "OpenMed",
        "version": "1.0",
        "category": "clinical-nlp"
    },
    "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."
}

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

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.

Workflow

  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.

Hand-off to / from OpenMed

  • From extracting-clinical-entities: this skill consumes analyze_text Disease/Finding entities. Without context resolution, every mention — including negated and historical ones — would be (wrongly) treated as present.
  • OpenMed calls: from openmed.clinical import resolve_negation, resolve_temporality, resolve_uncertainty, resolve_span_context, assert_context_axes, ClinicalAssertion and the NEGATED/AFFIRMED, HISTORICAL/RECENT/HYPOTHETICAL, CERTAIN/UNCERTAIN constants.
  • To reconciling-problem-lists: feed each entity plus its ClinicalContextResult so active vs. resolved vs. historical is decided correctly and negated mentions are excluded.
  • To FHIR grounding: negation=negatedverificationStatus=refuted; temporality=historical → inactive/resolved clinicalStatus; certainty=uncertainverificationStatus=provisional. The layer emits the axis; it does not build the FHIR record.

Edge cases & gotchas

  • Window scoping matters. Pass a sentence-sized window, not the whole document — a negation cue three sentences away should not flip an affirmed finding. Segment first (segmenting-clinical-sections) for long notes.
  • Pseudo-negation is handled, double-check anyway. "Cannot exclude PE" is affirmed-but-uncertain, not negated. The negation layer masks these cues; the uncertainty layer is what flags the hedge.
  • Experiencer (family history) is a separate axis. These helpers cover negation/temporality/uncertainty; "mother with breast cancer" being about a relative is the experiencer axis and is out of scope here — handle it before attributing the finding to the patient.
  • Deterministic, not ML. ConText is a rule layer: fast, transparent, auditable — but cue-list bound. Novel phrasings may need lexicon tuning; it will not infer assertion from semantics the way a model might.
  • Advisory only. Outputs are annotations for review and downstream grounding, not autonomous clinical decisions.

Standards & references

Version History

  • f213557 Current 2026-07-23 00:45

Same Skill Collection

skills/benchmark-pii-recall/SKILL.md
skills/building-with-openmed/SKILL.md
skills/deidentify-a-dataset/SKILL.md
skills/extract-clinical-entities-to-fhir/SKILL.md
skills/loading-openmed-models/SKILL.md
skills/pick-a-pii-model/SKILL.md
skills/annotating-variants/SKILL.md
skills/assembling-fhir-bundles/SKILL.md
skills/auditing-deid-leakage/SKILL.md
skills/auditing-deidentification-runs/SKILL.md
skills/auditing-part11-trails/SKILL.md
skills/auditing-safe-harbor-checklist/SKILL.md
skills/auditing-subgroup-fairness/SKILL.md
skills/authoring-model-cards/SKILL.md
skills/batch-processing-clinical-text/SKILL.md
skills/benchmarking-clinical-ner/SKILL.md
skills/bridging-presidio-and-spacy/SKILL.md
skills/building-gold-corpus/SKILL.md
skills/building-patient-timelines/SKILL.md
skills/checking-hipaa-compliance/SKILL.md
skills/choosing-openmed-models/SKILL.md
skills/coding-hcc-risk-adjustment/SKILL.md
skills/coding-icd10/SKILL.md
skills/computing-ecqms/SKILL.md
skills/configuring-privacy-policies/SKILL.md
skills/defining-cohort-phenotypes/SKILL.md
skills/deidentifying-clinical-text/SKILL.md
skills/deidentifying-multilingual-text/SKILL.md
skills/deploying-openmed-mcp/SKILL.md
skills/detecting-pv-signals/SKILL.md
skills/enforcing-nophi-logging/SKILL.md
skills/etl-to-omop-cdm/SKILL.md
skills/evaluating-with-leakage-gates/SKILL.md
skills/exporting-bulk-fhir/SKILL.md
skills/exporting-to-fhir/SKILL.md
skills/extracting-clinical-entities/SKILL.md
skills/extracting-dicom-metadata/SKILL.md
skills/extracting-lab-tables/SKILL.md
skills/extracting-pii-entities/SKILL.md
skills/extracting-sdoh/SKILL.md
skills/fetching-fhir-resources/SKILL.md
skills/gating-deid-leakage/SKILL.md
skills/generating-synthea-data/SKILL.md
skills/generating-synthetic-surrogates/SKILL.md
skills/ingesting-clinical-documents/SKILL.md
skills/linking-umls-concepts/SKILL.md
skills/mapping-loinc/SKILL.md
skills/mapping-to-snomed/SKILL.md
skills/mining-pubmed-literature/SKILL.md
skills/normalizing-rxnorm/SKILL.md

Metadata

Files
0
Version
c8017bb
Hash
707db621
Indexed
2026-07-23 00:45

Home - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-07 02:35
浙ICP备14020137号-1 $Map of visitor$