46 lines
1.1 KiB
Dart
46 lines
1.1 KiB
Dart
/// 血压测量数据模型
|
|
class BpReading {
|
|
final int systolic;
|
|
final int diastolic;
|
|
final int? pulse;
|
|
final DateTime timestamp;
|
|
final String? userId;
|
|
final bool isKpa;
|
|
final bool hasBodyMovement;
|
|
final bool hasIrregularPulse;
|
|
|
|
const BpReading({
|
|
required this.systolic,
|
|
required this.diastolic,
|
|
this.pulse,
|
|
required this.timestamp,
|
|
this.userId,
|
|
this.isKpa = false,
|
|
this.hasBodyMovement = false,
|
|
this.hasIrregularPulse = false,
|
|
});
|
|
|
|
String get display => '$systolic/$diastolic';
|
|
|
|
Map<String, dynamic> toHealthRecord() => {
|
|
'type': 'BloodPressure',
|
|
'systolic': systolic,
|
|
'diastolic': diastolic,
|
|
'source': 'DeviceSync',
|
|
'unit': 'mmHg',
|
|
'recordedAt': timestamp.toUtc().toIso8601String(),
|
|
};
|
|
|
|
Map<String, dynamic>? toHeartRateRecord() {
|
|
final value = pulse;
|
|
if (value == null || value <= 0) return null;
|
|
return {
|
|
'type': 'HeartRate',
|
|
'value': value,
|
|
'source': 'DeviceSync',
|
|
'unit': 'bpm',
|
|
'recordedAt': timestamp.toUtc().toIso8601String(),
|
|
};
|
|
}
|
|
}
|