public void Should_Correctly_Reference_AppDb()
        {
            var compilerCtx = GetCompilerContext();
            var compiler    = new DemographicSqlCompiler(GetSqlCompiler(), GetCompilerOptions());

            var executionCtx = compiler.BuildDemographicSql(compilerCtx, true);

            Assert.Contains("LeafDB", executionCtx.CompiledQuery);
        }
        public void Should_Correctly_Represent_Demographic_Shape()
        {
            var compilerCtx = GetCompilerContext();
            var compiler    = new DemographicSqlCompiler(GetSqlCompiler(), GetCompilerOptions());

            var executionCtx = compiler.BuildDemographicSql(compilerCtx, false);

            Assert.Equal(Shape.Demographic, executionCtx.Shape);
        }
        public void Should_Omit_Additional_Record_Fields()
        {
            var compilerCtx = GetCompilerContext();
            var compiler    = new DemographicSqlCompiler(GetSqlCompiler(), GetCompilerOptions());

            var executionCtx = compiler.BuildDemographicSql(compilerCtx, false);

            Assert.DoesNotContain(executionCtx.FieldSelectors, f => f.Name == DemographicColumns.Exported);
            Assert.DoesNotContain(executionCtx.FieldSelectors, f => f.Name == DatasetColumns.Salt);
        }
        public void Should_Correctly_Include_Phi_Fields()
        {
            var compilerCtx = GetCompilerContext();
            var compiler    = new DemographicSqlCompiler(GetSqlCompiler(), GetCompilerOptions());

            var executionCtx = compiler.BuildDemographicSql(compilerCtx, false);

            Assert.Contains(executionCtx.FieldSelectors, f => f.Name == DemographicColumns.Mrn);
            Assert.Contains(executionCtx.FieldSelectors, f => f.Name == DemographicColumns.Name);
        }
        public void Should_Correctly_Restrict_Phi_Fields()
        {
            var compilerCtx = GetCompilerContext();
            var compiler    = new DemographicSqlCompiler(GetSqlCompiler(), GetCompilerOptions());

            var executionCtx = compiler.BuildDemographicSql(compilerCtx, true);

            Assert.Contains(executionCtx.FieldSelectors, f => f.Name == DemographicColumns.BirthDate);
            Assert.DoesNotContain(executionCtx.FieldSelectors, f => f.Name == DemographicColumns.Name);
        }
        public void Should_Correctly_Reference_QueryId_Parameter()
        {
            var compilerCtx = GetCompilerContext();
            var compiler    = new DemographicSqlCompiler(GetSqlCompiler(), GetCompilerOptions());

            var executionCtx = compiler.BuildDemographicSql(compilerCtx, false);

            Assert.Contains(ShapedDatasetCompilerContext.QueryIdParam, executionCtx.CompiledQuery);
            Assert.Contains(executionCtx.Parameters, p => p.Name == ShapedDatasetCompilerContext.QueryIdParam && p.Value.Equals(compilerCtx.QueryContext.QueryId));
        }