private List <Userod> GetListDoseSpotUsers(bool includeProv, string provNpi = "") { List <Userod> retVal = new List <Userod>(); List <Provider> listProviders = Providers.GetWhere(x => x.NationalProvID == provNpi, true); List <UserOdPref> listUserPrefDoseSpotIds = UserOdPrefs.GetAllByFkeyAndFkeyType(_programErx.ProgramNum, UserOdFkeyType.Program); listUserPrefDoseSpotIds = listUserPrefDoseSpotIds.FindAll(x => string.IsNullOrWhiteSpace(x.ValueString)); if (includeProv) { retVal = Userods.GetWhere( (x => listProviders.Exists(y => y.ProvNum == x.ProvNum) && //Find users that have a link to the NPI that has been passed in !listUserPrefDoseSpotIds.Exists(y => y.UserNum == x.UserNum)) //Also, these users shouldn't already have a DoseSpot User ID. , true); //Only consider non-hidden users. } else { retVal = Userods.GetWhere( (x => !listUserPrefDoseSpotIds.Exists(y => y.UserNum == x.UserNum)) //All users that don't already have a DoseSpot User ID. , true); //Only consider non-hidden users. } return(retVal); }