Esempio n. 1
0
        public IActionResult DeleteAnalyticsRunReportingDb([FromServices] IReportingServicesClient reportingServicesClient, string customerShortName, string projectShortName, Guid analyticsRunId)
        {
            var input = new
            {
                customerShortName = customerShortName,
                projectShortName  = projectShortName,
                flowchartRunId    = analyticsRunId,
            };

            var json     = JsonConvert.SerializeObject(input);
            var method   = "DeleteFlowchartRun_Rest";
            var response = reportingServicesClient.Client.PostAsync(method, new StringContent(json, Encoding.UTF8, "application/json")).Result;

            _validation.ValidateResponse(response);

            var result    = response.Content.ReadAsStringAsync().Result;
            var succeeded = ((JProperty)JObject.Parse(result).First).Value.Value <bool>();

            if (!succeeded)
            {
                throw new OperationCanceledException($"Delete rates from reporting db failed for the following input: api: {method}, json: {json}");
            }

            _logging.Log("Deleted rates from reporting db", Orchestration.Shared.Domain.Log.LogLevels.Info, 100);
            return(Ok());
        }
Esempio n. 2
0
        public ActionResult Run
        (
            [FromServices] IReportingServicesClient reportingServicesClient,
            string customerShortName,
            string projectShortName,
            Guid jobId,
            Guid flowchartRunId,
            Operations operation,
            bool reRunRateGeneration = false
        )
        {
            var job          = _jobProxy.GetJob(customerShortName, projectShortName, jobId);
            var flowchartRun = job.flowchartRunRequest.FirstOrDefault(x => x.flowchartRunUUID == flowchartRunId);

            if (flowchartRun == null)
            {
                throw new NullReferenceException("The flowchart run was not present in the job.");
            }
            if (!reRunRateGeneration)
            {
                _workStatusProxy.Add(new WorkStatus(flowchartRunId, false, GetPercentage(operation), AnalyticsRunStatus.Running));
            }

            if (!reRunRateGeneration && operation == Operations.GenerateMemberMonthInfo)
            {
                var index = job.flowchartRunRequest.IndexOf(flowchartRun);

                if (index > 0)
                {
                    var percentage = Calculations.Percentage(_config.PreCacheDBPercentageContribution, index, job.flowchartRunRequest.Count, 100);
                    _workStatusProxy.Add(new WorkStatus(jobId, false, percentage, AnalyticsRunStatus.Running));
                }
                else
                {
                    _workStatusProxy.Add(new WorkStatus(jobId, false, _config.PreCacheDBPercentageContribution, AnalyticsRunStatus.Running));

                    for (int i = 1; i < job.flowchartRunRequest.Count; i++)
                    {
                        _workStatusProxy.Add(new WorkStatus(job.flowchartRunRequest[i].flowchartRunUUID, false, GetPercentage(operation), AnalyticsRunStatus.Running));
                    }
                }
            }

            var model = new RatesCacheModel()
            {
                customerShortName           = customerShortName,
                flowchartRunId              = flowchartRunId,
                flowchartCatalogPopulations = flowchartRun.flowchartCatalogPopulations,
                operation          = operation,
                populationIds      = (job.populationIds == null || job.populationIds.Count == 0) ? null : job.populationIds, // passing an empty list causes it to not populate
                projectShortName   = projectShortName,
                hrSampleMeasureIDs = flowchartRun.hrSampleMeasureMetadata.Keys.ToList()
            };

            if (!SkipOperation(model, operation))
            {
                RunOperation(reportingServicesClient, model, reRunRateGeneration);
            }
            return(Ok());
        }
Esempio n. 3
0
        private void RunOperation(IReportingServicesClient reportingServicesClient, RatesCacheModel model, bool reRunRateGeneration)
        {
            var json   = JsonConvert.SerializeObject(model);
            var method = GetServiceMethod(model.operation);

            var fallback  = _config.CacheDBPercentageContribution;
            var stopWatch = Stopwatch.StartNew();
            var response  = reportingServicesClient.Client.PostAsync(method, new StringContent(json, Encoding.UTF8, "application/json")).Result;

            _validation.ValidateResponse(response);

            if (!reRunRateGeneration)
            {
                _taskLogging.LogOperation
                (
                    model.customerShortName,
                    model.projectShortName,
                    model.operation.ToString(),
                    model.flowchartRunId,
                    stopWatch.Elapsed,
                    fallback
                );
            }

            var result    = response.Content.ReadAsStringAsync().Result;
            var succeeded = ((JProperty)JObject.Parse(result).First).Value.Value <bool>();

            if (!succeeded)
            {
                throw new OperationCanceledException($"Run failed for the following input: method: {method}, json: {json}");
            }
        }
Esempio n. 4
0
        public IActionResult PublishGreenplum([FromServices] IReportingServicesClient reportingServicesClient, string customerShortName, string projectShortName, Guid id)
        {
            var job = _jobProxy.GetJob(customerShortName, projectShortName, id);

            _workStatusProxy.Add(job, AnalyticsRunStatus.Running, 0, true, true);

            var content = job.flowchartRunRequest
                          .SelectMany(x => (x.flowchartCatalogMetadata), (request, metadata) => new { flowchartRunId = request.flowchartRunUUID, catalogId = metadata.flowchartCatalogID })
                          .GroupBy(x => x.catalogId)
                          .ToDictionary(g => g.Key, g => g.Select(x => x.flowchartRunId).ToList());

            var i      = 0;
            var length = content.Keys.Count;

            content.Keys.ToList().ForEach(x =>
            {
                var input = new
                {
                    customerShortName      = customerShortName,
                    projectShortName       = projectShortName,
                    flowchartContentItemId = x,
                    vaccuum = (i == (length - 1)) ? true : false
                };

                var json      = JsonConvert.SerializeObject(input);
                var method    = "publishflowchartMetaDataGreenPlum_Rest";
                var stopWatch = Stopwatch.StartNew();

                var response = reportingServicesClient.Client.PostAsync(method, new StringContent(json, Encoding.UTF8, "application/json")).Result;

                _validation.ValidateResponse(response);
                _taskLogging.LogOperation(customerShortName, projectShortName, "PublishMetadataGreenplum", job, stopWatch.Elapsed);

                var result    = response.Content.ReadAsStringAsync().Result;
                var succeeded = ((JProperty)JObject.Parse(result).First).Value.Value <bool>();

                if (!succeeded)
                {
                    throw new OperationCanceledException($"Published failed for the following input: api: {method}, json: {json}");
                }

                i++;
            });

            return(Ok());
        }
Esempio n. 5
0
        public IActionResult PublishEventMetaDataGreenplum([FromServices] IReportingServicesClient reportingServicesClient, string customerShortName, string projectShortName, Guid id)
        {
            var job = _jobProxy.GetJob(customerShortName, projectShortName, id);

            _workStatusProxy.Add(job, AnalyticsRunStatus.Running, 0, true, true);

            var eventCatalogs = job.flowchartRunRequest.SelectMany(fcr => fcr.flowchartCatalogMetadata.SelectMany(fcm => fcm.eventCatalogs));

            if (eventCatalogs.Count() > 0)
            {
                var input = new
                {
                    customerShortName = customerShortName,
                    projectShortName  = projectShortName,
                    eventCatalogs     = eventCatalogs
                };

                var json      = JsonConvert.SerializeObject(input);
                var method    = "PublishEventCatalogMetadataToGreenplum_Rest";
                var stopWatch = Stopwatch.StartNew();

                var response = reportingServicesClient.Client.PostAsync(method, new StringContent(json, Encoding.UTF8, "application/json")).Result;

                _validation.ValidateResponse(response);
                _taskLogging.LogOperation(customerShortName, projectShortName, "PublishEventCatalogMetadataToGreenplum_Rest", job, stopWatch.Elapsed);

                var result = response.Content.ReadAsStringAsync().Result;
                var failedEventCatalogs = ((JProperty)JObject.Parse(result).First).Value;

                if (failedEventCatalogs.Count() > 0)
                {
                    throw new OperationCanceledException($"Event Catalog sync failed for the following input: api: {method}, error:{failedEventCatalogs} json: {json}");
                }
            }

            return(Ok());
        }
Esempio n. 6
0
        public ActionResult LogParams([FromServices] IReportingServicesClient reportingServicesClient, string customerShortName, string projectShortName, Guid id)
        {
            var listWorkStatus = new List <WorkStatus>();
            var projectConfig  = _iam.GetProjectConfig(customerShortName, projectShortName);

            var job = _jobProxy.GetJob(customerShortName, projectShortName, id);

            _workStatusProxy.Add(job, AnalyticsRunStatus.Running, Calculations.Percentage(0, 13, 14, _config.PreTAPercentageContribution), true, true);

            // Add status to parent work id with WorkStatus of 'Running'
            listWorkStatus.Add(new WorkStatus(job.analyticsRunUUID, true, _config.PreTAPercentageContribution, AnalyticsRunStatus.Running));
            var stopWatch = Stopwatch.StartNew();

            job.flowchartRunRequest.ToList().ForEach(flowchartRunRequest =>
            {
                flowchartRunRequest.flowchartCatalogMetadata.ToList().ForEach(
                    catalog =>
                {
                    var advancedOptions = new string[16, 2]
                    {
                        { "continuousEnrollmentVariable", flowchartRunRequest.continuousEnrollmentVariable },
                        { "engine_type", "Orchestration" },
                        { "runType", flowchartRunRequest.runType },
                        { "excludeHospice", flowchartRunRequest.excludeHospice.ToString() },
                        { "hedisPPO", flowchartRunRequest.hedisPPO.ToString() },
                        { "ignoreOneDay", flowchartRunRequest.ignoreOneDay.ToString() },
                        { "includeDetailResults", flowchartRunRequest.includeDetailResults.ToString() },
                        { "includeFlaggedEventResults", flowchartRunRequest.includeFlaggedEventResults.ToString() },
                        { "includeGlobalEvents", flowchartRunRequest.includeGlobalEvents.ToString() },
                        { "includeMemberMonthResults", flowchartRunRequest.includeMemberMonthResults.ToString() },
                        { "includeMessageResults", flowchartRunRequest.includeMessageResults.ToString() },
                        { "nonDenomDetail", flowchartRunRequest.nonDenomDetail.ToString() },
                        { "reportingYearBeginDate", flowchartRunRequest.reportingYearBeginDate.ToString(CultureInfo.InvariantCulture) },
                        { "reportingYearEndDate", flowchartRunRequest.reportingYearEndDate.ToString(CultureInfo.InvariantCulture) },
                        { "skipContinuousEnrollment", flowchartRunRequest.skipContinuousEnrollment.ToString() },
                        { "skipHasBenefit", flowchartRunRequest.skipHasBenefit.ToString() },
                    };

                    var input = new
                    {
                        customerShortName  = customerShortName,
                        projectShortName   = projectShortName,
                        resultSchemaName   = projectConfig.GreenplumConfig.ResultSchema,
                        flowchartRunGuid   = flowchartRunRequest.flowchartRunUUID,
                        runId              = catalog.flowchartRunID,
                        populationIds      = job.populationIds ?? new List <int>(),
                        advancedOptions    = advancedOptions,
                        eventCatalogs      = catalog.eventCatalogs.Select(x => new string[] { x.eventCatalogID.ToString(), x.name }).ToArray(),
                        promptVariables    = catalog.promptVariables.Select(x => new string[] { x.variableName, x.value }).ToArray(),
                        gpConnectionString = projectConfig.GreenplumConfig.RawConnectionString,
                        sampleOptionsXml   = string.Empty
                    };


                    var json   = JsonConvert.SerializeObject(input);
                    var method = "LogParametersToGreenplum_REST";

                    var response = reportingServicesClient.Client.PostAsync(method, new StringContent(json, Encoding.UTF8, "application/json")).Result;
                    _validation.ValidateResponse(response);

                    var result    = response.Content.ReadAsStringAsync().Result;
                    var succeeded = ((JProperty)JObject.Parse(result).First).Value.Value <bool>();

                    if (!succeeded)
                    {
                        throw new OperationCanceledException($"Logging failed for the following input: method: {method}, json: {json}");
                    }
                });

                // Add status to child flowchart work id with WorkStatus of 'Running'
                listWorkStatus.Add(new WorkStatus(flowchartRunRequest.flowchartRunUUID, _config.PreTAPercentageContribution, AnalyticsRunStatus.Running));
            });

            _workStatusProxy.Add(listWorkStatus);
            _taskLogging.LogOperation(customerShortName, projectShortName, "LogParams", job, stopWatch.Elapsed);

            return(Ok());
        }