Communitygithub.com

医疗CDSS开发模式

临床决策支持系统(CDSS)开发模式。包含药物相互作用检查、剂量验证、临床评分(NEWS2、qSOFA)、警报严重性分类以及与EMR工作流的集成。适用于构建临床决策支持功能——药物相互作用检查、剂量验证、临床评分或警报严重性分析。

医疗CDSS开发模式 是什么?

该技能提供了构建临床决策支持系统(CDSS)的标准化模式,专注于与电子病历(EMR)工作流的无缝集成。CDSS模块对患者安全至关重要,要求对假阴性零容忍。它主要包含三个核心模块:药物相互作用检查(`checkInteractions`)、剂量验证(`validateDose`)和临床评分(例如`calculateNEWS2`)。每个模块都设计为无副作用的纯函数,确保完全可测试性和可靠性。 技能详细定义了药物相互作用的双向检查逻辑、基于体重/年龄/肾功能的剂量验证规则,以及遵循英国皇家医师学会精确规范的NEWS2评分表。警报系统按严重性分级(关键、主要、次要),并有明确的UI行为规则——关键警报必须阻止操作且不可自动关闭。此外,它还提供了测试示例和反模式列表,帮助开发者避免常见错误,如使CDSS检查可选、使用toast通知实现交互检查或缺少体重时忽略基于体重的验证。该技能适用于任何需要在其医疗软件中集成临床决策支持的开发者或AI Agent平台。

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

在你喜欢的 AI 中提问

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

文档

医疗CDSS开发模式 是做什么的?

构建与EMR工作流集成的临床决策支持系统的模式。CDSS模块对患者安全至关重要——对假阴性零容忍。

何时使用

  • 实施药物相互作用检查
  • 构建剂量验证引擎
  • 实现临床评分系统(NEWS2、qSOFA、APACHE、GCS)
  • 设计异常临床值的警报系统
  • 构建带有安全检查的药物医嘱录入
  • 结合临床上下文解释实验室结果

工作原理

CDSS引擎是一个无副作用的纯函数库。输入临床数据,输出警报。这使得它完全可测试。

三个主要模块:

  1. checkInteractions(newDrug, currentMeds, allergies) — 检查新药物与当前用药及已知过敏原的相互作用。返回按严重性排序的InteractionAlert[]。使用DrugInteractionPair数据模型。
  2. validateDose(drug, dose, route, weight, age, renalFunction) — 根据基于体重、年龄调整和肾功能调整的规则验证处方剂量。返回DoseValidationResult。
  3. calculateNEWS2(vitals) — 基于NEWS2Input计算国家早期预警评分2。返回包含总分、风险等级和升级指导的NEWS2Result。
EMR用户界面
  ↓ (用户输入数据)
CDSS引擎(纯函数,无副作用)
  ├── 药物相互作用检查器
  ├── 剂量验证器
  ├── 临床评分(NEWS2、qSOFA等)
  └── 警报分类器
  ↓ (返回警报)
EMR用户界面(内联显示警报,关键则阻止)

药物相互作用检查

interface DrugInteractionPair {
  drugA: string;           // 通用名
  drugB: string;           // 通用名
  severity: 'critical' | 'major' | 'minor';
  mechanism: string;
  clinicalEffect: string;
  recommendation: string;
}

function checkInteractions(
  newDrug: string,
  currentMedications: string[],
  allergyList: string[]
): InteractionAlert[] {
  if (!newDrug) return [];
  const alerts: InteractionAlert[] = [];
  for (const current of currentMedications) {
    const interaction = findInteraction(newDrug, current);
    if (interaction) {
      alerts.push({ severity: interaction.severity, pair: [newDrug, current],
        message: interaction.clinicalEffect, recommendation: interaction.recommendation });
    }
  }
  for (const allergy of allergyList) {
    if (isCrossReactive(newDrug, allergy)) {
      alerts.push({ severity: 'critical', pair: [newDrug, allergy],
        message: `与记录的过敏原存在交叉反应: ${allergy}`,
        recommendation: '未经过敏咨询,请勿开具处方' });
    }
  }
  return alerts.sort((a, b) => severityOrder(a.severity) - severityOrder(b.severity));
}

相互作用对必须是双向的:如果药物A与药物B相互作用,那么药物B也与药物A相互作用。

剂量验证

interface DoseValidationResult {
  valid: boolean;
  message: string;
  suggestedRange: { min: number; max: number; unit: string } | null;
  factors: string[];
}

function validateDose(
  drug: string,
  dose: number,
  route: 'oral' | 'iv' | 'im' | 'sc' | 'topical',
  patientWeight?: number,
  patientAge?: number,
  renalFunction?: number
): DoseValidationResult {
  const rules = getDoseRules(drug, route);
  if (!rules) return { valid: true, message: '无验证规则可用', suggestedRange: null, factors: [] };
  const factors: string[] = [];

  // 安全:如果规则需要体重但体重缺失,则阻止(不通过)
  if (rules.weightBased) {
    if (!patientWeight || patientWeight <= 0) {
      return { valid: false, message: `${drug} 需要体重(mg/kg药物)`,
        suggestedRange: null, factors: ['weight_missing'] };
    }
    factors.push('weight');
    const maxDose = rules.maxPerKg * patientWeight;
    if (dose > maxDose) {
      return { valid: false, message: `剂量超过${patientWeight}kg的最大剂量`,
        suggestedRange: { min: rules.minPerKg * patientWeight, max: maxDose, unit: rules.unit }, factors };
    }
  }

  // 基于年龄的调整(当规则定义年龄分段且提供了年龄时)
  if (rules.ageAdjusted && patientAge !== undefined) {
    factors.push('age');
    const ageMax = rules.getAgeAdjustedMax(patientAge);
    if (dose > ageMax) {
      return { valid: false, message: `超过${patientAge}岁的年龄调整最大值`,
        suggestedRange: { min: rules.typicalMin, max: ageMax, unit: rules.unit }, factors };
    }
  }

  // 肾功能调整(当规则定义了eGFR分段且提供了eGFR时)
  if (rules.renalAdjusted && renalFunction !== undefined) {
    factors.push('renal');
    const renalMax = rules.getRenalAdjustedMax(renalFunction);
    if (dose > renalMax) {
      return { valid: false, message: `超过eGFR ${renalFunction}的肾功能调整最大值`,
        suggestedRange: { min: rules.typicalMin, max: renalMax, unit: rules.unit }, factors };
    }
  }

  // 绝对最大值
  if (dose > rules.absoluteMax) {
    return { valid: false, message: `超过绝对最大值 ${rules.absoluteMax}${rules.unit}`,
      suggestedRange: { min: rules.typicalMin, max: rules.absoluteMax, unit: rules.unit },
      factors: [...factors, 'absolute_max'] };
  }
  return { valid: true, message: '在范围内',
    suggestedRange: { min: rules.typicalMin, max: rules.typicalMax, unit: rules.unit }, factors };
}

临床评分:NEWS2

interface NEWS2Input {
  respiratoryRate: number; oxygenSaturation: number; supplementalOxygen: boolean;
  temperature: number; systolicBP: number; heartRate: number;
  consciousness: 'alert' | 'voice' | 'pain' | 'unresponsive';
}
interface NEWS2Result {
  total: number;           // 0-20
  risk: 'low' | 'low-medium' | 'medium' | 'high';
  components: Record<string, number>;
  escalation: string;
}

评分表必须与英国皇家医师学会的规范完全一致。

警报严重性和UI行为

严重性UI行为临床医生需执行的操作
关键阻止操作。不可关闭的模态框。红色。必须记录覆盖理由才能继续
主要内联警告横幅。橙色。必须在继续前确认
次要内联信息提示。黄色。仅用于知晓,无需操作

关键警报绝不能自动关闭或实现为toast通知。覆盖理由必须存储在审计跟踪中。

测试CDSS(对假阴性零容忍)

describe('CDSS — 患者安全', () => {
  INTERACTION_PAIRS.forEach(({ drugA, drugB, severity }) => {
    it(`检测 ${drugA} + ${drugB} (${severity})`, () => {
      const alerts = checkInteractions(drugA, [drugB], []);
      expect(alerts.length).toBeGreaterThan(0);
      expect(alerts[0].severity).toBe(severity);
    });
    it(`检测 ${drugB} + ${drugA}(反向)`, () => {
      const alerts = checkInteractions(drugB, [drugA], []);
      expect(alerts.length).toBeGreaterThan(0);
    });
  });
  it('当体重缺失时阻止mg/kg药物', () => {
    const result = validateDose('gentamicin', 300, 'iv');
    expect(result.valid).toBe(false);
    expect(result.factors).toContain('weight_missing');
  });
  it('优雅地处理格式错误的药物数据', () => {
    expect(() => checkInteractions('', [], [])).not.toThrow();
  });
});

通过标准:100%。单个遗漏的相互作用就是一个患者安全事件。

反模式

  • 使CDSS检查可选或在没有记录理由时可跳过
  • 将相互作用检查实现为toast通知
  • 对药物或临床数据使用any类型
  • 硬编码相互作用对而不是使用可维护的数据结构
  • 在CDSS引擎中静默捕获错误(必须大声暴露失败)
  • 当体重不可用时跳过基于体重的验证(必须阻止,不通过)

示例

示例1:药物相互作用检查

const alerts = checkInteractions('warfarin', ['aspirin', 'metformin'], ['penicillin']);
// [{ severity: 'critical', pair: ['warfarin', 'aspirin'],
//    message: '出血风险增加', recommendation: '避免联合使用' }]

示例2:剂量验证

const ok = validateDose('paracetamol', 1000, 'oral', 70, 45);
// { valid: true, suggestedRange: { min: 500, max: 4000, unit: 'mg' } }

const bad = validateDose('paracetamol', 5000, 'oral', 70, 45);
// { valid: false, message: '超过绝对最大值 4000mg' }

const noWeight = validateDose('gentamicin', 300, 'iv');
// { valid: false, factors: ['weight_missing'] }

示例3:NEWS2评分

const result = calculateNEWS2({
  respiratoryRate: 24, oxygenSaturation: 93, supplementalOxygen: true,
  temperature: 38.5, systolicBP: 100, heartRate: 110, consciousness: 'voice'
});
// { total: 13, risk: 'high', escalation: '紧急临床复查。考虑ICU。' }

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.

相关技能