# Bridging Presidio And Spacy

Combine OpenMed clinical NLP with Microsoft Presidio, spaCy, or LangChain through...

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

## Install

Claude Code: `npx skills add maziyarpanahi/openmed --skill bridging-presidio-and-spacy -g -a claude-code -y`
Codex: `npx skills add maziyarpanahi/openmed --skill bridging-presidio-and-spacy -g -a codex -y`
Cursor: `npx skills add maziyarpanahi/openmed --skill bridging-presidio-and-spacy -g -a cursor -y`
Gemini CLI: `npx skills add maziyarpanahi/openmed --skill bridging-presidio-and-spacy -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add maziyarpanahi/openmed`

## Description

Combine OpenMed clinical NLP with Microsoft Presidio, spaCy, or LangChain through OpenMed's built-in interop adapter registry (openmed.interop). Covers the lazy adapter registry (available_adapters, get_adapter, adapter_spec), the presidio/spacy/langchain pip extras, and the verified callables, Presidio to_canonical/from_canonical/merge_with_openmed, the spaCy openmed_deid pipeline factory, and the LangChain create_redaction_runnable. Use when the user wants to add Presidio recognizers, embed OpenMed PII detection in a spaCy pipeline, or use OpenMed de-identification as a LangChain runnable. Pairs adjacent to the OpenMed PII skills.

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

# Bridging Presidio, spaCy & LangChain

OpenMed interoperates with the dominant PII/NLP ecosystems through a single,
**lazy** adapter registry: `openmed.interop`. Adapters live behind explicit
imports, so importing `openmed` never drags in Presidio, spaCy, or LangChain, each is an optional extra you install only when you need that bridge.

## When to use

Reach for a bridge when:

- you already run **Microsoft Presidio** and want OpenMed's clinical PII recall
  on top (or to feed OpenMed spans back into Presidio's anonymizer);
- you have a **spaCy** pipeline and want OpenMed PII spans on the `Doc`;
- you build **LangChain** chains and want to redact PHI *before* text reaches an
  LLM (the on-device guardrail in front of a cloud model);
- you need OpenMed's de-identification reachable from an existing framework
  instead of rewriting the pipeline around `openmed.deidentify`.

## The lazy adapter registry (verified)

```python
import openmed.interop as interop

interop.available_adapters()
# ('cda', 'hl7v2', 'langchain', 'presidio', 'spacy')

spec = interop.adapter_spec("presidio")
# AdapterSpec(name='presidio', module='openmed.interop.presidio',
#             extra='presidio', description='Presidio RecognizerResult adapter')

mod = interop.get_adapter("presidio")        # imports openmed.interop.presidio
# Attribute access also works lazily:
openmed.interop.presidio                      # same module, imported on first touch
```

`available_adapters()` and `adapter_spec()` never import the adapter module, so
they are safe to call for discovery even without the extra installed.
`get_adapter(name)` (and attribute access) triggers the import, and the
adapter's own optional dependency.

Install only the extra you need:

The rest: https://github.com/maziyarpanahi/openmed/blob/HEAD/skills/bridging-presidio-and-spacy/SKILL.md
