public static List<YellowstonePathology.Business.Test.PanelSetOrderView> GetNextCasesToPublish()
        {
            #if MONGO
            return AccessionOrderGatewayMongo.GetNextCasesToPublish();
            #else
            List<YellowstonePathology.Business.Test.PanelSetOrderView> result = new List<Test.PanelSetOrderView>();
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "Select * from tblPanelSetOrder pso where pso.Final = 1 and pso.finalTime < dateAdd(mi, -15, getdate()) and pso.ScheduledPublishTime <= getdate() union " +
                "Select pso.* from tblPanelSetOrder pso join tblTestOrderReportDistribution trd on pso.ReportNo = trd.ReportNo " +
                "where pso.Final = 1 and pso.finalTime < dateAdd(mi, -15, getdate()) and trd.ScheduledDistributionTime <= getdate() and pso.Distribute = 1";
            cmd.CommandType = CommandType.Text;

            using (SqlConnection cn = new SqlConnection(YellowstonePathology.Properties.Settings.Default.CurrentConnectionString))
            {
                cn.Open();
                cmd.Connection = cn;
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        YellowstonePathology.Business.Test.PanelSetOrderView panelSetOrderView = new Test.PanelSetOrderView();
                        YellowstonePathology.Business.Persistence.SqlDataReaderPropertyWriter sqlDataReaderPropertyWriter = new Persistence.SqlDataReaderPropertyWriter(panelSetOrderView, dr);
                        sqlDataReaderPropertyWriter.WriteProperties();
                        result.Add(panelSetOrderView);
                    }
                }
            }
            return result;
            #endif
        }
        public static List<YellowstonePathology.Business.Test.PanelSetOrderView> GetUnsetDistributions()
        {
            List<YellowstonePathology.Business.Test.PanelSetOrderView> result = new List<Test.PanelSetOrderView>();
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "Select * from tblPanelSetOrder pso where final = 1 and distribute = 1 and not exists (Select * from tblTestOrderReportDistribution where reportNo = pso.ReportNo)";
            cmd.CommandType = CommandType.Text;

            using (SqlConnection cn = new SqlConnection(YellowstonePathology.Properties.Settings.Default.CurrentConnectionString))
            {
                cn.Open();
                cmd.Connection = cn;
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        YellowstonePathology.Business.Test.PanelSetOrderView panelSetOrderView = new Test.PanelSetOrderView();
                        YellowstonePathology.Business.Persistence.SqlDataReaderPropertyWriter sqlDataReaderPropertyWriter = new Persistence.SqlDataReaderPropertyWriter(panelSetOrderView, dr);
                        sqlDataReaderPropertyWriter.WriteProperties();
                        result.Add(panelSetOrderView);
                    }
                }
            }
            return result;
        }
        public static YellowstonePathology.Business.Test.PanelSetOrderView GetCaseToSchedule(string reportNo)
        {
            #if MONGO
            return AccessionOrderGatewayMongo.GetCaseToSchedule(reportNo);
            #else
            YellowstonePathology.Business.Test.PanelSetOrderView result = null;
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "Select * from tblPanelSetOrder where ReportNo = @ReportNo";
            cmd.Parameters.Add("@ReportNo", SqlDbType.VarChar).Value = reportNo;
            cmd.CommandType = CommandType.Text;

            using (SqlConnection cn = new SqlConnection(YellowstonePathology.Properties.Settings.Default.CurrentConnectionString))
            {
                cn.Open();
                cmd.Connection = cn;
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        result = new Test.PanelSetOrderView();
                        YellowstonePathology.Business.Persistence.SqlDataReaderPropertyWriter sqlDataReaderPropertyWriter = new Persistence.SqlDataReaderPropertyWriter(result, dr);
                        sqlDataReaderPropertyWriter.WriteProperties();

                    }
                }
            }
            return result;
            #endif
        }
        public static List<YellowstonePathology.Business.Test.PanelSetOrderView> GetCasesToSchedule()
        {
            #if MONGO
            return AccessionOrderGatewayMongo.GetCasesToSchedule();
            #else
            List<YellowstonePathology.Business.Test.PanelSetOrderView> result = new List<Test.PanelSetOrderView>();
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "Select * from tblPanelSetOrder pso where pso.Final = 1 and pso.ScheduledPublishTime is null and pso.Published = 0";
            cmd.CommandType = CommandType.Text;

            using (SqlConnection cn = new SqlConnection(YellowstonePathology.Properties.Settings.Default.CurrentConnectionString))
            {
                cn.Open();
                cmd.Connection = cn;
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        YellowstonePathology.Business.Test.PanelSetOrderView panelSetOrderView = new Test.PanelSetOrderView();
                        YellowstonePathology.Business.Persistence.SqlDataReaderPropertyWriter sqlDataReaderPropertyWriter = new Persistence.SqlDataReaderPropertyWriter(panelSetOrderView, dr);
                        sqlDataReaderPropertyWriter.WriteProperties();
                        result.Add(panelSetOrderView);
                    }
                }
            }
            return result;
            #endif
        }