Builds chronological patient timelines from OpenMed clinical events by normalizing dates and resolving relative time expressions. Useful for longitudinal history reconstruction and FHIR export.
Ships in openmed-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A patient timeline is a chronologically ordered list of clinical events —
diagnoses, medications, procedures, encounters — each carrying a normalized
date. OpenMed gives you the events (via analyze_text) and the clinical
temporality of each mention (current vs. historical, see
resolving-clinical-context); this skill turns those into a sorted timeline.
Everything runs on-device — de-identify first if the source notes contain
PHI, and keep raw identifiers out of logs.
After you have extracted entities from one or more notes and want them ordered
in time: a longitudinal history, a "course of illness" view, a feed for a
summary card, or a pre-step before FHIR export. If you only need to extract
entities, use extracting-clinical-entities. If you need negation/temporality
on a single mention, use resolving-clinical-context.
import datetime as dt
import openmed
note = (
"Discharge summary, 2024-03-12. Patient admitted 2024-03-08 with chest pain. "
"History of type 2 diabetes diagnosed in 2019. Started on metformin two days "
"after admission. Cardiac catheterization performed yesterday."
)
# 1) Extract clinical events (entities carry char offsets: start/end)
result = openmed.analyze_text(note, output_format="dict")
events = result["entities"] # each: {text, label, confidence, start, end}
# 2) Normalize the temporal frame: an explicit document/anchor date drives
# resolution of relative expressions ("two days after", "yesterday").
anchor = dt.date(2024, 3, 12) # parsed from the note header or document metadata
analyze_text returns {text, entities, model_name, timestamp, ...}; each
entity is {text, label, confidence, start, end}. Use start/end to locate
each event in the source and to find the nearest date expression.
openmed.deidentify(...)
first, or keep the timeline keyed by stable internal IDs — never log raw
names/MRNs.openmed.analyze_text(note) for conditions, drugs,
procedures; pick the model that matches your target entities
(choosing-openmed-models).resolving-clinical-context
to tag it current / historical / hypothetical and to drop negated or
family-history mentions that should not appear on the patient's own line.2024-03-08, March 2019) → parse directly. Record the
granularity (day / month / year) — a year-only event sorts to a coarse
bucket, not a fake Jan 1.two days after admission, yesterday, on POD 2) →
resolve against an anchor: the document date, admission date, or a
prior event's date. Without an anchor, relative expressions are
unresolvable — flag them, don't guess.(date, granularity, label, surface_text, char_span, temporality, confidence, source_note_id).(date, granularity); merge repeated
mentions of the same event across notes (same label + overlapping date).def to_timeline(events, *, anchor, note_id):
"""events: list of {text,label,start,end,confidence}. anchor: date.
Returns sorted [(date, granularity, label, text, confidence)]."""
timeline = []
for e in events:
date, gran = resolve_event_date(e, note=note, anchor=anchor) # your resolver
if date is None:
continue # undated/unresolvable: route to an "undated" bucket, don't drop silently
timeline.append((date, gran, e["label"], e["text"], e["confidence"]))
# year-only ('Y') sorts before month ('M') before day ('D') on ties
order = {"Y": 0, "M": 1, "D": 2}
return sorted(timeline, key=lambda r: (r[0], order[r[1]]))
# resolve_event_date handles: ISO dates, "March 2019" (gran='M'),
# "yesterday"/"two days after admission" (relative to anchor/admission), POD-n, etc.
analyze_text entities (extracting-clinical-entities) and
clinical context tags (resolving-clinical-context) are the inputs. Run
deidentify upstream when notes carry PHI.exporting-to-fhir (openmed.interop). Map an admission/discharge event to a
FHIR Encounter, a diagnosis date to Condition.onsetDateTime, a med-start
to MedicationStatement.effectiveDateTime, a procedure to
Procedure.performedDateTime.etl-to-omop-cdm (start/end dates on
condition_occurrence / drug_exposure) and clinical-summary cards.2019-01-01 and then sort it
as if it were a precise day — it'll outrank real January events. Carry a
granularity flag and sort coarse dates conservatively.dd/mm vs mm/dd from the document locale, not a guess.onsetDateTime, recordedDate):
https://www.hl7.org/fhir/condition.htmlopenmed/processing/ (analyze_text output), openmed.clinical
(temporality), openmed.interop (FHIR export).What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/openmed-skills:building-patient-timelinesfrom openmed-skills
npx claudepluginhub maziyarpanahi/openmed --plugin openmed-skills74 skills in this plugin
/annotating-variantsAnnotates VCF variants and normalizes HGVS nomenclature with public, license-free annotators (Ensembl VEP REST, VEP/SnpEff/ANNOVAR offline) and links variants to gnomAD population frequencies and the clinical context OpenMed extracts. Use when the user wants to predict variant consequences, map HGVS to genomic coordinates, annotate a VCF, attach allele frequencies, or pair variants with phenotype/oncology context. Trigger keywords: VCF, HGVS, variant annotation, VEP, SnpEff, ANNOVAR, consequence, missense, gnomAD, allele frequency, GRCh38, rsID, transcript. Pairs adjacent to OpenMed: combine annotated variants with Genomics/Oncology entities and phenotype from openmed.analyze_text. Tools used are free; restricted clinical databases are user-supplied./ask-openmedChoose the first OpenMed workflow skill for an intake, privacy, extraction, exchange, or verification request using deterministic local routing. Use when a goal is broad, spans several clinical-data stages, or leaves the data-sensitivity status unclear; the privacy gate is selected before downstream work when raw clinical or personal content may be present./assembling-fhir-bundlesPackage multiple FHIR R4 resources produced from OpenMed output into a single valid transaction Bundle ready to POST to an EHR, using OpenMed's verified bundle assembler openmed.clinical.exporters.fhir.to_bundle. Covers deterministic urn:uuid fullUrls, automatic in-Bundle reference rewriting, request blocks (method/url) for transaction vs batch, and conditional create. Use after exporting-to-fhir when the user has several Condition/Observation/MedicationStatement resources and wants one transaction Bundle, mentions Bundle, transaction, references, or posting to a FHIR server. Builds on exporting-to-fhir; pairs after.Other plugins' skills for the same job