reidentifying-text
यह क्या करती है
यह स्किल एजेंट को सिखाती है कि क्लिनिकल टेक्स्ट से व्यक्तिगत विवरण कैसे हटाएँ और एक मैपिंग रखें जो उन्हें वापस ला सके। यह उन मामलों के लिए है जहाँ अनुमति के तहत मूल पहचान वापस जोड़नी हो।
कब इस्तेमाल करें
- ✓जब किसी टीम को अभी मरीज़ का विवरण छिपाना हो और अधिकार के तहत बाद में रिकॉर्ड वापस जोड़ने हों।
- ✓जब कोई प्रोजेक्ट GDPR छद्म-नामकरण का पालन करता हो और पहचानकर्ता डेटा से अलग रखने हों।
- ✓जब कोई समीक्षक रिडैक्ट किए गए टेक्स्ट की तुलना मूल से करके मास्किंग की जाँच करना चाहता हो।
Skill का लिंक
https://github.com/maziyarpanahi/openmed/blob/master/skills/reidentifying-text/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“क्या आप मेरे नोट्स में मरीज़ों के नाम मास्क कर सकते हैं, पर मैपिंग सहेज सकते हैं ताकि हम उन्हें बाद में वापस ला सकें?”
हर हफ़्ते 5 नई skills, 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
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
annotating-variants
5.8kआपके एजेंट को मुफ़्त सार्वजनिक एनोटेटर से जेनेटिक वेरिएंट का असर बताने, HGVS नामों को जीनोम पोज़िशन में बदलने और जनसंख्या आवृत्ति जोड़ने में मदद करती है।
ask-openmed
5.8kआपके एजेंट को क्लिनिकल टेक्स्ट अनुरोध के लिए सही OpenMed वर्कफ़्लो चुनने में मदद करती है, जहाँ मरीज़ का डेटा हो सकता है वहाँ पहले गोपनीयता जाँच से शुरू करके।
assembling-fhir-bundles
5.8kकई FHIR स्वास्थ्य रिकॉर्ड को एक ट्रांज़ैक्शन Bundle में पैक करती है, जो EHR को भेजने के लिए तैयार हो और आंतरिक संदर्भ सही जुड़े हों।
auditing-deid-leakage
5.8kडी-आइडेंटिफ़ाइड क्लिनिकल टेक्स्ट में बचे पहचानकर्ता जैसे SSN, कार्ड नंबर, ईमेल और तारीखें खोजती है, और कुछ बचा हो तो रिलीज़ रोक देती है।
मिलती-जुलती skills
gitcrawl
394kयह आपके एजेंट को GitHub issues और pull requests के सेव आर्काइव में खोजने, मिलते-जुलते मामलों को समूह में रखने और लाइव स्थिति जांचने देती है।
slacrawl
394kयह आपके एजेंट को स्थानीय Slack आर्काइव में संदेश खोजने और गिनने, उसकी ताज़गी जांचने और ज़रूरत पड़ने पर उसे ताज़ा करने देती है।
goplaces
394kयह आपके एजेंट को Google Places से जगहें खोजने, उनका विवरण और समीक्षाएं पाने, और जगह के नाम हल करने में मदद करती है, स्क्रिप्ट के लिए JSON आउटपुट के साथ।