feature: In-App Simulation Runner (Backend)
CI / frontend (push) Canceled after 0s
CI / backend (push) Canceled after 8m32s

This commit is contained in:
voltsrage
2026-08-06 01:52:53 +08:00
parent 943d41339c
commit 24f45851e9
83 changed files with 3974 additions and 120 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,75 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace VigilCareClinicalAPI.Migrations
{
/// <inheritdoc />
public partial class AddSimulationSupport : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "is_simulated",
table: "patients",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.CreateTable(
name: "simulation_runs",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
scenario_id = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
scenario_name = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
speed = table.Column<double>(type: "double precision", nullable: false),
status = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
patient_id = table.Column<Guid>(type: "uuid", nullable: true),
encounter_id = table.Column<Guid>(type: "uuid", nullable: true),
started_by_user_id = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
started_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
completed_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
observations_sent = table.Column<int>(type: "integer", nullable: false),
medications_sent = table.Column<int>(type: "integer", nullable: false),
orders_placed = table.Column<int>(type: "integer", nullable: false),
last_offset_minutes = table.Column<double>(type: "double precision", nullable: false),
total_offset_minutes = table.Column<double>(type: "double precision", nullable: false),
failure_reason = table.Column<string>(type: "character varying(2000)", maxLength: 2000, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_simulation_runs", x => x.id);
});
migrationBuilder.CreateIndex(
name: "IX_Patients_IsSimulated",
table: "patients",
column: "is_simulated",
filter: "is_simulated = true");
migrationBuilder.CreateIndex(
name: "IX_simulation_runs_status_started_at",
table: "simulation_runs",
columns: new[] { "status", "started_at" },
descending: new[] { false, true });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "simulation_runs");
migrationBuilder.DropIndex(
name: "IX_Patients_IsSimulated",
table: "patients");
migrationBuilder.DropColumn(
name: "is_simulated",
table: "patients");
}
}
}
@@ -1166,6 +1166,12 @@ namespace VigilCareClinicalAPI.Migrations
.HasColumnType("character varying(10)")
.HasColumnName("gender");
b.Property<bool>("IsSimulated")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false)
.HasColumnName("is_simulated");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(100)
@@ -1193,6 +1199,10 @@ namespace VigilCareClinicalAPI.Migrations
b.HasKey("Id");
b.HasIndex("IsSimulated")
.HasDatabaseName("IX_Patients_IsSimulated")
.HasFilter("is_simulated = true");
b.HasIndex("Mrn")
.IsUnique();
@@ -1524,6 +1534,92 @@ namespace VigilCareClinicalAPI.Migrations
});
});
modelBuilder.Entity("SimulationRun", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid")
.HasColumnName("id")
.HasDefaultValueSql("gen_random_uuid()");
b.Property<DateTimeOffset?>("CompletedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("completed_at");
b.Property<Guid?>("EncounterId")
.HasColumnType("uuid")
.HasColumnName("encounter_id");
b.Property<string>("FailureReason")
.HasMaxLength(2000)
.HasColumnType("character varying(2000)")
.HasColumnName("failure_reason");
b.Property<double>("LastOffsetMinutes")
.HasColumnType("double precision")
.HasColumnName("last_offset_minutes");
b.Property<int>("MedicationsSent")
.HasColumnType("integer")
.HasColumnName("medications_sent");
b.Property<int>("ObservationsSent")
.HasColumnType("integer")
.HasColumnName("observations_sent");
b.Property<int>("OrdersPlaced")
.HasColumnType("integer")
.HasColumnName("orders_placed");
b.Property<Guid?>("PatientId")
.HasColumnType("uuid")
.HasColumnName("patient_id");
b.Property<string>("ScenarioId")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)")
.HasColumnName("scenario_id");
b.Property<string>("ScenarioName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)")
.HasColumnName("scenario_name");
b.Property<double>("Speed")
.HasColumnType("double precision")
.HasColumnName("speed");
b.Property<DateTimeOffset>("StartedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("started_at");
b.Property<string>("StartedByUserId")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)")
.HasColumnName("started_by_user_id");
b.Property<string>("Status")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)")
.HasColumnName("status");
b.Property<double>("TotalOffsetMinutes")
.HasColumnType("double precision")
.HasColumnName("total_offset_minutes");
b.HasKey("Id");
b.HasIndex("Status", "StartedAt")
.IsDescending(false, true)
.HasDatabaseName("IX_simulation_runs_status_started_at");
b.ToTable("simulation_runs", (string)null);
});
modelBuilder.Entity("SofaScore", b =>
{
b.Property<Guid>("Id")