-
-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathTherapySettingsEntity.cs
More file actions
210 lines (177 loc) · 5.87 KB
/
Copy pathTherapySettingsEntity.cs
File metadata and controls
210 lines (177 loc) · 5.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Nocturne.Infrastructure.Data.Entities;
namespace Nocturne.Infrastructure.Data.Entities.V4;
/// <summary>
/// PostgreSQL entity for therapy settings (decomposed profile configuration)
/// Maps to Nocturne.Core.Models.V4.TherapySettings
/// </summary>
[Table("therapy_settings")]
public class TherapySettingsEntity : ITenantScoped, IAuditable, ISoftDeletable, IV4TimeSeriesEntity, ISystemTimestamped
{
/// <summary>
/// The unique identifier of the tenant this record belongs to.
/// </summary>
[Column("tenant_id")]
public Guid TenantId { get; set; }
/// <summary>
/// Primary key - UUID Version 7 for time-ordered, globally unique identification
/// </summary>
[Key]
public Guid Id { get; set; }
/// <summary>
/// Canonical timestamp as UTC DateTime (timestamptz)
/// </summary>
[Column("timestamp")]
public DateTime Timestamp { get; set; }
/// <summary>
/// UTC offset in minutes
/// </summary>
[Column("utc_offset")]
public int? UtcOffset { get; set; }
/// <summary>
/// Device identifier that created this settings record
/// </summary>
[Column("device")]
[MaxLength(256)]
public string? Device { get; set; }
/// <summary>
/// Application that uploaded this settings record
/// </summary>
[Column("app")]
[MaxLength(256)]
public string? App { get; set; }
/// <summary>
/// Origin data source identifier
/// </summary>
[Column("data_source")]
[MaxLength(256)]
public string? DataSource { get; set; }
/// <summary>
/// Links records that were split from the same legacy Treatment
/// </summary>
[Column("correlation_id")]
public Guid? CorrelationId { get; set; }
/// <summary>
/// Original v1/v3 record ID for migration traceability
/// </summary>
[Column("legacy_id")]
[MaxLength(64)]
public string? LegacyId { get; set; }
/// <summary>
/// System tracking: when record was inserted
/// </summary>
[Column("sys_created_at")]
public DateTime SysCreatedAt { get; set; } = DateTime.UtcNow;
/// <summary>
/// System tracking: when record was last updated
/// </summary>
[Column("sys_updated_at")]
public DateTime SysUpdatedAt { get; set; } = DateTime.UtcNow;
/// <summary>
/// Profile name this therapy settings record belongs to
/// </summary>
[Column("profile_name")]
[MaxLength(100)]
public string ProfileName { get; set; } = string.Empty;
/// <summary>
/// IANA timezone identifier (e.g. "America/New_York")
/// </summary>
[Column("timezone")]
[MaxLength(64)]
public string? Timezone { get; set; }
/// <summary>
/// Glucose display units (e.g. "mg/dl", "mmol/L")
/// </summary>
[Column("units")]
[MaxLength(10)]
public string? Units { get; set; }
/// <summary>
/// Duration of insulin action in hours
/// </summary>
[Column("dia")]
public double Dia { get; set; }
/// <summary>
/// Carb absorption rate in grams per hour
/// </summary>
[Column("carbs_hr")]
public int CarbsHr { get; set; }
/// <summary>
/// Delay in minutes before carb absorption starts
/// </summary>
[Column("delay")]
public int Delay { get; set; }
/// <summary>
/// Whether per-GI absorption values are used
/// </summary>
[Column("per_gi_values")]
public bool? PerGiValues { get; set; }
/// <summary>
/// Carb absorption rate for high-GI foods (grams per hour)
/// </summary>
[Column("carbs_hr_high")]
public int? CarbsHrHigh { get; set; }
/// <summary>
/// Carb absorption rate for medium-GI foods (grams per hour)
/// </summary>
[Column("carbs_hr_medium")]
public int? CarbsHrMedium { get; set; }
/// <summary>
/// Carb absorption rate for low-GI foods (grams per hour)
/// </summary>
[Column("carbs_hr_low")]
public int? CarbsHrLow { get; set; }
/// <summary>
/// Absorption delay for high-GI foods (minutes)
/// </summary>
[Column("delay_high")]
public int? DelayHigh { get; set; }
/// <summary>
/// Absorption delay for medium-GI foods (minutes)
/// </summary>
[Column("delay_medium")]
public int? DelayMedium { get; set; }
/// <summary>
/// Absorption delay for low-GI foods (minutes)
/// </summary>
[Column("delay_low")]
public int? DelayLow { get; set; }
/// <summary>
/// Loop/APS system settings stored as JSONB
/// </summary>
[Column("loop_settings_json", TypeName = "jsonb")]
public string? LoopSettingsJson { get; set; }
/// <summary>
/// Whether this is the default/active profile
/// </summary>
[Column("is_default")]
public bool IsDefault { get; set; }
/// <summary>
/// User or system that created/modified this settings record
/// </summary>
[Column("entered_by")]
[MaxLength(100)]
public string? EnteredBy { get; set; }
/// <summary>
/// Whether this profile is managed by an external system (e.g. pump)
/// </summary>
[Column("is_externally_managed")]
public bool IsExternallyManaged { get; set; }
/// <summary>
/// ISO date string indicating when the profile became active
/// </summary>
[Column("start_date")]
[MaxLength(50)]
public string? StartDate { get; set; }
/// <summary>
/// Catch-all JSONB column for fields not mapped to dedicated columns
/// </summary>
[Column("additional_properties", TypeName = "jsonb")]
public string? AdditionalPropertiesJson { get; set; }
/// <summary>
/// Soft-delete timestamp. When non-null the record is treated as deleted
/// by the global query filter and is invisible above the repository layer.
/// </summary>
[Column("deleted_at")]
public DateTime? DeletedAt { get; set; }
}