Table : RuleDetailRepo
Fields: ConditionAttributesAndValues
RuleDetailId ConditionAttributesAndValues
1 <br> IF Px Between Range (H0000 - H9999) <br> AND Px Between Range (G2000 - G5000)
2 <br> IF Dx Between Range (G23- G40) <br> AND Dx Between Range (M23- M50)
3 if Members Group ID is in the list ( 71796) <br><br> AND Dx Between Range (C00- C90) AND Dx Not Between Range (D19 - D90)
4 if Member is ( URMBT ) and<br>Place of Service is ( Inpatient Hospital ) and <br>Case Type is ( Medical or Surgical or BH )and<br>AND Dx Between
Range (F01-F99) <br> AND Px Between Range (G2000 - G5000)
5 IF Member Source Type Concept = 2 (BCN)<br> AND Px Between Range (H0000 - H9999) <br> AND Px Not Between Range (G2000 - G5000)
<br> AND Dx Not Between Range (D20 - D60)
list = _unitOfWorkCABusinessRules.RuleDetailRepo.GetAll().ToList();
//Filter Group Txt
if (model.GroupTxt != null)
list = list.Where(x => InListOrRange(model.GroupTxt, x.ConditionAttributesAndValues));
private bool InListOrRange(string search, string source)
{
var result = default(bool);
var start = default(int);
var end = default(int);
var searchRange = default(Dictionary<string, IEnumerable<int>>);
var sourceRange = default(Dictionary<string, IEnumerable<int>>);
var list = default(IEnumerable<string>);
try
{
// Replace the whitespace for easier parsing
search = search.Replace(" ", "");
source = source.Replace(" ", "");
// Get our ranges
start = source.IndexOf("BetweenRange(", StringComparison.OrdinalIgnoreCase) + "BetweenRange(".Length;
end = source.IndexOf(")", start);
searchRange = GetRangeDictionary(search);
sourceRange = GetRangeDictionary(source.Substring(start, end - start));
// Get our list
start = source.IndexOf("(") != start ? source.IndexOf('(') + 1 : -1;
if (start != -1)
{
end = source.IndexOf(")", start);
}
list = start != -1 ? source.Substring(start, end - start).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Replace("<br>", "")) : new string[] { };
result = (from lhs in searchRange
from rhs in sourceRange
where Equals(lhs.Key, rhs.Key)
select lhs.Value.Intersect(rhs.Value).Any()).Any(x => x) || list.Any(x => string.Equals(search, x, StringComparison.OrdinalIgnoreCase));
}
catch (Exception e)
{
//Console.WriteLine($"Message: {ex.Message}{Environment.NewLine}{ex.StackTrace}");
result = false;
}
return result;
}
private Dictionary<string, IEnumerable<int>> GetRangeDictionary(string source)
{
var result = default(Dictionary<string, IEnumerable<int>>);
try
{
result = source.Split('-')
.Select(x => new KeyValuePair<string, int>(Regex.Match(x, @"\D+")?.Value ?? string.Empty, Convert.ToInt32(Regex.Match(x, @"\d+")?.Value ?? "0")))
.OrderBy(x => x.Value)
.GroupBy(x => x.Key)
.Select(x => new KeyValuePair<string, IEnumerable<int>>(x.Key, Enumerable.Range(x.First().Value, x.LastOrDefault().Value == 0 ? 1 : x.Last().Value - x.First().Value + 1)))
.ToDictionary(x => x.Key, x => x.Value);
}
catch (Exception e)
{
//Console.WriteLine($"Message: {ex.Message}{Environment.NewLine}{ex.StackTrace}");
result = new Dictionary<string, IEnumerable<int>>();
}
return result;
}
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.