Langsung ke konten
Skillpedia
Keamanan5.8k ยท #14707

generating-synthetic-surrogates

Fungsinya

Skill ini mengganti pengenal pasien dalam teks klinis dengan nilai palsu yang realistis dan sesuai jenisnya, misalnya nama palsu untuk nama asli. Teks tetap mudah dibaca dan masih bisa diurai oleh alat lain. Skill ini untuk tim yang membutuhkan teks yang alami dan aman.

Kapan dipakai

  • โœ“Saat catatan yang sudah dihapus identitasnya harus tetap alami, bukan penuh tanda sunting.
  • โœ“Saat teks untuk pelatihan atau demo membutuhkan identitas palsu yang konsisten di seluruh dokumen.
  • โœ“Saat Anda menginginkan format pengganti kustom, seperti pola nomor rekam Anda sendiri.

Link skill

https://github.com/maziyarpanahi/openmed/blob/master/skills/generating-synthetic-surrogates/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/maziyarpanahi/openmed/blob/master/skills/generating-synthetic-surrogates/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit โ†’

Contoh permintaan ke AI

โ€œHapus identitas catatan ini dengan mengganti nama dan nomor rekam dengan nilai palsu yang realistis dan konsisten dalam dokumen.โ€

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Agent mendeteksi pengenal, membuat nilai palsu yang sesuai untuk setiap jenis, menjaga nilai palsu setiap orang tetap sama di seluruh catatan, lalu mengembalikan teks yang mudah dibaca.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

Generating synthetic surrogates

method="replace" swaps each detected identifier for a realistic, type-matched fake โ€” John Doe becomes Mark Lee, a phone becomes a plausible phone, a date becomes a plausible date. Unlike opaque [REDACTED]/[NAME] masks, surrogate text reads naturally and stays parseable by downstream NLP, while still containing no real PHI. OpenMed generates surrogates on-device via Faker-backed providers keyed to each canonical label.

When to use this skill

Use surrogates when the de-identified text must remain readable or machine- parseable: training data for clinical NLP, demos, QA, or notes a human still needs to skim. If you only need the identifiers gone and don't care about readability, plain method="mask" is simpler and more obviously redacted.

Quick start

import openmed

note = (
    "Patient John Doe (MRN 1234567) saw Dr. John Doe's colleague on 2024-03-02. "
    "Reach John Doe at 617-555-0142."
)

result = openmed.deidentify(
    note,
    method="replace",
    consistent=True,     # every "John Doe" -> the SAME surrogate within this call
    seed=42,             # reproducible across runs
    locale="en_US",      # shapes the fakes; defaults from lang via LANG_TO_LOCALE
)
print(result.deidentified_text)
# Patient Mark Lee (MRN 8830127) saw Dr. Mark Lee's colleague on 2024-07-18. ...

consistent=True is what makes the output coherent: the three mentions of "John Doe" collapse to one fake identity instead of three different ones, so the note still makes sense. seed= makes that mapping reproducible run to run.

Surrogates vs opaque redaction

method="mask" ([NAME]) method="replace" (surrogate)
Readability low โ€” placeholders high โ€” reads like a real note
Downstream NLP tokenizers see [NAME] everywhere natural distribution preserved
Co-reference lost (all [NAME]) preserved with consistent=True
Obvious it's de-identified yes no (must be tracked out-of-band)
Reversible with keep_mapping=True with keep_mapping=True

Custom providers and label generators

When a built-in surrogate doesn't match your house format (e.g. your MRNs are H + 7 digits), register a generator or a Faker provider.

from openmed import (
    register_label_generator, register_clinical_provider,
    Anonymizer, AnonymizerConfig,
)

# Override the surrogate for one canonical label. Signature: (faker, original, *, locale)
def hospital_mrn(faker, original, *, locale):
    return f"H{faker.numerify('#######')}"

register_label_generator("ID_NUM", hospital_mrn)   # global, all new Anonymizers

# Add a whole custom Faker provider (e.g. proprietary identifier formats):
register_clinical_provider(MyClinicalProvider)     # a faker BaseProvider subclass

# Per-instance control (preferred for isolation): pass providers via config,
# and pull a single surrogate directly when you need one.
anon = Anonymizer(AnonymizerConfig(
    lang="en", consistent=True, seed=7, custom_providers=[MyClinicalProvider],
))
fake = anon.surrogate("1234567", "ID_NUM")

Use register_label_generator(canonical_label, fn) to swap one label's surrogate; register_clinical_provider(provider) to add providers globally; or AnonymizerConfig.custom_providers for per-run scoping. Validate any custom label against openmed.CANONICAL_LABELS.

Workflow

  1. Choose method="replace" (or a profile like gdpr_pseudonymization / canada_pipeda that replaces by default โ€” see configuring-privacy-policies).
  2. Enable consistency with consistent=True and a seed= so repeated mentions resolve to one identity and the result is reproducible.
  3. Set locale= so surrogates look native (pt_BR, de_DE, โ€ฆ); it defaults from lang via LANG_TO_LOCALE (deidentifying-multilingual-text).
  4. Register custom generators for any house-specific formats (MRN, account, address) before the run.
  5. If reversibility is needed, add keep_mapping=True and store result.mapping as a secret, separate from the output.
  6. Verify no surrogate collides with a real value and residual risk is low (auditing-deidentification-runs).

Hand-off to / from OpenMed

  • Core de-id: deidentifying-clinical-text โ€” method, thresholds, keep_mapping, policies.
  • Policies that replace: configuring-privacy-policies (gdpr_pseudonymization, canada_pipeda).
  • **Multilingual surrogat
Pertanyaan umum

Bisakah nilai palsu direproduksi?

Bisa. Penggunaan seed tetap membuat keluaran bisa direproduksi di setiap run.

Apakah orang yang sama mendapat nama palsu yang sama?

Dengan mode konsisten aktif, setiap pengenal dipetakan ke nilai palsu yang sama dalam satu dokumen.

Apakah penyamaran lebih baik dalam beberapa kasus?

Ya. Jika keterbacaan tidak penting, penyamaran biasa lebih sederhana dan jelas ditandai sebagai disunting.

Detail

Deskripsi asli dari pembuat

Replace detected PHI with realistic, type-matched fake values in OpenMed so clinical notes stay readable and parseable instead of full of [REDACTED] markers. Use when the user wants surrogate names, MRNs, addresses, or dates rather than opaque masks, needs consistent fake identities across a document, must keep notes natural for downstream NLP, or wants to register a custom surrogate generator or provider. Covers deidentify(method=\"replace\", consistent=True, seed=..., locale=...), register_label_generator, register_clinical_provider, and Anonymizer/AnonymizerConfig. Pairs with OpenMed deiden

repo: maziyarpanahi/openmed

Popularitas

Bintang GitHub
5.8k
Peringkat
#14707
Lisensi
Apache-2.0
Diperbarui
2/11/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • โ€ฆ

Skill lain dari repositori ini

Skill serupa