begin: PHI Column Encryption
This commit is contained in:
@@ -21,6 +21,9 @@ public class PatientConfiguration : IEntityTypeConfiguration<Patient>
|
||||
builder.Property(p => p.Allergies).HasColumnName("allergies");
|
||||
builder.Property(p => p.EmergencyContactName).HasColumnName("emergency_contact_name").HasMaxLength(200);
|
||||
builder.Property(p => p.EmergencyContactPhone).HasColumnName("emergency_contact_phone").HasMaxLength(20);
|
||||
builder.Property(p => p.NameSearchToken)
|
||||
.HasColumnName("name_search_token")
|
||||
.HasMaxLength(64);
|
||||
builder.Property(p => p.CreatedAt).HasColumnName("created_at").HasDefaultValueSql("NOW()");
|
||||
|
||||
// MRN uses exact-match unique index — MRN lookups are always equality checks,
|
||||
@@ -29,5 +32,6 @@ public class PatientConfiguration : IEntityTypeConfiguration<Patient>
|
||||
// equality match — so no index here; full ILIKE is intentionally unindexed
|
||||
// at this scale (pg_trgm GIN would be warranted at >500k patients).
|
||||
builder.HasIndex(p => p.Mrn).IsUnique();
|
||||
builder.HasIndex(p => p.NameSearchToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
public class PhiAccessLogConfiguration : IEntityTypeConfiguration<PhiAccessLog>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<PhiAccessLog> builder)
|
||||
{
|
||||
builder.ToTable("phi_access_logs");
|
||||
builder.HasKey(p => p.Id);
|
||||
builder.Property(p => p.Id).HasColumnName("id").HasDefaultValueSql("gen_random_uuid()");
|
||||
builder.Property(p => p.AccessType).HasColumnName("access_type").HasMaxLength(20).IsRequired()
|
||||
.HasConversion(v => v.ToDbString(), v => PhiAccessTypeExtensions.FromDbString(v));
|
||||
builder.Property(p => p.PatientId).HasColumnName("patient_id");
|
||||
builder.Property(p => p.UserId).HasColumnName("user_id").IsRequired();
|
||||
builder.Property(p => p.UserDisplayName).HasColumnName("user_display_name").HasMaxLength(200).IsRequired();
|
||||
builder.Property(p => p.ResourcePath).HasColumnName("resource_path").HasMaxLength(500).IsRequired();
|
||||
builder.Property(p => p.SearchQueryHash).HasColumnName("search_query_hash").HasMaxLength(64);
|
||||
builder.Property(p => p.ResultCount).HasColumnName("result_count");
|
||||
builder.Property(p => p.IpAddress).HasColumnName("ip_address").HasMaxLength(45);
|
||||
builder.Property(p => p.CorrelationId).HasColumnName("correlation_id").HasMaxLength(100);
|
||||
builder.Property(p => p.AccessedAt).HasColumnName("accessed_at").HasDefaultValueSql("NOW()");
|
||||
|
||||
builder.HasIndex(p => p.PatientId);
|
||||
builder.HasIndex(p => p.UserId);
|
||||
builder.HasIndex(p => p.AccessedAt);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user