Understanding HIPAA for Developers
HIPAA isn't just a legal checkbox. It's a comprehensive security framework that fundamentally shapes how healthcare software must be designed. This guide covers the technical safeguards every developer needs to implement, the administrative work that surrounds them, and the mistakes we see most often when reviewing healthcare applications.
This is an engineering guide, not legal advice. Your compliance officer and legal counsel decide how HIPAA applies to your organisation; your job as an engineer is to make the system capable of meeting those obligations.
Who and What HIPAA Covers
- Covered entities: healthcare providers, health plans and clearinghouses.
- Business associates: vendors that create, receive, store or transmit protected health information on their behalf. If you build or host software for a hospital or clinic, you are very likely a business associate.
- Protected Health Information (PHI): health information linked to an identifiable person, such as names, dates, contact details, record numbers and many other identifiers. When stored or transmitted electronically it is called ePHI.
The HIPAA Security Rule groups its requirements into administrative, physical and technical safeguards. Developers work most directly with the technical safeguards in § 164.312, but the administrative ones decide whether those controls are used correctly.
Technical Safeguards Deep Dive
Access Control (§ 164.312(a))
Implement role-based access control (RBAC) with the principle of least privilege. Every user should only have access to the minimum data necessary for their role.
The standard also expects unique user identification (no shared accounts), an emergency access procedure, automatic logoff after inactivity, and encryption of ePHI where appropriate.
const hipaaAuth = (requiredRole) => (req, res, next) => {
const user = req.user;
if (!user) return res.status(401).json({ error: "Authentication required" });
if (!user.roles.includes(requiredRole)) {
auditLog({ event: "ACCESS_DENIED", userId: user.id, resource: req.path });
return res.status(403).json({ error: "Insufficient permissions" });
}
next();
};Role checks are only the first layer. Most real breaches of least privilege happen inside an allowed role: a clinician viewing a patient they are not treating. Add relationship checks (is this user part of the patient's care team?) for the most sensitive records.
Audit Controls (§ 164.312(b))
Implement comprehensive audit logging for every access to Protected Health Information (PHI). Log who accessed what data, when, from where, and what action they performed.
- Record reads as well as writes. Inappropriate viewing is a common source of incidents.
- Write audit events to append-only storage that application users and ordinary administrators cannot edit or delete.
- Log identifiers (user ID, patient ID, resource ID), never the clinical content itself.
- Review the logs. Alert on unusual patterns, such as one account opening hundreds of records in a short time.
Integrity (§ 164.312(c))
ePHI must be protected from improper alteration or destruction. In practice this means validated inputs, database constraints, versioned records instead of silent overwrites, authenticated encryption (which detects tampering), and tested backups.
Person or Entity Authentication (§ 164.312(d))
Verify that every user and system is who it claims to be. Use multi-factor authentication for staff accounts, short-lived tokens for APIs, and mutual TLS or signed credentials for system-to-system integrations.
Transmission Security (§ 164.312(e))
Protect ePHI in transit with modern TLS on every connection, including internal service-to-service traffic. Disable outdated protocol versions and weak ciphers, and never send ePHI through plain email, SMS or push notification content.
Data Encryption at Rest
Use AES-256-GCM for encrypting sensitive fields. Always generate a unique IV (nonce) per encryption operation and store it alongside the ciphertext. A 12-byte IV is the recommended size for GCM.
import crypto from "crypto";
const ALGORITHM = "aes-256-gcm";
export function encryptField(plaintext, key) {
const iv = crypto.randomBytes(12);
const cipher = crypto.createCipheriv(ALGORITHM, key, iv);
const encrypted = Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]);
const tag = cipher.getAuthTag();
return Buffer.concat([iv, tag, encrypted]).toString("base64");
}
export function decryptField(payload, key) {
const data = Buffer.from(payload, "base64");
const iv = data.subarray(0, 12);
const tag = data.subarray(12, 28);
const encrypted = data.subarray(28);
const decipher = crypto.createDecipheriv(ALGORITHM, key, iv);
decipher.setAuthTag(tag);
return Buffer.concat([decipher.update(encrypted), decipher.final()]).toString("utf8");
}Keep encryption keys out of the database and source code. Store them in a managed key service (such as AWS KMS, Azure Key Vault or Google Cloud KMS), restrict who can use them, and plan for key rotation from the start.
Administrative Safeguards That Affect Engineering
- Risk analysis: a documented assessment of where ePHI lives and what threatens it. Update it when the architecture changes.
- Business Associate Agreements: a BAA is needed with every vendor that handles ePHI for you, including cloud hosting, email, logging, monitoring and AI services. Use only services that are covered by a BAA.
- Minimum necessary: APIs, exports and reports should return only the fields the use case needs.
- Workforce training and access reviews: remove access promptly when people change roles or leave.
- Contingency planning: backups, disaster recovery and an emergency mode of operation, all tested.
Breach Readiness
Under the Breach Notification Rule, a breach of unsecured PHI must be reported to affected individuals without unreasonable delay and no later than 60 days after discovery, with additional reporting to the regulator and, for large breaches, the media. Data encrypted to recognised standards is generally treated as secured, which is one of the strongest reasons to encrypt. Engineering's part is to make detection and investigation possible: good audit logs, alerting, and a written incident response plan that names who does what.
Development Practices That Keep You Compliant
- No real PHI outside production. Use synthetic or properly de-identified data in development, testing and demos.
- No PHI in logs, error trackers or analytics. Scrub request bodies and URLs before they leave the application.
- Secrets management: no credentials in code or configuration files committed to version control.
- Security in the pipeline: dependency scanning, static analysis and code review for every change.
- Regular testing: periodic vulnerability scans and independent penetration tests.
Common HIPAA Violations in Software
| Violation | Prevention |
|---|---|
| Insufficient Access Controls | Implement RBAC with least privilege |
| Missing Audit Logs | Comprehensive audit logging for all PHI access |
| Unencrypted Data | Field-level encryption for sensitive data at rest |
| No BAA with Vendors | Execute BAAs with all vendors handling PHI |
| PHI in Logs and Error Reports | Scrub payloads before logging; log identifiers only |
| Real Patient Data in Test Environments | Use synthetic or de-identified data outside production |
| Shared or Stale Accounts | Unique user IDs, MFA and regular access reviews |
Developer Checklist
- Every user has a unique account; MFA is enforced for staff
- Role and relationship checks protect every PHI endpoint
- Every read and write of PHI creates a tamper-resistant audit event
- ePHI is encrypted in transit and at rest, with keys in a managed key service
- Sessions time out automatically after inactivity
- No PHI in logs, analytics, test data or notifications
- Every vendor that touches ePHI is covered by a BAA
- Backups are encrypted and restores are tested
- An incident response plan exists and has been rehearsed
Conclusion
HIPAA compliance is a continuous process, not a one-time achievement. Build compliance into your development lifecycle from day one, and conduct regular security assessments.
Building healthcare software on modern standards? See how we apply these safeguards in a FHIR-compliant healthcare platform, or talk to our team about your project.