docs(health-profile): 添加防编造加固修订记录到导出健康档案设计文档

补充了关于导出摘要出现虚构病例问题的详细分析和修复方案,
包括检索策略优化、空数据兜底处理和prompt重写等三层防护措施。
```
This commit is contained in:
link2026
2026-05-30 20:06:12 +08:00
parent dad9d43486
commit 7ad41c5f09
26 changed files with 9062 additions and 7697 deletions

View File

@@ -261,6 +261,13 @@ final class MetricReminder {
var timeLabel: String {
String(format: "%02d:%02d", hour, minute)
}
/// (weekday , 7 = ); false
///
func occurs(on date: Date, calendar: Calendar = .current) -> Bool {
guard enabled else { return false }
return weekdays.contains(calendar.component(.weekday, from: date))
}
}
/// ( 20:00 5 12:30 2 )
@@ -269,12 +276,20 @@ final class MetricReminder {
/// 沿 weekday ( 7 = ); `ReminderService`
@Model
final class CustomReminder {
/// ; weekdays; dayOfMonth; month + dayOfMonth
enum Frequency: String, CaseIterable, Sendable {
case daily, weekly, monthly, yearly
}
@Attribute(.unique) var id: UUID
var title: String // , "5"
var note: String //
var hour: Int // 0...23
var minute: Int // 0...59
var weekdays: [Int] // iOS Calendar :1=, 2=, ..., 7= 7 =
var frequencyRaw: String = "daily" // CustomReminder.Frequency
var dayOfMonth: Int = 1 // monthly / yearly ,1...31
var month: Int = 1 // yearly ,1...12
var enabled: Bool
var createdAt: Date
var updatedAt: Date
@@ -285,6 +300,9 @@ final class CustomReminder {
hour: Int = 8,
minute: Int = 0,
weekdays: [Int] = [1, 2, 3, 4, 5, 6, 7],
frequency: Frequency = .daily,
dayOfMonth: Int = 1,
month: Int = 1,
enabled: Bool = true,
createdAt: Date = .now) {
self.id = id
@@ -293,6 +311,9 @@ final class CustomReminder {
self.hour = max(0, min(23, hour))
self.minute = max(0, min(59, minute))
self.weekdays = weekdays
self.frequencyRaw = frequency.rawValue
self.dayOfMonth = max(1, min(31, dayOfMonth))
self.month = max(1, min(12, month))
self.enabled = enabled
self.createdAt = createdAt
self.updatedAt = createdAt
@@ -300,19 +321,46 @@ final class CustomReminder {
var isEveryDay: Bool { Set(weekdays) == Set(1...7) }
/// MetricReminder.frequencyLabel , key
var frequency: Frequency {
get { Frequency(rawValue: frequencyRaw) ?? .daily }
set { frequencyRaw = newValue.rawValue }
}
/// : / / 15 / 315
var frequencyLabel: String {
if !enabled { return String(appLoc: "已关闭") }
if isEveryDay { return String(appLoc: "每天") }
if weekdays.isEmpty { return String(appLoc: "未选日") }
let names = [String(appLoc: ""), String(appLoc: ""), String(appLoc: ""), String(appLoc: ""), String(appLoc: ""), String(appLoc: ""), String(appLoc: "")]
let sorted = weekdays.sorted()
return String(appLoc: "") + sorted.map { names[$0 - 1] }.joined()
switch frequency {
case .daily:
return String(appLoc: "每天")
case .weekly:
if isEveryDay { return String(appLoc: "") }
if weekdays.isEmpty { return String(appLoc: "未选日") }
let names = [String(appLoc: ""), String(appLoc: ""), String(appLoc: ""), String(appLoc: ""), String(appLoc: ""), String(appLoc: ""), String(appLoc: "")]
return String(appLoc: "每周 ") + weekdays.sorted().map { names[$0 - 1] }.joined()
case .monthly:
return String(appLoc: "每月\(dayOfMonth)")
case .yearly:
return String(appLoc: "每年\(month)\(dayOfMonth)")
}
}
var timeLabel: String {
String(format: "%02d:%02d", hour, minute)
}
/// (,); false
/// monthly/yearly ( 31 ) false,
/// iOS
func occurs(on date: Date, calendar: Calendar = .current) -> Bool {
guard enabled else { return false }
let c = calendar.dateComponents([.weekday, .day, .month], from: date)
switch frequency {
case .daily: return true
case .weekly: return weekdays.contains(c.weekday ?? -1)
case .monthly: return dayOfMonth == (c.day ?? -1)
case .yearly: return month == (c.month ?? -1) && dayOfMonth == (c.day ?? -1)
}
}
}
@Model