Beispiel #1
0
        public void Process(CaseReportReceived @event)
        {
            var dataCollector = _dataCollectors.GetById(@event.DataCollectorId);

            if (dataCollector.InTraining)
            {
                return;                           // don't include training data
            }
            // Each day contains a health risk dictionary
            // Each healthrisk in the healthrisk dictionary contains two collections of case-reports from 7 and 30 days
            var totalCases            = @event.NumberOfFemalesAged5AndOlder + @event.NumberOfFemalesUnder5 + @event.NumberOfMalesAged5AndOlder + @event.NumberOfMalesUnder5;
            var locationForCaseReport = new Location(@event.Latitude, @event.Longitude);
            var healthRisk            = _healthRisks.GetById(@event.HealthRiskId);

            var dayOfCaseReport = Day.From(@event.Timestamp);
            var timeLimit4Weeks = dayOfCaseReport + 28;
            var timeLimit7Days  = dayOfCaseReport + 7;

            // Insert or update casereport depending on if it is in the list of not
            for (Day day = dayOfCaseReport; day < timeLimit4Weeks; day++)
            {
                var caseReport = new CaseReportForMap()
                {
                    HealthRiskName = healthRisk.Name,
                    NumberOfPeople = totalCases,
                    Location       = locationForCaseReport
                };

                if (day < timeLimit7Days)
                {
                    UpdateCaseReportLast7Days(caseReport, day, healthRisk.HealthRiskNumber);
                }
                UpdateCaseReportLast4Weeks(caseReport, day, healthRisk.HealthRiskNumber);
            }
        }
Beispiel #2
0
        public void Process(CaseReportReceived @event)
        {
            // Each day contains a health risk dictionary
            // Each healthrisk in the healthrisk dictionary contains two collections of case-reports from 7 and 30 days
            var totalCases            = @event.NumberOfFemalesAged5AndOlder + @event.NumberOfFemalesUnder5 + @event.NumberOfMalesAged5AndOlder + @event.NumberOfMalesUnder5;
            var locationForCaseReport = new Location(@event.Latitude, @event.Longitude);
            var healthRiskId          = @event.HealthRiskId;
            var healthRiskName        = _healthRisks.GetById(healthRiskId).Name;

            var dayOfCaseReport = Day.From(@event.Timestamp);
            var timeLimit30Days = dayOfCaseReport + 30;
            var timeLimit7Days  = dayOfCaseReport + 7;

            // Insert or update casereport depending on if it is in the list of not
            for (Day day = dayOfCaseReport; day < timeLimit30Days; day++)
            {
                var caseReport = new CaseReportForMap()
                {
                    NumberOfPeople = totalCases,
                    Location       = locationForCaseReport
                };

                if (day < timeLimit7Days)
                {
                    UpdateCaseReportLast7Days(caseReport, day, healthRiskName);
                }
                UpdateCaseReportLast30Days(caseReport, day, healthRiskName);
            }
        }
Beispiel #3
0
        private void UpdateCaseReportLast4Weeks(CaseReportForMap caseReportMap, Day day, HealthRiskNumber healthRiskNumber)
        {
            var caseReportsLast4Weeks = _caseReportRepositoryLast4Weeks.GetById(day);

            if (caseReportsLast4Weeks == null)
            {
                caseReportsLast4Weeks = new CaseReportsLast4Weeks()
                {
                    Id = day,
                    CaseReportsPerHealthRisk = new Dictionary <HealthRiskNumber, IList <CaseReportForMap> > {
                    }
                };
                caseReportsLast4Weeks.CaseReportsPerHealthRisk[healthRiskNumber] = new List <CaseReportForMap> {
                    caseReportMap
                };
                _caseReportRepositoryLast4Weeks.Insert(caseReportsLast4Weeks);
            }
            else
            {
                UpdateCaseReportsPerHealthRisk(caseReportsLast4Weeks.CaseReportsPerHealthRisk, caseReportMap, healthRiskNumber);
                _caseReportRepositoryLast4Weeks.Update(caseReportsLast4Weeks);
            }
        }
Beispiel #4
0
 private void UpdateCaseReportsPerHealthRisk(IDictionary <HealthRiskNumber, IList <CaseReportForMap> > caseReportsPerHealthRisk, CaseReportForMap caseReportForMap, HealthRiskNumber healthRiskNumber)
 {
     if (caseReportsPerHealthRisk.ContainsKey(healthRiskNumber))
     {
         caseReportsPerHealthRisk[healthRiskNumber].Add(caseReportForMap);
     }
     else
     {
         caseReportsPerHealthRisk[healthRiskNumber] = new List <CaseReportForMap> {
             caseReportForMap
         };
     }
 }