Communitygithub.com

医疗保健评估测试框架

用于医疗应用部署的患者安全验证框架。自动测试CDSS准确性、PHI暴露、临床工作流完整性和集成合规性。安全失败将阻止部署。当医疗部署必须通过患者安全测试(CDSS准确性、PHI暴露和工作流完整性)时使用。

医疗保健评估测试框架 是什么?

医疗保健评估测试框架是一个自动化的验证系统,专为医疗类应用(如EMR/EHR系统)的部署而设计。它运行五个测试类别,其中前三个(CDSS准确性、PHI暴露、数据完整性)为“关键”门控,要求100%通过率;后两个(临床工作流和集成合规性)为“高”门控,要求95%以上。该框架适用于任何测试框架(如Jest、Vitest、pytest等),并可直接集成到CI/CD管道中(提供GitHub Actions示例)。当单个关键类别失败时,部署会被阻止,以确保患者安全。同时,它提供了反模式清单(如不要跳过CDSS测试、不要将关键阈值设置为低于100%、不要在生产环境中模拟CDSS引擎)以及本地运行和生成评估报告的示例。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/tree/main/skills/healthcare-eval-harness

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

医疗保健评估框架 —— 患者安全验证

用于医疗应用部署的自动化验证系统。任何一个关键失败都会阻止部署。患者安全不容置疑。

注: 示例使用 Jest 作为参考测试运行器。请根据您的测试框架(Vitest、pytest、PHPUnit 等)调整命令 —— 测试类别和通过阈值与框架无关。

何时使用

  • 部署 EMR/EHR 应用程序之前
  • 修改 CDSS 逻辑(药物相互作用、剂量验证、评分)之后
  • 更改涉及患者数据的数据库模式之后
  • 修改身份验证或访问控制之后
  • 在配置医疗应用的 CI/CD 管道期间
  • 解决临床模块中的合并冲突之后

工作原理

评估框架按顺序运行五个测试类别。前三个(CDSS 准确性、PHI 暴露、数据完整性)是关键门控,要求 100% 通过率 —— 任何一个失败都会阻止部署。后两个(临床工作流、集成合规性)是高门控,要求 95% 以上通过率。

每个类别对应一个 Jest 测试路径模式。CI 管道对关键门控使用 --bail(遇到第一个失败即停止),并通过 --coverage --coverageThreshold 强制覆盖阈值。

评估类别

1. CDSS 准确性(关键 —— 要求 100%)

测试所有临床决策支持逻辑:药物相互作用对(双向)、剂量验证规则、临床评分与已发布规范的对比、无假阴性、无静默失败。

npx jest --testPathPattern='tests/cdss' --bail --ci --coverage

2. PHI 暴露(关键 —— 要求 100%)

测试受保护健康信息泄露:API 错误响应、控制台输出、URL 参数、浏览器存储、跨机构隔离、未认证访问、服务角色密钥缺失。

npx jest --testPathPattern='tests/security/phi' --bail --ci

3. 数据完整性(关键 —— 要求 100%)

测试临床数据安全:锁定病历、审计跟踪条目、级联删除保护、并发编辑处理、无孤立记录。

npx jest --testPathPattern='tests/data-integrity' --bail --ci

4. 临床工作流(高 —— 要求 95%+)

测试端到端流程:病历生命周期、模板渲染、用药组合、药物/诊断搜索、处方 PDF、红色警报。

tmp_json=$(mktemp)
npx jest --testPathPattern='tests/clinical' --ci --json --outputFile="$tmp_json" || true
total=$(jq '.numTotalTests // 0' "$tmp_json")
passed=$(jq '.numPassedTests // 0' "$tmp_json")
if [ "$total" -eq 0 ]; then
  echo "No clinical tests found" >&2
  exit 1
fi
rate=$(echo "scale=2; $passed * 100 / $total" | bc)
echo "Clinical pass rate: ${rate}% ($passed/$total)"

5. 集成合规性(高 —— 要求 95%+)

测试外部系统:HL7 消息解析(v2.x)、FHIR 验证、实验室结果映射、格式错误消息处理。

tmp_json=$(mktemp)
npx jest --testPathPattern='tests/integration' --ci --json --outputFile="$tmp_json" || true
total=$(jq '.numTotalTests // 0' "$tmp_json")
passed=$(jq '.numPassedTests // 0' "$tmp_json")
if [ "$total" -eq 0 ]; then
  echo "No integration tests found" >&2
  exit 1
fi
rate=$(echo "scale=2; $passed * 100 / $total" | bc)
echo "Integration pass rate: ${rate}% ($passed/$total)"

通过/失败矩阵

类别阈值失败时操作
CDSS 准确性100%阻止部署
PHI 暴露100%阻止部署
数据完整性100%阻止部署
临床工作流95%+警告,允许经审核后部署
集成合规性95%+警告,允许经审核后部署

CI/CD 集成

name: Healthcare Safety Gate
on: [push, pull_request]

jobs:
  safety-gate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
      - run: npm ci

      # 关键门控 —— 要求 100%,遇到第一个失败即停止
      - name: CDSS Accuracy
        run: npx jest --testPathPattern='tests/cdss' --bail --ci --coverage --coverageThreshold='{"global":{"branches":80,"functions":80,"lines":80}}'

      - name: PHI Exposure Check
        run: npx jest --testPathPattern='tests/security/phi' --bail --ci

      - name: Data Integrity
        run: npx jest --testPathPattern='tests/data-integrity' --bail --ci

      # 高门控 —— 要求 95%+,自定义阈值检查
      - name: Clinical Workflows
        run: |
          TMP_JSON=$(mktemp)
          npx jest --testPathPattern='tests/clinical' --ci --json --outputFile="$TMP_JSON" || true
          TOTAL=$(jq '.numTotalTests // 0' "$TMP_JSON")
          PASSED=$(jq '.numPassedTests // 0' "$TMP_JSON")
          if [ "$TOTAL" -eq 0 ]; then
            echo "::error::No clinical tests found"; exit 1
          fi
          RATE=$(echo "scale=2; $PASSED * 100 / $TOTAL" | bc)
          echo "Pass rate: ${RATE}% ($PASSED/$TOTAL)"
          if (( $(echo "$RATE < 95" | bc -l) )); then
            echo "::warning::Clinical pass rate ${RATE}% below 95%"
          fi

      - name: Integration Compliance
        run: |
          TMP_JSON=$(mktemp)
          npx jest --testPathPattern='tests/integration' --ci --json --outputFile="$TMP_JSON" || true
          TOTAL=$(jq '.numTotalTests // 0' "$TMP_JSON")
          PASSED=$(jq '.numPassedTests // 0' "$TMP_JSON")
          if [ "$TOTAL" -eq 0 ]; then
            echo "::error::No integration tests found"; exit 1
          fi
          RATE=$(echo "scale=2; $PASSED * 100 / $TOTAL" | bc)
          echo "Pass rate: ${RATE}% ($PASSED/$TOTAL)"
          if (( $(echo "$RATE < 95" | bc -l) )); then
            echo "::warning::Integration pass rate ${RATE}% below 95%"
          fi

反模式

  • 跳过 CDSS 测试,因为“上次通过了”
  • 将关键阈值设置为低于 100%
  • 在关键测试套件中使用 --no-bail
  • 在集成测试中模拟 CDSS 引擎(必须测试真实逻辑)
  • 在安全门控显示红色时允许部署
  • 在 CDSS 套件上运行测试时不使用 --coverage

示例

示例 1:本地运行所有关键门控

npx jest --testPathPattern='tests/cdss' --bail --ci --coverage && \
npx jest --testPathPattern='tests/security/phi' --bail --ci && \
npx jest --testPathPattern='tests/data-integrity' --bail --ci

示例 2:检查高门控通过率

tmp_json=$(mktemp)
npx jest --testPathPattern='tests/clinical' --ci --json --outputFile="$tmp_json" || true
jq '{
  passed: (.numPassedTests // 0),
  total: (.numTotalTests // 0),
  rate: (if (.numTotalTests // 0) == 0 then 0 else ((.numPassedTests // 0) / (.numTotalTests // 1) * 100) end)
}' "$tmp_json"
# 预期输出: { "passed": 21, "total": 22, "rate": 95.45 }

示例 3:评估报告

## Healthcare Eval: 2026-03-27 [commit abc1234]

### Patient Safety: PASS

| Category | Tests | Pass | Fail | Status |
|----------|-------|------|------|--------|
| CDSS Accuracy | 39 | 39 | 0 | PASS |
| PHI Exposure | 8 | 8 | 0 | PASS |
| Data Integrity | 12 | 12 | 0 | PASS |
| Clinical Workflow | 22 | 21 | 1 | 95.5% PASS |
| Integration | 6 | 6 | 0 | PASS |

### Coverage: 84% (target: 80%+)
### Verdict: SAFE TO DEPLOY

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.

相关技能