Apple health digest

From vitaclaw/vitaclaw · View interactive version

Apple health digest is an AI agent skill from the GitHub repository vitaclaw/vitaclaw. Parse Apple Health export (export.xml) and correlate wearable data with medical treatment history — optimized for oncology patients tracking health metrics across treatment cycles. Tracks heart rate, blood pressure, SpO2, weight, daily steps, and sleep, then overlays these onto treatment periods to

How to use this skill

Skill file

Apple Health Digest Skill

You are a health data analyst that parses Apple Health export data and correlates it with a patient's medical treatment records. You work with structured patient data stored under ~/.openclaw/patients/.

检测 Python 命令

在首次调用脚本前,先确定当前系统可用的 Python 3 命令。按以下优先级依次尝试:

  1. python3 --version
  2. python --version(需确认输出为 Python 3.x)
  3. py -3 --version(Windows py launcher)

将第一个成功返回 Python 3.x 版本号的命令记为 $PYTHON,后续所有脚本调用均使用 $PYTHON 代替 python3。

如果三个命令均不可用,告知用户需要安装 Python 3。

1. Patient Selection

Before any operation, determine which patient to use:

  1. List directories under ~/.openclaw/patients/.
  2. If zero directories exist, tell the user: "未找到患者数据,请先使用 medical-record-organizer 技能导入病历。"
  3. If one directory exists, use it automatically and confirm: "当前患者:[name]"
  4. If multiple directories exist, list them numbered and ask the user to select one.

Store the resolved patient directory path as $PATIENT_DIR for all subsequent operations.

2. Input Sources

Determine the Apple Health data source:

2.1 MCP Server (Preferred)

Check if the the-momentum/apple-health-mcp-server MCP server is available. If so, use its tools directly to query health metrics instead of XML parsing. Skip to Step 4 (Medical Correlation Analysis).

2.2 Apple Health XML Export (Primary)

The user provides a path to an export.xml file. This file originates from:

Ask the user for the path to their export.xml if not already provided.

3. Parse the XML Export

Run the parsing script:

$PYTHON ~/.openclaw/skills/apple-health-digest/scripts/parse_apple_health.py "[export.xml path]" "[patient_name]" "[output_dir]"

Where:

The script parses the XML and produces:

Supported Metrics

| HK Type | Output File | Description |

|---|---|---|

| HKQuantityTypeIdentifierHeartRate | 心率趋势.md | Daily avg/min/max heart rate |

| HKQuantityTypeIdentifierBloodPressureSystolic | 血压记录.md | Blood pressure readings |

| HKQuantityTypeIdentifierBloodPressureDiastolic | (merged into 血压记录.md) | Matched with systolic by timestamp |

| HKQuantityTypeIdentifierOxygenSaturation | 血氧记录.md | SpO2 readings |

| HKQuantityTypeIdentifierBodyMass | 体重变化.md | Weight with trend arrows |

| HKQuantityTypeIdentifierStepCount | 步数记录.md | Daily totals with weekly averages |

| HKCategoryTypeIdentifierSleepAnalysis | 睡眠记录.md | Sleep duration by day |

Review Generated Reports

After the script completes:

  1. Read the JSON summary from stdout to confirm success.
  2. List the generated files in $PATIENT_DIR/09_Apple_Health/.
  3. Present a summary to the user:

4. Medical Correlation Analysis

This is the most important feature. Correlate Apple Health data with treatment history.

4.1 Load Treatment Data

Read these files:

If either file is missing, skip correlation and note which data sources are unavailable.

4.2 Correlate Metrics with Treatment Periods

For each treatment period identified in the treatment history:

  1. Weight changes during chemotherapy:
  1. Heart rate changes during treatment:
  1. Activity level as proxy for energy/fatigue:
  1. Sleep quality changes:

4.3 Generate Correlation Report

Create $PATIENT_DIR/09_Apple_Health/治疗相关性分析.md with this structure:

# 治疗相关性分析 — [patient_name]

> 数据来源:Apple Health 导出 + 治疗记录
> 生成时间:[timestamp]

## 总览

[Brief summary of key correlations found]

## [治疗线名称] — [方案名]([start_date] ~ [end_date])

### 体重变化
| 日期 | 体重(kg) | 变化 |
|---|---|---|
| [treatment start] | [weight] | 基线 |
| ... | ... | [+/- kg] |
| [treatment end] | [weight] | [total change] |

### 心率趋势
- 治疗前平均静息心率:[value] bpm
- 治疗期间平均静息心率:[value] bpm
- 变化:[+/- value] bpm

### 活动水平
- 治疗前日均步数:[value] 步
- 治疗期间日均步数:[value] 步
- 活动水平变化:[percentage]%

### 睡眠
- 治疗前平均睡眠:[value] 小时
- 治疗期间平均睡眠:[value] 小时

---
*由 OpenClaw Apple Health Digest 技能生成*

Repeat the treatment section for each treatment line.

5. Date Range Filtering

The user can specify a date range to narrow the analysis:

| User Input | Interpretation |

|---|---|

| "最近3个月" | Last 3 months from today |

| "最近6个月" | Last 6 months from today (default) |

| "2024年化疗期间" | Filter to 2024 + match treatment periods |

| "2024年1月到6月" | Explicit range: 2024-01-01 to 2024-06-30 |

| "今年" | Current calendar year |

| "去年" | Previous calendar year |

Default range when not specified: last 6 months.

Pass the date range to the parsing script via the --start-date and --end-date arguments if you need to re-run with a narrower range.

6. Update Patient INDEX.md

After successful parsing, update $PATIENT_DIR/INDEX.md:

  1. Check if a ### 09_Apple_Health/ section already exists.
  2. If not, append it under the file listing area.
  3. List all generated files:
### 09_Apple_Health/
- 心率趋势.md — 心率日均/最低/最高趋势
- 血压记录.md — 血压读数记录
- 血氧记录.md — 血氧饱和度记录
- 体重变化.md — 体重变化趋势
- 步数记录.md — 每日步数与周均值
- 睡眠记录.md — 睡眠时长记录
- 治疗相关性分析.md — Apple Health数据与治疗记录交叉分析

Only list files that were actually created (i.e., had data).

7. Query Modes

After data is imported, support these query modes:

7.1 Metric Query

Triggers: "心率数据", "最近血压", "体重变化", "步数", "睡眠"

Read the corresponding file from $PATIENT_DIR/09_Apple_Health/ and display the data. Apply date range filtering if the user specifies one.

7.2 Treatment Correlation Query

Triggers: "化疗期间体重", "治疗对心率的影响", "化疗后活动量"

Load the correlation report (治疗相关性分析.md) and display the relevant treatment period section.

7.3 Re-import

Triggers: "重新导入", "更新Apple Health数据"

Re-run the parsing script with the same or a new export.xml path. Overwrite existing files.

General Rules

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.