# Extract Clinical Entities To Fhir

Extract clinical entities from synthetic or already de-identified text with OpenMed and...

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

## Install

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

## Description

Extract clinical entities from synthetic or already de-identified text with OpenMed and map them into deterministic FHIR R4 resources and a Bundle. Use when an agent must turn local clinical NER output into Conditions, MedicationStatements, Observations, or other FHIR resources without inventing terminology codes.

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

# Extract clinical entities to FHIR

Separate extraction from clinical coding. OpenMed finds spans and supplies the
mechanical FHIR builders; the application decides which resource type and
status are clinically appropriate.

## Procedure

1. Keep the source synthetic, or de-identify it inside the trusted boundary
   before extraction.
2. Run `openmed.analyze_text` with the task-appropriate clinical model.
3. Filter predictions by label and confidence; preserve offsets in a
   PHI-safe audit record.
4. Map each accepted span to the correct FHIR resource type.
5. Add terminology codes only from a user-approved mapping or terminology
   service. Never invent a code.
6. Assemble resources with `to_bundle` and validate against the target profile.

## Runnable synthetic example

Install the model runtime first with `python -m pip install "openmed[hf]"`.

```python
import json

from openmed import analyze_text
from openmed.clinical.exporters.fhir import to_bundle

note = "Assessment: type 2 diabetes mellitus is stable on metformin."
result = analyze_text(
    note,
    model_name="disease_detection_superclinical",
    confidence_threshold=0.5,
)

The rest: https://github.com/maziyarpanahi/openmed/blob/HEAD/skills/extract-clinical-entities-to-fhir/SKILL.md
