コード例 #1
0
        /// <summary>
        /// Load the patients survey history into the grid of follow up dates
        /// </summary>
        /// <param name="patientId"></param>
        private void LoadPatientData(int patientId)
        {
            string noRecordMsg = "This patient has not had a qualifying procedure and is not scheduled for one within Caisis. Follow up surveys therefore do not apply at this time.";

            // set page title
            Patient p = new Patient();

            p.Get(patientId);
            this.ResultsTitle.Text += p[Patient.PtFirstName].ToString() + " " + p[Patient.PtLastName].ToString();

            FollowUpDA da = new FollowUpDA();

            // retrieve procedure lookupcode values specified for Follow up module
            DataTable followupProcLkpcodes = CacheManager.GetLookupCodeList(FollowUpUtil.DEFAULT_PROCEDURE_LOOKUPCODE);
            string    followupProcList     = CreateDelimitedString(followupProcLkpcodes, LookupCode.LkpCode, ",");

            // retrive most recent Follow up related procedure for patient
            DataTable dtProc = da.GetPatientProcedureInfo(patientId, followupProcList);

            Status.Value = da.GetPatientContactStatus(patientId);

            if (dtProc.Rows.Count > 0)
            {
                DataTable dt = da.GetPatientSentSurveysList(patientId);

                ProcedureName.Value = dtProc.Rows[0][Procedure.ProcName].ToString();
                _redirectPath      += "&proc=" + ProcedureName.Value + "&processDate=" + DateTime.Now.ToShortDateString();

                string   dosString = dtProc.Rows[0][Procedure.ProcDate].ToString();
                DateTime dos       = DateTime.Parse(dosString);
                DOS.Value = dos.ToShortDateString();

                // Build DataSource to contain Dates
                int[]     months   = new int[] { 0, 1, 3, 6, 12, 18, 24, 30, 36, 48, 60 };
                DataTable myTable  = new DataTable();
                string[]  colNames = new string[] { "MonthName", "MonthNumber", "DueDate", "SentDate", "TimesSent", "CompletedDate", "CompletedSurveyId", "SurveyType", "UserSurveyType", "ActionId" };
                foreach (string colName in colNames)
                {
                    myTable.Columns.Add(new DataColumn(colName));
                }

                foreach (int month in months)
                {
                    DataRow newRow    = myTable.NewRow();
                    string  monthName = "Month" + " " + month.ToString();
                    if (month == 0)
                    {
                        monthName = "Pre Op";
                        DateTime dueDate = dos.AddDays(-14);
                        newRow["DueDate"] = dueDate.ToShortDateString();
                    }

                    newRow["MonthName"]   = monthName;
                    newRow["MonthNumber"] = month.ToString();

                    if (month > 0)
                    {
                        DateTime dueDate = dos.AddMonths(month);
                        newRow["DueDate"] = dueDate.ToShortDateString();
                    }

                    // Action Items are always in format:  'Survey Name X Month Sent' where X is the month number
                    string    expression = "ActionItem LIKE '% " + month.ToString() + " Month Sent'";
                    DataRow[] sentDates  = dt.Select(expression);

                    string actionItem = string.Empty;

                    // TODO: confirm that sent dates work
                    if (sentDates.Length > 0)
                    {
                        actionItem = (string)sentDates[sentDates.Length - 1][Caisis.BOL.Action.ActionItem];
                        string surveyName = FollowUpUtil.GetSurveyNameFromActionItem(actionItem);

                        // use the most recent Date
                        DateTime sentDate = (DateTime)sentDates[sentDates.Length - 1][Caisis.BOL.Action.ActionDate];
                        newRow["SentDate"] = sentDate.ToShortDateString();

                        // parse out the survey type from the "ActionItem" column
                        newRow["ActionId"]       = (int)sentDates[sentDates.Length - 1][Caisis.BOL.Action.ActionId];
                        newRow["SurveyType"]     = surveyName;
                        newRow["UserSurveyType"] = surveyName;
                    }

                    newRow["TimesSent"] = sentDates.Length.ToString();

                    // if survey was sent (action item exists), then see if survey data was already entered
                    if (!string.IsNullOrEmpty(actionItem))
                    {
                        // to see data has been entered for a survey we now look for a RELATED RECORD: Actions to Survey
                        DataTable completeSurveysDt = da.GetSurveyByActionItem(patientId, actionItem);

                        if (completeSurveysDt.Rows.Count > 0)
                        {
                            DateTime completedDate = (DateTime)completeSurveysDt.Rows[0][Survey.SurveyDate];
                            newRow["CompletedDate"]     = completedDate.ToShortDateString();
                            newRow["CompletedSurveyId"] = completeSurveysDt.Rows[0][Survey.SurveyId].ToString();
                        }
                    }

                    // Finally add new row to datasource
                    myTable.Rows.Add(newRow);
                }

                // Bind Rptr to DataSource
                MyRptr.DataSource = myTable;
                MyRptr.DataBind();
            }
            else
            {
                this.noResultsRow.Visible = true;
                this.noRecordsFound.Text  = noRecordMsg;
            }
        }