deidentifying-multilingual-text
它能做什么
这项技能使用各语言专属的国家证件号和电话号码模式,去除多种语言临床记录中的患者标识符。适合处理非英语病历的团队。
适用场景
- ✓当临床记录使用英语以外的语言撰写的时候。
- ✓当记录中包含国家身份标识符,例如西班牙的 DNI 或巴西的 CPF 的时候。
- ✓当替代值需要符合记录所在地区的习惯、看起来自然的时候。
技能链接
https://github.com/maziyarpanahi/openmed/blob/master/skills/deidentifying-multilingual-text/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“这些医疗记录是西班牙语的,并且包含 DNI 号码。请去除患者标识符,并保持文本自然。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会根据记录的语言选择对应的语言模型和模式,然后使用符合当地习惯的替代值去除或替换标识符。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
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
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)
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:
befund = "Patientin Anna Müller, geb. 11.04.1979, Steuer-ID 12 345 678 901."
result = openmed.deidentify(befund, lang="de", method="replace")
Workflow
- Confirm the language is supported by checking
SUPPORTED_LANGUAGES. - Pass
lang=todeidentify/extract_pii. This selects the language-specific model (viaget_pii_models_by_language) and the regex pattern set (viaget_patterns_for_language) for national IDs and formats. - Set
locale=for surrogates whenmethod="replace". If omitted, the locale is derived fromlangthroughLANG_TO_LOCALE(e.g.pt→pt_PT). Override for regional variants (pt_BR,en_GB, Gulf/Levant Arabic). - Let accent normalization happen. For models trained on accent-free text
(Spanish),
deidentifyauto-strips diacritics before inference and maps spans back to the original accented text. You normally do not setnormalize_accentsyourself. - Keep surrogates stable across a document with
consistent=True, seed=....
Language-specific national IDs
The pattern sets encode and the validators check real national identifier
formats and checksums, so structured IDs are caught even when the model is
unsure. Examples available in openmed.core.pii_i18n:
| Language | Identifier | Validator |
|---|---|---|
| French | NIR / INSEE | validate_french_nir |
| German | Steuer-ID | validate_german_steuer_id |
| Italian | Codice Fiscale | validate_italian_codice_fiscale |
| Spanish | DNI / NIE | validate_spanish_dni, validate_spanish_nie |
| Dutch | BSN | validate_dutch_bsn |
| Hindi | Aadhaar | validate_aadhaar |
| Portuguese | CPF / CNPJ | validate_portuguese_cpf, validate_portuguese_cnpj |
| Turkish | TCKN | validate_turkish_tckn |
These map to OpenMed CANONICAL_LABELS (ID_NUM, SSN) and are redacted by
the same policy actions as any other identifier.
Hand-off to / from OpenMed
- Core de-id:
deidentifying-clinical-text— methods, thresholds,keep_mapping, policies (all acceptlang/locale). - Surrogates:
generating-synthetic-surrogates— locale-native fakes and custom providers per language. - Policies:
configuring-privacy-policies—policy=works with anylang. - Audit:
auditing-deidentification-runsrecords the model and language in the no-PHI report. - Other surfaces: MCP
openmed_deidentify/openmed_list_pii_languages; RESTPOST /pii/deidentify(both take a language parameter).
Edge cases & gotchas
- **Never
常见问题
支持哪些语言?
这项技能会在运行时检查支持的语言列表,因为随着新模型发布,列表会不断增加。
需要网络连接吗?
不需要。模型下载一次后,处理在设备上进行。
它支持国家证件号格式吗?
支持。它使用各语言专属的模式识别 DNI、codice fiscale 和 CPF 等国家证件号。
详情
作者的原始描述
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-tex
repo: maziyarpanahi/openmed
热度
- GitHub 星标
- 5.8k
- 排名
- #14690
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
annotating-variants
5.8k帮你的智能体预测基因变异的作用,把 HGVS 名称转换为基因组位置,并使用免费的公共注释工具添加人群频率。
ask-openmed
5.8k帮你的智能体为临床文本请求选择合适的 OpenMed 工作流程,并在可能涉及患者数据时,先进行隐私检查。
assembling-fhir-bundles
5.8k把多份 FHIR 健康记录打包成一个事务 Bundle,可直接发送给 EHR 系统,并正确链接其中的内部引用。
auditing-deid-leakage
5.8k扫描已去标识化的临床文本,查找残留的标识符,例如社会安全号、银行卡号、电子邮件地址和日期,若仍有残留则阻止发布。