Skip to content
Skillpedia
Databases5.8k · #14698

extract-clinical-entities-to-fhir

What it does

This skill extracts clinical entities from synthetic or de-identified text and maps them into FHIR R4 resources, such as Condition or Observation. It is for developers who need structured FHIR output from local clinical text, with codes added only from approved sources.

When to use it

  • ✓When an agent must turn clinical text into FHIR Condition or Observation resources.
  • ✓When you want extraction kept separate from clinical coding decisions.
  • ✓When the source text is synthetic or has already been de-identified.

Skill link

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

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/maziyarpanahi/openmed/blob/master/skills/extract-clinical-entities-to-fhir/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

Example of what to ask your AI

“From this synthetic note, extract the diagnoses and turn each one into a FHIR Condition inside a Bundle.”

5 new skills a week. 1 minute to read.

How it works

The agent runs entity extraction, keeps only the accepted labels above a confidence threshold, maps each one to a resource type, and assembles the Bundle.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

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]".

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,
)

resources = [{"resourceType": "Patient", "id": "synthetic-patient"}]
for index, entity in enumerate(result.entities, start=1):
    if entity.label.upper() not in {"CONDITION", "DIAGNOSIS", "DISEASE"}:
        continue
    resources.append(
        {
            "resourceType": "Condition",
            "id": f"condition-{index}",
            "clinicalStatus": {
                "coding": [
                    {
                        "system": (
                            "http://terminology.hl7.org/CodeSystem/"
                            "condition-clinical"
                        ),
                        "code": "active",
                    }
                ]
            },
            "verificationStatus": {
                "coding": [
                    {
                        "system": (
                            "http://terminology.hl7.org/CodeSystem/"
                            "condition-ver-status"
                        ),
                        "code": "confirmed",
                    }
                ]
            },
            # A text-only CodeableConcept is preferable to an invented code.
            "code": {"text": entity.text},
            "subject": {"reference": "Patient/synthetic-patient"},
        }
    )

if len(resources) == 1:
    raise RuntimeError("No condition spans met the label and confidence rules")

bundle = to_bundle(resources, doc_id="synthetic-note-001")
print(json.dumps(bundle, indent=2))

Safety checks

  • Do not put raw identifiers, source text, or reversible mappings in logs, OperationOutcome.diagnostics, or trace metadata.
  • Keep a patient identity service separate from extracted clinical facts.
  • Preserve negation, temporality, and experiencer context before asserting a resource as active or confirmed.
  • Use a text-only CodeableConcept when no approved code is available.
  • Validate the Bundle against the receiver's FHIR and profile requirements.
  • Do not bundle restricted terminologies; use the user's licensed service.

Repository example

Read and run the redaction-to-FHIR walkthrough for an offline-friendly pipeline with deterministic extraction.

FAQ

Will it add codes like ICD-10 on its own?

No. Codes come only from a mapping you approve or from a terminology service.

Which text is allowed?

The guidance requires synthetic text, or text de-identified inside the trusted boundary before extraction.

Does it check the output?

The guidance says to validate the resources against the target profile.

Details

Original description by the author

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.

repo: maziyarpanahi/openmed

Popularity

GitHub stars
5.8k
Ranking position
#14698
License
Apache-2.0
Updated
11/2/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills