feature: Schema, Migrations, Core CRUD, and Redis Threshold Cache

This commit is contained in:
voltsrage
2026-06-16 17:59:16 +08:00
commit 882d4af3e6
63 changed files with 3923 additions and 0 deletions
@@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
public class ReconciliationAlertConfiguration : IEntityTypeConfiguration<ReconciliationAlert>
{
public void Configure(EntityTypeBuilder<ReconciliationAlert> builder)
{
builder.ToTable("reconciliation_alerts", t =>
{
t.HasCheckConstraint("chk_reconciliation_alerts_check_type",
"check_type IN ('UNACKNOWLEDGED_CRITICAL_ALERT', 'PENDING_ORDER_NO_RESULT', 'ACTIVE_INPATIENT_NO_OBSERVATION')");
});
builder.HasKey(r => r.Id);
builder.Property(r => r.Id).HasColumnName("id").HasDefaultValueSql("gen_random_uuid()");
builder.Property(r => r.CheckType)
.HasColumnName("check_type")
.HasMaxLength(50)
.HasConversion(
v => v.ToDbString(),
v => ReconciliationCheckTypeExtensions.FromDbString(v))
.IsRequired();
builder.Property(r => r.EncounterId).HasColumnName("encounter_id");
builder.Property(r => r.PatientId).HasColumnName("patient_id");
builder.Property(r => r.Details).HasColumnName("details").IsRequired();
builder.Property(r => r.ResolvedAt).HasColumnName("resolved_at");
builder.Property(r => r.CreatedAt).HasColumnName("created_at").HasDefaultValueSql("NOW()");
builder.HasIndex(r => new { r.CheckType, r.EncounterId })
.HasFilter("resolved_at IS NULL");
}
}