Fix issues with critical alerts breaking the simulation

This commit is contained in:
voltsrage
2026-06-25 02:06:35 +08:00
parent df6fbed401
commit 09a84f34ba
29 changed files with 196 additions and 155 deletions
@@ -0,0 +1,11 @@
using System.Text.Json;
using System.Text.Json.Serialization;
public sealed class AlertSeverityJsonConverter : JsonConverter<AlertSeverity>
{
public override AlertSeverity Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
=> AlertSeverityExtensions.FromDbString(reader.GetString()!);
public override void Write(Utf8JsonWriter writer, AlertSeverity value, JsonSerializerOptions options)
=> writer.WriteStringValue(value.ToDbString());
}
@@ -0,0 +1,11 @@
using System.Text.Json;
using System.Text.Json.Serialization;
public sealed class AlertStatusJsonConverter : JsonConverter<AlertStatus>
{
public override AlertStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
=> AlertStatusExtensions.FromDbString(reader.GetString()!);
public override void Write(Utf8JsonWriter writer, AlertStatus value, JsonSerializerOptions options)
=> writer.WriteStringValue(value.ToDbString());
}
@@ -0,0 +1,11 @@
using System.Text.Json;
using System.Text.Json.Serialization;
public sealed class AlertTypeJsonConverter : JsonConverter<AlertType>
{
public override AlertType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
=> AlertTypeExtensions.FromDbString(reader.GetString()!);
public override void Write(Utf8JsonWriter writer, AlertType value, JsonSerializerOptions options)
=> writer.WriteStringValue(value.ToDbString());
}
@@ -44,7 +44,10 @@ namespace VigilCareClinicalAPI.Migrations
table: "patients");
migrationBuilder.Sql(
"ALTER TABLE patients ALTER COLUMN date_of_birth TYPE date USING date_of_birth::date;");
"""
UPDATE patients SET date_of_birth = '1900-01-01' WHERE date_of_birth !~ '^\d{4}-\d{2}-\d{2}$';
ALTER TABLE patients ALTER COLUMN date_of_birth TYPE date USING date_of_birth::date;
""");
}
}
}
@@ -56,6 +56,14 @@ namespace VigilCareClinicalAPI.Migrations
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(
"""
UPDATE patients SET last_name = LEFT(last_name, 100);
UPDATE patients SET first_name = LEFT(first_name, 100);
UPDATE patients SET emergency_contact_phone = LEFT(emergency_contact_phone, 20);
UPDATE patients SET emergency_contact_name = LEFT(emergency_contact_name, 200);
""");
migrationBuilder.AlterColumn<string>(
name: "last_name",
table: "patients",
+4 -1
View File
@@ -258,9 +258,12 @@ try
opts.JsonSerializerOptions.Converters.Add(new BloodTypeJsonConverter());
opts.JsonSerializerOptions.Converters.Add(new AuditActionJsonConverter());
opts.JsonSerializerOptions.Converters.Add(new SepsisBundleComplianceStatusJsonConverter());
opts.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
opts.JsonSerializerOptions.Converters.Add(new AlertTypeJsonConverter());
opts.JsonSerializerOptions.Converters.Add(new AlertSeverityJsonConverter());
opts.JsonSerializerOptions.Converters.Add(new AlertStatusJsonConverter());
opts.JsonSerializerOptions.Converters.Add(new ObservationSourceJsonConverter());
opts.JsonSerializerOptions.Converters.Add(new DepartmentJsonConverter());
opts.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
});
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(options =>