|
|
@@ -26,9 +26,8 @@ export interface HealthMetricHistory {
|
|
|
|
|
|
// 数据记录表单接口
|
|
|
export interface DataRecordForm {
|
|
|
- type: 'heartRate' | 'bloodPressure' | 'bloodOxygen';
|
|
|
+ type: 'heartRate' | 'bloodOxygen';
|
|
|
value: number;
|
|
|
- diastolic?: number;
|
|
|
date: Date;
|
|
|
}
|
|
|
|
|
|
@@ -95,12 +94,6 @@ export class MonitoringComponent implements OnInit, OnDestroy {
|
|
|
trend: 'stable'
|
|
|
};
|
|
|
|
|
|
- // 血压(保留字段以兼容旧弹窗/趋势代码,主界面不再展示)
|
|
|
- bloodPressure: { systolic: HealthMetric; diastolic: HealthMetric } = {
|
|
|
- systolic: { value: 0, unit: 'mmHg', status: 'normal', timestamp: new Date(), trend: 'stable' },
|
|
|
- diastolic: { value: 0, unit: 'mmHg', status: 'normal', timestamp: new Date(), trend: 'stable' }
|
|
|
- };
|
|
|
-
|
|
|
recovery: { status: string; ratio: number; baseline: number; hrv: number; restingHr: number } | null = null;
|
|
|
|
|
|
// 血氧数据
|
|
|
@@ -134,10 +127,6 @@ export class MonitoringComponent implements OnInit, OnDestroy {
|
|
|
|
|
|
// 历史数据
|
|
|
heartRateHistory: HealthMetricHistory[] = [];
|
|
|
- bloodPressureHistory: { systolic: HealthMetricHistory[]; diastolic: HealthMetricHistory[] } = {
|
|
|
- systolic: [],
|
|
|
- diastolic: []
|
|
|
- };
|
|
|
bloodOxygenHistory: HealthMetricHistory[] = [];
|
|
|
|
|
|
// 数据记录表单
|
|
|
@@ -179,7 +168,7 @@ export class MonitoringComponent implements OnInit, OnDestroy {
|
|
|
healthScore: number = 85;
|
|
|
|
|
|
// 当前趋势图标签
|
|
|
- activeTrendTab: 'heartRate' | 'bloodPressure' | 'bloodOxygen' = 'heartRate';
|
|
|
+ activeTrendTab: 'heartRate' | 'bloodOxygen' = 'heartRate';
|
|
|
|
|
|
// 合并后的趋势图表
|
|
|
trendChart: any = null;
|
|
|
@@ -290,8 +279,6 @@ export class MonitoringComponent implements OnInit, OnDestroy {
|
|
|
// 根据各项指标状态扣分
|
|
|
if (this.heartRate.status === 'warning') score -= 10;
|
|
|
if (this.heartRate.status === 'danger') score -= 20;
|
|
|
- if (this.bloodPressure.systolic.status === 'warning') score -= 10;
|
|
|
- if (this.bloodPressure.systolic.status === 'danger') score -= 20;
|
|
|
if (this.bloodOxygen.status === 'warning') score -= 10;
|
|
|
if (this.bloodOxygen.status === 'danger') score -= 20;
|
|
|
this.healthScore = Math.max(0, score);
|
|
|
@@ -305,19 +292,19 @@ export class MonitoringComponent implements OnInit, OnDestroy {
|
|
|
|
|
|
// 获取健康摘要
|
|
|
getHealthSummary(): string {
|
|
|
- const statuses = [this.heartRate.status, this.bloodPressure.systolic.status, this.bloodOxygen.status];
|
|
|
+ const statuses = [this.heartRate.status, this.bloodOxygen.status];
|
|
|
const allNormal = statuses.every(s => s === 'normal');
|
|
|
const hasWarning = statuses.some(s => s === 'warning');
|
|
|
const hasDanger = statuses.some(s => s === 'danger');
|
|
|
-
|
|
|
- if (allNormal) return '心率、血压、血氧指标均在正常范围内,继续保持!';
|
|
|
+
|
|
|
+ if (allNormal) return '心率、血氧指标均在正常范围内,继续保持!';
|
|
|
if (hasDanger) return '部分指标异常,建议及时就医检查。';
|
|
|
if (hasWarning) return '部分指标需要关注,请注意调整生活方式。';
|
|
|
return '请定期监测健康指标。';
|
|
|
}
|
|
|
|
|
|
// 设置当前趋势图标签
|
|
|
- setActiveTrendTab(tab: 'heartRate' | 'bloodPressure' | 'bloodOxygen'): void {
|
|
|
+ setActiveTrendTab(tab: 'heartRate' | 'bloodOxygen'): void {
|
|
|
this.activeTrendTab = tab;
|
|
|
this.initializeTrendChart();
|
|
|
}
|
|
|
@@ -367,14 +354,6 @@ export class MonitoringComponent implements OnInit, OnDestroy {
|
|
|
minVal = data.length > 0 ? Math.max(50, Math.min(...data.map(d => d.value)) - 10) : 50;
|
|
|
maxVal = data.length > 0 ? Math.min(120, Math.max(...data.map(d => d.value)) + 10) : 120;
|
|
|
break;
|
|
|
- case 'bloodPressure':
|
|
|
- data = filteredData.bloodPressure.systolic;
|
|
|
- color = '#3b82f6';
|
|
|
- name = '收缩压';
|
|
|
- unit = 'mmHg';
|
|
|
- minVal = data.length > 0 ? Math.max(80, Math.min(...data.map(d => d.value)) - 10) : 80;
|
|
|
- maxVal = data.length > 0 ? Math.min(180, Math.max(...data.map(d => d.value)) + 10) : 180;
|
|
|
- break;
|
|
|
case 'bloodOxygen':
|
|
|
data = filteredData.bloodOxygen;
|
|
|
color = '#8b5cf6';
|
|
|
@@ -455,18 +434,6 @@ export class MonitoringComponent implements OnInit, OnDestroy {
|
|
|
value: heartRateValue
|
|
|
});
|
|
|
|
|
|
- // 血压历史数据
|
|
|
- const systolicValue = 110 + Math.floor(Math.random() * 30);
|
|
|
- const diastolicValue = 70 + Math.floor(Math.random() * 20);
|
|
|
- this.bloodPressureHistory.systolic.push({
|
|
|
- date: new Date(date),
|
|
|
- value: systolicValue
|
|
|
- });
|
|
|
- this.bloodPressureHistory.diastolic.push({
|
|
|
- date: new Date(date),
|
|
|
- value: diastolicValue
|
|
|
- });
|
|
|
-
|
|
|
// 血氧历史数据(95-100之间波动)
|
|
|
const bloodOxygenValue = 95 + Math.floor(Math.random() * 5);
|
|
|
this.bloodOxygenHistory.push({
|
|
|
@@ -499,10 +466,6 @@ export class MonitoringComponent implements OnInit, OnDestroy {
|
|
|
|
|
|
return {
|
|
|
heartRate: this.heartRateHistory.filter(item => item.date >= startDate),
|
|
|
- bloodPressure: {
|
|
|
- systolic: this.bloodPressureHistory.systolic.filter(item => item.date >= startDate),
|
|
|
- diastolic: this.bloodPressureHistory.diastolic.filter(item => item.date >= startDate)
|
|
|
- },
|
|
|
bloodOxygen: this.bloodOxygenHistory.filter(item => item.date >= startDate)
|
|
|
};
|
|
|
}
|
|
|
@@ -515,12 +478,11 @@ export class MonitoringComponent implements OnInit, OnDestroy {
|
|
|
}
|
|
|
|
|
|
// 打开数据记录模态框
|
|
|
- openRecordModal(type: 'heartRate' | 'bloodPressure' | 'bloodOxygen'): void {
|
|
|
+ openRecordModal(type: 'heartRate' | 'bloodOxygen'): void {
|
|
|
const now = new Date();
|
|
|
this.recordForm = {
|
|
|
type,
|
|
|
value: 0,
|
|
|
- diastolic: type === 'bloodPressure' ? 0 : undefined,
|
|
|
date: now
|
|
|
};
|
|
|
// 初始化datetime-local输入框的值
|
|
|
@@ -544,7 +506,7 @@ export class MonitoringComponent implements OnInit, OnDestroy {
|
|
|
}
|
|
|
|
|
|
// 选择指标并打开记录模态框
|
|
|
- selectMetricAndRecord(type: 'heartRate' | 'bloodPressure' | 'bloodOxygen'): void {
|
|
|
+ selectMetricAndRecord(type: 'heartRate' | 'bloodOxygen'): void {
|
|
|
this.closeMetricSelectionModal();
|
|
|
this.openRecordModal(type);
|
|
|
}
|
|
|
@@ -648,11 +610,6 @@ export class MonitoringComponent implements OnInit, OnDestroy {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (this.recordForm.type === 'bloodPressure' && (!this.recordForm.diastolic || this.recordForm.diastolic <= 0)) {
|
|
|
- alert('请输入有效的舒张压数值');
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
// 更新当前数据
|
|
|
switch (this.recordForm.type) {
|
|
|
case 'heartRate':
|
|
|
@@ -668,31 +625,6 @@ export class MonitoringComponent implements OnInit, OnDestroy {
|
|
|
value: this.recordForm.value
|
|
|
});
|
|
|
break;
|
|
|
- case 'bloodPressure':
|
|
|
- this.bloodPressure = {
|
|
|
- systolic: {
|
|
|
- ...this.bloodPressure.systolic,
|
|
|
- value: this.recordForm.value,
|
|
|
- timestamp: this.recordForm.date,
|
|
|
- status: this.calculateBloodPressureStatus(this.recordForm.value, 'systolic')
|
|
|
- },
|
|
|
- diastolic: {
|
|
|
- ...this.bloodPressure.diastolic,
|
|
|
- value: this.recordForm.diastolic || 0,
|
|
|
- timestamp: this.recordForm.date,
|
|
|
- status: this.calculateBloodPressureStatus(this.recordForm.diastolic || 0, 'diastolic')
|
|
|
- }
|
|
|
- };
|
|
|
- // 添加到历史记录
|
|
|
- this.bloodPressureHistory.systolic.push({
|
|
|
- date: new Date(this.recordForm.date),
|
|
|
- value: this.recordForm.value
|
|
|
- });
|
|
|
- this.bloodPressureHistory.diastolic.push({
|
|
|
- date: new Date(this.recordForm.date),
|
|
|
- value: this.recordForm.diastolic || 0
|
|
|
- });
|
|
|
- break;
|
|
|
case 'bloodOxygen':
|
|
|
this.bloodOxygen = {
|
|
|
...this.bloodOxygen,
|
|
|
@@ -738,19 +670,6 @@ export class MonitoringComponent implements OnInit, OnDestroy {
|
|
|
return 'danger';
|
|
|
}
|
|
|
|
|
|
- // 计算血压状态
|
|
|
- calculateBloodPressureStatus(value: number, type: 'systolic' | 'diastolic'): 'normal' | 'warning' | 'danger' {
|
|
|
- if (type === 'systolic') {
|
|
|
- if (value < 120) return 'normal';
|
|
|
- if (value < 140) return 'warning';
|
|
|
- return 'danger';
|
|
|
- } else {
|
|
|
- if (value < 80) return 'normal';
|
|
|
- if (value < 90) return 'warning';
|
|
|
- return 'danger';
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
// 计算血氧状态
|
|
|
calculateBloodOxygenStatus(value: number): 'normal' | 'warning' | 'danger' {
|
|
|
if (value >= 95) return 'normal';
|
|
|
@@ -819,17 +738,11 @@ export class MonitoringComponent implements OnInit, OnDestroy {
|
|
|
} else {
|
|
|
return '心率异常,建议尽快就医检查,并避免剧烈运动。';
|
|
|
}
|
|
|
- case 'bloodPressure':
|
|
|
- const systolicStatus = this.bloodPressure.systolic.status;
|
|
|
- const diastolicStatus = this.bloodPressure.diastolic.status;
|
|
|
-
|
|
|
- if (systolicStatus === 'normal' && diastolicStatus === 'normal') {
|
|
|
- return '血压控制良好,建议减少盐的摄入,保持适量运动。';
|
|
|
- } else if (systolicStatus === 'warning' || diastolicStatus === 'warning') {
|
|
|
- return '血压略偏高,建议减少盐分摄入,增加运动,定期监测。';
|
|
|
- } else {
|
|
|
- return '血压明显偏高,建议遵循医嘱,限制盐分,避免剧烈运动。';
|
|
|
+ case 'hrv':
|
|
|
+ if (this.recovery && this.recovery.ratio < 0.85) {
|
|
|
+ return 'HRV 低于近期均值,身体可能处于疲劳状态,建议低强度训练或休息。';
|
|
|
}
|
|
|
+ return 'HRV 反映自主神经调节能力,保持规律作息和适度运动有助于提升 HRV。';
|
|
|
case 'bloodOxygen':
|
|
|
if (this.bloodOxygen.status === 'normal') {
|
|
|
return '血氧饱和度正常,继续保持良好的生活习惯。';
|
|
|
@@ -855,12 +768,15 @@ export class MonitoringComponent implements OnInit, OnDestroy {
|
|
|
report += `- 状态: ${this.getStatusText(this.heartRate.status)}\n`;
|
|
|
report += `- 趋势: ${this.getTrendText(this.heartRate.trend)}\n\n`;
|
|
|
|
|
|
- // 血压评估
|
|
|
- report += `### 血压状况\n`;
|
|
|
- report += `- 当前值: ${this.bloodPressure.systolic.value}/${this.bloodPressure.diastolic.value} ${this.bloodPressure.systolic.unit}\n`;
|
|
|
- report += `- 状态: ${this.getStatusText(this.bloodPressure.systolic.status)}\n`;
|
|
|
- report += `- 趋势: ${this.getTrendText(this.bloodPressure.systolic.trend)}\n\n`;
|
|
|
-
|
|
|
+ // HRV 评估
|
|
|
+ report += `### HRV 状况\n`;
|
|
|
+ report += `- 当前值: ${this.hrv.value} ${this.hrv.unit}\n`;
|
|
|
+ if (this.recovery) {
|
|
|
+ report += `- 30天均值: ${this.recovery.baseline} ${this.hrv.unit}\n`;
|
|
|
+ report += `- 恢复比值: ${this.recovery.ratio}\n`;
|
|
|
+ }
|
|
|
+ report += `- 趋势: ${this.getTrendText(this.hrv.trend)}\n\n`;
|
|
|
+
|
|
|
// 血氧评估
|
|
|
report += `### 血氧状况\n`;
|
|
|
report += `- 当前值: ${this.bloodOxygen.value} ${this.bloodOxygen.unit}\n`;
|
|
|
@@ -873,11 +789,7 @@ export class MonitoringComponent implements OnInit, OnDestroy {
|
|
|
report += `- 饮食清淡,减少盐分和脂肪摄入\n`;
|
|
|
report += `- 保证充足睡眠,避免熬夜\n`;
|
|
|
report += `- 保持良好心态,避免长期精神压力\n`;
|
|
|
-
|
|
|
- if (this.bloodPressure.systolic.status !== 'normal' || this.bloodPressure.diastolic.status !== 'normal') {
|
|
|
- report += `- 建议每日测量血压并记录,如有异常及时就医\n`;
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
return report;
|
|
|
}
|
|
|
|