Run initial test for Climate Resilience Verification Suite
Add first part of Alert Quality Analytics
This commit is contained in:
+1866
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,114 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace VigilCareClinicalAPI.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddAlertQualityAnalytics : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "feedback_received",
|
||||
table: "clinical_alerts",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "alert_feedbacks",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<Guid>(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
|
||||
alert_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
user_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
feedback_type = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
|
||||
comment = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true),
|
||||
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "NOW()")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_alert_feedbacks", x => x.id);
|
||||
table.ForeignKey(
|
||||
name: "FK_alert_feedbacks_clinical_alerts_alert_id",
|
||||
column: x => x.alert_id,
|
||||
principalTable: "clinical_alerts",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "alert_quality_metrics",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<Guid>(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
|
||||
alert_type = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
||||
window_start = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
window_end = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
total_alerts = table.Column<int>(type: "integer", nullable: false),
|
||||
acknowledged_count = table.Column<int>(type: "integer", nullable: false),
|
||||
resolved_count = table.Column<int>(type: "integer", nullable: false),
|
||||
escalated_count = table.Column<int>(type: "integer", nullable: false),
|
||||
feedback_useful_count = table.Column<int>(type: "integer", nullable: false),
|
||||
feedback_false_positive_count = table.Column<int>(type: "integer", nullable: false),
|
||||
feedback_would_act_count = table.Column<int>(type: "integer", nullable: false),
|
||||
feedback_count = table.Column<int>(type: "integer", nullable: false),
|
||||
acknowledgement_rate = table.Column<double>(type: "double precision", nullable: false),
|
||||
false_positive_rate = table.Column<double>(type: "double precision", nullable: false),
|
||||
useful_rate = table.Column<double>(type: "double precision", nullable: false),
|
||||
would_act_rate = table.Column<double>(type: "double precision", nullable: false),
|
||||
avg_seconds_to_acknowledge = table.Column<double>(type: "double precision", nullable: false),
|
||||
avg_seconds_to_resolution = table.Column<double>(type: "double precision", nullable: false),
|
||||
computed_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "NOW()")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_alert_quality_metrics", x => x.id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_alert_feedbacks_alert_id",
|
||||
table: "alert_feedbacks",
|
||||
column: "alert_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_alert_feedbacks_alert_id_user_id",
|
||||
table: "alert_feedbacks",
|
||||
columns: new[] { "alert_id", "user_id" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_alert_feedbacks_feedback_type",
|
||||
table: "alert_feedbacks",
|
||||
column: "feedback_type");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_alert_quality_metrics_alert_type_window_start_window_end",
|
||||
table: "alert_quality_metrics",
|
||||
columns: new[] { "alert_type", "window_start", "window_end" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_alert_quality_metrics_window_start",
|
||||
table: "alert_quality_metrics",
|
||||
column: "window_start");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "alert_feedbacks");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "alert_quality_metrics");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "feedback_received",
|
||||
table: "clinical_alerts");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,145 @@ namespace VigilCareClinicalAPI.Migrations
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("AlertFeedback", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("id")
|
||||
.HasDefaultValueSql("gen_random_uuid()");
|
||||
|
||||
b.Property<Guid>("AlertId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("alert_id");
|
||||
|
||||
b.Property<string>("Comment")
|
||||
.HasMaxLength(1000)
|
||||
.HasColumnType("character varying(1000)")
|
||||
.HasColumnName("comment");
|
||||
|
||||
b.Property<DateTimeOffset>("CreatedAt")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("created_at")
|
||||
.HasDefaultValueSql("NOW()");
|
||||
|
||||
b.Property<string>("FeedbackType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(30)
|
||||
.HasColumnType("character varying(30)")
|
||||
.HasColumnName("feedback_type");
|
||||
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("user_id");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AlertId");
|
||||
|
||||
b.HasIndex("FeedbackType");
|
||||
|
||||
b.HasIndex("AlertId", "UserId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("alert_feedbacks", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AlertQualityMetric", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("id")
|
||||
.HasDefaultValueSql("gen_random_uuid()");
|
||||
|
||||
b.Property<int>("AcknowledgedCount")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("acknowledged_count");
|
||||
|
||||
b.Property<double>("AcknowledgementRate")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("acknowledgement_rate");
|
||||
|
||||
b.Property<string>("AlertType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("character varying(50)")
|
||||
.HasColumnName("alert_type");
|
||||
|
||||
b.Property<double>("AvgSecondsToAcknowledge")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("avg_seconds_to_acknowledge");
|
||||
|
||||
b.Property<double>("AvgSecondsToResolution")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("avg_seconds_to_resolution");
|
||||
|
||||
b.Property<DateTimeOffset>("ComputedAt")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("computed_at")
|
||||
.HasDefaultValueSql("NOW()");
|
||||
|
||||
b.Property<int>("EscalatedCount")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("escalated_count");
|
||||
|
||||
b.Property<double>("FalsePositiveRate")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("false_positive_rate");
|
||||
|
||||
b.Property<int>("FeedbackCount")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("feedback_count");
|
||||
|
||||
b.Property<int>("FeedbackFalsePositiveCount")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("feedback_false_positive_count");
|
||||
|
||||
b.Property<int>("FeedbackUsefulCount")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("feedback_useful_count");
|
||||
|
||||
b.Property<int>("FeedbackWouldActCount")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("feedback_would_act_count");
|
||||
|
||||
b.Property<int>("ResolvedCount")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("resolved_count");
|
||||
|
||||
b.Property<int>("TotalAlerts")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("total_alerts");
|
||||
|
||||
b.Property<double>("UsefulRate")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("useful_rate");
|
||||
|
||||
b.Property<DateTimeOffset>("WindowEnd")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("window_end");
|
||||
|
||||
b.Property<DateTimeOffset>("WindowStart")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("window_start");
|
||||
|
||||
b.Property<double>("WouldActRate")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("would_act_rate");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("WindowStart");
|
||||
|
||||
b.HasIndex("AlertType", "WindowStart", "WindowEnd")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("alert_quality_metrics", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AlertThreshold", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
@@ -117,6 +256,12 @@ namespace VigilCareClinicalAPI.Migrations
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("encounter_id");
|
||||
|
||||
b.Property<bool>("FeedbackReceived")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("boolean")
|
||||
.HasDefaultValue(false)
|
||||
.HasColumnName("feedback_received");
|
||||
|
||||
b.Property<string>("ObservationCode")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("character varying(50)")
|
||||
@@ -1476,6 +1621,17 @@ namespace VigilCareClinicalAPI.Migrations
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AlertFeedback", b =>
|
||||
{
|
||||
b.HasOne("ClinicalAlert", "Alert")
|
||||
.WithMany("Feedbacks")
|
||||
.HasForeignKey("AlertId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Alert");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ClinicalAlert", b =>
|
||||
{
|
||||
b.HasOne("Encounter", "Encounter")
|
||||
@@ -1668,6 +1824,11 @@ namespace VigilCareClinicalAPI.Migrations
|
||||
b.Navigation("Site");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ClinicalAlert", b =>
|
||||
{
|
||||
b.Navigation("Feedbacks");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ClinicalSite", b =>
|
||||
{
|
||||
b.Navigation("Gateways");
|
||||
|
||||
Reference in New Issue
Block a user