feature: Reconciliation Jobs

This commit is contained in:
voltsrage
2026-06-17 14:36:10 +08:00
parent 56d052aa4f
commit 101040f9d9
40 changed files with 2845 additions and 32 deletions
@@ -4,7 +4,7 @@ public class Encounter
public Guid PatientId { get; set; }
public EncounterType EncounterType { get; set; }
public EncounterStatus Status { get; set; }
public string Department { get; set; } = null!;
public Department Department { get; set; }
public string AttendingPhysician { get; set; } = null!;
public DateTimeOffset AdmittedAt { get; set; }
public DateTimeOffset? DischargedAt { get; set; }
@@ -5,7 +5,7 @@ public class Order
public OrderType OrderType { get; set; }
public string Description { get; set; } = null!;
public string OrderedBy { get; set; } = null!;
public string Status { get; set; } = "pending";
public OrderStatus Status { get; set; } = OrderStatus.Pending;
public DateTimeOffset OrderedAt { get; set; }
public DateTimeOffset? ResultedAt { get; set; }
@@ -7,4 +7,7 @@ public class ReconciliationAlert
public string Details { get; set; } = null!;
public DateTimeOffset? ResolvedAt { get; set; }
public DateTimeOffset CreatedAt { get; set; }
public Encounter? Encounter { get; set; }
public Patient? Patient { get; set; }
}
@@ -0,0 +1,34 @@
public enum Department
{
Icu,
GeneralMedicine,
Emergency,
Cardiology,
Surgery,
Pediatrics
}
public static class DepartmentExtensions
{
public static string ToDbString(this Department d) => d switch
{
Department.Icu => "ICU",
Department.GeneralMedicine => "GENERAL_MEDICINE",
Department.Emergency => "EMERGENCY",
Department.Cardiology => "CARDIOLOGY",
Department.Surgery => "SURGERY",
Department.Pediatrics => "PEDIATRICS",
_ => throw new ArgumentOutOfRangeException(nameof(d))
};
public static Department FromDbString(string v) => v switch
{
"ICU" => Department.Icu,
"GENERAL_MEDICINE" => Department.GeneralMedicine,
"EMERGENCY" => Department.Emergency,
"CARDIOLOGY" => Department.Cardiology,
"SURGERY" => Department.Surgery,
"PEDIATRICS" => Department.Pediatrics,
_ => throw new ArgumentOutOfRangeException(nameof(v), $"Unknown department: '{v}'")
};
}
@@ -0,0 +1,22 @@
public enum OrderStatus { Pending, InProgress, Resulted, Cancelled }
public static class OrderStatusExtensions
{
public static string ToDbString(this OrderStatus s) => s switch
{
OrderStatus.Pending => "PENDING",
OrderStatus.InProgress => "IN_PROGRESS",
OrderStatus.Resulted => "RESULTED",
OrderStatus.Cancelled => "CANCELLED",
_ => throw new ArgumentOutOfRangeException(nameof(s))
};
public static OrderStatus FromDbString(string v) => v switch
{
"PENDING" => OrderStatus.Pending,
"IN_PROGRESS" => OrderStatus.InProgress,
"RESULTED" => OrderStatus.Resulted,
"CANCELLED" => OrderStatus.Cancelled,
_ => throw new ArgumentOutOfRangeException(nameof(v), $"Unknown order status: '{v}'")
};
}
@@ -0,0 +1,11 @@
using System.Text.Json;
using System.Text.Json.Serialization;
public sealed class DepartmentJsonConverter : JsonConverter<Department>
{
public override Department Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
=> DepartmentExtensions.FromDbString(reader.GetString()!);
public override void Write(Utf8JsonWriter writer, Department value, JsonSerializerOptions options)
=> writer.WriteStringValue(value.ToDbString());
}