Help us improve
Share bugs, ideas, or general feedback.
PHI/PII compliance patterns for healthcare apps covering data classification, row-level security, audit trails, encryption, and common leak vectors.
npx claudepluginhub aaione/everything-claude-code-zhHow this skill is triggered — by the user, by Claude, or both
Slash command
/everything-claude-code:healthcare-phi-complianceThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
用于保护医疗应用程序中患者数据、临床医生数据和财务数据的模式。适用于 HIPAA(美国)、DISHA(印度)、GDPR(欧盟)和通用医疗数据保护。
Data classification, access control, audit trails, and leak vectors for PHI/PII in healthcare applications. Use when building patient-facing features or reviewing data exposure.
Guides PHI data handling per HIPAA: 18 identifiers, Safe Harbor/Expert Determination de-identification, minimum necessary principle, RBAC access controls, audit logging, encryption at rest/transit, secure disposal.
Provides HIPAA-specific compliance rules and decision gates for healthcare software handling PHI. Delegates to healthcare-phi-compliance and healthcare-reviewer for implementation and review.
Share bugs, ideas, or general feedback.
用于保护医疗应用程序中患者数据、临床医生数据和财务数据的模式。适用于 HIPAA(美国)、DISHA(印度)、GDPR(欧盟)和通用医疗数据保护。
医疗数据保护在三个层面运作:分类(什么是敏感的)、访问控制(谁可以看到它)和审计(谁确实看到了它)。
PHI(受保护健康信息) — 可以识别患者且与其健康相关的任何数据:患者姓名、出生日期、地址、电话、电子邮件、国家 ID 号码(SSN、Aadhaar、NHS 号码)、医疗记录号码、诊断、药物、实验室结果、影像、保险单和索赔详情、预约和入院记录,或上述任何组合。
PII(非患者敏感数据) 在医疗系统中:临床医生/员工个人详细信息、医生费用结构和支付金额、员工薪资和银行详细信息、供应商支付信息。
ALTER TABLE patients ENABLE ROW LEVEL SECURITY;
-- 按机构限制访问
CREATE POLICY "staff_read_own_facility"
ON patients FOR SELECT TO authenticated
USING (facility_id IN (
SELECT facility_id FROM staff_assignments
WHERE user_id = auth.uid() AND role IN ('doctor','nurse','lab_tech','admin')
));
-- 审计日志:仅插入(防篡改)
CREATE POLICY "audit_insert_only" ON audit_log FOR INSERT
TO authenticated WITH CHECK (user_id = auth.uid());
CREATE POLICY "audit_no_modify" ON audit_log FOR UPDATE USING (false);
CREATE POLICY "audit_no_delete" ON audit_log FOR DELETE USING (false);
每次 PHI 访问或修改必须记录:
interface AuditEntry {
timestamp: string;
user_id: string;
patient_id: string;
action: 'create' | 'read' | 'update' | 'delete' | 'print' | 'export';
resource_type: string;
resource_id: string;
changes?: { before: object; after: object };
ip_address: string;
session_id: string;
}
错误消息: 永远不要在抛给客户端的错误消息中包含患者识别数据。仅在服务器端记录详细信息。
控制台输出: 永远不要记录完整的患者对象。使用不透明的内部记录 ID(UUID)——而非医疗记录号码、国家 ID 或姓名。
URL 参数: 永远不要将患者识别数据放在可能出现在日志或浏览器历史记录中的查询字符串或路径段中。仅使用不透明的 UUID。
浏览器存储: 永远不要在 localStorage 或 sessionStorage 中存储 PHI。仅将 PHI 保存在内存中,按需获取。
服务角色密钥: 永远不要在客户端代码中使用 service_role 密钥。始终使用 anon/publishable 密钥,让 RLS 强制执行访问。
日志和监控: 永远不要记录完整的患者记录。仅使用不透明的记录 ID(而非医疗记录号码)。在发送到错误跟踪服务之前清理堆栈跟踪。
在架构级别标记 PHI/PII 列:
COMMENT ON COLUMN patients.name IS 'PHI: patient_name';
COMMENT ON COLUMN patients.dob IS 'PHI: date_of_birth';
COMMENT ON COLUMN patients.aadhaar IS 'PHI: national_id';
COMMENT ON COLUMN doctor_payouts.amount IS 'PII: financial';
每次部署前:
// 错误 — 在错误中泄露 PHI
throw new Error(`在 ${patient.facility} 中未找到患者 ${patient.name}`);
// 正确 — 通用错误,仅在服务器端记录带有不透明 ID 的详细信息
logger.error('患者查找失败', { recordId: patient.id, facilityId });
throw new Error('未找到记录');
-- 机构 A 的医生无法看到机构 B 的患者
CREATE POLICY "facility_isolation"
ON patients FOR SELECT TO authenticated
USING (facility_id IN (
SELECT facility_id FROM staff_assignments WHERE user_id = auth.uid()
));
-- 测试:以 doctor-facility-a 身份登录,查询 facility-b 患者
-- 预期:返回 0 行
// 错误 — 记录可识别的患者数据
console.log('正在处理患者:', patient);
// 正确 — 仅记录不透明的内部记录 ID
console.log('正在处理记录:', patient.id);
// 注意:即使是 patient.id 也应该是不透明的 UUID,而非医疗记录号码