/// <summary>
        /// Returns true if survey was receieved. False otherwise.
        /// ActionItem is of form "NAME x Month Sent", where x is month number and NAME is from SurveyKey
        /// </summary>
        /// <param name="surveyName"></param>
        /// <param name="month"></param>
        /// <param name="patientId"></param>
        /// <returns></returns>
        private bool SurveyAlreadyReceived(string surveyName, int month, int patientId)
        {
            // retrieve action tiem
            string actionItem = FollowUpUtil.GetSurveyActionItem(surveyName, month.ToString());

            if (!String.IsNullOrEmpty(actionItem))
            {
                FollowUpDA da = new FollowUpDA();

                // if nothing returned, survey data has not been entered, therefore survey has not been received
                DataTable dt = da.GetSurveyByActionItem(patientId, actionItem);

                if (dt.Rows.Count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// Returns the date of the last survey sent that matches the ActionItem for this patient.
        /// ActionItem is of form "NAME x Month Sent"
        /// </summary>
        /// <param name="surveyShortType">Either "QOL" or "EPIC"</param>
        /// <param name="month"></param>
        /// <returns></returns>
        private DataTable GetThisLastSurveySentRecord(string surveyName, int month, int patientId)
        {
            string actionName = FollowUpUtil.GetSurveyActionItem(surveyName, month.ToString());

            FollowUpDA da = new FollowUpDA();
            DataTable  dt = da.GetThisLastSurveySent(patientId, actionName);

            return(dt);
        }
        /// <summary>
        /// Returns true if survey was already sent. False otherwise.
        /// ActionItem is of form "NAME x Month Survey Sent", where x is month number and NAME is from SurveyKey
        /// </summary>
        /// <param name="surveyName"></param>
        /// <param name="month"></param>
        /// <returns></returns>
        private bool SurveyAlreadySent(string surveyName, int month, int patientId)
        {
            // 1. check Action to see if Action exists for this survey/month
            string actionName = FollowUpUtil.GetSurveyActionItem(surveyName, month.ToString());

            FollowUpDA da = new FollowUpDA();

            return(da.SurveyAlreadySent(patientId, actionName));
        }
Beispiel #4
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                // Default Dates
                StartDateField.Value = DateTime.Today.Subtract(TimeSpan.FromDays(31)).ToShortDateString();
                EndDateField.Value   = DateTime.Today.ToShortDateString();

                FollowUpUtil.PopulateSurveyDropDown(ddlSurveyType);
            }
        }
Beispiel #5
0
 /// <summary>
 /// Get action item to log for surveys or letters.
 /// </summary>
 /// <param name="formLongName">Names of surveys/letter</param>
 /// <param name="month">month survey due</param>
 /// <param name="isSurvey">true/false</param>
 /// <returns>the action item</returns>
 public static string GetActionItemToLog(int patientId, string month, string formLongName, bool isSurvey)
 {
     if (isSurvey)
     {
         return(FollowUpUtil.GetSurveyActionItem(formLongName, month));
     }
     else // a follow up letter
     {
         return(GetLetterActionItem(formLongName, month, patientId));
     }
 }
        private bool PassesSurveyReceivedRule(int[,] surveyMonths, int i, string patientId, string selectedSurvey)
        {
            bool passesRule = true;

            // get name for Pre TX Survey
            int    month      = 0;
            string surveyName = FollowUpUtil.GetSurveyFullName(month, selectedSurvey);

            // if patient has already answered a Pre TX Survey
            if (SurveyAlreadyReceived(surveyName, month, Int32.Parse(patientId)))
            {
                int index = i;

                // ensure we are at, at least, the fourth survey (month 12) to be sent
                if (index > 2)
                {
                    int numOfSurveysMissed = 0;

                    // check if the last 3 surveys were all sent, but not received
                    for (int j = 1; j <= 3; j++)
                    {
                        index--;
                        month      = surveyMonths[index, 0];
                        surveyName = FollowUpUtil.GetSurveyFullName(month, selectedSurvey);

                        if (SurveyAlreadySent(surveyName, month, Int32.Parse(patientId)) && !SurveyAlreadyReceived(surveyName, month, Int32.Parse(patientId)))
                        {
                            numOfSurveysMissed++;
                        }
                        else
                        {
                            break;
                        }
                    }

                    // if last 3 surveys were all sent, but none received, DO NOT send current survey
                    if (numOfSurveysMissed == 3)
                    {
                        passesRule = false;
                    }
                }
            }
            // if patient has NOT answered a Pre TX Survey
            else
            {
                // send no other surveys
                passesRule = false;
            }
            return(passesRule);
        }
        protected override void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int ptId = -1;
                if (Request.QueryString["usePtInSession"] != null && Request.QueryString["usePtInSession"].Equals("true"))
                {
                    SessionHandler sh = new SessionHandler(Session);
                    ptId = sh.GetPatientId();
                }
                else if (Request.QueryString["ptId"] != null && Request.QueryString["ptId"].Length > 0)
                {
                    ptId = int.Parse(Request.QueryString["ptId"]);
                    // Place patient in session
                    PatientController ptController = new PatientController();
                    ptController.PutPatientInSession(Page, ptId);
                }

                FollowUpUtil.PopulateSurveyDropDown(SurveyDD);
                LoadPatientData(ptId);
            }
        }
Beispiel #8
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private DataView GetReport()
        {
            DateTime startDate = !string.IsNullOrEmpty(StartDateField.Value) ? DateTime.Parse(StartDateField.Value) : DateTime.Today;
            DateTime endDate   = !string.IsNullOrEmpty(EndDateField.Value) ? DateTime.Parse(EndDateField.Value) : DateTime.Today;

            string surveyType = ddlSurveyType.SelectedValue + "%";

            FollowUpDA da = new FollowUpDA();
            DataTable  dt = da.GetCompletedSurveysByType(startDate.ToShortDateString(), endDate.ToShortDateString(), surveyType);

            DataTable myTable = new DataTable();

            string[] colNames = new string[] { "MRN", "Patient Name", "SurveyId", "Survey", "Month", "Sent Date", "Received Date" };
            foreach (string colName in colNames)
            {
                myTable.Columns.Add(new DataColumn(colName));
            }

            // get the names of the scoring sections for the column names from the first survey returned
            if (dt.Rows.Count > 0)
            {
                int       surveyId = (int)dt.Rows[0][Survey.SurveyId];
                DataTable scoreDt1 = SurveyScoringUtil.FillScores(surveyId);

                foreach (DataRow dr1 in scoreDt1.Rows)
                {
                    myTable.Columns.Add(new DataColumn(dr1["Section"].ToString()));
                }
            }



            foreach (DataRow dr in dt.Rows)
            {
                DataRow newRow   = myTable.NewRow();
                string  ptName   = dr[Patient.PtFirstName].ToString() + " " + dr[Patient.PtMiddleName].ToString() + " " + dr[Patient.PtLastName].ToString();
                int     surveyId = int.Parse(dr[Survey.SurveyId].ToString());

                // get table with scores
                DataTable scoreDt2 = new DataTable();
                scoreDt2 = SurveyScoringUtil.FillScores(surveyId);

                newRow["MRN"]          = dr[Patient.PtMRN].ToString();
                newRow["Patient Name"] = ptName;
                newRow["SurveyId"]     = dr[Survey.SurveyId].ToString();
                newRow["Survey"]       = dr[Survey.SurveyType].ToString();

                string actionItemStr = dr[Caisis.BOL.Action.ActionItem].ToString();
                string surveyMonth   = FollowUpUtil.GetSurveyMonthNoFromActionItem(actionItemStr);
                newRow["Month"] = surveyMonth;

                newRow["Sent Date"]     = DateTime.Parse(dr[Caisis.BOL.Action.ActionDate].ToString()).ToShortDateString();
                newRow["Received Date"] = DateTime.Parse(dr[Survey.SurveyDate].ToString()).ToShortDateString();

                // translate the scores that are in rows to columns in this patients record
                for (int i = 0; i < scoreDt2.Rows.Count; i++)
                {
                    int columnIndex = i + 7;
                    newRow[columnIndex] = scoreDt2.Rows[i]["AverageStandardized"].ToString();
                }

                myTable.Rows.Add(newRow);
            }

            return(myTable.DefaultView);
        }
Beispiel #9
0
        protected void LogPrintJob(object sender, ImageClickEventArgs e)
        {
            if (!bool.Parse(_isSurvey))
            {
                URLHolder.Value = URLHolder.Value + "&isSurvey=false";
            }
            else
            {
                URLHolder.Value = URLHolder.Value + "&isSurvey=true";
            }

            DateTime processDate;

            if (!String.IsNullOrEmpty(_processDate))
            {
                processDate = DateTime.Parse(_processDate);
            }
            else
            {
                processDate = DateTime.Now;
            }

            // need to parse query string and log actions ("PrintForms.aspx?batchPrint=true&8113=EVUQOLPostEarlyTx&7523=EVUQOLPostEarlyTx")
            string printFrameUrl = URLHolder.Value;

            int index;

            if (printFrameUrl.Contains("&isSurvey=false"))
            {
                _isSurvey     = "false";
                index         = printFrameUrl.IndexOf("&isSurvey=false");
                printFrameUrl = printFrameUrl.Remove(index);
            }
            else if (printFrameUrl.Contains("&isSurvey=true"))
            {
                _isSurvey     = "true";
                index         = printFrameUrl.IndexOf("&isSurvey=true");
                printFrameUrl = printFrameUrl.Remove(index);
            }

            if (printFrameUrl.Contains("&processDate="))
            {
                index         = printFrameUrl.IndexOf("&processDate=");
                printFrameUrl = printFrameUrl.Remove(index);
            }

            printFrameUrl = printFrameUrl.Remove(0, 1);//remove the first &
            string[] surveyArray = printFrameUrl.Split('&');

            foreach (string s in surveyArray)
            {
                // parse p to get patient id and survey name
                string[] patientArray       = s.Split('=');
                string   patientId          = patientArray[0];
                string[] surveyNameAndMonth = patientArray[1].Split('_'); //split the month and survey name
                string   surveyName         = surveyNameAndMonth[1];
                string   month = surveyNameAndMonth[0];

                //  Save Action Item
                Caisis.BOL.Action a = new Caisis.BOL.Action();
                a[Caisis.BOL.Action.ActionDate]     = processDate;
                a[Caisis.BOL.Action.ActionDateText] = processDate.ToShortDateString();
                a[Caisis.BOL.Action.ActionItem]     = FollowUpUtil.GetActionItemToLog(int.Parse(patientId), month, surveyName, bool.Parse(_isSurvey));
                a[Caisis.BOL.Action.PatientId]      = patientId;

                if (!string.IsNullOrEmpty(a[Caisis.BOL.Action.ActionItem].ToString()))
                {
                    a.Save();
                }
            }
        }
Beispiel #10
0
        /// <summary>
        /// Gets a report of surveys OR letters sent by date range
        /// </summary>
        /// <param name="physicianName"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        private DataView GetReportsDataView()
        {
            DateTime startDate = !string.IsNullOrEmpty(StartDateField.Value) ? DateTime.Parse(StartDateField.Value) : DateTime.Today;
            DateTime endDate   = !string.IsNullOrEmpty(EndDateField.Value) ? DateTime.Parse(EndDateField.Value) : DateTime.Today;
            string   procType  = this.ProcedureType.SelectedValue;

            string actionItem;

            if (this.GetFormType() == "Survey")
            {
                actionItem = "%" + this.GetFormType() + "% Month Sent";
            }
            else
            {
                actionItem = "%Month " + this.GetFormType() + " Sent";
            }

            FollowUpDA da = new FollowUpDA();
            DataTable  followUpReportTable = da.GetFollowUpReportList(procType, startDate.ToShortDateString(), endDate.ToShortDateString(), actionItem);

            // now we need to create a new datatable so we can loop and add the column for Completed Date
            DataTable myTable = new DataTable();

            string[] colNames = new string[] { "PatientId", "Patient", "Survey", "Month", "Treating Physician", "Sent Date", "Received Date" };
            foreach (string colName in colNames)
            {
                myTable.Columns.Add(new DataColumn(colName));
            }

            foreach (DataRow dr in followUpReportTable.Rows)
            {
                DataRow newRow = myTable.NewRow();
                string  ptName = dr[Patient.PtFirstName].ToString() + " " + dr[Patient.PtMiddleName].ToString() + " " + dr[Patient.PtLastName].ToString();
                newRow["PatientId"] = dr[Patient.PatientId].ToString();
                newRow["Patient"]   = ptName;

                newRow["Treating Physician"] = da.GetMostRecentTreatingPhysician(int.Parse(dr[Patient.PatientId].ToString()));

                string actionItemStr = dr[Caisis.BOL.Action.ActionItem].ToString();
                string actionId      = dr[Caisis.BOL.Action.ActionId].ToString();

                string fuMonth = FollowUpUtil.GetSurveyMonthNoFromActionItem(actionItemStr);
                newRow["Month"] = fuMonth;

                string formName = FollowUpUtil.GetSurveyNameFromActionItem(actionItemStr);

                if (this.GetFormType() == "Letter")
                {
                    formName += " " + "Follow Up Letter";
                }

                newRow["Survey"]    = formName;
                newRow["Sent Date"] = DateTime.Parse(dr[Caisis.BOL.Action.ActionDate].ToString()).ToShortDateString();

                // Add Survey completed date, if it exists (we check the Surveys table)
                string completedDate = string.Empty;

                //DataTable dtRec = da.GetSurveyReceived(Int32.Parse(dr[Patient.PatientId].ToString()), actionItemExpr);

                DataTable dtRec = da.GetSurveyByActionItem(Int32.Parse(dr[Patient.PatientId].ToString()), actionItemStr);

                if (dtRec.Rows.Count > 0 && !string.IsNullOrEmpty(dtRec.Rows[0][Survey.SurveyDate].ToString()))
                {
                    completedDate = DateTime.Parse(dtRec.Rows[0][Survey.SurveyDate].ToString()).ToShortDateString();
                }
                else
                {
                    completedDate = "--";
                }

                newRow["Received Date"] = completedDate;

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

            return(myTable.DefaultView);
        }
Beispiel #11
0
        private DataTable SetFollowUpLetterList()
        {
            // need to validate string is actual date
            DateTime processDate = Convert.ToDateTime(ProcessDate.Text);

            // procedure can be entered from UI too
            string procedureType = ProcedureType.Text;

            _redirectPath += "&proc=" + procedureType + "&processDate=" + processDate.ToShortDateString();

            FollowUpDA da = new FollowUpDA();
            DataTable  lastSurveyPatientsDt = new DataTable();

            lastSurveyPatientsDt = da.GetPatientsLastSurveySentList(procedureType, FollowUpUtil.GetSurveyShortName(ddlSurveyType.SelectedValue));

            DataTable  fuLetterPatientsDt = new DataTable();
            DataColumn dc0  = new DataColumn("PatientId");
            DataColumn dc1  = new DataColumn("PtName");
            DataColumn dc2  = new DataColumn("PtMRN");
            DataColumn dc3  = new DataColumn("Surgeon");
            DataColumn dc4  = new DataColumn("FUMonth");
            DataColumn dc5  = new DataColumn("SurveyName");
            DataColumn dc6  = new DataColumn("SentDate");
            DataColumn dc7  = new DataColumn("Address1");
            DataColumn dc8  = new DataColumn("Address2");
            DataColumn dc9  = new DataColumn("City");
            DataColumn dc10 = new DataColumn("State");
            DataColumn dc11 = new DataColumn("Zip");
            DataColumn dc12 = new DataColumn("LastName");
            DataColumn dc13 = new DataColumn("FirstName");

            fuLetterPatientsDt.Columns.Add(dc12);
            fuLetterPatientsDt.Columns.Add(dc13);
            fuLetterPatientsDt.Columns.Add(dc0);
            fuLetterPatientsDt.Columns.Add(dc1);
            fuLetterPatientsDt.Columns.Add(dc2);
            fuLetterPatientsDt.Columns.Add(dc3);
            fuLetterPatientsDt.Columns.Add(dc4);
            fuLetterPatientsDt.Columns.Add(dc5);
            fuLetterPatientsDt.Columns.Add(dc6);
            fuLetterPatientsDt.Columns.Add(dc7);
            fuLetterPatientsDt.Columns.Add(dc8);
            fuLetterPatientsDt.Columns.Add(dc9);
            fuLetterPatientsDt.Columns.Add(dc10);
            fuLetterPatientsDt.Columns.Add(dc11);

            // HERE: remove patients who have completed the survey within 20 days after it was sent to them
            foreach (DataRow dr in lastSurveyPatientsDt.Rows)
            {
                int      pId            = Int32.Parse(dr[Patient.PatientId].ToString());
                DateTime surveySentDate = Convert.ToDateTime(dr[Caisis.BOL.Action.ActionDate].ToString());

                // we have the surveySent actionItem is "NAME x Month Sent"
                string surveySentActionItem = dr[Caisis.BOL.Action.ActionItem].ToString();

                string surveyType = FollowUpUtil.GetSurveyNameFromActionItem(surveySentActionItem);
                string month      = FollowUpUtil.GetSurveyMonthNoFromActionItem(surveySentActionItem);

                // and want to get the equivalent letterSent ActionItem: for now it is "NAME x Month Letter Sent"
                string letterSentActionItem = FollowUpUtil.GetActionItemToLog(pId, month, surveyType, false);

                if (processDate > surveySentDate.AddDays(20)) //expected to receive survey within 20 days of processdate
                {
                    // if expected survey was not received, send letter to patient only if not already sent before
                    if (da.GetSurveyByActionItem(pId, surveySentActionItem).Rows.Count == 0 && da.LetterAlreadySent(pId, letterSentActionItem) == false)
                    {
                        // get the (full) survey name to display in the list of results
                        string selectedSurvey = ddlSurveyType.SelectedValue;
                        string surveyFullName = FollowUpUtil.GetSurveyFullName(int.Parse(month), selectedSurvey);

                        // patient is due for a follow up letter
                        DataRow fuRow = fuLetterPatientsDt.NewRow();
                        fuRow["PatientId"]  = pId.ToString();
                        fuRow["LastName"]   = dr[Patient.PtLastName].ToString();
                        fuRow["FirstName"]  = dr[Patient.PtFirstName].ToString();
                        fuRow["PtName"]     = dr[Patient.PtLastName].ToString() + ", " + dr[Patient.PtFirstName].ToString();
                        fuRow["PtMRN"]      = dr[Patient.PtMRN].ToString();
                        fuRow["Surgeon"]    = da.GetMostRecentTreatingPhysician(pId);
                        fuRow["FUMonth"]    = month.ToString();
                        fuRow["SurveyName"] = surveyFullName;

                        DateTime dt;
                        dt = Convert.ToDateTime(dr[Caisis.BOL.Action.ActionDate].ToString());
                        fuRow["SentDate"] = dt.ToShortDateString(); //last survey sent date
                        //fuRow["SentDate"] = dr[Caisis.BOL.Action.ActionDate].ToString(); //last survey sent date

                        if (string.IsNullOrEmpty(letterSentActionItem))
                        {
                            fuRow["SurveyName"] = fuRow["SurveyName"].ToString() + "<BR>Invalid Action Name";
                        }

                        // retrieve additional patient data
                        if (!String.IsNullOrEmpty(dr[Patient.PtMRN].ToString()))
                        {
                            PatientDa ptDa     = new PatientDa();
                            DataTable ptInfoDt = ptDa.GetPatientByMRN(dr[Patient.PtMRN].ToString());
                            if (ptInfoDt.Rows.Count > 0)
                            {
                                fuRow["Address1"] = ptInfoDt.Rows[0][Patient.PtAddress1].ToString();
                                fuRow["Address2"] = ptInfoDt.Rows[0][Patient.PtAddress2].ToString();
                                fuRow["City"]     = ptInfoDt.Rows[0][Patient.PtCity].ToString();
                                fuRow["State"]    = ptInfoDt.Rows[0][Patient.PtState].ToString();
                                fuRow["Zip"]      = ptInfoDt.Rows[0][Patient.PtPostalCode].ToString();
                            }
                        }

                        fuLetterPatientsDt.Rows.Add(fuRow);

                        // NOTE: all patients get the same follow up letter, but this could change?
                        _redirectPath += "&" + dr[Patient.PatientId].ToString() + "=" + month + "_Follow Up Letter";
                    }
                }

                CreateBatchButton.Attributes.Add("onclick", "window.location.href='" + _redirectPath + "'");
            }

            return(fuLetterPatientsDt);
        }
        /// <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;
            }
        }
Beispiel #13
0
        private DataTable SetFollowUpList()
        {
            // get user input
            DateTime processDate    = Convert.ToDateTime(ProcessDate.Text);
            string   selectedSurvey = ddlSurveyType.SelectedValue;
            string   procedureType  = ddlProcedure.Text;

            _redirectPath += "&proc=" + procedureType + "&processDate=" + processDate.ToShortDateString();


            FollowUpDA da             = new FollowUpDA();
            DataTable  surgPatientsDt = new DataTable();

            // return all patients with PtContactStatus as selected
            surgPatientsDt = da.GetActivePatientsForQOLFollowUp(processDate.ToShortDateString(), procedureType, selectedSurvey);

            DataTable  fuPatientsDt = new DataTable();
            DataColumn dc0          = new DataColumn("PatientId");
            DataColumn dc1          = new DataColumn("PtName");
            DataColumn dc2          = new DataColumn("PtMRN");
            DataColumn dc3          = new DataColumn("DueDate");
            DataColumn dc4          = new DataColumn("FUMonth");
            DataColumn dc5          = new DataColumn("ProcName");
            DataColumn dc6          = new DataColumn("ProcDate");
            DataColumn dc7          = new DataColumn("Surgeon");
            DataColumn dc8          = new DataColumn("SurveyName");
            DataColumn dc9          = new DataColumn("Address1");
            DataColumn dc10         = new DataColumn("Address2");
            DataColumn dc11         = new DataColumn("City");
            DataColumn dc12         = new DataColumn("State");
            DataColumn dc13         = new DataColumn("Zip");
            DataColumn dc14         = new DataColumn("LastName");
            DataColumn dc15         = new DataColumn("FirstName");

            fuPatientsDt.Columns.Add(dc14);
            fuPatientsDt.Columns.Add(dc15);
            fuPatientsDt.Columns.Add(dc0);
            fuPatientsDt.Columns.Add(dc1);
            fuPatientsDt.Columns.Add(dc2);
            fuPatientsDt.Columns.Add(dc3);
            fuPatientsDt.Columns.Add(dc4);
            fuPatientsDt.Columns.Add(dc5);
            fuPatientsDt.Columns.Add(dc6);
            fuPatientsDt.Columns.Add(dc7);
            fuPatientsDt.Columns.Add(dc8);
            fuPatientsDt.Columns.Add(dc9);
            fuPatientsDt.Columns.Add(dc10);
            fuPatientsDt.Columns.Add(dc11);
            fuPatientsDt.Columns.Add(dc12);
            fuPatientsDt.Columns.Add(dc13);

            // remove patients who don't belong;
            foreach (DataRow dr in surgPatientsDt.Rows)
            {
                DateTime surgDate = (DateTime)dr[Procedure.ProcDate];

                int  daysPriorToDueDate = -15;
                int  daysAfterDueDate;
                int  month, previousMonth;
                bool breakLoop = false;

                // TODO: HANDLE PRE_TREATMENT SURVEY
                //-- processingdate < scheduledSurgeryDate
                //-- AND PreOP has not been sent before
                //-- AND processDate is no earlier than 30 days before due date
                //-- AND IF it was sent before, make sure it was not 14 days or less ago
                //-- THEN Send PreOp

                if (processDate < surgDate) //means PRE-OP
                {
                    DateTime dueDate         = surgDate.AddDays(-14);
                    string   surveyShortType = FollowUpUtil.GetSurveyFullName(-1, ddlSurveyType.SelectedValue); //month is -1 since pre-op
                    int      pId             = Int32.Parse(dr[Patient.PatientId].ToString());


                    DataTable dt = GetThisLastSurveySentRecord(surveyShortType, 0, pId);

                    //1. survey has not been sent before and processdate is no earlier than 30 days before duedate
                    //2. survey was sent before, we will send again if it was sent out more than 14 days ago and has not been received yet

                    if ((SurveyAlreadySent(surveyShortType, 0, pId) == false && processDate > dueDate.AddDays(-30)) ||
                        (dt.Rows.Count > 0 && da.GetSurveyByActionItem(pId, dt.Rows[0][Caisis.BOL.Action.ActionItem].ToString()).Rows.Count == 0 && DateTime.Parse(dt.Rows[0][Caisis.BOL.Action.ActionDate].ToString()) < processDate.AddDays(-14)))
                    {
                        string surveyName = FollowUpUtil.GetSurveyFullName(0, surveyShortType);

                        DataRow fuRow = fuPatientsDt.NewRow();
                        fuRow["PatientId"]  = pId.ToString();
                        fuRow["LastName"]   = dr[Patient.PtLastName].ToString();
                        fuRow["FirstName"]  = dr[Patient.PtFirstName].ToString();
                        fuRow["PtName"]     = dr[Patient.PtLastName].ToString() + ", " + dr[Patient.PtFirstName].ToString();
                        fuRow["PtMRN"]      = dr[Patient.PtMRN].ToString();
                        fuRow["DueDate"]    = dueDate.ToShortDateString();
                        fuRow["FUMonth"]    = "Pre-Op";
                        fuRow["ProcName"]   = dr[Procedure.ProcName].ToString();
                        fuRow["ProcDate"]   = surgDate.ToShortDateString();
                        fuRow["Surgeon"]    = da.GetMostRecentTreatingPhysician(pId);
                        fuRow["SurveyName"] = surveyName;

                        // retrieve additional patient data
                        if (!String.IsNullOrEmpty(dr[Patient.PtMRN].ToString()))
                        {
                            PatientDa ptDa     = new PatientDa();
                            DataTable ptInfoDt = ptDa.GetPatientByMRN(dr[Patient.PtMRN].ToString());
                            if (ptInfoDt.Rows.Count > 0)
                            {
                                fuRow["Address1"] = ptInfoDt.Rows[0][Patient.PtAddress1].ToString();
                                fuRow["Address2"] = ptInfoDt.Rows[0][Patient.PtAddress2].ToString();
                                fuRow["City"]     = ptInfoDt.Rows[0][Patient.PtCity].ToString();
                                fuRow["State"]    = ptInfoDt.Rows[0][Patient.PtState].ToString();
                                fuRow["Zip"]      = ptInfoDt.Rows[0][Patient.PtPostalCode].ToString();
                            }
                        }

                        fuPatientsDt.Rows.Add(fuRow);

                        // 0 used for PreTx surveys
                        // _redirectPath += "&" + dr[Patient.PatientId].ToString() + "=0_" + surveyName.Replace(" ", "");
                        _redirectPath += "&" + dr[Patient.PatientId].ToString() + "=0_" + surveyName;
                    }
                }

                // rules for distribution: 1 dimension contains send month; 2 dimension contains number of days before due date in which survey should be received
                //int[,] surveyMonths = { { 1, 21 }, { 3, 30 }, { 6, 45 }, { 12, 60 }, { 18, 75 }, { 24, 75 }, { 30, 75 }, { 36, 75 }, { 48, 75 }, { 60, 75 } };

                // rules for new distribution: 1 dimension contains send month; 2 dimension contains number of days before due date in which survey should be received
                int[,] surveyMonths = { { 1, 21 }, { 3, 21 }, { 6, 21 }, { 12, 21 }, { 18, 30 }, { 24, 30 }, { 30, 30 }, { 36, 30 }, { 48, 30 }, { 60, 30 } };

                for (int i = 0; i < 10; i++)
                {
                    // retrieve send month
                    month = surveyMonths[i, 0];

                    daysAfterDueDate = surveyMonths[i, 1];
                    DateTime dueDate = surgDate.AddMonths(month);

                    if (dueDate >= processDate.AddDays(daysPriorToDueDate) && dueDate <= processDate.AddDays(daysAfterDueDate))
                    {
                        breakLoop = true;

                        string currentSurveyDueName = FollowUpUtil.GetSurveyFullName(month, selectedSurvey);
                        //string previousSurveyName = FollowUpUtil.GetSurveyFullName(previousMonth, selectedSurvey);

                        // if 1) current survey was not already sent AND 2) At least 1 of the previous 3 surveys have been sent AND received
                        if (!SurveyAlreadySent(currentSurveyDueName, month, Int32.Parse(dr[Patient.PatientId].ToString())) &&
                            PassesSurveyReceivedRule(surveyMonths, i, dr[Patient.PatientId].ToString(), selectedSurvey))
                        {
                            // patient is due for a month survey
                            DataRow fuRow = fuPatientsDt.NewRow();
                            string  pId   = dr[Patient.PatientId].ToString();
                            fuRow["PatientId"]  = pId;
                            fuRow["LastName"]   = dr[Patient.PtLastName].ToString();
                            fuRow["FirstName"]  = dr[Patient.PtFirstName].ToString();
                            fuRow["PtName"]     = dr[Patient.PtLastName].ToString() + ", " + dr[Patient.PtFirstName].ToString();
                            fuRow["PtMRN"]      = dr[Patient.PtMRN].ToString();
                            fuRow["DueDate"]    = dueDate.ToShortDateString();
                            fuRow["FUMonth"]    = month.ToString();
                            fuRow["ProcName"]   = dr[Procedure.ProcName].ToString();
                            fuRow["ProcDate"]   = surgDate.ToShortDateString();
                            fuRow["Surgeon"]    = da.GetMostRecentTreatingPhysician(Int32.Parse(pId));
                            fuRow["SurveyName"] = currentSurveyDueName;

                            // retrieve additional patient data
                            if (!String.IsNullOrEmpty(dr[Patient.PtMRN].ToString()))
                            {
                                PatientDa ptDa     = new PatientDa();
                                DataTable ptInfoDt = ptDa.GetPatientByMRN(dr[Patient.PtMRN].ToString());
                                if (ptInfoDt.Rows.Count > 0)
                                {
                                    fuRow["Address1"] = ptInfoDt.Rows[0][Patient.PtAddress1].ToString();
                                    fuRow["Address2"] = ptInfoDt.Rows[0][Patient.PtAddress2].ToString();
                                    fuRow["City"]     = ptInfoDt.Rows[0][Patient.PtCity].ToString();
                                    fuRow["State"]    = ptInfoDt.Rows[0][Patient.PtState].ToString();
                                    fuRow["Zip"]      = ptInfoDt.Rows[0][Patient.PtPostalCode].ToString();
                                }
                            }

                            fuPatientsDt.Rows.Add(fuRow);

                            _redirectPath += "&" + dr[Patient.PatientId].ToString() + "=" + month + "_" + currentSurveyDueName;
                        }
                    }

                    if (breakLoop)
                    {
                        break;
                    }
                }
            }

            CreateBatchButton.Attributes.Add("onclick", "window.location.href='" + _redirectPath + "'");

            return(fuPatientsDt);
        }