feature: Observation Ingest, Synchronous Alert Detection, and Alert Lifecycle
This commit is contained in:
@@ -0,0 +1 @@
|
||||
public record BatchIngestRequest(List<IngestObservationRequest> Observations);
|
||||
@@ -0,0 +1,8 @@
|
||||
public record IngestObservationRequest(
|
||||
string ObservationCode,
|
||||
decimal Value,
|
||||
string Unit,
|
||||
ObservationSource Source,
|
||||
DateTimeOffset RecordedAt,
|
||||
string? IdempotencyKey
|
||||
);
|
||||
@@ -0,0 +1,8 @@
|
||||
public record IngestResult(Observation Observation, ClinicalAlert? AlertCreated, bool IsDuplicate = false)
|
||||
{
|
||||
public static IngestResult Created(Observation obs, ClinicalAlert? alert) =>
|
||||
new(obs, alert, false);
|
||||
|
||||
public static IngestResult Duplicate(Observation obs) =>
|
||||
new(obs, null, true);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
||||
public record ObservationCursor(DateTimeOffset RecordedAt, Guid Id)
|
||||
{
|
||||
public string Encode()
|
||||
{
|
||||
var json = JsonSerializer.Serialize(this);
|
||||
return Convert.ToBase64String(Encoding.UTF8.GetBytes(json));
|
||||
}
|
||||
|
||||
public static ObservationCursor? Decode(string? encoded)
|
||||
{
|
||||
if (string.IsNullOrEmpty(encoded)) return null;
|
||||
try
|
||||
{
|
||||
var json = Encoding.UTF8.GetString(Convert.FromBase64String(encoded));
|
||||
return JsonSerializer.Deserialize<ObservationCursor>(json);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
public record ThresholdCacheEntry(
|
||||
string ObservationCode,
|
||||
decimal? CriticalLow,
|
||||
decimal? WarningLow,
|
||||
decimal? WarningHigh,
|
||||
decimal? CriticalHigh);
|
||||
Reference in New Issue
Block a user