begin: PHI Column Encryption

This commit is contained in:
voltsrage
2026-06-22 21:18:36 +08:00
parent 518cc5b99a
commit 46db694820
21 changed files with 3177 additions and 6 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,55 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace VigilCareClinicalAPI.Migrations
{
/// <inheritdoc />
public partial class AddPatientNameSearchToken : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "date_of_birth",
table: "patients",
type: "text",
nullable: false,
oldClrType: typeof(DateOnly),
oldType: "date");
migrationBuilder.AddColumn<string>(
name: "name_search_token",
table: "patients",
type: "character varying(64)",
maxLength: 64,
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_patients_name_search_token",
table: "patients",
column: "name_search_token");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_patients_name_search_token",
table: "patients");
migrationBuilder.DropColumn(
name: "name_search_token",
table: "patients");
migrationBuilder.AlterColumn<DateOnly>(
name: "date_of_birth",
table: "patients",
type: "date",
nullable: false,
oldClrType: typeof(string),
oldType: "text");
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,58 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace VigilCareClinicalAPI.Migrations
{
/// <inheritdoc />
public partial class AddPhiAccessLogs : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "phi_access_logs",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
access_type = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
patient_id = table.Column<Guid>(type: "uuid", nullable: true),
user_id = table.Column<Guid>(type: "uuid", nullable: false),
user_display_name = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
resource_path = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: false),
search_query_hash = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
result_count = table.Column<int>(type: "integer", nullable: true),
ip_address = table.Column<string>(type: "character varying(45)", maxLength: 45, nullable: true),
correlation_id = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
accessed_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "NOW()")
},
constraints: table =>
{
table.PrimaryKey("PK_phi_access_logs", x => x.id);
});
migrationBuilder.CreateIndex(
name: "IX_phi_access_logs_accessed_at",
table: "phi_access_logs",
column: "accessed_at");
migrationBuilder.CreateIndex(
name: "IX_phi_access_logs_patient_id",
table: "phi_access_logs",
column: "patient_id");
migrationBuilder.CreateIndex(
name: "IX_phi_access_logs_user_id",
table: "phi_access_logs",
column: "user_id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "phi_access_logs");
}
}
}
@@ -828,8 +828,9 @@ namespace VigilCareClinicalAPI.Migrations
.HasColumnName("created_at")
.HasDefaultValueSql("NOW()");
b.Property<DateOnly>("DateOfBirth")
.HasColumnType("date")
b.Property<string>("DateOfBirth")
.IsRequired()
.HasColumnType("text")
.HasColumnName("date_of_birth");
b.Property<string>("EmergencyContactName")
@@ -866,6 +867,11 @@ namespace VigilCareClinicalAPI.Migrations
.HasColumnType("character varying(20)")
.HasColumnName("mrn");
b.Property<string>("NameSearchToken")
.HasMaxLength(64)
.HasColumnType("character varying(64)")
.HasColumnName("name_search_token");
b.Property<string>("Status")
.IsRequired()
.ValueGeneratedOnAdd()
@@ -879,9 +885,81 @@ namespace VigilCareClinicalAPI.Migrations
b.HasIndex("Mrn")
.IsUnique();
b.HasIndex("NameSearchToken");
b.ToTable("patients", (string)null);
});
modelBuilder.Entity("PhiAccessLog", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid")
.HasColumnName("id")
.HasDefaultValueSql("gen_random_uuid()");
b.Property<string>("AccessType")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)")
.HasColumnName("access_type");
b.Property<DateTimeOffset>("AccessedAt")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasColumnName("accessed_at")
.HasDefaultValueSql("NOW()");
b.Property<string>("CorrelationId")
.HasMaxLength(100)
.HasColumnType("character varying(100)")
.HasColumnName("correlation_id");
b.Property<string>("IpAddress")
.HasMaxLength(45)
.HasColumnType("character varying(45)")
.HasColumnName("ip_address");
b.Property<Guid?>("PatientId")
.HasColumnType("uuid")
.HasColumnName("patient_id");
b.Property<string>("ResourcePath")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("character varying(500)")
.HasColumnName("resource_path");
b.Property<int?>("ResultCount")
.HasColumnType("integer")
.HasColumnName("result_count");
b.Property<string>("SearchQueryHash")
.HasMaxLength(64)
.HasColumnType("character varying(64)")
.HasColumnName("search_query_hash");
b.Property<string>("UserDisplayName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)")
.HasColumnName("user_display_name");
b.Property<Guid>("UserId")
.HasColumnType("uuid")
.HasColumnName("user_id");
b.HasKey("Id");
b.HasIndex("AccessedAt");
b.HasIndex("PatientId");
b.HasIndex("UserId");
b.ToTable("phi_access_logs", (string)null);
});
modelBuilder.Entity("ReconciliationAlert", b =>
{
b.Property<Guid>("Id")