# ai-analyzer

Adopt this skill: https://proskills.md/skills/other/huifer-wellally-health-skills-ai-analyzer

Page: https://proskills.md/skills/other/huifer-wellally-health-skills-ai-analyzer
This document is the public skill bundle for that page. It contains SKILL.md and every helper file the catalog carries. No login is required.

## File: skills/ai-analyzer/SKILL.md
size: 7394
upstream: https://github.com/huifer/wellally-health/blob/main/skills/ai-analyzer/SKILL.md

````text
---
name: ai-analyzer
description: AI驱动的综合健康分析系统，整合多维度健康数据、识别异常模式、预测健康风险、提供个性化建议。支持智能问答和AI健康报告生成。
allowed-tools: Read, Grep, Glob, Write
---

# AI健康分析器

基于AI技术的综合健康分析系统，提供智能健康洞察、风险预测和个性化建议。

## 核心功能

### 1. 智能健康分析
- **多维度数据整合**: 整合基础指标、生活方式、心理健康、医疗历史等4类数据源
- **异常模式识别**: 使用CUSUM、Z-score等算法检测异常值和变化点
- **相关性分析**: 计算不同健康指标之间的相关性（皮尔逊、斯皮尔曼）
- **趋势预测**: 基于历史数据进行趋势分析和预测

### 2. 健康风险预测
- **高血压风险**: 基于Framingham风险评分模型
- **糖尿病风险**: 基于ADA糖尿病风险评分标准
- **心血管疾病风险**: 基于ACC/AHA ASCVD指南
- **营养缺乏风险**: 基于RDA达成率和饮食模式分析
- **睡眠障碍风险**: 基于PSQI和睡眠模式分析

### 3. 个性化建议引擎
- **基础个性化**: 基于年龄、性别、BMI、活动水平等静态档案
- **建议分级**: Level 1（一般性）、Level 2（参考性）、Level 3（医疗建议）
- **循证依据**: 基于医学指南和循证医学证据
- **可操作性**: 提供具体、可行的改进建议

### 4. 自然语言交互
- **智能问答**: 支持健康数据查询、趋势分析、相关性查询等
- **上下文理解**: 维护对话历史，支持多轮对话
- **意图识别**: 识别用户查询意图，提供精准回复

### 5. AI健康报告生成
- **综合报告**: 包含所有维度健康数据、AI洞察、风险评估
- **快速摘要**: 关键指标概览、异常警示、主要建议
- **风险评估报告**: 各类疾病风险、风险因素分析、预防措施
- **趋势分析报告**: 多维度趋势、变化点识别、预测分析
- **HTML交互式报告**: ECharts图表、Tailwind CSS样式

## 使用说明

### 触发条件

当用户提到以下场景时，使用此技能：

**通用询问**:
- ✅ "AI分析我的健康状况"
- ✅ "我的健康有什么风险？"
- ✅ "生成AI健康报告"
- ✅ "AI分析所有数据"

**风险预测**:
- ✅ "预测我的高血压风险"
- ✅ "我有糖尿病风险吗？"
- ✅ "评估我的心血管风险"
- ✅ "AI预测健康风险"

**智能问答**:
- ✅ "我的睡眠怎么样？"
- ✅ "运动对我的健康有什么影响？"
- ✅ "我应该如何改善健康状况？"
- ✅ "AI健康助手问答"

**报告生成**:
- ✅ "生成AI健康报告"
- ✅ "创建综合分析报告"
- ✅ "AI风险评估报告"

### 执行步骤

#### 步骤 1: 读取AI配置

```javascript
const aiConfig = readFile('data/ai-config.json');
const aiHistory = readFile('data/ai-history.json');
```

检查AI功能是否启用，验证数据源配置。

#### 步骤 2: 读取用户档案

```javascript
const profile = readFile('data/profile.json');
```

获取基础信息：年龄、性别、身高、体重、BMI等。

#### 步骤 3: 读取健康数据

根据配置的数据源读取相关数据：

```javascript
// 基础健康指标
const indexData = readFile('data/index.json');

// 生活方式数据
const fitnessData = readFile('data-example/fitness-tracker.json');
const sleepData = readFile('data-example/sleep-tracker.json');
const nutritionData = readFile('data-example/nutrition-tracker.json');

// 心理健康数据
const mentalHealthData = readFile('data-example/mental-health-tracker.json');

// 医疗历史
const medications = exists('data/medications.json') ? readFile('data/medications.json') : null;
const allergies = exists('data/allergies.json') ? readFile('data/allergies.json') : null;
```

#### 步骤 4: 数据整合和预处理

整合所有数据源，进行数据清洗、时间对齐和缺失值处理。

#### 步骤 5: 多维度分析

**相关性分析**: 计算睡眠↔情绪、运动↔体重、营养↔生化指标等关联

**趋势分析**: 使用线性回归、移动平均等方法识别趋势方向

**异常检测**: 使用CUSUM、Z-score算法检测异常值和变化点

#### 步骤 6: 风险预测

基于Framingham、ADA、ACC/AHA等标准进行风险预测：

- 高血压风险（10年概率）
- 糖尿病风险（10年概率）
- 心血管疾病风险（10年概率）
- 营养缺乏风险
- 睡眠障碍风险

#### 步骤 7: 生成个性化建议

根据分析结果生成三级建议：

- **Level 1**: 一般性建议（基于标准指南）
- **Level 2**: 参考性建议（基于个人数据）
- **Level 3**: 医疗建议（需医生确认，包含免责声明）

#### 步骤 8: 生成分析报告

**文本报告**: 包含总体评估、风险预测、关键趋势、相关性发现、个性化建议

**HTML报告**: 调用 `scripts/generate_ai_report.py` 生成包含ECharts图表的交互式报告

#### 步骤 9: 更新AI历史记录

记录分析结果到 `data/ai-history.json`

## 数据源

| 数据源 | 文件路径 | 数据内容 |
|--------|---------|---------|
| 用户档案 | `data/profile.json` | 年龄、性别、身高、体重、BMI |
| 医疗记录 | `data/index.json` | 生化指标、影像检查 |
| 运动追踪 | `data-example/fitness-tracker.json` | 运动类型、时长、强度、MET值 |
| 睡眠追踪 | `data-example/sleep-tracker.json` | 睡眠时长、质量、PSQI评分 |
| 营养追踪 | `data-example/nutrition-tracker.json` | 饮食记录、营养素摄入、RDA达成率 |
| 心理健康 | `data-example/mental-health-tracker.json` | PHQ-9、GAD-7评分 |
| 用药记录 | `data/medications.json` | 药物名称、剂量、用法、依从性 |
| 过敏史 | `data/allergies.json` | 过敏原、严重程度 |

## 算法说明

### 相关性分析
- **皮尔逊相关系数**: 连续变量（如睡眠时长与情绪评分）
- **斯皮尔曼相关系数**: 有序变量（如症状严重程度）

### 异常检测
- **CUSUM算法**: 时间序列变化点检测
- **Z-score方法**: 统计异常值检测（|z| > 2）
- **IQR方法**: 四分位数异常值检测

### 风险预测
- **Framingham风险评分**: 高血压、心血管疾病风险
- **ADA风险评分**: 2型糖尿病风险
- **ASCVD计算器**: 动脉粥样硬化心血管病风险

## 安全与合规

### 必须遵循
- ❌ 不给出医疗诊断
- ❌ 不给出具体用药剂量建议
- ❌ 不判断生死预后
- ❌ 不替代医生建议
- ✅ 所有分析必须标注"仅供参考"
- ✅ Level 3建议必须包含免责声明
- ✅ 高风险预测必须建议咨询医生

### 隐私保护
- ✅ 所有数据保持本地
- ✅ 无外部API调用
- ✅ HTML报告独立运行

## 相关命令

- `/ai analyze` - AI综合分析
- `/ai predict [risk_type]` - 健康风险预测
- `/ai chat [query]` - 自然语言问答
- `/ai report generate [type]` - 生成AI健康报告
- `/ai status` - 查看AI功能状态

## 技术实现

### 工具限制
此Skill仅使用以下工具：
- **Read**: 读取JSON数据文件
- **Grep**: 搜索特定模式
- **Glob**: 按模式查找数据文件
- **Write**: 生成HTML报告和更新历史记录

### 性能优化
- 增量读取：仅读取指定时间范围的数据文件
- 数据缓存：避免重复读取同一文件
- 延迟计算：按需生成图表数据
````

## File: README.md
upstream: https://github.com/huifer/wellally-health/blob/main/README.md

````text
# WellAlly Health — Privacy-First Personal Health Intelligence System

[![English](https://img.shields.io/badge/lang-English-blue.svg)](README.md)
[![中文](https://img.shields.io/badge/lang-中文-red.svg)](README.zh-CN.md)

[![GitHub stars](https://img.shields.io/github/stars/huifer/WellAlly-health?style=social)](https://github.com/huifer/WellAlly-health)
[![GitHub forks](https://img.shields.io/github/forks/huifer/WellAlly-health?style=social)](https://github.com/huifer/WellAlly-health)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Last Commit](https://img.shields.io/github/last-commit/huifer/WellAlly-health)](https://github.com/huifer/WellAlly-health/commits/main)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/huifer/WellAlly-health/blob/main/.github/CONTRIBUTING.md)
[![Made with Claude Code](https://img.shields.io/badge/made%20with-Claude%20Code-ff6f00.svg)](https://claude.com/claude-code)
[![Star History Chart](https://api.star-history.com/svg?repos=huifer/WellAlly-health&type=date&legend=top-left)](https://www.star-history.com/#huifer/WellAlly-health&type=date&legend=top-left)

**WellAlly Health** is a local-first, AI-powered **personal health record (PHR)** system. It turns your medical reports, prescriptions, imaging, and daily health tracking into a private, searchable, structured knowledge base that runs entirely on your own machine — no cloud, no database server, no account required.

> **GitHub**: https://github.com/huifer/WellAlly-health

> **⚠️ Disclaimer**: This project is **NOT** affiliated with, endorsed by, or associated with [Anthropic](https://www.anthropic.com/) or [Claude.ai](https://claude.ai/). It is an independent open-source project developed by [WellAlly Tech](https://www.wellally.tech/). WellAlly Health is built on top of Claude Code's command-line tooling and uses AI image recognition (e.g. GLM `mcp__4_5v_mcp__analyze_image`) for document understanding.
>
> **This is not a medical device.** All analysis is for personal reference only and must never replace professional medical advice.

## Table of Contents

- [Why WellAlly Health](#why-wellally-health)
- [✨ Features](#-features)
- [🚀 Quick Start](#-quick-start)
- [📂 Directory Structure](#-directory-structure)
- [🧩 Command Reference (60+)](#-command-reference-60)
- [👨‍⚕️ Specialist Domains](#-specialist-domains)
- [🛠️ Analysis Skills](#️-analysis-skills)
- [🔧 Technical Architecture](#-technical-architecture)
- [💊 Drug Interaction Database](#-drug-interaction-database)
- [🔒 Data Privacy](#-data-privacy)
- [🗺️ Roadmap](#️-roadmap)
- [🤝 Contributing](#-contributing)
- [🛡️ Security](#️-security)
- [⚠️ Important Safety Statement](#-important-safety-statement)
- [📄 License](#-license)

## Why WellAlly Health

Your health data is scattered across hospital portals, paper printouts, photos, and memory. Commercial apps ask you to upload it to *their* cloud. WellAlly Health takes the opposite approach:

- **🔒 Truly private** — everything lives in plain files on your disk. Nothing leaves your machine.
- **📄 Zero effort ingestion** — drop in a photo of a lab report or discharge summary; AI extracts the structured data for you.
- **🧠 AI that knows your history** — drug-interaction checks, multi-specialty analysis, and trend tracking all understand *your* records.
- **🗂️ One searchable source of truth** — biochemical values, imaging, surgeries, radiation exposure, medications, and allergies in one place.
- **♻️ Yours forever** — open JSON + Markdown format, no lock-in, easy to back up or export.

WellAlly Health is the **personal health record (PHR)** / **personal health information system (PHIS)** for people who want AI assistance *without* surrendering their medical privacy.

## ✨ Features

**Local-first & private**
- 📁 Pure file-based storage (JSON + Markdown), **no database required**
- 💾 100% on-device — no uploads, no telemetry, no external accounts
- 🔓 Open format you fully own and can back up anywhere

**Intelligent medical document understanding**
- 🖼️ Medical report image recognition (OCR + AI structuring)
- 📊 Automatic biochemical test value & reference-range extraction
- 🔍 Structured medical imaging data extraction
- 📋 Structured discharge summary storage

**Clinical safety intelligence**
- 💊 **Drug interaction detection** — drug–drug, drug–disease, drug–dose, drug–food
- 🚨 **Five-level severity warning system** (A / B / C / D / X, where X = absolute contraindication)
- ☢️ Medical radiation dose tracking (BSA-adjusted + decay model)
- 🔪 Surgery history & implant management
- 👤 User profile, allergy, and medication management

**Multi-disciplinary expertise**
- 👨‍⚕️ **Multi-Disciplinary Team (MDT) consultation** across 16 specialty domains
- 🔬 13+ single-specialist deep-dive analyses
- 🧩 20 specialized analysis skills (sleep, nutrition, fitness, mental health, TCM constitution, and more)

**Whole-lifecycle coverage**
- 🧒 Child health (development, illness, nutrition, sleep, vaccination, safety)
- 🤰 Women's & men's health (cycle, pregnancy, postpartum, menopause, fertility, prostate)
- 🩺 Chronic disease management (diabetes, hypertension, COPD, cognitive health)
- 🧘 Lifestyle & wellness (diet, goal, travel, occupational, rehabilitation)
- 🌿 Traditional Chinese Medicine constitution analysis

## 🚀 Quick Start

> Prerequisite: [Claude Code](https://claude.com/claude-code) installed and opened in this project directory.

```bash
# 1. First-time setup — set height(cm) weight(kg) birthdate
/profile set 175 70 1990-01-01

# 2. Save your first lab report from an image
/save-report /path/to/image.jpg

# 3. Record a radiation scan
/radiation add CT chest

# 4. Record a past surgery in plain language
/surgery Gallbladder removal surgery in August last year due to gallstones

# 5. Save a discharge summary from a photo
/discharge @医疗报告/出院小结.jpg

# 6. Query everything
/query all

# 7. Start a multi-disciplinary consultation
/consult
```

That's it — no programming, no server, no sign-up.

## 📂 Directory Structure

```
my-his/
├── .claude/
│   ├── commands/            # 60+ slash commands (see Command Reference)
│   │   ├── save-report.md
│   │   ├── query.md
│   │   ├── profile.md
│   │   ├── radiation.md
│   │   ├── surgery.md
│   │   ├── discharge.md
│   │   ├── medication.md
│   │   ├── interaction.md
│   │   ├── consult.md
│   │   └── specialist.md
│   └── specialists/         # 16 specialty + MDT coordinator Skills
├── data/
│   ├── profile.json          # User basic profile
│   ├── radiation-records.json
│   ├── allergies.json
│   ├── interactions/         # Drug interaction database + logs
│   │   ├── interaction-db.json
│   │   └── interaction-logs/
│   ├── medications/
│   ├── 生化检查/             # Biochemical test data (YYYY-MM/...)
│   ├── 影像检查/             # Medical imaging data + image backups
│   ├── 手术记录/             # Surgery history
│   ├── 出院小结/             # Discharge summaries
│   └── index.json            # Global index
└── README.md
```

## 🧩 Command Reference (60+)

WellAlly Health ships **62 slash commands**. Highlights by domain:

**Core data management**
`/profile` · `/get-profile` · `/query` · `/save-report` · `/report` · `/report-instructions` · `/prepare` · `/ai` · `/consult` · `/specialist` · `/allergy` · `/medication` · `/interaction` · `/surgery` · `/discharge` · `/radiation` · `/radiation-data` · `/symptom` · `/screening` · `/polypharmacy`

**Specialty analysis**
`/sleep` · `/nutrition` · `/diet` · `/fitness` · `/mental-health` · `/mood` · `/psych-assess` · `/cognitive` · `/tcm-constitution` · `/skin-health` · `/oral-health` · `/eye-health` · `/ent` · `/sexual-health` · `/occupational-health` · `/rehabilitation` · `/infection` · `/rheumatology`

**Child & family**
`/family` · `/child-development` · `/child-illness` · `/child-mental` · `/child-nutrition` · `/child-safety` · `/child-sleep` · `/child-vaccine`

**Women's & men's health**
`/cycle` · `/pregnanc
````
