Fix CCS category order search
This commit is contained in:
@@ -695,12 +695,25 @@ public sealed class CcsStore
|
||||
PresentingLocation = value.PresentingLocation, RealTimeMinutes = value.RealTimeMinutes,
|
||||
Difficulty = value.Difficulty, Tags = value.Tags
|
||||
};
|
||||
private static int Rank(CcsOrderDefinition order, string query)
|
||||
internal static int Rank(CcsOrderDefinition order, string query)
|
||||
{
|
||||
var values = new[] { order.CanonicalName }.Concat(order.Aliases).Select(value => value.ToLowerInvariant());
|
||||
if (values.Any(value => value == query)) return 0;
|
||||
if (values.Any(value => value.StartsWith(query))) return 1;
|
||||
if (values.Any(value => value.Contains(query))) return 2;
|
||||
if (CategorySearchTerms(order.Category).Contains(query, StringComparer.OrdinalIgnoreCase)) return 3;
|
||||
return 1000;
|
||||
}
|
||||
|
||||
private static IReadOnlyList<string> CategorySearchTerms(string category) =>
|
||||
category.Trim().ToLowerInvariant() switch
|
||||
{
|
||||
"laboratory" => ["laboratory", "laboratories", "lab", "labs", "test", "tests", "diagnostic", "diagnostics", "study", "studies"],
|
||||
"diagnostic" => ["diagnostic", "diagnostics", "test", "tests", "study", "studies"],
|
||||
"medication" => ["medication", "medications", "medicine", "medicines", "drug", "drugs", "treatment", "treatments", "therapy", "therapies"],
|
||||
"procedure" => ["procedure", "procedures", "intervention", "interventions", "treatment", "treatments"],
|
||||
"monitoring" => ["monitor", "monitoring", "treatment", "treatments"],
|
||||
"disposition" => ["disposition", "admission", "admit", "transfer", "discharge"],
|
||||
_ => [category.Trim().ToLowerInvariant()]
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user