BlogHealthTech

Patient Data Security: Architecture Decisions That Protect PHI

AS

Akash Shahriar

5 min read

Encryption Decisions That Actually Matter (Key Management, Not Just Algorithms)

Every patient data security conversation starts with "is it encrypted," but encryption at rest and in transit is close to table stakes at this point — the decision that actually determines your security posture is key management. Who can request a decryption, under what conditions, and whether that access is itself logged and reviewable are the questions that matter, because an attacker who compromises an application server with standing decrypt access defeats encryption regardless of the algorithm behind it. We architect key access behind a separate service with its own audit trail, so that decrypting a patient record is itself an event the system can account for, not an implicit capability every application service quietly holds.

Row-Level Segregation in Multi-Tenant Systems

Multi-tenant healthtech products — a platform serving multiple clinics or provider groups — face a segregation problem that's easy to get subtly wrong: a shared database with a tenant identifier column and application-level filtering works until a single query anywhere in the codebase forgets the filter, and one bug exposes one clinic's patients to another's staff. Row-level security enforced at the database layer, not just the application layer, closes that gap by making the database itself refuse to return rows outside a session's authorized tenant, regardless of what the application code does or fails to do. It's a small addition in schema design and a significant reduction in blast radius when a bug does happen. We've seen this exact failure mode play out with a well-intentioned encryption-at-rest rollout that technically satisfied an audit checklist while leaving every application server with an unlogged, always-on decrypt capability, which is the architectural equivalent of putting a lock on the front door and leaving the back door propped open.

RBAC Isn't Enough on Its Own — Add Purpose-Based Access

Role-based access control answers "what can this role see," but healthcare workflows often need a sharper question: why is this specific person looking at this specific patient's record right now. A nurse's role might legitimately grant access to any patient on the floor, but that same nurse looking up a patient they aren't currently treating — a coworker, a public figure, an ex-partner — is a real, recurring privacy violation category that pure RBAC doesn't catch. Purpose-based access controls, paired with anomaly detection on access patterns unrelated to a documented care relationship, catch what role-based permissions structurally can't. The same discipline applies to backups and data warehouse replicas, which are easy to forget are also multi-tenant surfaces the moment a shared analytics environment pulls from more than one client's production data.

De-Identification for Analytics Without Breaking the Product

Healthtech products increasingly need patient data for analytics, model training, or population health reporting, and the architecture decision that matters here is building a genuine de-identification pipeline rather than treating "internal use" as an exemption from PHI handling. A proper pipeline strips or generalizes the HIPAA-defined identifiers before data reaches an analytics environment, and critically, that pipeline needs to be a one-way, auditable transformation, not a shared database view that a sufficiently curious analyst could join back to identifiable records. Get this separation architecturally clean, and your analytics team can move fast without ever touching a PHI boundary.

The right question isn't whether patient data is encrypted. It's whether you could explain, for any record, exactly who accessed it and why.

Audit Trails as an Architectural Primitive, Not a Logging Add-On

Audit logging for patient data security has to be an architectural primitive baked into the data access layer itself, not a logging statement someone remembers to add at each call site. Every read and write to a PHI-bearing table should generate an audit record automatically, at the framework or ORM level, so that "did we log this access" is never a question that depends on an individual engineer's diligence during a code review. This is the same principle as our approach to ledger design in fintech systems: the things that need to be provably true under scrutiny shouldn't depend on every developer remembering to do them correctly, every time.

The real test of a patient data security architecture isn't whether it passes a HIPAA checklist — it's whether, for any given patient record, you could produce a complete, accurate account of every person who accessed it, when, and under what authorization, without reconstructing the answer from scattered application logs after the fact. Architectures that pass that test were built with the audit trail, the key management boundary, and the access model as first-class design decisions. Architectures that fail it usually have all three, just none of them talking to each other.

For more on how we build in this space, see our HealthTech development work.

Written by

Co-Founder & CTO at CookieTech, a product engineering studio. Mobile and full-stack engineer, Toptal-vetted, leading client strategy and technical direction.

AS

Akash Shahriar

5 min read

Building somethinglike this? Let's talk.

Book a free 30-min call we'll tell you if it's a 90-day build.