Exemple #1
0
        IReadOnlyCollection <Panel> ValidatePanels(PanelValidationContext ctx)
        {
            var validated = new List <Panel>();

            foreach (var panel in ctx.Allowed)
            {
                var itemCount = panel.SubPanels.SelectMany(x => x.PanelItems).Count();
                if (itemCount == 0)
                {
                    continue;
                }

                CheckDateFilter(panel);

                var validatedSubs = new List <SubPanel>();
                foreach (var subpanel in panel.SubPanels)
                {
                    if (subpanel.PanelItems.Any())
                    {
                        subpanel.PanelIndex = panel.Index;
                        foreach (var panelItem in subpanel.PanelItems)
                        {
                            panelItem.SubPanelIndex = subpanel.Index;
                            panelItem.PanelIndex    = panel.Index;
                        }
                        validatedSubs.Add(subpanel);
                    }
                }
                panel.SubPanels = validatedSubs;

                validated.Add(panel);
            }

            return(validated);
        }
Exemple #2
0
        void ValidateItems(PanelValidationContext ctx)
        {
            var zipped = ZipContextItems(ctx);

            foreach (var mapping in zipped)
            {
                EnsureSpecializationAlignment(mapping);
                EnsureValidRecencyFilter(mapping);
                EnsureValidNumericFilter(mapping);
            }
        }
Exemple #3
0
        // NOTE(cspital) at this point, we are certain the counts are the same.
        IEnumerable <PanelItemMapping> ZipContextItems(PanelValidationContext ctx)
        {
            var dtos = ctx.Requested
                       .SelectMany(p => p.SubPanels)
                       .SelectMany(s => s.PanelItems)
                       .ToArray();

            var mods = ctx.Allowed
                       .SelectMany(p => p.SubPanels)
                       .SelectMany(s => s.PanelItems)
                       .ToArray();

            return(dtos.Zip(mods, (dto, mod) => new PanelItemMapping(dto, mod)));
        }
Exemple #4
0
        /// <summary>
        /// Validate the specified context. Throws if there are unrecoverable errors.
        /// </summary>
        /// <returns>The validated PatientCountQuery.</returns>
        /// <param name="ctx">Context.</param>
        /// <exception cref="LeafCompilerException"/>
        public PatientCountQuery Validate(PanelValidationContext ctx)
        {
            if (!ctx.PreflightPassed)
            {
                throw new LeafCompilerException("PreflightCheck failed, nothing to validate.");
            }
            ValidateItems(ctx);
            var panels = ValidatePanels(ctx);

            return(new PatientCountQuery
            {
                QueryId = ctx.QueryId,
                Panels = panels
            });
        }
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
                }
            });
        }