Full SOFA Score: Data Layer + Scoring Engine Glasgow Coma Scale: Data Layer + Scoring Engine
33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
using StackExchange.Redis;
|
|
|
|
public static class QsofaCalculator
|
|
{
|
|
public static readonly IReadOnlyList<string> QsofaCodes = new[]
|
|
{
|
|
"RESP_RATE", "SYSTOLIC_BP", "AVPU"
|
|
};
|
|
|
|
public static readonly IReadOnlySet<string> QsofaCodeSet =
|
|
new HashSet<string>(QsofaCodes);
|
|
|
|
public static bool MeetsCriterion(string observationCode, decimal value) =>
|
|
observationCode switch
|
|
{
|
|
"RESP_RATE" => value >= 22m,
|
|
"SYSTOLIC_BP" => value <= 100m,
|
|
"AVPU" => value >= 1m,
|
|
_ => false
|
|
};
|
|
|
|
public static bool MeetsGcsAlteredMentation(int gcsTotal) =>
|
|
GcsCalculator.MeetsQsofaAlteredMentation(gcsTotal);
|
|
|
|
public static string CriterionKey(Guid encounterId, string code) =>
|
|
$"qsofa:{encounterId}:{code}";
|
|
|
|
public static RedisKey[] AllCriterionKeys(Guid encounterId) =>
|
|
QsofaCodes.Select(c => (RedisKey)CriterionKey(encounterId, c)).ToArray();
|
|
|
|
public static int CountActiveCriteria(RedisValue[] values) =>
|
|
values.Count(v => v.HasValue);
|
|
} |