コード例 #1
0
ファイル: Analyse.cs プロジェクト: TraceLD/IbdTracker
            public async Task <FlareUpDetectionResult> Handle(Query request, CancellationToken cancellationToken)
            {
                var patientId       = _userService.GetUserAuthId();
                var startDate       = DateTime.UtcNow.AddDays(-DaysAnalysed);
                var painEventsCount = await _context.PainEvents
                                      .AsNoTracking()
                                      .Where(pe => pe.PatientId.Equals(patientId) &&
                                             pe.DateTime >= startDate)
                                      .OrderBy(pe => pe.DateTime)
                                      .CountAsync(cancellationToken);

                var bmsTotalCount = await _context.BowelMovementEvents
                                    .AsNoTracking()
                                    .Where(bm => bm.PatientId.Equals(patientId) &&
                                           bm.DateTime >= startDate)
                                    .CountAsync(cancellationToken);

                var bmsBloodyCount = await _context.BowelMovementEvents
                                     .AsNoTracking()
                                     .Where(bm => bm.PatientId.Equals(patientId) &&
                                            bm.DateTime >= startDate &&
                                            bm.ContainedBlood)
                                     .CountAsync(cancellationToken);

                return(_flareUpDetectionService.AnalyseLatestDailyAverages(patientId, DaysAnalysed, painEventsCount,
                                                                           bmsTotalCount, bmsBloodyCount));
            }
コード例 #2
0
        public void ShouldReturnTrueIfAllParametersAboveThresholds()
        {
            // arrange;
            const int timePeriodInDays = 14;
            var       painEventsCount  = _flareUpService.PainEventsPerDayThreshold * timePeriodInDays + 1;
            var       bmsTotalCount    = _flareUpService.BmsPerDayThreshold * timePeriodInDays + 1;
            var       bmsBloodyCount   = _flareUpService.BloodyBmsPercentageThreshold + 1;

            // act;
            var res = _flareUpService.AnalyseLatestDailyAverages(TestUserHelper.TestPatientId, timePeriodInDays,
                                                                 painEventsCount, bmsTotalCount, bmsBloodyCount);

            // assert;
            res.IsInFlareUp.Should().BeTrue();
        }
コード例 #3
0
        public void ShouldThrowIfTimePeriodLessThan0()
        {
            // arrange;
            var       patientId        = TestUserHelper.TestPatientId;
            const int timePeriodInDays = -1;
            const int painEventsCount  = 0;
            const int bmsTotalCount    = 0;
            const int bmsBloodyCount   = 0;

            // act;
            Func <FlareUpDetectionResult> act = () => _service.AnalyseLatestDailyAverages(patientId, timePeriodInDays, painEventsCount, bmsTotalCount,
                                                                                          bmsBloodyCount);

            // assert;
            act.Should().Throw <ArgumentException>();
        }