Exemplo n.º 1
0
        public string GetSql()
        {
            string sql = "";
            var    ac  = AggregateConfiguration;

            if (ac.IsCohortIdentificationAggregate)
            {
                var cic        = ac.GetCohortIdentificationConfigurationIfAny();
                var isJoinable = ac.IsJoinablePatientIndexTable();
                var globals    = cic.GetAllParameters();

                var builder = new CohortQueryBuilder(ac, globals, isJoinable);

                if (UseQueryCache)
                {
                    builder.CacheServer = GetCacheServer();
                }

                sql = builder.GetDatasetSampleSQL(100);
            }
            else
            {
                var builder = ac.GetQueryBuilder();
                sql = builder.SQL;
            }

            return(sql);
        }
Exemplo n.º 2
0
        public string GetSql()
        {
            string sql = "";
            var    ac  = AggregateConfiguration;

            if (ac.IsCohortIdentificationAggregate)
            {
                var cic     = ac.GetCohortIdentificationConfigurationIfAny();
                var globals = cic.GetAllParameters();

                var builder = new CohortQueryBuilder(ac, globals, null);

                if (UseQueryCache)
                {
                    builder.CacheServer = GetCacheServer();
                }

                sql = TopX.HasValue ? builder.GetDatasetSampleSQL(TopX.Value) : builder.SQL;
            }
            else
            {
                var builder = ac.GetQueryBuilder();
                sql = builder.SQL;
            }

            return(sql);
        }
Exemplo n.º 3
0
        public void Test_GetDatasetSampleSQL_WithHAVING()
        {
            aggregate1.HavingSQL = "count(*)>1";

            CohortQueryBuilder builder = new CohortQueryBuilder(aggregate1, null);

            Assert.AreEqual(CollapseWhitespace(
                                string.Format(@"/*cic_{0}_UnitTestAggregate1*/
	SELECT
    distinct
	TOP 1000
	["     + _scratchDatabaseName + @"]..[BulkData].[chi]
	FROM 
	["     + _scratchDatabaseName + @"]..[BulkData]
    group by 
    [" + _scratchDatabaseName + @"]..[BulkData].[chi]
    HAVING
    count(*)>1", cohortIdentificationConfiguration.ID)), CollapseWhitespace(builder.GetDatasetSampleSQL()));
        }
Exemplo n.º 4
0
        public void TestGettingAggregateJustFromConfig_SelectStar()
        {
            CohortQueryBuilder builder = new CohortQueryBuilder(aggregate1, null);

            Assert.AreEqual(CollapseWhitespace(
                                string.Format(@"/*cic_{0}_UnitTestAggregate1*/
	SELECT
	TOP 1000
	*
	FROM 
	["     + _scratchDatabaseName + @"]..[BulkData]", cohortIdentificationConfiguration.ID)), CollapseWhitespace(builder.GetDatasetSampleSQL()));
        }