public List<Evaluation> getAdultCaseManagmentEvaluation()
        {
            evaluationList = new List<Evaluation>();
            var connectionString = ConfigurationManager.ConnectionStrings["CacheODBCCWS"].ConnectionString;
            var cmd = "Select Draft_PA_Final, Assessing_Date, EPISODE_NUMBER " +
                         "From SYSTEM.Adult_Case_Management_Assess " +
                         "Where PATID = ? AND EPISODE_NUMBER = ? AND (Draft_PA_Final='D')" +
                         "Order By CAST(STRING(convert(varchar(10),Assessing_Date,101),' ',Assessing_Time) as TIMESTAMP) DESC";
            try
            {
                using (var con = new OdbcConnection(connectionString))
                {
                    con.Open();

                    using (var dbCommand = new OdbcCommand(cmd, con))
                    {
                        dbCommand.CommandType = CommandType.Text;
                        dbCommand.Parameters.Add(new OdbcParameter("PATID", clientId));
                        dbCommand.Parameters.Add(new OdbcParameter("EPISODE_NUMBER", episode_number));

                        using (var reader = dbCommand.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                eval = new Evaluation();
                                eval.status_code = reader["Draft_PA_Final"].ToString();
                                eval.evalution_type = "AdultCaseManagementAssessment";
                                eval.prog_eval_purpose_code = "";
                                eval.evaluation_date = reader["Assessing_Date"].ToString();
                                eval.evaluation_errorMesg = inDraftMessage;
                                eval.EPISODE_NUMBER = reader["EPISODE_NUMBER"].ToString();
                                EvaluationList.Add(eval);
                            }
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                eval = new Evaluation();
                eval.status_code = "1";
                eval.evalution_type = "Error connecting to Database, please contact your IT Department";
            }
            return evaluationList;
        }
        public List<Evaluation> getLastMHOutcomesEvaluation()
        {
            evaluationList = new List<Evaluation>();
            var connectionString = ConfigurationManager.ConnectionStrings["CacheODBCCWS"].ConnectionString;
            var cmd = "Select TOP (1) mh_outcomes_status_code, purp_of_perf_eval_code, evaluation_date " +
                        "From CWSSF.florida_fsr_mh_outcomes " +
                        "Where PATID = ? " +
                        "Order By evaluation_date Desc, CAST(STRING(convert(varchar(10),data_entry_date,101),' ',data_entry_time) as TIMESTAMP) DESC";
            try
            {
                using (var con = new OdbcConnection(connectionString))
                {
                    con.Open();

                    using (var dbCommand = new OdbcCommand(cmd, con))
                    {
                        dbCommand.CommandType = CommandType.Text;
                        dbCommand.Parameters.Add(new OdbcParameter("PATID", clientId));

                        using (var reader = dbCommand.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                eval = new Evaluation();
                                eval.status_code = reader["mh_outcomes_status_code"].ToString();
                                eval.evalution_type = "Last MHOutcomes";
                                eval.prog_eval_purpose_code = reader["purp_of_perf_eval_code"].ToString();
                                eval.evaluation_date = reader["evaluation_date"].ToString();
                                eval.evaluation_errorMesg = missingLastDischOutcomeErrorMsg;
                                eval.EPISODE_NUMBER = "N/A";
                                EvaluationList.Add(eval);
                            }
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                eval = new Evaluation();
                eval.status_code = "1";
                eval.evalution_type = "Error connecting to Database, please contact your IT Department";
            }
            return evaluationList;
        }
        public List<Evaluation> getLastASAMEvaluation()
        {
            evaluationList = new List<Evaluation>();
            var connectionString = ConfigurationManager.ConnectionStrings["CacheODBCCWS"].ConnectionString;
            var cmd = "Select Top (1) asam_status_code, purpose_code, asam_creation_date " +
                         "From CWSSF.florida_fsr_asam " +
                         "Where PATID = ? " +
                         "Order By asam_creation_date DESC";
            try
            {
                using (var con = new OdbcConnection(connectionString))
                {
                    con.Open();

                    using (var dbCommand = new OdbcCommand(cmd, con))
                    {
                        dbCommand.CommandType = CommandType.Text;
                        dbCommand.Parameters.Add(new OdbcParameter("PATID", clientId));

                        using (var reader = dbCommand.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                eval = new Evaluation();
                                eval.status_code = reader["asam_status_code"].ToString();
                                eval.evalution_type = "Last ASAM";
                                eval.prog_eval_purpose_code = reader["purpose_code"].ToString();
                                eval.evaluation_date = reader["asam_creation_date"].ToString();
                                eval.evaluation_errorMesg = missingLastDischOutcomeErrorMsg;
                                eval.EPISODE_NUMBER = "N/A";
                                EvaluationList.Add(eval);
                            }
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                eval = new Evaluation();
                eval.status_code = "1";
                eval.evalution_type = "Error connecting to Database, please contact your IT Department";
            }
            return evaluationList;
        }
        public List<Evaluation> getFarsEvaluation()
        {
            evaluationList = new List<Evaluation>();
            var connectionString = ConfigurationManager.ConnectionStrings["CacheODBCCWS"].ConnectionString;
            var cmd = "Select fars_status_code, dcf_evaluation_code, evaluation_date " +
                           "From CWSSF.florida_fsr_fars cfars " +
                           "Where PATID = ? AND (fars_status_code = '1' OR (dcf_evaluation_code ='3' OR dcf_evaluation_code='4'))" +
                           "Order By evaluation_date Desc, CAST(STRING(convert(varchar(10),data_entry_date,101),' ',data_entry_time) as TIMESTAMP) DESC";
            try
            {
                using (var con = new OdbcConnection(connectionString))
                {
                    con.Open();

                    using (var dbCommand = new OdbcCommand(cmd, con))
                    {
                        dbCommand.CommandType = CommandType.Text;
                        dbCommand.Parameters.Add(new OdbcParameter("PATID", clientId));

                        using (var reader = dbCommand.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                eval = new Evaluation();
                                eval.status_code = reader["fars_status_code"].ToString();
                                eval.evalution_type = "FARS";
                                eval.prog_eval_purpose_code = reader["dcf_evaluation_code"].ToString();
                                eval.evaluation_date = reader["evaluation_date"].ToString();
                                eval.evaluation_errorMesg = inDraftMessage;
                                eval.EPISODE_NUMBER = "N/A";
                                EvaluationList.Add(eval);
                            }
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                eval = new Evaluation();
                eval.status_code = "1";
                eval.evalution_type = "Error connecting to Database, please contact your IT Department";
            }
            return evaluationList;
        }
        public int getClientOpenOutPatientEpisodes()
        {
            int countOutPatientOpenEp = 0;

            var cmd = "Select count(episode_number) AS open_episodes " +
                        "From episode_history " +
                        "Where PATID = ? and date_of_discharge IS NULL " +
                        "AND program_code NOT IN " + inpatientCodes;
            try
            {
                using (OdbcConnection con = new OdbcConnection(connectionStringPM))
                {
                    con.Open();
                    using (var dbCommand = new OdbcCommand(cmd, con))
                    {
                        dbCommand.Parameters.Add(new OdbcParameter("PATID", clientId));
                        using (var reader = dbCommand.ExecuteReader())
                        {
                            if (reader.Read())
                            {
                                countOutPatientOpenEp = Convert.ToInt32(reader["open_episodes"]);
                            }
                        }
                    }
                }

            }
            catch (Exception exc)
            {
                eval = new Evaluation();
                eval.status_code = "1";
                eval.evalution_type = "Error connecting to Database, please contact your IT Department";
            }
            return countOutPatientOpenEp;
        }