Communitygithub.com

醫療保健 PHI/PII 合規模式

針對醫療保健應用程式中的受保護健康資訊 (PHI) 及個人識別資訊 (PII) 合規模式,涵蓋資料分類、存取控制、稽核軌跡、加密及常見洩漏向量。

PII 合規模式 是什麼?

此技能提供一套全面的指南,用於在醫療保健應用程式中保護受保護健康資訊 (PHI) 與個人識別資訊 (PII)。它適用於 HIPAA、DISHA 及 GDPR 等法規。該模式圍繞三個核心層次組織:資料分類(識別 PHI 與 PII)、存取控制(透過資料列層級安全性 (RLS) 強制執行最小權限原則),以及稽核軌跡(記錄所有資料存取以確保問責性)。此外,該技能還詳細列出了常見的漏洞洩漏向量,例如錯誤訊息、主控台日誌、URL 參數、瀏覽器儲存以及服務角色金鑰的使用,並提供關於如何安全處理這些問題的具體指導。它還包括用於資料庫模式標記的 SQL 範例(將欄位標記為 PHI 或 PII)、部署前檢查清單,以及展示安全與不安全編碼實踐的範例,例如錯誤處理、多設施資料隔離以及安全日誌記錄。該技能與基於 SQL 的資料庫和 TypeScript/JavaScript 環境相關。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/healthcare-phi-compliance

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

PII 合規模式 是做什麼的?

用於保護醫療保健應用程式中病患資料、臨床醫生資料及財務資料的模式。適用於 HIPAA(美國)、DISHA(印度)、GDPR(歐盟)及一般醫療保健資料保護。

使用時機

  • 建置任何涉及病患紀錄的功能
  • 為臨床系統實作存取控制或驗證
  • 設計醫療保健資料的資料庫結構描述
  • 建置會回傳病患或臨床醫生資料的 API
  • 實作稽核軌跡或記錄
  • 審查程式碼中是否存在資料暴露漏洞
  • 為多租戶醫療保健系統設定資料列層級安全性 (RLS)

運作方式

醫療保健資料保護運作於三個層面:分類(哪些是敏感資料)、存取控制(誰可以查看)以及稽核(誰查看了資料)。

資料分類

PHI(受保護健康資訊) — 任何能識別病患身份且與其健康相關的資料:病患姓名、出生日期、地址、電話、電子郵件、國民身分證號碼(社會安全碼、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)— 而非病歷號碼、國民身分證號碼或姓名。

URL 參數: 絕不在可能出現在日誌或瀏覽器歷史記錄中的查詢字串或路徑區段中放置可識別病患的資料。僅使用不透明的 UUID。

瀏覽器儲存: 絕不在 localStorage 或 sessionStorage 中儲存 PHI。僅將 PHI 保存在記憶體中,按需擷取。

服務角色金鑰: 絕不在客戶端程式碼中使用服務角色金鑰。始終使用匿名/公開金鑰,並讓 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
  • console.log/console.error 中不包含 PHI
  • URL 參數中不包含 PHI
  • 瀏覽器儲存中不包含 PHI
  • 用戶端程式碼中不包含服務角色金鑰
  • 所有 PHI/PII 資料表上皆已啟用 RLS
  • 所有資料修改皆有稽核軌跡
  • 已設定工作階段逾時
  • 所有 PHI 端點皆已啟用 API 驗證
  • 已驗證跨機構資料隔離

範例

範例 1:安全與不安全的錯誤處理

// 錯誤 — 在錯誤訊息中洩露 PHI
throw new Error(`Patient ${patient.name} not found in ${patient.facility}`);

// 正確 — 通用錯誤,詳細資訊以不透明 ID 在伺服器端記錄
logger.error('Patient lookup failed', { recordId: patient.id, facilityId });
throw new Error('Record not found');

範例 2:多機構隔離的 RLS 政策

-- 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()
  ));

-- 測試:以 A 機構的醫生身份登入,查詢 B 機構的病患
-- 預期:回傳 0 行

範例 3:安全的日誌記錄

// 錯誤 — 記錄可識別的病患資料
console.log('Processing patient:', patient);

// 正確 — 僅記錄不透明的內部紀錄 ID
console.log('Processing record:', patient.id);
// 注意:即使 patient.id 也應是 UUID,而非病歷號碼

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

相關技能