跳轉到

HIPAA 合規文件保護

HIPAA(Health Insurance Portability and Accountability Act)安全規則 § 164.312 要求涵蓋實體(Covered Entities)與業務夥伴(Business Associates)對電子受保護健康資訊(ePHI)實施技術保障措施。NextPDF Enterprise 在 PDF 生成層直接實現這些保障,確保含有 PHI 的文件天生具備合規性。


技術保障措施對應

HIPAA § 164.312 條款 要求分類 要求 NextPDF Enterprise 實現
§ 164.312(a)(1) 必要 存取控制 HipaaAccessPolicy — 角色基礎存取
§ 164.312(a)(2)(i) 必要 唯一使用者識別 每份文件綁定使用者 ID,稽核不可偽造
§ 164.312(a)(2)(iii) 必要 自動登出 文件存取 Token 自動過期
§ 164.312(b) 必要 稽核控制 HipaaAuditLogger — 完整 PHI 存取日誌
§ 164.312(c)(1) 必要 完整性 SHA-384 文件完整性驗證
§ 164.312(c)(2) 可定址 電子機制完整性 數位簽章(PAdES B-B)
§ 164.312(d) 必要 個人 / 實體驗證 憑證綁定身份驗證
§ 164.312(e)(1) 必要 傳輸安全 mTLS 1.3 通道
§ 164.312(e)(2)(ii) 可定址 加密傳輸 AES-256-GCM + TLS 1.3

核心 API

HipaaDocumentBuilder

use NextPDF\Enterprise\Compliance\Hipaa\HipaaDocumentBuilder;
use NextPDF\Enterprise\Compliance\Hipaa\PhiField;
use NextPDF\Enterprise\Compliance\Hipaa\HipaaAccessPolicy;
use NextPDF\Enterprise\Compliance\Hipaa\MinimumNecessaryRule;

$policy = HipaaAccessPolicy::create()
    ->allowRole('treating-physician', PhiField::all())
    ->allowRole('billing-staff', PhiField::only([
        PhiField::PatientName,
        PhiField::DateOfBirth,
        PhiField::InsuranceId,
    ]))
    ->allowRole('admin', PhiField::deidentified())
    ->applyMinimumNecessary(MinimumNecessaryRule::RoleBasedFiltering)
    ->requireAuditLog()
    ->encryptWithAes256Gcm();

$document = HipaaDocumentBuilder::create($policy)
    ->withPatientRecord($patientData)
    ->withClinicalNotes($notes)
    ->withAuditTrail($hipaaAuditLogger)
    ->build();

PHP Compatibility

This example uses PHP 8.5 syntax. If your environment runs PHP 8.1 or 7.4, use NextPDF Backport for a backward-compatible build.

HipaaAuditLogger

每次 PHI 文件存取均自動記錄,符合 § 164.312(b) 要求:

use NextPDF\Enterprise\Compliance\Hipaa\HipaaAuditLogger;
use NextPDF\Enterprise\Compliance\Hipaa\AuditEvent;

$logger = new HipaaAuditLogger(
    storageAdapter: $immutableLogAdapter,
    retentionYears: 6, // HIPAA 最低 6 年
);

// 文件存取時自動呼叫(由 HipaaDocumentBuilder 注入)
$logger->log(
    AuditEvent::documentAccessed(
        documentId: $doc->id(),
        accessedBy: $userId,
        patientId: $patientId,
        accessPurpose: AuditPurpose::Treatment,
        fieldsAccessed: $accessedFields,
        ipAddress: $request->ip(),
        timestamp: new DateTimeImmutable(),
    )
);

PhiRedactor

對不具存取權限的使用者執行 PHI 去識別化或遮蔽:

use NextPDF\Enterprise\Compliance\Hipaa\PhiRedactor;
use NextPDF\Enterprise\Compliance\Hipaa\RedactionStrategy;

$redactor = new PhiRedactor(
    strategy: RedactionStrategy::ExpertDetermination, // HIPAA 45 CFR § 164.514(b)
);

// 產生去識別化版本(移除 18 個 HIPAA 識別元素)
$deidentifiedDoc = $redactor->deidentify(
    document: $originalDocument,
    retainFieldsForResearch: [PhiField::AgeGroup, PhiField::GeographicRegion],
);

// 或選擇性遮蔽(保留部分識別元素)
$redactedDoc = $redactor->redact(
    document: $originalDocument,
    fieldsToRedact: PhiField::exceptFor([PhiField::PatientName, PhiField::DateOfBirth]),
    redactionMark: '████', // 視覺遮蔽
);

PHI 最小必要原則

HIPAA § 164.514(d) 要求存取與揭露 PHI 時遵循最小必要原則:

use NextPDF\Enterprise\Compliance\Hipaa\MinimumNecessaryEnforcer;

$enforcer = new MinimumNecessaryEnforcer($roleRepository);

// 依角色自動過濾 PHI 欄位
$filteredDocument = $enforcer->applyFor(
    document: $fullDocument,
    requestingRole: $currentUser->role(),
    disclosurePurpose: DisclosurePurpose::PaymentProcessing,
);

業務夥伴協議(BAA)支援

use NextPDF\Enterprise\Compliance\Hipaa\BaaComplianceValidator;

// 驗證 BAA 條款是否涵蓋當前使用場景
$validator = new BaaComplianceValidator($baaRepository);

$validation = $validator->validateDisclosure(
    recipientId: $thirdPartyId,
    disclosureType: DisclosureType::CloudStorage,
    dataClassification: DataClassification::Phi,
);

if (!$validation->isPermitted()) {
    throw new HipaaViolationException(
        'BAA does not cover this disclosure type: ' . $validation->reason()
    );
}

文件加密規格

加密層 演算法 金鑰長度 說明
PDF 加密 AES-256-GCM 256 bit 文件靜態加密
金鑰加密 RSA-OAEP / ECDH 4096 / P-384 KEK 保護
傳輸層 TLS 1.3 mTLS 雙向驗證
稽核日誌 HMAC-SHA-384 384 bit 日誌完整性封印

延伸閱讀