Rajan Sharma commited on
Commit
d0e3a07
·
verified ·
1 Parent(s): ae6bba9

Create privacy.py

Browse files
Files changed (1) hide show
  1. privacy.py +17 -0
privacy.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+
3
+ # Simple, configurable redaction. Replace with your enterprise DLP when ready.
4
+ RE_PATTERNS = {
5
+ "MRN": re.compile(r"\b(?:MRN|Med(?:ical)?\s*Record)\s*[:#]?\s*\d{5,10}\b", re.I),
6
+ "DOB": re.compile(r"\b(?:DOB|DoB|Birth\s*Date)\s*[:#]?\s*(\d{4}[-/]\d{2}[-/]\d{2}|\d{2}[-/]\d{2}[-/]\d{4})\b", re.I),
7
+ "PHONE": re.compile(r"\b(?:\+?\d{1,2}\s*)?(?:\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4})\b"),
8
+ "EMAIL": re.compile(r"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b"),
9
+ }
10
+
11
+ def redact_text(text: str) -> str:
12
+ if not text:
13
+ return text
14
+ red = text
15
+ for pat in RE_PATTERNS.values():
16
+ red = pat.sub("[REDACTED]", red)
17
+ return red