Communitygithub.com

醫療保健臨床決策支援系統開發模式

臨床決策支援系統(CDSS)開發模式。包含藥物交互作用檢查、劑量驗證、臨床評分(NEWS2、qSOFA)、警報嚴重度分類,以及與電子病歷工作流程整合。適用於建構臨床決策支援功能時使用:藥物交互作用檢查、劑量驗證、臨床評分或警報嚴重度分類。

醫療保健臨床決策支援系統開發模式 是什麼?

這個技能提供了一套用於建構臨床決策支援系統(CDSS)的開發模式,重點在於與電子病歷工作流程的無縫整合。它將CDSS引擎設計為一個純函式庫,完全無副作用,能接收臨床資料並輸出警報,確保系統可完全測試且高度可靠。技能涵蓋三個核心模組:藥物交互作用檢查(checkInteractions)、劑量驗證(validateDose)以及臨床評分(例如NEWS2)。每個模組都提供了TypeScript介面定義和清晰的實作邏輯,例如在劑量驗證中,當體重資訊缺失時,系統必須阻擋而非通過,以維護病人安全。此外,技能還定義了警報的嚴重度等級(critical、major、minor)及其對應的使用者介面行為(封鎖、警告、資訊提示),並強調測試的嚴格標準:對偽陰性零容忍,任何遺漏的交互作用或錯誤都被視為病人安全事件。此技能適用於任何需要建構CDSS的開發團隊或平台。

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

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

醫療保健臨床決策支援系統開發模式 是做什麼的?

用於建構可整合至電子病歷工作流程的臨床決策支援系統之開發模式。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) — 國家早期預警評分 2,輸入 NEWS2Input。回傳包含總分、風險等級及升級指引的 NEWS2Result。
電子病歷使用者介面
  ↓ (使用者輸入資料)
CDSS 引擎(純函式,無副作用)
  ├── 藥物交互作用檢查器
  ├── 劑量驗證器
  ├── 臨床評分(NEWS2、qSOFA 等)
  └── 警報分類器
  ↓ (回傳警報)
電子病歷使用者介面(內嵌顯示警報,若為關鍵級則封鎖)

藥物交互作用檢查

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;
}

評分表必須完全符合皇家內科醫學會的規格。

警報嚴重度與使用者介面行為

嚴重度使用者介面行為臨床醫師必須採取的行動
Critical(關鍵)封鎖動作。不可關閉的模態視窗。紅色。必須記錄豁免理由才能繼續
Major(重大)內嵌警告橫幅。橘色。必須確認才能繼續
Minor(輕微)內嵌資訊提示。黃色。僅供知悉,無需採取行動

Critical(關鍵)警報絕不可自動關閉或以 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: '緊急臨床評估。考慮加護病房。' }

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.

相關技能