feat: 新增健康档案模块,支持家庭邀请与个人健康数据管理
This commit is contained in:
@@ -1745,6 +1745,48 @@ export async function fetchSmartHRVData(date: Date): Promise<HRVData | null> {
|
||||
}
|
||||
}
|
||||
|
||||
// 获取指定时间范围内的所有HRV样本
|
||||
export async function fetchHRVSamples(startDate: Date, endDate: Date): Promise<HRVData[]> {
|
||||
try {
|
||||
const options = {
|
||||
startDate: startDate.toISOString(),
|
||||
endDate: endDate.toISOString(),
|
||||
limit: 1000 // 获取足够多的样本
|
||||
};
|
||||
|
||||
const result = await HealthKitManager.getHeartRateVariabilitySamples(options);
|
||||
|
||||
if (result && result.data && Array.isArray(result.data)) {
|
||||
const samples: HRVData[] = [];
|
||||
|
||||
for (const sample of result.data) {
|
||||
const validatedValue = validateHRVValue(sample.value);
|
||||
if (validatedValue !== null) {
|
||||
samples.push({
|
||||
value: validatedValue,
|
||||
recordedAt: sample.startDate,
|
||||
endDate: sample.endDate,
|
||||
source: {
|
||||
name: sample.source?.name || 'Unknown',
|
||||
bundleIdentifier: sample.source?.bundleIdentifier || ''
|
||||
},
|
||||
isManualMeasurement: sample.isManualMeasurement || false,
|
||||
qualityScore: sample.qualityScore,
|
||||
sampleId: sample.id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return samples;
|
||||
}
|
||||
|
||||
return [];
|
||||
} catch (error) {
|
||||
console.error('获取HRV样本列表失败:', error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
// === 锻炼记录相关方法 ===
|
||||
|
||||
// 获取最近锻炼记录
|
||||
|
||||
Reference in New Issue
Block a user