← All articles

An Engineer's Guide to HIPAA Consent and 42 CFR Part 2

HIPAA compliance is one of the areas where 1Putt Health clients most consistently underestimate the engineering scope. The regulatory framework is well-documented — HHS has published extensive guidance, and the Privacy and Security Rules are not ambiguous. What is less documented is what the regulations actually require you to build: the consent data models, the enforcement architecture, the audit systems, and the distinct requirements that apply when you are handling substance use disorder records under 42 CFR Part 2.

This is the guide for engineers. Not the policy overview — the implementation requirements.

What HIPAA Actually Requires: Two Distinct Frameworks

HIPAA establishes two separate sets of patient-facing requirements that engineers frequently conflate.

Notice of Privacy Practices (NPP) acknowledgment: Every covered entity must provide patients with a written notice describing how their PHI may be used and disclosed. Patients must acknowledge receipt of this notice. This acknowledgment is not consent to data use — it is documentation that the patient received the notice and understands their rights. You need to capture and store this acknowledgment, but it does not restrict what you can do with data for treatment, payment, or healthcare operations (TPO).

Authorization: Written patient permission for uses of PHI that fall outside the TPO exception. Research studies, marketing communications, sharing data with non-covered entities, and most secondary uses of clinical data require explicit, documented patient authorization. Authorization is meaningful consent — it restricts what you can do with data to the specific uses the patient approved.

The engineering requirements differ significantly between these two. NPP acknowledgment tracking is a record-keeping problem. Authorization management is an access control problem. Conflating them leads to systems that capture consent correctly but do not enforce it — which is the most common compliance failure mode we see.

Designing a Consent Data Model

A consent record needs to be more than a row in a user table with a consent_accepted boolean. It needs to be an immutable, verifiable record that answers the following questions in a compliance audit:

  • Who consented, and how was their identity verified?
  • What exactly did they consent to — and what was the precise language they saw?
  • When did they consent, and from where?
  • Is the consent still active, or has it been revoked or expired?
  • What specific data uses does this consent cover?

A schema that satisfies these requirements:

enum ConsentType {
  NPP_ACKNOWLEDGMENT = 'NPP_ACKNOWLEDGMENT',
  AUTHORIZATION = 'AUTHORIZATION',
  RESEARCH_AUTHORIZATION = 'RESEARCH_AUTHORIZATION',
  MARKETING_AUTHORIZATION = 'MARKETING_AUTHORIZATION',
  PART2_CONSENT = 'PART2_CONSENT',       // 42 CFR Part 2 specific
}

enum ConsentStatus {
  ACTIVE = 'ACTIVE',
  WITHDRAWN = 'WITHDRAWN',
  EXPIRED = 'EXPIRED',
}

enum DataScope {
  TREATMENT = 'TREATMENT',
  PAYMENT = 'PAYMENT',
  OPERATIONS = 'OPERATIONS',
  RESEARCH = 'RESEARCH',
  MARKETING = 'MARKETING',
  THIRD_PARTY_SHARING = 'THIRD_PARTY_SHARING',
  SUD_TREATMENT = 'SUD_TREATMENT',       // 42 CFR Part 2 classified
}

interface ConsentRecord {
  id: string                        // Stable UUID for this consent event
  patientId: string                 // Internal patient identifier
  consentType: ConsentType
  status: ConsentStatus
  // Document verification
  consentDocumentVersion: string    // e.g. "NPP-2026-01"
  consentDocumentHash: string       // SHA-256 of exact consent text presented
  // Timing
  grantedAt: string                 // ISO 8601, server-side timestamp
  expiresAt?: string                // For time-limited authorizations
  revokedAt?: string                // Set when withdrawn
  // Scope
  dataScopes: DataScope[]           // Specific uses authorized
  recipientOrganizations?: string[] // For 42 CFR Part 2: explicit named recipients
  // Collection context
  collectionMethod: string          // 'WEB_FORM' | 'PATIENT_PORTAL' | 'IN_PERSON' | 'PAPER_SCAN'
  collectionIpAddress?: string
  collectionUserAgent?: string
  collectionSessionId?: string
  // Non-repudiation
  verificationMethod: string        // 'EMAIL_CONFIRMED' | 'SMS_OTP' | 'IN_PERSON_ID'
  verificationToken?: string        // Token from email/SMS confirmation
  // Audit trail — append-only
  auditEvents: ConsentAuditEvent[]
}

interface ConsentAuditEvent {
  eventId: string
  timestamp: string
  eventType: 'CREATED' | 'ACTIVATED' | 'WITHDRAWN' | 'EXPIRED' | 'VIEWED' | 'EXPORTED'
  performedBy: string               // userId or 'SYSTEM'
  details?: Record<string, string>
}

The consentDocumentHash field is the most commonly omitted and most important field. In an audit, you need to prove exactly what language the patient saw when they consented. Hash the full consent document text at the time of presentation and store it with the record. If your consent language changes later, existing records remain unambiguously tied to the version that was actually presented.

Implementing Consent Enforcement

Capturing consent is the easy part. Enforcing it — ensuring that every downstream data use respects the scope of what was actually authorized — is where most systems fail.

Consent enforcement has to be a policy layer, not a series of ad-hoc checks scattered through business logic. Here is a minimal enforcement middleware:

import { ConsentService } from './consent-service'
import { DataScope } from './types'

export class ConsentEnforcementError extends Error {
  constructor(
    public readonly patientId: string,
    public readonly requiredScope: DataScope,
    public readonly reason: 'NOT_CONSENTED' | 'EXPIRED' | 'WITHDRAWN'
  ) {
    super(`Consent enforcement failed for patient ${patientId}: ${reason} for scope ${requiredScope}`)
  }
}

export async function requireConsent(
  patientId: string,
  requiredScope: DataScope
): Promise<ConsentRecord> {
  const consent = await ConsentService.getActiveConsent(patientId, requiredScope)

  if (!consent) {
    throw new ConsentEnforcementError(patientId, requiredScope, 'NOT_CONSENTED')
  }

  if (consent.status === ConsentStatus.WITHDRAWN) {
    throw new ConsentEnforcementError(patientId, requiredScope, 'WITHDRAWN')
  }

  if (consent.expiresAt && new Date(consent.expiresAt) < new Date()) {
    // Update status and throw
    await ConsentService.markExpired(consent.id)
    throw new ConsentEnforcementError(patientId, requiredScope, 'EXPIRED')
  }

  return consent
}

// Decorator pattern for route handlers
export function withConsentCheck(scope: DataScope) {
  return function (target: unknown, propertyKey: string, descriptor: PropertyDescriptor) {
    const originalMethod = descriptor.value
    descriptor.value = async function (...args: unknown[]) {
      const req = args[0] as { params: { patientId: string } }
      await requireConsent(req.params.patientId, scope)
      return originalMethod.apply(this, args)
    }
    return descriptor
  }
}

// Usage
class PatientDataController {
  @withConsentCheck(DataScope.RESEARCH)
  async getPatientDataForResearch(req: Request, res: Response) {
    // This method only executes if consent is verified
    const data = await PatientService.getData(req.params.patientId)
    res.json(data)
  }
}

The DataScope enum maps directly to the uses described in your authorization language. Consent for RESEARCH does not imply consent for MARKETING. The enforcement layer must check the specific scope of the requested use, not just whether any consent record exists.

42 CFR Part 2: The Stricter Framework You May Not Know About

42 CFR Part 2 is a federal regulation governing the confidentiality of substance use disorder (SUD) patient records maintained by federally assisted programs. It is materially stricter than HIPAA, and engineers who have not encountered it before often do not know it exists until they are building for a behavioral health, addiction treatment, or integrated care platform.

The February 2024 final rule aligned several aspects of Part 2 with HIPAA — most significantly by allowing a single consent for all future uses for treatment, payment, and healthcare operations. But Part 2 still maintains restrictions that HIPAA does not:

RequirementHIPAA42 CFR Part 2
Consent for TPO usesNot requiredRequired (single consent, post-2024 rule)
Named recipient requiredNoYes — consent must name specific recipients
Redisclosure restrictionLimitedExplicit prohibition with patient consent or court order
Use in legal proceedingsPermitted with court orderRestricted even with court order in most cases
PenaltiesCivil and criminalSame as HIPAA post-2024 rule alignment

The engineering implications are concrete:

Data classification: Your data model must classify SUD treatment records separately from general PHI. This is not optional metadata — it is a structural requirement. Every data access path must check classification before applying enforcement logic.

Named recipient requirement: Part 2 consent must name the specific organizations authorized to receive the records. "Healthcare providers involved in treatment" is sufficient for TPO consents under the 2024 rule, but a consent to share records with a research institution must name that institution specifically. Your consent model needs a recipientOrganizations field that is actually enforced.

Redisclosure prevention: If you share Part 2 records with a downstream service, that service must receive explicit notice that the records are subject to Part 2 and cannot be redisclosed. This needs to be in your API contracts and in the Business Associate Agreements with every vendor that handles this data.

Audit granularity: Every Part 2 disclosure must be logged with the recipient identity, the purpose of disclosure, and the specific consent record that authorized it. This is a higher standard than general HIPAA audit logging, which tracks access events but does not require per-disclosure consent linkage.

// 42 CFR Part 2 compliant disclosure log entry
interface Part2DisclosureLog {
  disclosureId: string
  patientId: string
  disclosureTimestamp: string
  recipient: {
    organizationName: string
    organizationId: string
    npi?: string
  }
  purposeOfDisclosure: string
  recordsDisclosed: string[]         // Resource IDs or record identifiers
  authorizedByConsentId: string      // Links to the Part2ConsentRecord
  part2NoticeDelivered: boolean      // Did recipient receive the redisclosure prohibition notice?
  part2NoticeText: string            // The actual notice language delivered
}

Electronic Consent Validity Requirements

For consent collected digitally, the E-SIGN Act and UETA provide the legal framework for electronic signature validity. For healthcare authorization specifically, regulators and courts have looked for:

  • Affirmative action: The patient must take a deliberate action — clicking a button, checking a checkbox that is not pre-checked, completing a drawn signature. Passive implied consent does not meet the standard.
  • Full text presentation: The patient must be presented with the complete consent text at the time of signing, not a summary or a link. Scroll-gated consent flows — where the submission button is only enabled after the user has scrolled through the full text — create a better evidence record.
  • Server-side timestamp: The timestamp of the consent event must be recorded server-side. A client-provided timestamp can be manipulated.
  • Confirmation delivery: Send a copy of the signed consent to the patient's verified contact — email or patient portal message. This creates an independently timestamped record that the patient received the consent language.
  • Revocation path: Patients have the right to revoke authorization. Your consent system must provide a clear mechanism for revocation that is at least as accessible as the original consent flow.

For high-stakes authorizations — research participation, data sharing with third parties, commercial uses — add a secondary verification step (email confirmation link, SMS OTP) that generates an additional timestamped event in your audit trail.

The PHI Audit Logging Requirement

The HIPAA Security Rule requires audit controls: mechanisms that record and examine activity in systems that contain ePHI. The practical requirement is an audit log for every PHI access event.

interface PhiAuditEvent {
  eventId: string
  timestamp: string                  // Server-side, not client-provided
  userId: string
  userRole: string
  patientId: string
  resourceType: string               // FHIR resource type or internal data type
  resourceId: string
  action: 'READ' | 'CREATE' | 'UPDATE' | 'DELETE' | 'EXPORT' | 'TRANSMIT'
  dataClassification: 'PHI' | 'SUD_PHI' | 'MENTAL_HEALTH_PHI'
  purposeOfAccess: string
  success: boolean
  ipAddress: string
  sessionId: string
  requestId: string                  // Correlates with application logs
  consentId?: string                 // Which consent authorized this access
  part2DisclosureId?: string         // If this is a Part 2 disclosure
}

Audit logs for ePHI access must be:

  • Tamper-evident: Write to an append-only store or a WORM storage system. Do not write audit logs to the same database as application data where they could be modified by the same code paths.
  • Retained for minimum six years from date of creation (HIPAA's six-year retention requirement for documentation applies; many state laws add additional requirements).
  • Reviewable: You must be able to query your audit logs to answer "who accessed this patient's record and when" within a reasonable timeframe. Store logs in a queryable format, not just a text dump.
  • Comprehensive: Log access failures as well as successes. A pattern of failed access attempts against a specific patient record is a security signal.

HITRUST and SOC 2: The Enterprise Proof Layer

HIPAA compliance is self-attested. There is no federal certification. Enterprise buyers — health systems, large employer groups, payers — increasingly require independent third-party validation: a SOC 2 Type II report, a HITRUST certification, or both.

SOC 2 Type II tests your security controls against the AICPA Trust Services Criteria over an observation period (typically 6-12 months). Type II means the auditor verified that the controls operated effectively during the period, not just that they existed on paper. The observation period starts when you say it does — which means you need your controls in place before the clock starts, not as you are preparing for the audit.

HITRUST r2 (Risk-based, 2-Year) is the gold standard for enterprise health system procurement. It validates 200+ controls across 19 control categories and is increasingly a contractual requirement for vendors working with large health systems and payers. The i1 (Implemented, 1-Year) certification validates 44 controls and is a reasonable starting point for earlier-stage companies that need to demonstrate healthcare-specific security posture.

The practical path for most digital health startups: implement HIPAA controls correctly from the start, pursue SOC 2 Type II at Series A or when the first enterprise procurement requires it, evaluate HITRUST i1 when health system customers request it as a qualification criterion.

Do not treat compliance as a retrofit. The cost of implementing controls correctly during initial development is a fraction of the cost of retrofitting them after a security assessment reveals gaps.


Get Your Compliance Architecture Right Before Your First Enterprise Deal

HIPAA and 42 CFR Part 2 compliance gaps surface during health system security reviews — and when they do, they kill deals that took a year to develop. 1Putt Health specializes in HIPAA compliance architecture, SOC 2 readiness, and HITRUST assessment preparation for digital health companies. We help you build the controls correctly and document them in a way that survives enterprise procurement scrutiny.

Book a discovery call to assess where your current architecture stands.