Communitygithub.com

医療ヘルスケアPHI/PIIコンプライアンス

医療アプリケーション向けの要保護医療情報(PHI)および個人識別情報(PII)のコンプライアンスパターン。データ分類、アクセス制御、監査証跡、暗号化、一般的な漏洩ベクトルをカバーします。コードがPHIまたはPIIに触れる場合や、アクセス制御、監査証跡、漏洩ベクトルを監査する場合に使用します。

PIIコンプライアンス とは?

このスキルは、医療アプリケーションにおける要保護医療情報(PHI)および個人識別情報(PII)のコンプライアンスを実現するための包括的なパターンを提供します。HIPAA(米国)、DISHA(インド)、GDPR(EU)などの規制に準拠したデータ保護を支援し、患者記録、臨床データ、財務データを扱うあらゆる機能開発において参照すべきベストプラクティスをまとめています。スキルは3層のデータ保護(データ分類、アクセス制御、監査証跡)を中心に構成され、特にRow-Level Security(RLS)を用いたマルチテナント環境でのデータ隔離や、SQLポリシーの具体例、エラーメッセージやコンソール出力、URLパラメータ、ブラウザストレージ、サービスロールキー、ログ監視といった一般的な漏洩ベクトルへの対策を詳細に解説します。また、データベーススキーマレベルでのPHI/PIIカラムのタグ付け方法やデプロイ前チェックリストも含まれており、実装時の安全な設計とコードレビューに役立ちます。サポートするプラットフォームは特に限定されませんが、主にPostgreSQL(Supabase等)のRLSとTypeScript/Node.js環境での実装例が提供されています。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/tree/main/skills/healthcare-phi-compliance

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

医療ヘルスケアPHI/PIIコンプライアンスパターン

医療アプリケーションにおける患者データ、臨床医データ、財務データを保護するためのパターン。HIPAA(米国)、DISHA(インド)、GDPR(EU)、および一般的な医療データ保護に適用可能。

使用するタイミング

  • 患者記録に触れるあらゆる機能の構築
  • 臨床システム向けのアクセス制御または認証の実装
  • 医療データのデータベーススキーマ設計
  • 患者データまたは臨床医データを返すAPIの構築
  • 監査証跡またはログの実装
  • データ露出脆弱性のコードレビュー
  • マルチテナント医療システム向けの行レベルセキュリティ(RLS)の設定

仕組み

医療データ保護は3つの層で機能します:分類(何が機密か)、アクセス制御(誰が閲覧できるか)、監査(誰が閲覧したか)。

データ分類

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のみを使用する。

ブラウザストレージ: PHIをlocalStorageやsessionStorageに保存しない。PHIはメモリ内にのみ保持し、オンデマンドで取得する。

サービスロールキー: クライアントサイドコードでサービスロールキーを使用しない。常に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がないこと
  • 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()
  ));

-- テスト:医師-facility-a としてログインし、facility-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/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

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.

関連スキル