feature: PHI Column Encryption + Access Logging
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
public static class EncryptPhiCommand
|
||||
{
|
||||
public static async Task RunAsync(IServiceProvider services)
|
||||
{
|
||||
using var scope = services.CreateScope();
|
||||
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||
var crypto = scope.ServiceProvider.GetRequiredService<IPhiEncryptionService>();
|
||||
|
||||
var patients = await db.Patients.ToListAsync();
|
||||
foreach (var p in patients)
|
||||
{
|
||||
p.NameSearchToken = crypto.ComputeNameSearchToken(p.FirstName, p.LastName);
|
||||
}
|
||||
|
||||
await db.SaveChangesAsync();
|
||||
Console.WriteLine($"Encrypted {patients.Count} patient records.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user