Example #1
0
        public void QueryGeneration_WithLinkedCohort_WHERECHIIN()
        {
            var csqb = new CohortSummaryQueryBuilder(acDataset, acCohort);

            var ex = Assert.Throws <NotSupportedException>(() => csqb.GetAdjustedAggregateBuilder(CohortSummaryAdjustment.WhereExtractionIdentifiersIn));

            Assert.AreEqual("No Query Caching Server configured", ex.Message);
        }
Example #2
0
        public AggregateConfigurationMenu(RDMPContextMenuStripArgs args, AggregateConfiguration aggregate) : base(args, aggregate)
        {
            //if it is a cohort aggregate (but not joinables since they don't match patients they match records and select many columns)
            if (aggregate.IsCohortIdentificationAggregate && !aggregate.IsJoinablePatientIndexTable())
            {
                //with a cic (it really should do!)
                var cic = aggregate.GetCohortIdentificationConfigurationIfAny();

                if (cic != null)
                {
                    //find other non cohort aggregates (graphs)
                    AggregateConfiguration[] graphsAvailableInCatalogue;

                    try
                    {
                        graphsAvailableInCatalogue = CohortSummaryQueryBuilder.GetAllCompatibleSummariesForCohort(aggregate);
                    }
                    catch (System.Exception)
                    {
                        // Occurs if the AggregateConfiguration is badly set up e.g. has too many extraction identifiers
                        graphsAvailableInCatalogue = new AggregateConfiguration[0];
                    }

                    //and offer graph generation for the cohort subsets
                    var matchRecords     = new ToolStripMenuItem("Graph Matching Records Only", _activator.CoreIconProvider.GetImage(RDMPConcept.AggregateGraph));
                    var matchIdentifiers = new ToolStripMenuItem("Graph All Records For Matching Patients", _activator.CoreIconProvider.GetImage(RDMPConcept.AggregateGraph));

                    matchRecords.Enabled     = graphsAvailableInCatalogue.Any();
                    matchIdentifiers.Enabled = graphsAvailableInCatalogue.Any() && cic.QueryCachingServer_ID != null;

                    foreach (AggregateConfiguration graph in graphsAvailableInCatalogue)
                    {
                        //records in
                        Add(new ExecuteCommandViewCohortAggregateGraph(_activator, new CohortSummaryAggregateGraphObjectCollection(aggregate, graph, CohortSummaryAdjustment.WhereRecordsIn)),
                            Keys.None,
                            matchRecords);

                        //extraction identifiers in
                        Add(
                            new ExecuteCommandViewCohortAggregateGraph(_activator, new CohortSummaryAggregateGraphObjectCollection(aggregate, graph, CohortSummaryAdjustment.WhereExtractionIdentifiersIn)),
                            Keys.None,
                            matchIdentifiers
                            );
                    }

                    Items.Add(matchRecords);
                    Items.Add(matchIdentifiers);
                }
            }
        }
Example #3
0
        protected override AggregateBuilder GetQueryBuilder(AggregateConfiguration summary)
        {
            CohortSummaryQueryBuilder builder;

            if (_collection.CohortIfAny != null)
            {
                builder = new CohortSummaryQueryBuilder(summary, _collection.CohortIfAny, Activator.CoreChildProvider);
            }
            else
            {
                builder = new CohortSummaryQueryBuilder(summary, _collection.CohortContainerIfAny);
            }

            return(builder.GetAdjustedAggregateBuilder(_collection.Adjustment, _collection.SingleFilterOnly));
        }
Example #4
0
        public void QueryGeneration_BothHaveWHEREContainerAndParameters()
        {
            CreateParameters("'bob'", "'fish'");

            var global = new AnyTableSqlParameter(CatalogueRepository, cic, "DECLARE @bob AS varchar(50);");

            global.Value = "'zomber'";
            global.SaveToDatabase();

            try
            {
                ((IDeleteable)parama1).DeleteInDatabase();
                var csqb = new CohortSummaryQueryBuilder(acDataset, acCohort);

                var builder = csqb.GetAdjustedAggregateBuilder(CohortSummaryAdjustment.WhereRecordsIn);

                Assert.AreEqual(CollapseWhitespace(@"DECLARE @bob AS varchar(50);
SET @bob='zomber';
/*Agg2_Dataset*/
SELECT
Year,
count(*) AS MyCount
FROM 
MyTable
WHERE
(
	(
	/*Filter2*/
	@bob = 'fish'
	)
AND
	(
	/*Filter1*/
	@bob = 'bob'
	)
)

group by 
Year
order by 
Year"), CollapseWhitespace(builder.SQL));
            }
            finally
            {
                global.DeleteInDatabase();
                DestroyParameters();
            }
        }
Example #5
0
        public void QueryGeneration_NoCohortWhereLogic()
        {
            var csqb = new CohortSummaryQueryBuilder(acDataset, acCohort);

            var builder = csqb.GetAdjustedAggregateBuilder(CohortSummaryAdjustment.WhereRecordsIn);

            Assert.AreEqual(@"/*Agg2_Dataset*/
SELECT
Year,
count(*) AS MyCount
FROM 
MyTable
group by
Year
order by
Year", builder.SQL);
        }
Example #6
0
        public void QueryGeneration_Parameters_DifferentValues_WHERECHIIN()
        {
            CreateParameters("'bob'", "'fish'");

            try
            {
                var csqb = new CohortSummaryQueryBuilder(acDataset, acCohort);

                var ex = Assert.Throws <NotSupportedException>(() => csqb.GetAdjustedAggregateBuilder(CohortSummaryAdjustment.WhereExtractionIdentifiersIn));

                Assert.AreEqual("No Query Caching Server configured", ex.Message);
            }
            finally
            {
                DestroyParameters();
            }
        }
Example #7
0
        public AggregateConfigurationMenu(RDMPContextMenuStripArgs args, AggregateConfiguration aggregate) : base(args, aggregate)
        {
            _aggregate = aggregate;

            Add(new ExecuteCommandViewSample(args.ItemActivator, aggregate));

            Add(new ExecuteCommandDisableOrEnable(_activator, aggregate));

            //only allow them to execute graph if it is normal aggregate graph
            if (!aggregate.IsCohortIdentificationAggregate)
            {
                Add(new ExecuteCommandExecuteAggregateGraph(_activator, aggregate));
            }

            Add(new ExecuteCommandViewSqlParameters(_activator, aggregate));

            Items.Add(new ToolStripSeparator());

            var addFilterContainer = new ToolStripMenuItem("Add Filter Container", GetImage(RDMPConcept.FilterContainer, OverlayKind.Add), (s, e) => AddFilterContainer());

            //if it doesn't have a root container or a hijacked container shortcut
            addFilterContainer.Enabled = aggregate.RootFilterContainer_ID == null && aggregate.OverrideFiltersByUsingParentAggregateConfigurationInstead_ID == null;
            Items.Add(addFilterContainer);

            Add(new ExecuteCommandImportFilterContainerTree(_activator, aggregate));

            Add(new ExecuteCommandCreateNewFilter(_activator,
                                                  new AggregateFilterFactory(_activator.RepositoryLocator.CatalogueRepository),
                                                  () => {
                aggregate.CreateRootContainerIfNotExists();
                return(aggregate.RootFilterContainer);
            }));

            Add(new ExecuteCommandCreateNewFilterFromCatalogue(_activator,
                                                               aggregate.Catalogue,
                                                               () =>
            {
                aggregate.CreateRootContainerIfNotExists();
                return(aggregate.RootFilterContainer);
            }));

            Items.Add(new ToolStripSeparator());

            var addShortcutFilterContainer = new ToolStripMenuItem("Create Shortcut to Another AggregateConfigurations Filter Container",
                                                                   GetImage(aggregate, OverlayKind.Shortcut), (s, e) => ChooseHijacker());


            //if it doesn't have a root container or a hijacked container shortcut
            addShortcutFilterContainer.Enabled = aggregate.RootFilterContainer_ID == null && aggregate.OverrideFiltersByUsingParentAggregateConfigurationInstead_ID == null;

            Items.Add(addShortcutFilterContainer);

            var clearShortcutFilterContainer = new ToolStripMenuItem("Clear Shortcut", GetImage(aggregate, OverlayKind.Shortcut), (s, e) => ClearShortcut());

            clearShortcutFilterContainer.Enabled = aggregate.OverrideFiltersByUsingParentAggregateConfigurationInstead_ID != null;
            Items.Add(clearShortcutFilterContainer);

            Add(new ExecuteCommandCreateNewCatalogueByExecutingAnAggregateConfiguration(_activator).SetTarget(aggregate));

            //if it is a cohort aggregate (but not joinables since they don't match patients they match records and select many columns)
            if (aggregate.IsCohortIdentificationAggregate && !aggregate.IsJoinablePatientIndexTable())
            {
                //with a cic (it really should do!)
                var cic = aggregate.GetCohortIdentificationConfigurationIfAny();

                if (cic != null)
                {
                    //find other non cohort aggregates (graphs)
                    AggregateConfiguration[] graphsAvailableInCatalogue;

                    try
                    {
                        graphsAvailableInCatalogue = CohortSummaryQueryBuilder.GetAllCompatibleSummariesForCohort(aggregate);
                    }
                    catch (System.Exception)
                    {
                        // Occurs if the AggregateConfiguration is badly set up e.g. has too many extraction identifiers
                        graphsAvailableInCatalogue = new AggregateConfiguration[0];
                    }

                    //and offer graph generation for the cohort subsets
                    var matchRecords     = new ToolStripMenuItem("Graph Matching Records Only", _activator.CoreIconProvider.GetImage(RDMPConcept.AggregateGraph));
                    var matchIdentifiers = new ToolStripMenuItem("Graph All Records For Matching Patients", _activator.CoreIconProvider.GetImage(RDMPConcept.AggregateGraph));

                    matchRecords.Enabled     = graphsAvailableInCatalogue.Any();
                    matchIdentifiers.Enabled = graphsAvailableInCatalogue.Any() && cic.QueryCachingServer_ID != null;

                    foreach (AggregateConfiguration graph in graphsAvailableInCatalogue)
                    {
                        //records in
                        Add(new ExecuteCommandViewCohortAggregateGraph(_activator, new CohortSummaryAggregateGraphObjectCollection(aggregate, graph, CohortSummaryAdjustment.WhereRecordsIn)),
                            Keys.None,
                            matchRecords);

                        //extraction identifiers in
                        Add(
                            new ExecuteCommandViewCohortAggregateGraph(_activator, new CohortSummaryAggregateGraphObjectCollection(aggregate, graph, CohortSummaryAdjustment.WhereExtractionIdentifiersIn)),
                            Keys.None,
                            matchIdentifiers
                            );
                    }

                    Items.Add(matchRecords);
                    Items.Add(matchIdentifiers);
                }
            }
        }