healthcare-eval-harness

healthcare-eval-harness

热门

面向医疗应用部署的患者安全评估工具。自动化测试套件,涵盖CDSS准确性、PHI暴露、临床工作流完整性和集成合规性。安全失败时阻止部署。

23万Star
3.5万Fork
更新于 2026/7/20
SKILL.md
readonly只读
name
healthcare-eval-harness
description

面向医疗应用部署的患者安全评估工具。自动化测试套件,涵盖CDSS准确性、PHI暴露、临床工作流完整性和集成合规性。安全失败时阻止部署。

version
1.0.0

Healthcare Eval Harness — 患者安全验证

医疗应用部署的自动化验证系统。单个CRITICAL失败即阻止部署。患者安全不容妥协。

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

使用时机

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

工作原理

评估工具按顺序运行五个测试类别。前三个(CDSS准确性、PHI暴露、数据完整性)是CRITICAL门控,要求100%通过率——单个失败即阻止部署。后两个(临床工作流、集成)是HIGH门控,要求95%以上通过率。

每个类别对应一个Jest测试路径模式。CI流水线使用--bail(首次失败即停止)运行CRITICAL门控,并使用--coverage --coverageThreshold强制执行覆盖率阈值。

评估类别

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

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

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

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

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

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

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

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

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

4. 临床工作流(HIGH — 要求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. 集成合规性(HIGH — 要求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: 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

      # CRITICAL门控 — 要求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

      # HIGH门控 — 要求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测试
  • 将CRITICAL阈值设置为低于100%
  • 在CRITICAL测试套件中使用--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:检查HIGH门控通过率

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%+)
### 结论: 可安全部署