HIPAA Compliance Auditor
A clinical-grade PII/PHI detection and de-identification tool for healthcare text data.
Overview
This skill analyzes text for HIPAA-protected identifiers and automatically redacts or anonymizes them. It uses a combination of regex patterns, NLP entity recognition, and contextual analysis to identify 18 HIPAA identifier categories.
Features
- 18 HIPAA Identifiers Detection: Names, dates, SSN, MRN, phone/fax, email, geographic data, etc.
- Automatic De-identification: Replace PII with semantic tokens (e.g.,
[PATIENT_NAME], [DATE_1])
- Context-Aware Detection: Distinguishes between similar patterns (dates vs. lab values)
- Audit Logging: Track all redaction actions for compliance documentation
- Confidence Scoring: Flag uncertain detections for manual review
Usage
Command Line
python scripts/main.py --input "patient_text.txt" --output "deidentified.txt"
python scripts/main.py --text "Patient John Doe, SSN 123-45-6789..." --audit-log audit.json
Python API
from scripts.main import HIPAAAuditor
auditor = HIPAAAuditor()
result = auditor.deidentify("Patient John Doe was admitted on 2024-01-15...")
print(result.cleaned_text) # De-identified output
print(result.detected_pii) # List of found PII entities
Parameters
| Parameter |
Type |
Default |
Required |
Description |
--input, -i |
string |
- |
No |
Path to input text file |
--text |
string |
- |
No |
Direct text input (alternative to file) |
--output, -o |
string |
- |
No |
Path for de-identified output file |
--audit-log |
string |
- |
No |
Path for JSON audit log |
--confidence |
float |
0.7 |
No |
Minimum confidence threshold (0.0-1.0) |
--preserve-structure |
bool |
true |
No |
Maintain document structure |
--custom-patterns |
string |
- |
No |
Path to custom regex patterns JSON |
HIPAA Identifier Categories Detected
- Names (patient, relatives, employers)
- Geographic subdivisions smaller than state
- Dates (except year) related to individual
- Phone numbers
- Fax numbers
- Email addresses
- SSN
- Medical record numbers
- Health plan beneficiary numbers
- Account numbers
- Certificate/license numbers
- Vehicle identifiers
- Device identifiers
- URLs
- IP addresses
- Biometric identifiers
- Full-face photos
- Any other unique identifying numbers
Output Format
De-identified Text
Original identifiers replaced with semantic tags:
[PATIENT_NAME_1], [PATIENT_NAME_2] ...
[DATE_1], [DATE_2] ...
[SSN_1]
[PHONE_1], [PHONE_2] ...
[EMAIL_1]
[MRN_1] (Medical Record Number)
[ADDRESS_1]
Audit Log JSON
{
"timestamp": "2024-01-15T10:30:00Z",
"input_hash": "sha256:abc123...",
"detections": [
{
"type": "PATIENT_NAME",
"position": [10, 18],
"confidence": 0.95,
"replacement": "[PATIENT_NAME_1]",
"original_length": 8
}
],
"statistics": {
"total_pii_found": 5,
"categories_detected": ["NAME", "DATE", "PHONE", "SSN"]
}
}
Technical Architecture
- Preprocessing: Normalize text encoding, handle line breaks
- Regex Engine: Pattern matching for structured identifiers (SSN, phone, email, MRN)
- NLP Pipeline: spaCy NER for names, organizations, locations
- Context Filter: Remove false positives (e.g., "Dr. Smith" vs. "smith fracture")
- Replacement Engine: Sequential replacement with semantic tokens
- Validation: Ensure no original PII remains in output
Dependencies
- Python 3.9+
- spaCy (en_core_web_trf or en_core_web_lg)
- regex (for advanced pattern matching)
- Presidio (optional, for enhanced PII detection)
See references/requirements.txt for full dependency list.
Limitations & Warnings
⚠️ CRITICAL: This tool is designed as a helper, not a replacement for human review.
- Context-dependent PII (e.g., rare disease names + location) may not be fully detected
- Unstructured narrative text may contain identifying information not caught by patterns
- Always perform manual QA on output before HIPAA-compliant release
- AI Autonomous Acceptance Status: 需人工检查 (Requires Manual Review)
References
references/hipaa_safe_harbor_guide.pdf - HIPAA Safe Harbor de-identification standards
references/pii_patterns.json - Complete regex pattern definitions
references/test_cases/ - Sample clinical texts with expected outputs
references/requirements.txt - Python dependencies
Technical Difficulty: High
Complex NLP pipelines, contextual disambiguation, regulatory compliance requirements.
Risk Assessment
| Risk Indicator |
Assessment |
Level |
| Code Execution |
Python/R scripts executed locally |
Medium |
| Network Access |
No external API calls |
Low |
| File System Access |
Read input files, write output files |
Medium |
| Instruction Tampering |
Standard prompt guidelines |
Low |
| Data Exposure |
Output files saved to workspace |
Low |
Security Checklist
Prerequisites
# Python dependencies
pip install -r requirements.txt
Evaluation Criteria
Success Metrics
Test Cases
- Basic Functionality: Standard input → Expected output
- Edge Case: Invalid input → Graceful error handling
- Performance: Large dataset → Acceptable processing time
Lifecycle Status
- Current Stage: Draft
- Next Review Date: 2026-03-06
- Known Issues: None
- Planned Improvements:
- Performance optimization
- Additional feature support
1---2name: hipaa-compliance-auditor3description: Automatically detect and de-identify PII (Personal Identifiable Information)4 and PHI (Protected Health Information) from clinical/medical text to ensure HIPAA5 compliance. Trigger when processing medical records, patient data, clinical notes,6 insurance information, or any healthcare-related text containing potential patient7 identifiers.8version: 1.0.09category: Clinical10tags: []11author: AIPOCH12license: MIT13status: Draft14risk_level: Medium15skill_type: Tool/Script16owner: AIPOCH17reviewer: ''18last_updated: '2026-02-06'19---2021# HIPAA Compliance Auditor2223A clinical-grade PII/PHI detection and de-identification tool for healthcare text data.2425## Overview2627This skill analyzes text for HIPAA-protected identifiers and automatically redacts or anonymizes them. It uses a combination of regex patterns, NLP entity recognition, and contextual analysis to identify 18 HIPAA identifier categories.2829## Features3031- **18 HIPAA Identifiers Detection**: Names, dates, SSN, MRN, phone/fax, email, geographic data, etc.32- **Automatic De-identification**: Replace PII with semantic tokens (e.g., `[PATIENT_NAME]`, `[DATE_1]`)33- **Context-Aware Detection**: Distinguishes between similar patterns (dates vs. lab values)34- **Audit Logging**: Track all redaction actions for compliance documentation35- **Confidence Scoring**: Flag uncertain detections for manual review3637## Usage3839### Command Line40```bash41python scripts/main.py --input "patient_text.txt" --output "deidentified.txt"42python scripts/main.py --text "Patient John Doe, SSN 123-45-6789..." --audit-log audit.json43```4445### Python API46```python47from scripts.main import HIPAAAuditor4849auditor = HIPAAAuditor()50result = auditor.deidentify("Patient John Doe was admitted on 2024-01-15...")51print(result.cleaned_text) # De-identified output52print(result.detected_pii) # List of found PII entities53```5455## Parameters5657| Parameter | Type | Default | Required | Description |58|-----------|------|---------|----------|-------------|59| `--input`, `-i` | string | - | No | Path to input text file |60| `--text` | string | - | No | Direct text input (alternative to file) |61| `--output`, `-o` | string | - | No | Path for de-identified output file |62| `--audit-log` | string | - | No | Path for JSON audit log |63| `--confidence` | float | 0.7 | No | Minimum confidence threshold (0.0-1.0) |64| `--preserve-structure` | bool | true | No | Maintain document structure |65| `--custom-patterns` | string | - | No | Path to custom regex patterns JSON |6667## HIPAA Identifier Categories Detected68691. Names (patient, relatives, employers)702. Geographic subdivisions smaller than state713. Dates (except year) related to individual724. Phone numbers735. Fax numbers746. Email addresses757. SSN768. Medical record numbers779. Health plan beneficiary numbers7810. Account numbers7911. Certificate/license numbers8012. Vehicle identifiers8113. Device identifiers8214. URLs8315. IP addresses8416. Biometric identifiers8517. Full-face photos8618. Any other unique identifying numbers8788## Output Format8990### De-identified Text91Original identifiers replaced with semantic tags:92- `[PATIENT_NAME_1]`, `[PATIENT_NAME_2]` ...93- `[DATE_1]`, `[DATE_2]` ...94- `[SSN_1]`95- `[PHONE_1]`, `[PHONE_2]` ...96- `[EMAIL_1]`97- `[MRN_1]` (Medical Record Number)98- `[ADDRESS_1]`99100### Audit Log JSON101```json102{103 "timestamp": "2024-01-15T10:30:00Z",104 "input_hash": "sha256:abc123...",105 "detections": [106 {107 "type": "PATIENT_NAME",108 "position": [10, 18],109 "confidence": 0.95,110 "replacement": "[PATIENT_NAME_1]",111 "original_length": 8112 }113 ],114 "statistics": {115 "total_pii_found": 5,116 "categories_detected": ["NAME", "DATE", "PHONE", "SSN"]117 }118}119```120121## Technical Architecture1221231. **Preprocessing**: Normalize text encoding, handle line breaks1242. **Regex Engine**: Pattern matching for structured identifiers (SSN, phone, email, MRN)1253. **NLP Pipeline**: spaCy NER for names, organizations, locations1264. **Context Filter**: Remove false positives (e.g., "Dr. Smith" vs. "smith fracture")1275. **Replacement Engine**: Sequential replacement with semantic tokens1286. **Validation**: Ensure no original PII remains in output129130## Dependencies131132- Python 3.9+133- spaCy (en_core_web_trf or en_core_web_lg)134- regex (for advanced pattern matching)135- Presidio (optional, for enhanced PII detection)136137See `references/requirements.txt` for full dependency list.138139## Limitations & Warnings140141⚠️ **CRITICAL**: This tool is designed as a helper, not a replacement for human review.142143- Context-dependent PII (e.g., rare disease names + location) may not be fully detected144- Unstructured narrative text may contain identifying information not caught by patterns145- Always perform manual QA on output before HIPAA-compliant release146- **AI Autonomous Acceptance Status**: 需人工检查 (Requires Manual Review)147148## References149150- `references/hipaa_safe_harbor_guide.pdf` - HIPAA Safe Harbor de-identification standards151- `references/pii_patterns.json` - Complete regex pattern definitions152- `references/test_cases/` - Sample clinical texts with expected outputs153- `references/requirements.txt` - Python dependencies154155## Technical Difficulty: High156157Complex NLP pipelines, contextual disambiguation, regulatory compliance requirements.158159## Risk Assessment160161| Risk Indicator | Assessment | Level |162|----------------|------------|-------|163| Code Execution | Python/R scripts executed locally | Medium |164| Network Access | No external API calls | Low |165| File System Access | Read input files, write output files | Medium |166| Instruction Tampering | Standard prompt guidelines | Low |167| Data Exposure | Output files saved to workspace | Low |168169## Security Checklist170171- [ ] No hardcoded credentials or API keys172- [ ] No unauthorized file system access (../)173- [ ] Output does not expose sensitive information174- [ ] Prompt injection protections in place175- [ ] Input file paths validated (no ../ traversal)176- [ ] Output directory restricted to workspace177- [ ] Script execution in sandboxed environment178- [ ] Error messages sanitized (no stack traces exposed)179- [ ] Dependencies audited180## Prerequisites181182```bash183# Python dependencies184pip install -r requirements.txt185```186187## Evaluation Criteria188189### Success Metrics190- [ ] Successfully executes main functionality191- [ ] Output meets quality standards192- [ ] Handles edge cases gracefully193- [ ] Performance is acceptable194195### Test Cases1961. **Basic Functionality**: Standard input → Expected output1972. **Edge Case**: Invalid input → Graceful error handling1983. **Performance**: Large dataset → Acceptable processing time199200## Lifecycle Status201202- **Current Stage**: Draft203- **Next Review Date**: 2026-03-06204- **Known Issues**: None205- **Planned Improvements**: 206 - Performance optimization207 - Additional feature support