Перейти к содержанию
Skillpedia
Анализ и таблицы5.8k · #14724

reidentifying-text

Что он делает

Этот скилл учит агента удалять личные данные из клинического текста и хранить соответствие, которое позволяет их восстановить. Он нужен для случаев, когда исходные личности нужно связать обратно с разрешения.

Когда использовать

  • ✓Когда команде нужно скрыть данные пациентов сейчас и позже связать записи обратно при наличии разрешения.
  • ✓Когда проект следует псевдонимизации по GDPR и должен хранить идентификаторы отдельно от данных.
  • ✓Когда проверяющему нужно сравнить текст с замаскированными данными и исходниками, чтобы выборочно проверить маскирование.

Ссылка на скилл

https://github.com/maziyarpanahi/openmed/blob/master/skills/reidentifying-text/SKILL.md

Скопируйте и вставьте её в ваш ИИ (Claude, ChatGPT или Cursor) с просьбой следовать инструкциям.

Как использовать

Самый простой способ: скопируйте сообщение и вставьте его в свой ИИ. Он прочитает скилл и выполнит инструкции.

Готовое сообщение для вставки

Используй этот скилл, чтобы помочь мне: https://github.com/maziyarpanahi/openmed/blob/master/skills/reidentifying-text/SKILL.md Прочитай файл SKILL.md по этой ссылке и следуй его инструкциям в моей задаче.
Хотите, чтобы ваш ИИ сам находил такие скиллы?Установите бесплатный MCP Skillpedia: одна строка, и перед каждой задачей он ищет среди 15 000+ скиллов.Установить за 1 минуту →

Пример запроса к вашему ИИ

“Можешь замаскировать имена пациентов в моих записях, но сохранить соответствие, чтобы позже мы могли их восстановить?”

5 новых скиллов в неделю. 1 минута чтения.

Как это работает

Агент запускает шаг обезличивания с сохранённым соответствием, затем использует шаг повторной идентификации, чтобы вернуть исходные значения. Соответствие должно храниться отдельно от текста с удалёнными данными.

Технический текст (оригинальный SKILL.md)

Оригинальный текст автора на английском, прямо с GitHub.

Reidentifying Text

Some workflows need to remove PHI for processing but keep the ability to restore it later under authorization — adjudication, patient recontact, linking results back to a record. That is pseudonymization (reversible), not anonymization (irreversible). OpenMed supports it with deidentify(..., keep_mapping=True) to capture a mapping, and reidentify to restore. Everything runs on-device.

When to use

  • You need to re-link redacted output to the original record later.
  • You are doing GDPR pseudonymization (Art. 4(5)): identifiers held separately, reversible under controlled conditions.
  • A reviewer must spot-check redactions against originals.

Do NOT use reversibility when:

  • The goal is HIPAA Safe Harbor anonymization or a true anonymous release — a re-identification mapping defeats anonymization. Use method="remove" and keep no mapping.
  • The redacted text leaves your trust boundary and the mapping might travel with it. The mapping is the secret; never co-locate it with the de-identified output.

Install

pip install "openmed[hf]"

Quick start: reversible round-trip

import openmed

note = "Patient John Doe (MRN 00481726) seen on 2024-03-02 by Dr. Alice Smith."

# 1) De-identify AND capture the reversal mapping
deid = openmed.deidentify(
    note,
    method="mask",          # or "replace" for realistic surrogates
    keep_mapping=True,       # <-- required to enable reidentify()
    policy="gdpr_pseudonymization",
)

safe_text = deid.deidentified_text       # ship/process this
mapping   = deid.mapping                  # SECRET: store separately, encrypted

# 2) Later, under authorization, restore the original
restored = openmed.reidentify(safe_text, mapping)
assert restored == note

reidentify(deidentified_text, mapping) performs the inverse substitution. The mapping is a dict[str, str] of redacted → original text, produced only when keep_mapping=True.

Use consistent surrogates for stable pseudonyms

For replacement that maps the same identifier to the same surrogate across a document (and reproducibly across runs with a seed):

import openmed

deid = openmed.deidentify(
    "Mr. John Doe called. John Doe's MRN is 00481726.",
    method="replace",
    consistent=True,    # same input value -> same surrogate within the run
    seed=42,            # reproducible across runs (implies consistent=True)
    keep_mapping=True,
)
print(deid.deidentified_text)
restored = openmed.reidentify(deid.deidentified_text, deid.mapping)

consistent=True keeps surrogates stable so analytics on the pseudonymized text stay coherent; seed makes them reproducible. Either way, reversal still requires the saved mapping.

Store the mapping securely — separate from the text

The mapping is the re-identification key. Treat it like a secret:

  • Never write it to the same store/file/log as the de-identified text.
  • Encrypt at rest; restrict access; audit every reversal.
  • Key the store by an opaque document id, not by any patient identifier.
import json, os
import openmed

note = "Patient John Doe (MRN 00481726), DOB 1970-01-15."
deid = openmed.deidentify(note, method="mask", keep_mapping=True, seed=7)

doc_id = "doc-7f3a"   # opaque id, no PHI

# De-identified text -> general processing store (safe to share downstream)
with open(f"deid/{doc_id}.txt", "w", encoding="utf-8") as fh:
    fh.write(deid.deidentified_text)

# Mapping -> SEPARATE, access-controlled, encrypted vault (illustrative path)
os.makedirs("vault", exist_ok=True)
with open(f"vault/{doc_id}.map.json", "w", encoding="utf-8") as fh:
    json.dump(deid.mapping, fh)   # encrypt this store in production

To re-identify later, load only the mapping for the authorized doc_id:

import json, openmed
with open("vault/doc-7f3a.map.json", encoding="utf-8") as fh:
    mapping = json.load(fh)
with open("deid/doc-7f3a.txt", encoding="utf-8") as fh:
    safe_text = fh.read()
original = openmed.reidentify(safe_text, mapping)

Reversible vs irreversible: pick deliberately

Goal Call Mapping
GDPR pseudonymization (reversible) deidentify(..., keep_mapping=True, policy="gdpr_pseudonymization") keep, encrypted, separate
HIPAA Safe Harbor anonymization deidentify(..., method="remove", policy="hipaa_safe_harbor") none
Irreversible token linking `deidenti
Частые вопросы

Это можно использовать для настоящей анонимной публикации?

Нет. Скилл указывает, что соответствие для повторной идентификации делает анонимизацию несостоятельной, поэтому для неё используется метод удаления без соответствия.

Где хранить соответствие?

Отдельно от обезличенного результата, потому что соответствие и есть секрет.

Он работает на устройстве?

Да. Скилл указывает, что всё выполняется на устройстве.

Подробности

Оригинальное описание автора

Reversibly de-identify clinical text with OpenMed and later restore the original PHI from a saved mapping. Use when the user needs pseudonymization rather than permanent anonymization, wants to mask PHI now and re-link it later under authorization (e.g. recontact, adjudication, GDPR pseudonymization), asks about deidentify keep_mapping, reidentify, or how to store and protect the re-identification mapping. Covers when reversibility is and is not appropriate (pseudonymization vs HIPAA Safe Harbor anonymization). Pairs after extracting-pii-entities and deidentifying-clinical-text.

repo: maziyarpanahi/openmed

Популярность

Звёзды на GitHub
5.8k
Место в рейтинге
#14724
Лицензия
Apache-2.0
Обновлён
02.11.2026

Полезен ли этот скилл?

0

Войдите , чтобы голосовать.

Комментарии

  • …

Другие скиллы из этого репозитория

Похожие скиллы