# Deidentifying Multilingual Text

De-identify non-English clinical text on-device with OpenMed by passing lang= and...

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

## Install

Claude Code: `npx skills add maziyarpanahi/openmed --skill deidentifying-multilingual-text -g -a claude-code -y`
Codex: `npx skills add maziyarpanahi/openmed --skill deidentifying-multilingual-text -g -a codex -y`
Cursor: `npx skills add maziyarpanahi/openmed --skill deidentifying-multilingual-text -g -a cursor -y`
Gemini CLI: `npx skills add maziyarpanahi/openmed --skill deidentifying-multilingual-text -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add maziyarpanahi/openmed`

## Description

De-identify non-English clinical text on-device with OpenMed by passing lang= and locale= to deidentify(). Use when the user has Spanish, German, French, Italian, Portuguese, Dutch, Hindi, Telugu, Arabic, Japanese, or Turkish medical notes, needs locale-aware fake surrogates, must handle language-specific national IDs (DNI, NIR, Steuer-ID, codice fiscale, BSN, CPF, TCKN, Aadhaar), or asks which languages OpenMed PII supports. Covers SUPPORTED_LANGUAGES, get_pii_models_by_language, get_patterns_for_language, LANG_TO_LOCALE, and accent normalization. Pairs with OpenMed deidentifying-clinical-text and generating-synthetic-surrogates.

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

# De-identifying multilingual text

OpenMed de-identifies clinical text in many languages, each with a dedicated
PII model, language-specific regex patterns (national IDs, phone formats), and a
locale-aware surrogate generator. Pass `lang=` to `deidentify` / `extract_pii`
and the right model, patterns, and fake-data tables are selected automatically.
Everything runs **on-device**.

## When to use this skill

Use it whenever the source text is not English, or when surrogates must look
native to the locale (a German note should get German-looking fake names and a
valid-format Steuer-ID surrogate, not a US SSN).

## Discover supported languages at runtime, don't hardcode

```python
import openmed
from openmed.core.pii_i18n import SUPPORTED_LANGUAGES, get_patterns_for_language

print(sorted(SUPPORTED_LANGUAGES))   # query it; the set is the source of truth
# Language-appropriate default model for a code:
models = openmed.get_pii_models_by_language("es")
# Language-specific regex patterns (national IDs, phones, etc.):
patterns = get_patterns_for_language("de")
```

The set currently spans English plus European, South Asian, Middle Eastern, and
East Asian languages, but **always read `SUPPORTED_LANGUAGES`** rather than
trusting a number, since it changes as models ship. MCP exposes the same list
via `openmed_list_pii_languages`.

## Quick start (Spanish)

```python
import openmed

nota = (
    "El paciente Carlos Hernández (DNI 12345678Z), nacido el 11/04/1979, "
    "vive en Calle Mayor 5, Madrid. Teléfono 612 345 678."
)

result = openmed.deidentify(
    nota,
    lang="es",                # selects the Spanish PII model + ES patterns
    method="replace",         # locale-native fake values
    locale="es_ES",           # Faker locale (defaults from lang via LANG_TO_LOCALE)
)
print(result.deidentified_text)
# El paciente [surrogate name] (DNI [surrogate]), nacido el [date], ...
```

For German, just switch the code:

The rest: https://github.com/maziyarpanahi/openmed/blob/HEAD/skills/deidentifying-multilingual-text/SKILL.md
