Exemple #1
0
        public CohortQueryBuilderDependency(AggregateConfiguration cohortSet,
                                            JoinableCohortAggregateConfigurationUse patientIndexTableIfAny, ICoreChildProvider childProvider)
        {
            _childProvider         = childProvider;
            CohortSet              = cohortSet;
            PatientIndexTableIfAny = patientIndexTableIfAny;

            //record the IsExtractionIdentifier column for the log (helps with debugging count issues)
            var eis = cohortSet?.AggregateDimensions?.Where(d => d.IsExtractionIdentifier).ToArray();

            //Multiple IsExtractionIdentifier columns is a big problem but it's handled elsewhere
            if (eis != null && eis.Length == 1)
            {
                ExtractionIdentifierColumn = eis[0];
            }

            if (PatientIndexTableIfAny != null)
            {
                var join = _childProvider.AllJoinables.SingleOrDefault(j =>
                                                                       j.ID == PatientIndexTableIfAny.JoinableCohortAggregateConfiguration_ID);

                if (join == null)
                {
                    throw new Exception("ICoreChildProvider did not know about the provided patient index table");
                }

                JoinedTo = _childProvider.AllAggregateConfigurations.SingleOrDefault(ac =>
                                                                                     ac.ID == join.AggregateConfiguration_ID);

                if (JoinedTo == null)
                {
                    throw new Exception("ICoreChildProvider did not know about the provided patient index table AggregateConfiguration");
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates arguments for an <see cref="AggregateConfiguration"/> which has a JOIN to a patient index table.  All arguments must be provided
        /// </summary>
        /// <param name="join">The join usage relationship object (includes join direction etc)</param>
        /// <param name="joinedTo">The patient index to which the join is made to (e.g. <see cref="JoinableCohortAggregateConfiguration.AggregateConfiguration"/>)</param>
        /// <param name="joinSql">The full SQL of the join</param>
        /// <param name="customisations"></param>
        /// <param name="globals"></param>
        public QueryBuilderArgs(JoinableCohortAggregateConfigurationUse join, AggregateConfiguration joinedTo, CohortQueryBuilderDependencySql joinSql, QueryBuilderCustomArgs customisations, ISqlParameter[] globals) : this(customisations, globals)
        {
            JoinIfAny = join;
            JoinedTo  = joinedTo;
            JoinSql   = joinSql;

            if (JoinIfAny == null != (JoinedTo == null) || JoinIfAny == null != (JoinSql == null))
            {
                throw new Exception("You must provide all arguments or no arguments");
            }

            if (JoinedTo != null)
            {
                if (!JoinedTo.IsCohortIdentificationAggregate || !JoinedTo.IsJoinablePatientIndexTable())
                {
                    throw new ArgumentException($"JoinedTo ({JoinedTo}) was not a patient index table", nameof(joinedTo));
                }
            }
        }