I have below 4 properties in a Filter class. I am going to parse below 4 properties to a StoredProcedure and get the filtered result.
/// <summary>
/// Gets and sets comma seperated condition ids.
/// Patients must have all these conditions in order to satisfy the filter.
/// </summary>
public string MustHaveAllConditions { get; set; }
/// <summary>
/// Gets and sets comma separated condition ids.
/// Patients must not have all of these conditions in order to satisfy the filter.
/// </summary>
public string MustNotHaveAllConditions { get; set; }
/// <summary>
/// Gets and sets comma separated condition ids.
/// Patients must have at least one of these conditions in order to satisfy the filter.
/// </summary>
public string MustHaveAtLeastOneCondition { get; set; }
/// <summary>
/// Gets and sets comma separated condition ids.
/// Patients must not have at least one of these conditions in order to satisfy the filter.
/// </summary>
public string MustNotHaveAtLeastOneCondition { get; set; }
My Stored procedure will have four parameters like below. Eg:
@*MustHaveAll*Conditions = "1,2"
@*MustNotHaveAll*Conditions = "3,4"
@*MustHaveAtLeastOne*Condition = "5,6,7,8"
@*MustNotHaveAtLeastOne*Condition = "9, 10"
I am using a UDF that returns a table with Ids column.
My question:
Basically I can use SQL "IN" operator to find the patients who has at least one Condition (ie : @MustHaveAtLeastOneCondition ) and "NOT IN" operator combination to filter @MustNotHaveAnyConditions.
Are there any SQL Operators(or esay ways) to filter MustHaveAllConditions, MustNotHaveAllConditions parameters ?