Exemple #1
0
        Concept Convert(QueryRef @ref, CompilerOptions opts)
        {
            var alias = $"{opts.Alias}C";

            return(new Concept
            {
                Id = @ref.Id.Value,
                UniversalId = @ref.UniversalId,
                RootId = Guid.Empty,
                SqlSetFrom = $"(SELECT {opts.FieldPersonId} = {alias}.PersonId FROM {opts.AppDb}.app.Cohort AS {alias} WHERE {alias}.QueryId = '{@ref.Id.Value}')",
            });
        }
 public ConceptDatasetExecutionRequest(QueryRef qr, IPanelItemDTO panelItem, long?early = null, long?late = null)
 {
     QueryRef  = qr;
     PanelItem = panelItem;
     if (early.HasValue)
     {
         EarlyBound = DateTimes.FromUTCTicks(early.Value);
     }
     if (late.HasValue)
     {
         LateBound = DateTimes.FromUTCTicks(late.Value);
     }
 }
 public DatasetExecutionRequest(QueryRef qr, DatasetQueryRef dr, long?early = null, long?late = null)
 {
     QueryRef   = qr;
     DatasetRef = dr;
     if (early.HasValue)
     {
         EarlyBound = DateTimes.FromUTCTicks(early.Value);
     }
     if (late.HasValue)
     {
         LateBound = DateTimes.FromUTCTicks(late.Value);
     }
 }
Exemple #4
0
        /// <summary>
        /// Get the <see cref="DemographicCompilerContext"/> from the provider, validates it's state, and wraps it in <see cref="CompilerValidationContext{DemographicCompilerContext}"/>.
        /// </summary>
        /// <returns>The compiler validation context.</returns>
        /// <param name="qr">Query reference.</param>
        /// <exception cref="Validation.LeafRPCException"/>
        /// <exception cref="System.Data.Common.DbException"/>
        public async Task <CompilerValidationContext <DemographicCompilerContext> > GetCompilerContextAsync(QueryRef qr)
        {
            log.LogInformation("Getting DemographicQueryCompilerContext. QueryRef:{@QueryRef}", qr);
            try
            {
                var context = await contextProvider.GetCompilerContextAsync(qr);

                var state = GetContextState(context);
                return(new CompilerValidationContext <DemographicCompilerContext>
                {
                    Context = context,
                    State = state
                });
            }
            catch (DbException de)
            {
                log.LogError("Could not get demographic query context. Query:{@QueryRef} Code:{Code} Error:{Error}", qr, de.ErrorCode, de.Message);
                de.MapThrow();
                throw;
            }
        }
Exemple #5
0
        /// <summary>
        /// Validate the specified context. Throws if there are unrecoverable errors.
        /// </summary>
        /// <returns>The validated Panel.</returns>
        /// <param name="ctx">Context.</param>
        /// <exception cref="LeafCompilerException"/>
        public PanelDatasetCompilerContext ValidateConceptPanel(PanelValidationContext ctx, QueryRef queryRef)
        {
            if (!ctx.PreflightPassed)
            {
                throw new LeafCompilerException("PreflightCheck failed, nothing to validate.");
            }
            ValidateItems(ctx);
            var panels = ValidatePanels(ctx);

            return(new PanelDatasetCompilerContext
            {
                Panel = panels.First(),
                QueryContext = new QueryContext
                {
                    QueryId = (Guid)queryRef.Id
                }
            });
        }
Exemple #6
0
        public async Task <CompilerValidationContext <PanelDatasetCompilerContext> > GetCompilerContextAsync(QueryRef qr, int panelIdx)
        {
            log.LogInformation("Getting ConceptDatasetCompilerContext. PanelIndex:{@PanelIndex}, QueryRef:{@QueryRef}", panelIdx, qr);
            try
            {
                var context = await contextProvider.GetCompilerContextAsync(qr, panelIdx);

                var state = GetContextState(context);
                return(new CompilerValidationContext <PanelDatasetCompilerContext>
                {
                    Context = context,
                    State = state
                });
            }
            catch (DbException de)
            {
                log.LogError("Failed to get PanelDatasetCompilerContext. Query:{@QueryRef} Code:{Code} Error:{Error}", qr, de.ErrorCode, de.Message);
                de.MapThrow();
                throw;
            }
        }