// TODO check for response codes mentioned in filter and only show those /// <summary> /// Sets the Filter property for each SurveyQuestion that has a PreP containing a VarName. /// </summary> private void PopulateFilters() { string filterList = ""; string filterVar = ""; string filterRO; string filterNR; string filterLabel; Regex rx1 = new Regex("[A-Z][A-Z][0-9][0-9][0-9][a-z]*"); // get any rows that contain a variable var refVars = from r in Questions.AsEnumerable() where r.PreP != null && rx1.IsMatch(r.PreP) select r; if (!refVars.Any()) { return; } foreach (var item in refVars) { QuestionFilter qf = new QuestionFilter(item.PreP); filterList = ""; for (int i = 0; i < qf.FilterVars.Count; i++) { filterVar = qf.FilterVars[i].Varname; var found = Questions.FirstOrDefault(x => x.VarName.RefVarName.Equals(filterVar)); if (found != null) { filterRO = found.RespOptions; filterNR = found.NRCodes; filterLabel = "<em>" + found.VarName.VarLabel + "</em>"; filterList += "<strong>" + filterVar.Substring(0, 2) + "." + filterVar.Substring(2) + "</strong>\r\n" + filterLabel + "\r\n" + filterRO + "\r\n" + filterNR + "\r\n"; } else { filterRO = ""; filterNR = ""; filterLabel = ""; filterList += "<strong>" + filterVar.Substring(0, 2) + "." + filterVar.Substring(2) + "</strong>\r\n"; } } item.Filters += filterList; } }
// TODO check for response codes mentioned in filter and only show those /// <summary> /// Sets the Filter property for each SurveyQuestion that has a PreP containing a VarName. /// </summary> private void PopulateOddFilters() { string filterList = ""; string filterVar = ""; string filterRO; string filterNR; string filterLabel; Regex rx1 = new Regex("[A-Z][A-Z][0-9][0-9][0-9]"); // get any rows that contain a variable var refVars = from r in Questions.AsEnumerable() where !string.IsNullOrEmpty(r.PreP) && !r.VarName.FullVarName.StartsWith("Z") select r; // get the variables that are not in standard form var oddVars = from r in Questions.AsEnumerable() where !rx1.IsMatch(r.VarName.RefVarName) select r; if (!refVars.Any()) { return; } foreach (var item in refVars) { QuestionFilter qf = new QuestionFilter(item.PreP, oddVars.ToList()); filterList = ""; if (qf.FilterVars == null) { continue; } for (int i = 0; i < qf.FilterVars.Count; i++) { filterVar = qf.FilterVars[i].Varname; var found = Questions.FirstOrDefault(x => x.VarName.RefVarName.Equals(filterVar)); if (found != null) { filterRO = found.RespOptions; filterNR = found.NRCodes; filterLabel = "<em>" + found.VarName.VarLabel + "</em>"; filterList += "<strong>" + filterVar.Substring(0, 2) + "." + filterVar.Substring(2) + "</strong>\r\n" + filterLabel + "\r\n" + filterRO + "\r\n" + filterNR + "\r\n"; } else { filterRO = ""; filterNR = ""; filterLabel = ""; filterList += "<strong>" + filterVar.Substring(0, 2) + "." + filterVar.Substring(2) + "</strong>\r\n"; } } item.Filters += filterList; } }