Пример #1
0
        void DisplayLatestSurveyResponses(DataTable surveys)
        {
            IDictionary <KeyValuePair <string, string>, string> map = SurveyDa.GetSurveyItemResponseMap(ActiveSurveillanceSurvey.ShortName);

            Func <string, string, string, string> getResponse =
                (text, num, result) =>
            {
                KeyValuePair <string, string> kvp =
                    new KeyValuePair <string, string>(text, result);

                KeyValuePair <string, string> numKVP =
                    new KeyValuePair <string, string>(num, result);

                if (map.ContainsKey(kvp))
                {
                    return(map[kvp]);
                }
                else if (map.ContainsKey(numKVP))
                {
                    return(map[numKVP]);
                }
                else
                {
                    return(result);
                }
            };

            DataView sv = surveys.DefaultView;

            sv.Sort = "SurveyDate DESC, SurveyId DESC";

            if (sv.Count == 0)
            {
                return;
            }

            int latestSurveyId = (int)sv[0]["SurveyId"];

            var ds =
                from row in surveys.AsEnumerable()
                let surveyId = (int)row["SurveyId"]
                               let itemNum                       = row["SurveyItemNum"].ToString()
                                                        let text = row["SurveyItem"].ToString()
                                                                   where surveyId == latestSurveyId &&
                                                                   !text.StartsWith("Total", StringComparison.CurrentCultureIgnoreCase) &&
                                                                   !text.StartsWith("Patient reported", StringComparison.CurrentCultureIgnoreCase)
                                                                   select new
            {
                QuestionNum    = itemNum,
                QuestionText   = text,
                QuestionResult = getResponse(text, itemNum, row["SurveyItemResult"].ToString())
            };

            SurveyResponsesRepeater.DataSource = ds;
            SurveyResponsesRepeater.DataBind();
        }
Пример #2
0
        // build a dynamic datasource for the survey response repeater
        void GetRecentSurveyReponses(DataTable surveys)
        {
            IDictionary <KeyValuePair <string, string>, string> map = SurveyDa.GetSurveyItemResponseMap(MSKProstateQOLSurvey.ShortName);

            Func <string, string, string, string> getResponse =
                (text, num, result) =>
            {
                KeyValuePair <string, string> kvp =
                    new KeyValuePair <string, string>(text, result);

                KeyValuePair <string, string> numKVP =
                    new KeyValuePair <string, string>(num, result);

                if (map.ContainsKey(kvp))
                {
                    return(map[kvp]);
                }
                else if (map.ContainsKey(numKVP))
                {
                    return(map[numKVP]);
                }
                else
                {
                    return(result);
                }
            };

            DataView sv = surveys.DefaultView;

            sv.Sort = "SurveyDate DESC, SurveyId DESC";
            int latestSurveyId = (int)sv[0]["SurveyId"];

            var ds =
                from row in surveys.AsEnumerable()
                let surveyId = (int)row["SurveyId"]
                               let itemNum                       = row["SurveyItemNum"].ToString()
                                                        let text = row["SurveyItem"].ToString()
                                                                   where surveyId == latestSurveyId &&
                                                                   !text.StartsWith("Total", StringComparison.CurrentCultureIgnoreCase) &&
                                                                   !text.StartsWith("Patient reported", StringComparison.CurrentCultureIgnoreCase)
                                                                   select new
            {
                QuestionNum    = itemNum,
                QuestionText   = text,
                QuestionResult = getResponse(text, itemNum, row["SurveyItemResult"].ToString())
            };

            SurveyResponsesRepeater.DataSource = ds;

            // handle injection questions
            var injections =
                from row in surveys.AsEnumerable()
                let surveyId = (int)row["SurveyId"]
                               let itemNum                       = row["SurveyItemNum"].ToString()
                                                        let text = row["SurveyItem"].ToString()
                                                                   where surveyId == latestSurveyId &&
                                                                   (text.Contains("use injections") || text.Contains("used injection"))
                                                                   select new
            {
                Num      = itemNum,
                Question = text,
                Response = row["SurveyItemResult"].ToString()
            };

            bool   hadInjection    = false;
            string injectionStatus = null;

            foreach (var i in injections)
            {
                if (i.Question.Contains("Do you use injections") && i.Response == "Yes")
                {
                    hadInjection = true;
                }
                else if (i.Question.Contains("used injection therapy"))
                {
                    int injectionResponse;
                    if (int.TryParse(i.Response, out injectionResponse))
                    {
                        injectionStatus = GetInjectionMessage(injectionResponse);
                    }
                    else
                    {
                        injectionStatus = MapInjectionMessage(i.Response);
                    }
                }
            }

            if (hadInjection)
            {
                CurrentInjectionStatus.Text = injectionStatus;
            }
        }