feature: In-App Simulation Runner (Backend)
This commit is contained in:
@@ -25,6 +25,7 @@ public class PatientConfiguration : IEntityTypeConfiguration<Patient>
|
||||
.HasColumnName("name_search_token")
|
||||
.HasMaxLength(64);
|
||||
builder.Property(p => p.CreatedAt).HasColumnName("created_at").HasDefaultValueSql("NOW()");
|
||||
builder.Property(p => p.IsSimulated).HasColumnName("is_simulated").HasDefaultValue(false);
|
||||
|
||||
// MRN uses exact-match unique index — MRN lookups are always equality checks,
|
||||
// never LIKE/ILIKE. A B-tree unique index satisfies O(log n) point lookup.
|
||||
@@ -33,5 +34,9 @@ public class PatientConfiguration : IEntityTypeConfiguration<Patient>
|
||||
// at this scale (pg_trgm GIN would be warranted at >500k patients).
|
||||
builder.HasIndex(p => p.Mrn).IsUnique();
|
||||
builder.HasIndex(p => p.NameSearchToken);
|
||||
// Filtered index keeps Phase 38 simulated-patient purge cheap.
|
||||
builder.HasIndex(p => p.IsSimulated)
|
||||
.HasDatabaseName("IX_Patients_IsSimulated")
|
||||
.HasFilter("is_simulated = true");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
public class SimulationRunConfiguration : IEntityTypeConfiguration<SimulationRun>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<SimulationRun> builder)
|
||||
{
|
||||
builder.ToTable("simulation_runs");
|
||||
builder.HasKey(r => r.Id);
|
||||
builder.Property(r => r.Id).HasColumnName("id").HasDefaultValueSql("gen_random_uuid()");
|
||||
builder.Property(r => r.ScenarioId).HasColumnName("scenario_id").HasMaxLength(100).IsRequired();
|
||||
builder.Property(r => r.ScenarioName).HasColumnName("scenario_name").HasMaxLength(200).IsRequired();
|
||||
builder.Property(r => r.Speed).HasColumnName("speed");
|
||||
builder.Property(r => r.Status).HasColumnName("status").HasMaxLength(20).IsRequired()
|
||||
.HasConversion(
|
||||
v => v.ToDbString(),
|
||||
v => SimulationRunStatusExtensions.FromDbString(v));
|
||||
builder.Property(r => r.PatientId).HasColumnName("patient_id");
|
||||
builder.Property(r => r.EncounterId).HasColumnName("encounter_id");
|
||||
builder.Property(r => r.StartedByUserId).HasColumnName("started_by_user_id").HasMaxLength(100).IsRequired();
|
||||
builder.Property(r => r.StartedAt).HasColumnName("started_at");
|
||||
builder.Property(r => r.CompletedAt).HasColumnName("completed_at");
|
||||
builder.Property(r => r.ObservationsSent).HasColumnName("observations_sent");
|
||||
builder.Property(r => r.MedicationsSent).HasColumnName("medications_sent");
|
||||
builder.Property(r => r.OrdersPlaced).HasColumnName("orders_placed");
|
||||
builder.Property(r => r.LastOffsetMinutes).HasColumnName("last_offset_minutes");
|
||||
builder.Property(r => r.TotalOffsetMinutes).HasColumnName("total_offset_minutes");
|
||||
builder.Property(r => r.FailureReason).HasColumnName("failure_reason").HasMaxLength(2000);
|
||||
|
||||
builder.HasIndex(r => new { r.Status, r.StartedAt })
|
||||
.IsDescending(false, true)
|
||||
.HasDatabaseName("IX_simulation_runs_status_started_at");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user