Example #1
0
        void TriggerAlerts(
            Read.AlertRules.AlertRule alertRule,
            Domain.Alerts.Alerts root,
            AvailableReport incommingReport) 
        {
            var openAlert = _openAlertsRepository.GetById(alertRule.HealthRiskId);
            if(openAlert != null)
            {
                root.AddReportToAlert(incommingReport.Id, openAlert.AlertId);
                return;
            }

            int casesThreshold = alertRule.NumberOfCasesThreshold;
            int healthRiskNumber = alertRule.HealthRiskId;
            TimeSpan alertRuleInterval = new TimeSpan(alertRule.ThresholdTimeframeInHours, 0, 0);

            DateTimeOffset horizon = DateTimeOffset.UtcNow - alertRuleInterval;
            var reportIds = _reportRepository.Query.Where(
                c => c.Timestamp >= horizon && c.HealthRiskNumber == healthRiskNumber)
                .Select(_ => _.Id.Value).ToList();

            if(reportIds.Count() >= casesThreshold)
            {
                root.OpenAlert(
                    Guid.NewGuid(),
                    alertRule.Id,
                    reportIds
                );
            }
            

        }
Example #2
0
        void TriggerAlerts(Read.AlertRules.AlertRule alertRule, Domain.Alerts.Alerts root)
        {
            int      casesThreshold    = alertRule.NumberOfCasesThreshold;
            int      healthRiskNumber  = alertRule.HealthRiskId;
            TimeSpan alertRuleInterval = new TimeSpan(alertRule.ThresholdTimeframeInHours, 0, 0);

            DateTimeOffset horizon   = DateTimeOffset.UtcNow - alertRuleInterval;
            var            reportIds = _reportRepository.Query.Where(
                c => c.Timestamp >= horizon && c.HealthRiskNumber == healthRiskNumber)
                                       .Select(_ => _.Id).ToList();

            if (reportIds.Count() >= casesThreshold)
            {
                root.OpenAlert(
                    Guid.NewGuid(),
                    alertRule.Id,
                    reportIds
                    );
            }
        }