# deidentify-clinical-text

Redact identifiers (names, dates, phone, email, record numbers, addresses, ZIPs) from clinical free text before it is shared or analysed

- **Space:** healthcare-admin-public (https://github.com/Tech-Realm/space-healthcare-admin-public/tree/main/deidentify-clinical-text)
- **Level:** L2 (as the registry reports it)
- **Keys it needs (names only):** none
- **Tools:** python3
- **Routes:** local-python; checks: 2
- **Uses:** new (no recorded use yet)
- **Install:** `logicpacks pack use healthcare-admin-public/deidentify-clinical-text` or MCP `get_pack healthcare-admin-public/deidentify-clinical-text`
- **Files:** CHANGELOG.md, code/deid.py, outcome/EVIDENCE.md, outcome/checks.yaml, outcome/fixtures/names.txt, outcome/fixtures/note.txt, outcome/results.json, pack.yaml, spec/SPEC.md, spec/source.md

## Purpose (spec/SPEC.md)

## Goal

A redacted copy of free text with HIPAA Safe Harbor style identifiers replaced by tags ([NAME], [DATE], [PHONE], [EMAIL], [MRN], [ZIP3]) and a count per type; dates reduced to year.

Verified by: Synthetic note: every planted identifier is replaced, clinical content (medications, vitals) is untouched.

## Steps

1. Run `python3 code/deid.py note.txt --names names.txt > note.redacted.txt`.
2. Review the redacted text by eye; add missed names to names.txt and re-run.
3. Only share data that passed human review, under the organisation's policy (BAA/DUA).

## Edge cases

- Names without a title or not in the names list can be missed; use the names list from the record's demographics.
- Ages over 89 must be grouped as 90+ (done).
- ZIP codes keep 3 digits; Safe Harbor requires 000 for sparsely populated ZIP3s, check the census list.

## Don'ts

- Never put real patient data in fixtures, prompts, logs or git; fixtures are synthetic.
- Don't call rule-based output 'de-identified' for compliance without expert determination or full Safe Harbor review.
- Don't send identifiable text to any cloud API to redact it.



---

Canonical URL: https://logicpacks.io/packs/healthcare-admin-public/deidentify-clinical-text

Developed by TechRealm (techrealm.online), the software team. Operated by Al Jash Trading (Establishment), Abu Dhabi, since 1994, the legal entity that hosts and is responsible for the service. Economic licence CN-1030597, Abu Dhabi Registration Authority. Address: Office 5, Bani Yas West 4, Bani Yas, Abu Dhabi, UAE. Website: https://aljashtrading.com. Contact: hello@logicpacks.io, security@logicpacks.io, WhatsApp +1 713 632 2262 (https://wa.me/17136322262).

Machine-readable index: [/llms.txt](/llms.txt). Plain facts: [/about.md](/about.md). Safety: [/safety.md](/safety.md).
