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
Software Engineering Fundamentals
Software Engineer
Abridge
November 29, 2026
Software Engineer
Phone Screen
Software Engineering Fundamentals
Easy

0

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
PHI handling
Regex
Recursion
Logging hygiene
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. 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 Problems
Sample 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 ...


Submit Your Answer
Markdown supported

Related Questions