Communitygithub.com

医疗评估测试框架 - 患者安全验证

面向医疗应用部署的患者安全评估测试框架。包含CDSS准确性、PHI暴露、临床工作流完整性及集成合规性的自动化测试套件。在安全失败时阻止部署。适用于需要基于患者安全测试(CDSS准确性、PHI暴露、工作流完整性)来把关部署的医疗场景。

医疗评估测试框架 - 患者安全验证 是什么?

医疗评估测试框架(Healthcare Eval Harness)是一个专门为医疗应用部署设计的患者安全自动化验证系统。它通过五个测试类别对部署进行严格把关:CDSS准确性、PHI暴露和数据完整性三个类别为关键门控(CRITICAL),必须达到100%通过率;临床工作流和集成合规性为高优先级门控(HIGH),要求95%以上的通过率。任何CRITICAL级别的失败都会直接阻止部署,从而保障患者安全。该框架支持多种开发平台(如Jest、Vitest、pytest、PHPUnit等)和CI/CD系统(如GitHub Actions),通过配置测试路径模式、阈值和`--bail`选项实现自动化的安全门控。它适用于EMR/EHR应用部署、CDSS逻辑修改、数据库模式变更、认证系统修改、CI/CD管道配置以及临床模块合并冲突解决等场景。该框架还提供了丰富的抗反模式指南,例如禁止跳过CDSS测试、禁止将CRITICAL阈值设为100%以下、禁止使用`--no-bail`选项等,确保测试的严格性和可靠性。

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

在你喜欢的 AI 中提问

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

文档

医疗评估测试框架 — 患者安全验证

面向医疗应用部署的自动化验证系统。任一CRITICAL级别失败将阻止部署。患者安全不容妥协。

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

何时使用

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

工作原理

评估测试框架按顺序运行五个测试类别。前三个类别(CDSS准确性、PHI暴露、数据完整性)是关键门控(CRITICAL),要求100%通过率——任何一个失败都会阻止部署。其余两个类别(临床工作流、集成)是高优先级门控(HIGH),要求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 "未找到临床测试" >&2
  exit 1
fi
rate=$(echo "scale=2; $passed * 100 / $total" | bc)
echo "临床通过率: ${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 "未找到集成测试" >&2
  exit 1
fi
rate=$(echo "scale=2; $passed * 100 / $total" | bc)
echo "集成通过率: ${rate}% ($passed/$total)"

通过/失败矩阵

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

CI/CD集成

name: 医疗安全门控
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准确性
        run: npx jest --testPathPattern='tests/cdss' --bail --ci --coverage --coverageThreshold='{"global":{"branches":80,"functions":80,"lines":80}}'

      - name: PHI暴露检查
        run: npx jest --testPathPattern='tests/security/phi' --bail --ci

      - name: 数据完整性
        run: npx jest --testPathPattern='tests/data-integrity' --bail --ci

      # 高优先级门控 — 要求95%以上,自定义阈值检查
      # 高优先级门控 — 要求95%以上
      - name: 临床工作流
        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::未找到临床测试"; exit 1
          fi
          RATE=$(echo "scale=2; $PASSED * 100 / $TOTAL" | bc)
          echo "通过率: ${RATE}% ($PASSED/$TOTAL)"
          if (( $(echo "$RATE < 95" | bc -l) )); then
            echo "::warning::临床通过率 ${RATE}% 低于95%"
          fi

      - name: 集成合规性
        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::未找到集成测试"; exit 1
          fi
          RATE=$(echo "scale=2; $PASSED * 100 / $TOTAL" | bc)
          echo "通过率: ${RATE}% ($PASSED/$TOTAL)"
          if (( $(echo "$RATE < 95" | bc -l) )); then
            echo "::warning::集成通过率 ${RATE}% 低于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]

### 患者安全:通过

| 类别 | 测试数 | 通过 | 失败 | 状态 |
|----------|-------|------|------|--------|
| CDSS准确性 | 39 | 39 | 0 | 通过 |
| PHI暴露 | 8 | 8 | 0 | 通过 |
| 数据完整性 | 12 | 12 | 0 | 通过 |
| 临床工作流 | 22 | 21 | 1 | 95.5% 通过 |
| 集成 | 6 | 6 | 0 | 通过 |

### 覆盖率:84%(目标:80%+)
### 判定:可安全部署

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.

相关技能