Handling Protected Health Information Under HIPAA: Best Practices for Developers
Any health data linkable to a person is Protected Health Information under HIPAA, including incidental data such as IP addresses logged during telehealth visits, ZIP codes in dashboards, or names in query logs and staging tables. The guide lists HIPAA's 18 identifiers and contrasts Safe Harbor de-identification (strip the identifiers, keep only years and 3-digit ZIPs, easy to automate in SQL views) with Expert Determination (date shifting, aggregation, k-anonymity for more analytical utility). Practices covered: AES-256/TLS 1.2+ with managed keys, no real PHI in dev/test, least-privilege RBAC with MFA, no PHI in URLs, BAAs for every third-party service, audit-logging access but not content, sanitizing free text and file metadata, and planning incident response early. It is framed around Neon Postgres becoming HIPAA-compliant.
Related posts
- The Difference Between Postgres Logging and PGAudit
Neon mediumAdept
Postgres's built-in logging is designed for operational monitoring and troubleshooting, while PGAudit produces structured audit logs for compliance regimes like HIPAA, SOX and PCI DSS. PGAudit supports session auditing by statement class (READ, WRITE, ROLE, DDL, etc.) and object auditing through an audit role, and emits AUDIT:-prefixed entries with session and statement counters. A side-by-side healthcare example shows standard logging writing a CREATE USER password in plaintext where PGAudit redacts it, and PGAudit labeling reads, writes, role switches and permission failures explicitly. The recommendation is to run both, ship audit logs to a SIEM, and set retention policies such as HIPAA's six years.
- De-identifying text at scale: How Airbnb protects personal data in AI training
Airbnb Engineering mediumAdeptAirbnb de-identifies messages, reviews and support chats before ML training using Presidio, an open-source PII framework, shipped as an in-process Python library and a shared pipeline step whose de-identified dataset tag gates model deployment. The team added Airbnb-specific pattern recognizers with multi-word phrase context scoring, replaced spaCy with the zero-shot GLiNER model for names and street addresses, and resolves overlapping detections in the Anonymizer. Replacement uses realistic custom Faker values seeded from the real value plus a per-run secret, so fakes stay consistent within a run but unlinkable across runs. Structured fields get salted hashing, coordinate truncation and format-preserving encryption for 64-bit IDs. Quality is tracked on recall, precision and throughput per entity and language, with recall prioritized.
- How to Handle PII in Staging Databases Without Losing Realistic Data
Neon mediumAdept
Four common ways to get realistic but PII-safe staging data are compared, with code for each: manual CSV export plus Python anonymization scripts, Faker-based masking libraries with deterministic seeding to preserve referential integrity, fully synthetic data generators, and replication into staging with SQL masking views or the PostgreSQL Anonymizer extension (declarative security labels, dynamic masking, anonymized dumps, k-anonymity checks). Scripts and libraries break silently when schemas add new PII columns, synthetic data loses production's skew and messiness, and replication with masking is robust but operationally heavy. The recommended approach is Neon's copy-on-write branches combined with user-defined masking rules, so a masked staging copy of production can be created or refreshed cheaply.
- Schematizing Deletion at Scale
Shopify Engineering mediumAdeptShopify handles PII deletion in a warehouse ingesting tens of billions of events per day by requiring privacy-annotated schemas for every analytical event (4,500+ active schemas) and pseudonymising PII before it lands. A Scrubber on the Kafka pipeline applies irreversible obfuscation, such as masking IPs with geo enrichment or reducing user agents to device and OS families. For data that must stay recoverable, it applies tokenization: a vault issues consistent per-controller, per-subject tokens, so a deletion request only removes the token-to-PII mapping in the vault and never touches the petabyte-scale warehouse. Adoption came from making schematized events the default easy path, proving correctness through reconciliation and stress tests, and adding value like dataset discoverability.
- How we handle sensitive data in BigQuery
incident.io mediumAdeptincident.io masks sensitive data in BigQuery by default: a daily Python job applies PII and confidential policy tags to every untagged STRING/BYTES column replicated by Fivetran, so humans see only SHA256-hashed values. Non-sensitive columns are allow-listed via PR-edited YAML files, and a slim run diffs against the previous YAML version stored in GCS so only affected tables are processed. dbt is split into a customer-facing pipeline with unmasked access and an internal analytics pipeline that persists masked values downstream. Tagging once at the source cuts human error, at the cost of being unable to derive non-sensitive values such as email domains. The job also syncs a Notion data catalogue and sends Slack alerts.