Files
2026-06-25 00:25:31 +08:00

42 lines
1.2 KiB
C#

public static class SofaContributorBuilder
{
private static readonly (string Label, string NormalRange)[] OrganSystems =
[
("Respiratory", "0"),
("Coagulation", "0"),
("Liver", "0"),
("Cardiovascular", "0"),
("CNS", "0"),
("Renal", "0"),
];
private static readonly string[] OrganKeys =
[
"RESPIRATORY", "COAGULATION", "LIVER", "CARDIOVASCULAR", "CNS", "RENAL"
];
public static List<ScoreContributor> Build(
SofaResult result,
IReadOnlyDictionary<string, string?>? rawValues = null)
{
var scores = new[]
{
result.Respiratory, result.Coagulation, result.Liver,
result.Cardiovascular, result.Cns, result.Renal
};
var contributors = new List<ScoreContributor>(scores.Length);
for (int i = 0; i < scores.Length; i++)
{
contributors.Add(new ScoreContributor
{
Parameter = OrganSystems[i].Label,
Points = scores[i],
RawValue = rawValues?.GetValueOrDefault(OrganKeys[i]),
NormalRange = OrganSystems[i].NormalRange
});
}
return contributors;
}
}