feat(monitor): add UserProfile + MonitorMetric catalog + Indicator.seriesKey

数据层(spec 2026-05-26):
- UserProfile @Model:核心 4 项 + 健康背景 + 用药,SwiftData 单例(loadOrCreate)
- Indicator 加 seriesKey: String?,标识长期指标分组('bp.systolic' 等)
- MonitorMetric enum 8 case:血压(2 field 拆 2 Indicator)/ 空腹+餐后血糖 /
  体重 / 体温 / 心率 / SpO2 / 身高
- effectiveRange(for:profile:) 实现 1 条 Profile-aware 规则:
  age >= 65 时 bp.systolic 上限 140→150
- KangkangApp schema 加 UserProfile.self

测试 17 个全绿(UserProfile 6 + MonitorMetric 11);schema 烟测扩 2(seriesKey roundtrip + UserProfile persist)。
UI 层 + Timeline 合并下个 commit。
This commit is contained in:
link2026
2026-05-26 07:40:42 +08:00
parent 7ede38ae06
commit 9a6d21100b
7 changed files with 484 additions and 1 deletions

View File

@@ -33,6 +33,11 @@ final class Indicator {
var asset: Asset?
var pinned: Bool = false
/// key, "bp.systolic" / "glucose.fasting" / "weight"
/// :IndicatorRecordSheet ;VL/Report/ nil
/// :Trends seriesKey ;Timeline ( bp.systolic + bp.diastolic )
var seriesKey: String?
init(name: String,
value: String,
unit: String,
@@ -42,7 +47,8 @@ final class Indicator {
capturedAt: Date = .now,
report: Report? = nil,
asset: Asset? = nil,
pinned: Bool = false) {
pinned: Bool = false,
seriesKey: String? = nil) {
self.name = name
self.value = value
self.unit = unit
@@ -53,6 +59,7 @@ final class Indicator {
self.report = report
self.asset = asset
self.pinned = pinned
self.seriesKey = seriesKey
}
var status: IndicatorStatus {