Scrub Protected Health Information From Structured Service Logs
Last updated: November 29, 2026
Quick Overview
Write a function that takes a log event (nested dicts, lists and strings) and returns a copy with PHI removed: known sensitive keys replaced wholesale and phone numbers, emails, SSNs, MRNs and dates of birth masked inside free text.
Abridge
November 29, 20260
0
0 solved
Write a function that takes a log event (nested dicts, lists and strings) and returns a copy with PHI removed: known sensitive keys replaced wholesale and phone numbers, emails, SSNs, MRNs and dates of birth masked inside free text.
Every Abridge service touches transcripts and patient identifiers, so HIPAA-safe logging is a basic engineering expectation. The interviewer checks recursion over JSON-like data, sensible regexes, and judgment about why regex alone is not a complete PHI defense.
What the Interviewer Expects
- Recurse over dicts and lists without mutating the input
- Redact whole values for keys known to carry PHI
- Mask common identifier patterns in strings
- Leave numbers and non-PHI fields untouched
- Explain the limits of pattern-based scrubbing
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- Names cannot be caught by regex; how would you keep them out of logs at all?
- Where should this run: in each service, the logging library, or the log pipeline?
- How would you test that a new field does not leak PHI?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Input: any JSON-like value. Output: a new value with the same shape. Keys such as patient_name, transcript, note_text are replaced by [REDACTED] regardless of content. Strings elsewhere get pa...
High-Level Design
A small recursive walker with two layers of defense: an allowlist mindset for keys (sensitive keys dropped outright) and regex masking for identifiers that slip into messages. Patterns run in a fixed ...