Fix CCS category order search
This commit is contained in:
@@ -143,6 +143,25 @@ public sealed class CcsCaseTests
|
||||
Assert.True(CcsRatingStore.ExpectedScore(800, 1000) < 0.25);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("medication", "medication")]
|
||||
[InlineData("medication", "medications")]
|
||||
[InlineData("medication", "treatment")]
|
||||
[InlineData("procedure", "procedures")]
|
||||
[InlineData("laboratory", "tests")]
|
||||
[InlineData("diagnostic", "study")]
|
||||
public void CcsOrderSearchMatchesClinicalCategories(string category, string query)
|
||||
{
|
||||
var order = new CcsOrderDefinition
|
||||
{
|
||||
Code = "order",
|
||||
CanonicalName = "Unrelated canonical name",
|
||||
Category = category
|
||||
};
|
||||
|
||||
Assert.True(CcsStore.Rank(order, query) < 1000);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ScoringReviewIncludesExpectedAndObservedEvidence()
|
||||
{
|
||||
|
||||
@@ -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