public void GroupedAndZeroTestResults() { var utcNow = DateTime.UtcNow; var suiteDto = new SuiteDto { SuiteID = 1, ApplicationId = 3, EnvironmentId = 4 }; var suiteDtos = new List <SuiteDto> { suiteDto, new SuiteDto { SuiteID = 5, EnvironmentId = 3, ApplicationId = 4 } }; var mockSuiteService = new Mock <ISuiteService>(); mockSuiteService.Setup(s => s.Get(1)).Returns(suiteDto); mockSuiteService.Setup(s => s.GetAll()).Returns(suiteDtos); var latestTestResultDtos = new List <LatestTestResultDto>(); var mockLatestTestResultsService = new Mock <ILatestTestResultService>(); mockLatestTestResultsService.Setup(s => s.Get(new int[] { 1 })).Returns(latestTestResultDtos); var mockTestFailureDurationService = new Mock <ITestFailureDurationService>(); mockTestFailureDurationService.Setup(f => f.GetAll()).Returns(new List <TestFailureDurationDto>()); var testResultService = new TestResultService(new Mock <IDbContext>().Object, mockLatestTestResultsService.Object, mockTestFailureDurationService.Object, mockSuiteService.Object); var actualLatestTestResults = testResultService.GetLatestGrouped(1).ToList(); Assert.AreEqual(0, actualLatestTestResults.Count); }
private async void FuncToCall2(object context) { if (SelectedOption == null) { MessageBox.Show("Please choose an answer."); return; } if (SelectedOption.OptionText == (SelectedTest.Questions.ToList())[CurrentQuestion].CorrectAnswer) { TotalTestMark += (SelectedTest.Questions.ToList())[CurrentQuestion].QuestionMark; } CurrentQuestion++; if (CurrentQuestion <= SelectedTest.Questions.Count() - 1) { _ = UpdateQuestion(); } else { ListVisibility = Visibility.Visible; DescriptionVisibility = Visibility.Visible; MainVisibility = Visibility.Collapsed; CreateQuestionVisibility = Visibility.Visible; CurrentQuestion = 0; TestResult newTestResult = new TestResult() { Mark = TotalTestMark * 100 / SelectedTest.TotalMark }; ITestResultService service = new TestResultService(); await service.CreatePersonalTestResult(CurrentAccount.Id, SelectedTest.TestName, newTestResult); } }
public void IgnoresTestFailureDurationsWithoutTestId() { var utcNow = DateTime.UtcNow; var latestTestResultDtos = new List <LatestTestResultDto> { new LatestTestResultDto { SuiteId = 1, TestId = 2, PassingFromDate = utcNow, } }; var mockLatestTestResultsService = new Mock <ILatestTestResultService>(); mockLatestTestResultsService.Setup(s => s.Get(1)).Returns(latestTestResultDtos); var testFailureDurationDtos = new List <TestFailureDurationDto> { new TestFailureDurationDto { SuiteId = 1, TestId = 99, FailureEnd = utcNow } }; var mockTestFailureDurationService = new Mock <ITestFailureDurationService>(); mockTestFailureDurationService.Setup(f => f.GetAll()).Returns(testFailureDurationDtos); var testResultService = new TestResultService(new Mock <IDbContext>().Object, mockLatestTestResultsService.Object, mockTestFailureDurationService.Object, new Mock <ISuiteService>().Object); var latestTestResults = testResultService.GetLatest(1).ToList(); Assert.AreEqual(1, latestTestResults.Count); Assert.AreEqual(0, latestTestResults[0].TestFailureDurations.Count()); }
public void GetsTestFailureDurationsWithStartDateOutside24Hours() { var utcNow = DateTime.UtcNow; var latestTestResultDtos = new List <LatestTestResultDto> { new LatestTestResultDto { SuiteId = 1, TestId = 2, PassingFromDate = utcNow, } }; var mockLatestTestResultsService = new Mock <ILatestTestResultService>(); mockLatestTestResultsService.Setup(s => s.Get(1)).Returns(latestTestResultDtos); var testFailureDurationDtos = new List <TestFailureDurationDto> { new TestFailureDurationDto { SuiteId = 1, TestId = 2, FailureStart = utcNow.AddHours(-48), FailureEnd = utcNow.AddHours(-23) } }; var mockTestFailureDurationService = new Mock <ITestFailureDurationService>(); mockTestFailureDurationService.Setup(f => f.GetAll()).Returns(testFailureDurationDtos); var testResultService = new TestResultService(new Mock <IDbContext>().Object, mockLatestTestResultsService.Object, mockTestFailureDurationService.Object, new Mock <ISuiteService>().Object); var latestTestResults = testResultService.GetLatest(1).ToList(); Assert.AreEqual(1, latestTestResults.Count); Assert.AreEqual(1, latestTestResults[0].TestFailureDurations.Count()); Assert.AreEqual(utcNow.AddHours(-48), latestTestResults[0].TestFailureDurations.ToList()[0].FailureStart); Assert.AreEqual(utcNow.AddHours(-23), latestTestResults[0].TestFailureDurations.ToList()[0].FailureEnd); }
private CompoundResultReading <decimal?> CreateTestReadingforaDecimalValue(CustomerEventReadingEntity testReadingEntity, int readingId, List <StandardFindingTestReadingEntity> standardFindingTestReadingEntities, decimal?value) { StandardFindingTestReadingEntity standardFindingTestReading = null; if (testReadingEntity.StandardFindingTestReadingId != null) { standardFindingTestReading = standardFindingTestReadingEntities.Find(standardFindingTestReadingEntity => (standardFindingTestReadingEntity.ReadingId == readingId) && (testReadingEntity.StandardFindingTestReadingId == standardFindingTestReadingEntity.StandardFindingTestReadingId) ); } var testReading = new CompoundResultReading <decimal?>(testReadingEntity.CustomerEventReadingId) { Label = (ReadingLabels)readingId, Reading = value, ReadingSource = testReadingEntity.IsManual ? ReadingSource.Manual : ReadingSource.Automatic, RecorderMetaData = new DataRecorderMetaData { DataRecorderCreator = new OrganizationRoleUser(testReadingEntity.CreatedByOrgRoleUserId), DateCreated = testReadingEntity.CreatedOn, DataRecorderModifier = testReadingEntity.UpdatedByOrgRoleUserId.HasValue ? new OrganizationRoleUser(testReadingEntity.UpdatedByOrgRoleUserId.Value) : null, DateModified = testReadingEntity.UpdatedOn } }; decimal testReadingValue = 0; var allFindings = new TestResultService().GetAllStandardFindings <decimal?>((int)TestType.Hemoglobin, readingId); if (testReadingEntity.Value != null && decimal.TryParse(testReadingEntity.Value, out testReadingValue)) { var findings = (new TestResultService()).GetMultipleCalculatedStandardFinding(decimal.Round(testReadingValue, 1), (int)TestType.Hemoglobin, readingId); var finding = findings.FirstOrDefault(); if (findings.Count() == 1) { testReading.Finding = new StandardFinding <decimal?>(Convert.ToInt64(testReadingEntity.StandardFindingTestReadingId == null ? finding : standardFindingTestReading.StandardFindingId)); } else if (findings.Count() > 1) { var avFindings = allFindings.FindAll(f => f.Label.ToLower().IndexOf(_toCheckFor) == 0); finding = findings.FirstOrDefault(f => avFindings.Select(av => av.Id).Contains(f)); testReading.Finding = new StandardFinding <decimal?>(Convert.ToInt64(testReadingEntity.StandardFindingTestReadingId == null ? finding : standardFindingTestReading.StandardFindingId)); } } else if (testReadingEntity.StandardFindingTestReadingId != null) { testReading.Finding = new StandardFinding <decimal?>(standardFindingTestReading.StandardFindingId); } if (testReading.Finding != null) { testReading.Finding = allFindings.Find(standardFinding => standardFinding.Id == testReading.Finding.Id); } return(testReading); }
public void SingleTestResultZeroFailures() { var utcNow = DateTime.UtcNow; var latestTestResultDtos = new List <LatestTestResultDto> { new LatestTestResultDto { SuiteId = 1, TestResultID = 2, TestName = "test1", SuiteName = "suite-name", PassingFromDate = utcNow, } }; var mockLatestTestResultsService = new Mock <ILatestTestResultService>(); mockLatestTestResultsService.Setup(s => s.Get(1)).Returns(latestTestResultDtos); var mockTestFailureDurationService = new Mock <ITestFailureDurationService>(); mockTestFailureDurationService.Setup(f => f.GetAll()).Returns(new List <TestFailureDurationDto>()); var testResultService = new TestResultService(new Mock <IDbContext>().Object, mockLatestTestResultsService.Object, mockTestFailureDurationService.Object, new Mock <ISuiteService>().Object); var actualLatestTestResults = testResultService.GetLatest(1).ToList(); Assert.AreEqual(1, actualLatestTestResults.Count); Assert.AreEqual(2, actualLatestTestResults[0].TestResultID); Assert.AreEqual("test1", actualLatestTestResults[0].TestName); Assert.AreEqual("suite-name", actualLatestTestResults[0].SuiteName); Assert.AreEqual(utcNow, actualLatestTestResults[0].PassingFromDate); Assert.IsNull(actualLatestTestResults[0].FailingFromDate); Assert.AreEqual(0, actualLatestTestResults[0].TestFailureDurations.ToList().Count); }
public static decimal?GetFraminghamRisk(int age, bool isGenderMale, int?totalCholestrol, int hdl, int?ldl, int systolic, int diastolic, bool isSmoker, bool isDiabetic) { var testResultService = new TestResultService(); return(testResultService.GetFraminghamRisk(age, isGenderMale, totalCholestrol, hdl, ldl, systolic, diastolic, isSmoker, isDiabetic)); }
private void SetHraInfo(long eventId, long customerId, DateTime eventDate, CorporateAccount account) { var settings = IoC.Resolve <ISettings>(); QuestionnaireType questionnaireType = QuestionnaireType.None; if (account != null && account.IsHealthPlan) { var accountHraChatQuestionnaireHistoryServices = IoC.Resolve <IAccountHraChatQuestionnaireHistoryServices>(); questionnaireType = accountHraChatQuestionnaireHistoryServices.QuestionnaireTypeByAccountIdandEventDate(account.Id, eventDate); } if (account != null && account.IsHealthPlan && (questionnaireType == QuestionnaireType.HraQuestionnaire)) { var testResultService = new TestResultService(); IsEawvPurchased = testResultService.IsTestPurchasedByCustomer(eventId, customerId, (long)TestType.eAWV); CorporateAccountTag = account.Tag; var sessionContext = IoC.Resolve <ISessionContext>(); HraQuestionerAppUrl = settings.HraQuestionerAppUrl; OrganizationNameForHraQuestioner = settings.OrganizationNameForHraQuestioner; HraToken = (Session.SessionID + "_" + sessionContext.UserSession.UserId + "_" + sessionContext.UserSession.CurrentOrganizationRole.RoleId + "_" + sessionContext.UserSession.CurrentOrganizationRole.OrganizationId).Encrypt(); ChatQuestionerAppUrl = string.Empty; } else if (account != null && (questionnaireType == QuestionnaireType.ChatQuestionnaire)) { ChatQuestionerAppUrl = settings.ChatQuestionerAppUrl; HraQuestionerAppUrl = string.Empty; } }
public async Task UsersWithTheSamePointArePlacedByTimeOffset() { //Arrange TestResultServiceTestBase testBase = new TestResultServiceTestBase(); TestResultRepository testResultRepository = await testBase.GetTestResultRepositoryAsync(); var service = new TestResultService(testResultRepository, new CorrectAnswerPointsRule(), new BonusPointsRule(), new AnsweringTimePlaceRule()); //Act service.CalculateWeeklyResults(1); var results = testResultRepository.GetFinalResults(); //Assert Assert.Equal( results.Where(x => x.UserId == UserModel.userD.Id).Select(x => x.Week1Points).FirstOrDefault(), results.Where(x => x.UserId == UserModel.userC.Id).Select(x => x.Week1Points).FirstOrDefault()); Assert.Equal( 2, results.Where(x => x.UserId == UserModel.userC.Id).Select(x => x.Week1Place).FirstOrDefault()); Assert.Equal( 1, results.Where(x => x.UserId == UserModel.userD.Id).Select(x => x.Week1Place).FirstOrDefault()); }
public override TestResult CreateActualTestResult(CustomerEventScreeningTestsEntity customerEventScreeningTestEntity) { var customerEventReadingEntities = customerEventScreeningTestEntity.CustomerEventReading.ToList(); var testResult = new HPyloriTestResult(customerEventScreeningTestEntity.CustomerEventScreeningTestId); var customerEventTestStandardFindingEntities = customerEventScreeningTestEntity.CustomerEventTestStandardFinding.ToList(); var standardFindingTestReadingEntities = customerEventScreeningTestEntity.StandardFindingTestReadingCollectionViaCustomerEventTestStandardFinding.ToList(); if (customerEventTestStandardFindingEntities.Any()) { var testResultService = new TestResultService(); var standardFindings = testResultService.GetAllStandardFindings <int?>((int)TestType.HPylori); customerEventTestStandardFindingEntities.ForEach(customerEventTestStandardFindingEntity => { var standardFindingTestReadingEntity = standardFindingTestReadingEntities.Find(entity => entity.StandardFindingTestReadingId == customerEventTestStandardFindingEntity.StandardFindingTestReadingId); if (standardFindingTestReadingEntity == null) { return; } var finding = CreateFindingObject(customerEventTestStandardFindingEntity, standardFindings, standardFindingTestReadingEntity, null); if (finding != null) { testResult.Finding = finding; return; } }); } testResult.TechnicallyLimitedbutReadable = CreateResultReading((int)ReadingLabels.TechnicallyLimitedbutReadable, customerEventReadingEntities); testResult.RepeatStudy = CreateResultReading((int)ReadingLabels.RepeatStudy, customerEventReadingEntities); return(testResult); }
public void GroupsMultipleSuites() { var utcNow = DateTime.UtcNow; var suiteDto = new SuiteDto { SuiteID = 1, ApplicationId = 4, EnvironmentId = 3 }; var suiteDtos = new List <SuiteDto> { suiteDto, new SuiteDto { SuiteID = 5, ApplicationId = 4, EnvironmentId = 3 } }; var mockSuiteService = new Mock <ISuiteService>(); mockSuiteService.Setup(s => s.Get(1)).Returns(suiteDto); mockSuiteService.Setup(s => s.GetAll()).Returns(suiteDtos); var latestTestResultDtos = new List <LatestTestResultDto> { new LatestTestResultDto { SuiteId = 1, TestResultID = 2, TestName = "test1", PassingFromDate = utcNow, }, new LatestTestResultDto { SuiteId = 5, TestResultID = 6, TestName = "test2", FailingFromDate = utcNow, } }; var mockLatestTestResultsService = new Mock <ILatestTestResultService>(); mockLatestTestResultsService.Setup(s => s.Get(new int[] { 1, 5 })).Returns(latestTestResultDtos); var mockTestFailureDurationService = new Mock <ITestFailureDurationService>(); mockTestFailureDurationService.Setup(f => f.GetAll()).Returns(new List <TestFailureDurationDto>()); var testResultService = new TestResultService(new Mock <IDbContext>().Object, mockLatestTestResultsService.Object, mockTestFailureDurationService.Object, mockSuiteService.Object); var actualLatestTestResults = testResultService.GetLatestGrouped(1).OrderBy(l => l.TestResultID).ToList(); Assert.AreEqual(2, actualLatestTestResults.Count); Assert.AreEqual(2, actualLatestTestResults[0].TestResultID); Assert.AreEqual("test1", actualLatestTestResults[0].TestName); Assert.AreEqual(utcNow, actualLatestTestResults[0].PassingFromDate); Assert.IsNull(actualLatestTestResults[0].FailingFromDate); Assert.AreEqual(0, actualLatestTestResults[0].TestFailureDurations.ToList().Count); Assert.AreEqual(6, actualLatestTestResults[1].TestResultID); Assert.AreEqual("test2", actualLatestTestResults[1].TestName); Assert.AreEqual(utcNow, actualLatestTestResults[1].FailingFromDate); Assert.IsNull(actualLatestTestResults[1].PassingFromDate); Assert.AreEqual(0, actualLatestTestResults[1].TestFailureDurations.ToList().Count); }
public async Task <ActionResult> ModeratorCourseTestResults(int?courseId, string userEmail) { try { // I. Checks. // Get course Id for the selected course and check User email. if (!int.TryParse(courseId.ToString(), out int intCourseId) && userEmail != null) { return(RedirectToAction("Index")); } // Get CourseDTO object. CourseDTO courseDTO = await CourseService.GetAsync(intCourseId); if (courseDTO == null) { return(RedirectToAction("Index")); } // II. Set ViewBag properties. ViewBag.CourseTitle = courseDTO.CourseTitle; ViewBag.ParentId = intCourseId; ViewBag.Trainee = userEmail; // III. AutoMapper Setup. var config = new MapperConfiguration(cfg => { cfg.CreateMap <TestResultDTO, TestResultViewModel>() .ForMember("Id", opt => opt.MapFrom(tr => tr.TestResultId)) .ForMember("TestTitle", opt => opt.MapFrom(tr => tr.TestResultDetails.FirstOrDefault().Question.Topic.Course.CourseTitle)) .ForMember("UserEmail", opt => opt.MapFrom(tr => tr.UserProfile.Email)); cfg.CreateMap <TestResultDetailDTO, TestResultDetailViewModel>() .ForMember("Question", opt => opt.MapFrom(trd => trd.Question.QuestionText)) .ForMember("Topic", opt => opt.MapFrom(trd => trd.Question.Topic.TopicTitle)); }); IMapper iMapper = config.CreateMapper(); // IV. Get data for a view. IEnumerable <SubscriptionDTO> courseSubscriptions = SubscriptionService.Find(dto => dto.CourseId == intCourseId && dto.Email == userEmail); IEnumerable <TestResultDTO> source = TestResultService.Find(tr => !tr.IsTopicTest) .Where(tr => tr.TestResultDetails.FirstOrDefault().Question.Topic.CourseId == intCourseId) .Join(courseSubscriptions, tr => tr.UserProfileId, cs => cs.UserProfileId, (tr, cs) => tr).Distinct(); //.ToList(); IEnumerable <TestResultViewModel> courseTestResults = iMapper.Map <IEnumerable <TestResultDTO>, IEnumerable <TestResultViewModel> >(source); // V. Session["PreviousAction"] = "ModeratorCourseTestResults"; Session["UserEmail"] = userEmail; return(View(courseTestResults)); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task <ActionResult> ModeratorTopicTestResults(int?courseId, string userEmail) { try { // I. Checks. if (userEmail == null) { return(RedirectToAction("Login", "Account")); } string userId = UserService.FindUserIdByEmail(userEmail); // Check id. if (!int.TryParse(courseId.ToString(), out int intCourseId)) { return(RedirectToAction("Index")); } // II. Set ViewBag properties. ViewBag.UserName = (await UserService.GetAsync(userId)).UserName; // Get CourseDTO object. CourseDTO courseDTO = await CourseService.GetAsync(intCourseId); ViewBag.CourseTitle = courseDTO.CourseTitle; ViewBag.ParentId = intCourseId; ViewBag.Trainee = userEmail; // III. AutoMapper Setup. var config = new MapperConfiguration(cfg => { cfg.CreateMap <TestResultDTO, TestResultViewModel>() .ForMember("Id", opt => opt.MapFrom(tr => tr.TestResultId)) .ForMember("TestTitle", opt => opt.MapFrom(tr => tr.TestResultDetails.FirstOrDefault().Question.Topic.TopicTitle)) .ForMember(tr => tr.TestResultDetails, option => option.Ignore()) .ForMember(tr => tr.UserEmail, option => option.Ignore()); }); IMapper iMapper = config.CreateMapper(); //IV.Get data for a View. IEnumerable <TestResultDTO> testResultDTOs = TestResultService.Find(tr => tr.UserProfileId == userId && tr.IsTopicTest); IEnumerable <TestResultDTO> source = TestResultService.Find(tr => tr.UserProfileId == userId && tr.IsTopicTest) .Where(course => course.TestResultDetails.FirstOrDefault().Question.Topic.CourseId == intCourseId); //.ToList(); IEnumerable <TestResultViewModel> testResults = iMapper.Map <IEnumerable <TestResultDTO>, IEnumerable <TestResultViewModel> >(source).OrderBy(tr => tr.TestTitle); // V. Session["PreviousAction"] = "ModeratorTopicTestResults"; Session["UserEmail"] = userEmail; return(View(testResults)); } catch (Exception ex) { string innerException = string.Empty; if (ex.InnerException != null) { innerException = ex.InnerException.Message; } throw new Exception("Error!!! InnerException: " + innerException + "; " + ex.Message); } }
// GET: CourseTestResults public async Task <ActionResult> CourseTestResults(int?id) { try { // I. Checks. string currentUserId = System.Web.HttpContext.Current.User.Identity.GetUserId(); if (currentUserId == null) { return(RedirectToAction("Login", "Account")); } // Check id. if (!int.TryParse(id.ToString(), out int intId)) { return(RedirectToAction("Index")); } // Get CourseDTO object. CourseDTO courseDTO = await CourseService.GetAsync(intId); if (courseDTO == null) { return(RedirectToAction("Index")); } // II. Set ViewBag properties. ViewBag.UserName = (await UserService.GetAsync(currentUserId)).UserName; ViewBag.CourseTitle = courseDTO.CourseTitle; // III. AutoMapper Setup. var config = new MapperConfiguration(cfg => { cfg.CreateMap <TestResultDTO, TestResultViewModel>() .ForMember("Id", opt => opt.MapFrom(tr => tr.TestResultId)) .ForMember("TestTitle", opt => opt.MapFrom(tr => tr.TestResultDetails.FirstOrDefault().Question.Topic.Course.CourseTitle)) .ForMember(tr => tr.TestResultDetails, option => option.Ignore()) .ForMember(tr => tr.UserEmail, option => option.Ignore()); }); IMapper iMapper = config.CreateMapper(); // IV. Get data for a View. IEnumerable <TestResultDTO> source = TestResultService.Find(tr => tr.UserProfileId == currentUserId && !tr.IsTopicTest); //.ToList(); IEnumerable <TestResultViewModel> courseTestResultList = iMapper.Map <IEnumerable <TestResultDTO>, IEnumerable <TestResultViewModel> >(source) .Where(tr => tr.TestTitle == courseDTO.CourseTitle) .OrderBy(tr => tr.TestTitle); // V. Session["PreviousAction"] = "CourseTestResults"; Session["UserEmail"] = null; return(View(courseTestResultList)); } catch (Exception ex) { throw new Exception(ex.Message); } }
public override TestResult CreateActualTestResult(CustomerEventScreeningTestsEntity customerEventScreeningTestEntity) { var customerEventReadingEntities = customerEventScreeningTestEntity.CustomerEventReading.ToList(); var testResult = new DpnTestResult(customerEventScreeningTestEntity.CustomerEventScreeningTestId); if (customerEventScreeningTestEntity.TestMedia != null && customerEventScreeningTestEntity.TestMedia.Count > 0) { var fileEntityCollection = customerEventScreeningTestEntity.FileCollectionViaTestMedia.ToList(); var testMediaEntity = customerEventScreeningTestEntity.TestMedia.FirstOrDefault(); testResult.ResultImage = new ResultMedia(testMediaEntity.MediaId) { File = GetFileObjectfromEntity(testMediaEntity.FileId, fileEntityCollection), Thumbnail = testMediaEntity.ThumbnailFileId != null ? new File(testMediaEntity.ThumbnailFileId.Value) : null, ReadingSource = testMediaEntity.IsManual ? ReadingSource.Manual : ReadingSource.Automatic }; } var customerEventTestStandardFindingEntities = customerEventScreeningTestEntity.CustomerEventTestStandardFinding.ToList(); var standardFindingTestReadingEntities = customerEventScreeningTestEntity.StandardFindingTestReadingCollectionViaCustomerEventTestStandardFinding.ToList(); if (customerEventTestStandardFindingEntities.Count() > 0) { var testResultService = new TestResultService(); var standardFindings = testResultService.GetAllStandardFindings <int?>((int)TestType.DPN); customerEventTestStandardFindingEntities.ForEach(customerEventTestStandardFindingEntity => { var standardFindingTestReadingEntity = standardFindingTestReadingEntities.Find(entity => entity.StandardFindingTestReadingId == customerEventTestStandardFindingEntity.StandardFindingTestReadingId); if (standardFindingTestReadingEntity == null) { return; } var finding = CreateFindingObject(customerEventTestStandardFindingEntity, standardFindings, standardFindingTestReadingEntity, null); if (finding != null) { testResult.Finding = finding; return; } }); } testResult.Amplitude = CreateResultReadingforNullableDecimal((int)ReadingLabels.DpnAmplitude, customerEventReadingEntities); testResult.ConductionVelocity = CreateResultReadingforNullableDecimal((int)ReadingLabels.DpnConductionVelocity, customerEventReadingEntities); testResult.RightLeg = CreateResultReadingforNullableBool((int)ReadingLabels.DpnRightLeg, customerEventReadingEntities); testResult.LeftLeg = CreateResultReadingforNullableBool((int)ReadingLabels.DpnLeftLeg, customerEventReadingEntities); testResult.TechnicallyLimitedbutReadable = CreateResultReading((int)ReadingLabels.TechnicallyLimitedbutReadable, customerEventReadingEntities); testResult.RepeatStudy = CreateResultReading((int)ReadingLabels.RepeatStudy, customerEventReadingEntities); return(testResult); }
public override TestResult CreateActualTestResult(CustomerEventScreeningTestsEntity customerEventScreeningTestEntity) { var customerEventReadingEntities = customerEventScreeningTestEntity.CustomerEventReading.ToList(); var testResult = new MedicareTestResult(customerEventScreeningTestEntity.CustomerEventScreeningTestId); var customerEventTestStandardFindingEntities = customerEventScreeningTestEntity.CustomerEventTestStandardFinding.ToList(); var standardFindingTestReadingEntities = customerEventScreeningTestEntity.StandardFindingTestReadingCollectionViaCustomerEventTestStandardFinding.ToList(); if (customerEventTestStandardFindingEntities.Count() > 0) { var testResultService = new TestResultService(); var standardFindings = testResultService.GetAllStandardFindings <int?>((int)TestType.Medicare); customerEventTestStandardFindingEntities.ForEach(customerEventTestStandardFindingEntity => { var standardFindingTestReadingEntity = standardFindingTestReadingEntities.Find(entity => entity.StandardFindingTestReadingId == customerEventTestStandardFindingEntity.StandardFindingTestReadingId); if (standardFindingTestReadingEntity == null) { return; } var finding = CreateFindingObject(customerEventTestStandardFindingEntity, standardFindings, standardFindingTestReadingEntity, null); if (finding != null) { testResult.Finding = finding; return; } }); } var testMediaCollection = customerEventScreeningTestEntity.TestMedia.ToList(); var fileEntityCollection = customerEventScreeningTestEntity.FileCollectionViaTestMedia.ToList(); if (testMediaCollection.Count > 0) { var resultMedia = new List <ResultMedia>(); testMediaCollection.ForEach(testMedia => resultMedia.Add(new ResultMedia(testMedia.MediaId) { File = GetFileObjectfromEntity(testMedia.FileId, fileEntityCollection), Thumbnail = testMedia.ThumbnailFileId != null ? new File(testMedia.ThumbnailFileId.Value) : null, ReadingSource = testMedia.IsManual ? ReadingSource.Manual : ReadingSource.Automatic })); testResult.ResultImages = resultMedia; } testResult.TechnicallyLimitedbutReadable = CreateResultReading((int)ReadingLabels.TechnicallyLimitedbutReadable, customerEventReadingEntities); testResult.RepeatStudy = CreateResultReading((int)ReadingLabels.RepeatStudy, customerEventReadingEntities); return(testResult); }
public FormMain() { InitializeComponent(); lblOperatorName.Text = Program.CurrentUser.OperatorName; lblLineID.Text = $"LINE #{Program.CurrentUser.LineID}"; testLogService = new TestLogService(); modelsService = new ModelsService(); testResultService = new TestResultService(); dataGridViewX1.AutoGenerateColumns = false; txtBarcode.Focus(); }
public async Task GetPersonalTestResults() { ITestResultService service = new TestResultService(); PersonalTestResults = await service.GetPersonalTestResults(CurrentAccount, SelectedSeries); Points = new List <DataPoint>(); for (int i = 0; i < PersonalTestResults.Count; i++) { Points.Add(new DataPoint(i, PersonalTestResults[i].Mark)); } MaximumY = PersonalTestResults.Count - 1; }
public override TestResult CreateActualTestResult(CustomerEventScreeningTestsEntity customerEventScreeningTestEntity) { var customerEventReadingEntities = customerEventScreeningTestEntity.CustomerEventReading.ToList(); var testResult = new UrineMicroalbuminTestResult(customerEventScreeningTestEntity.CustomerEventScreeningTestId); testResult.SerialKey = CreateResultReadingforInputValues((int)ReadingLabels.MicroalbuminSerialKey, customerEventReadingEntities); testResult.MicroalbuminValue = CreateResultReadingforString((int)ReadingLabels.MicroalbuminValue, customerEventReadingEntities); if (customerEventScreeningTestEntity.TestMedia != null && customerEventScreeningTestEntity.TestMedia.Count > 0) { var fileEntityCollection = customerEventScreeningTestEntity.FileCollectionViaTestMedia.ToList(); var testMediaEntity = customerEventScreeningTestEntity.TestMedia.FirstOrDefault(); testResult.ResultImage = new ResultMedia(testMediaEntity.MediaId) { File = GetFileObjectfromEntity(testMediaEntity.FileId, fileEntityCollection), Thumbnail = testMediaEntity.ThumbnailFileId != null ? new File(testMediaEntity.ThumbnailFileId.Value) : null, ReadingSource = testMediaEntity.IsManual ? ReadingSource.Manual : ReadingSource.Automatic }; } var customerEventTestStandardFindingEntities = customerEventScreeningTestEntity.CustomerEventTestStandardFinding.ToList(); var standardFindingTestReadingEntities = customerEventScreeningTestEntity.StandardFindingTestReadingCollectionViaCustomerEventTestStandardFinding.ToList(); if (customerEventTestStandardFindingEntities.Any()) { var testResultService = new TestResultService(); var standardFindings = testResultService.GetAllStandardFindings <int?>((int)TestType.UrineMicroalbumin); customerEventTestStandardFindingEntities.ForEach(customerEventTestStandardFindingEntity => { var standardFindingTestReadingEntity = standardFindingTestReadingEntities.Find(entity => entity.StandardFindingTestReadingId == customerEventTestStandardFindingEntity.StandardFindingTestReadingId); if (standardFindingTestReadingEntity == null) { return; } var finding = CreateFindingObject(customerEventTestStandardFindingEntity, standardFindings, standardFindingTestReadingEntity, null); if (finding != null) { testResult.Finding = finding; return; } }); } testResult.TechnicallyLimitedbutReadable = CreateResultReading((int)ReadingLabels.TechnicallyLimitedbutReadable, customerEventReadingEntities); testResult.RepeatStudy = CreateResultReading((int)ReadingLabels.RepeatStudy, customerEventReadingEntities); return(testResult); }
// Topic test result details list. public async Task <ActionResult> TopicTestResultDetails(int?id) { try { // I.Checks. // Check id. if (!int.TryParse(id.ToString(), out int intId)) { return(RedirectToAction("Index")); } // Get TestResultDTO object. TestResultDTO testResultDTO = await TestResultService.GetAsync(intId); if (testResultDTO == null) { return(RedirectToAction("Index")); } // II. AutoMapper Setup. var config = new MapperConfiguration(cfg => { cfg.CreateMap <TestResultDTO, TestResultViewModel>() .ForMember("Id", opt => opt.MapFrom(tr => tr.TestResultId)) .ForMember("TestTitle", opt => opt.MapFrom(tr => tr.TestResultDetails.FirstOrDefault().Question.Topic.TopicTitle)) .ForMember(tr => tr.UserEmail, option => option.Ignore()); cfg.CreateMap <TestResultDetailDTO, TestResultDetailViewModel>() .ForMember("Question", opt => opt.MapFrom(trd => trd.Question.QuestionText)) .ForMember("Topic", opt => opt.MapFrom(trd => trd.Question.Topic.TopicTitle)); }); IMapper iMapper = config.CreateMapper(); // III. Set ViewBag properties. TestResultViewModel testResult = iMapper.Map <TestResultDTO, TestResultViewModel>(testResultDTO); ViewBag.CourseName = testResultDTO.TestResultDetails.FirstOrDefault().Question.Topic.Course.CourseTitle; ViewBag.TopicName = testResultDTO.TestResultDetails.FirstOrDefault().Question.Topic.TopicTitle; ViewBag.Result = testResult.Result * 1000 / testResult.MaxScore; ViewBag.MaxScore = 1000; ViewBag.ParentId = testResultDTO.TestResultDetails.FirstOrDefault().Question.Topic.CourseId; // IV. Get data for a view. IEnumerable <TestResultDetailDTO> source = TestResultDetailService.Find(trd => trd.TestResultId == intId);//.ToList(); IEnumerable <TestResultDetailViewModel> testResultDetailList = iMapper.Map <IEnumerable <TestResultDetailDTO>, IEnumerable <TestResultDetailViewModel> >(source).OrderBy(trd => trd.Topic); // V. return(View(testResultDetailList)); } catch (Exception ex) { throw new Exception(ex.Message); } }
public void SortsByFailingTheLongestThenPassingTheShortest() { var utcNow = DateTime.UtcNow; var latestTestResultDtos = new List <LatestTestResultDto> { new LatestTestResultDto { SuiteId = 1, TestResultID = 2, TestName = "test passing the longest", PassingFromDate = new DateTime(2018, 3, 1, 1, 00, 00), }, new LatestTestResultDto { SuiteId = 1, TestResultID = 3, TestName = "test failing the longest", FailingFromDate = new DateTime(2018, 3, 1, 1, 00, 00), }, new LatestTestResultDto { SuiteId = 1, TestResultID = 4, TestName = "test passing the shortest", PassingFromDate = new DateTime(2018, 3, 1, 1, 01, 00), }, new LatestTestResultDto { SuiteId = 1, TestResultID = 5, TestName = "test failing the shortest", FailingFromDate = new DateTime(2018, 3, 1, 1, 01, 00), } }; var mockLatestTestResultsService = new Mock <ILatestTestResultService>(); mockLatestTestResultsService.Setup(s => s.Get(1)).Returns(latestTestResultDtos); var mockTestFailureDurationService = new Mock <ITestFailureDurationService>(); mockTestFailureDurationService.Setup(f => f.GetAll()).Returns(new List <TestFailureDurationDto>()); var testResultService = new TestResultService(new Mock <IDbContext>().Object, mockLatestTestResultsService.Object, mockTestFailureDurationService.Object, new Mock <ISuiteService>().Object); var actualLatestTestResults = testResultService.GetLatest(1).ToList(); Assert.AreEqual(4, actualLatestTestResults.Count); Assert.AreEqual("test failing the longest", actualLatestTestResults[0].TestName); Assert.AreEqual("test failing the shortest", actualLatestTestResults[1].TestName); Assert.AreEqual("test passing the shortest", actualLatestTestResults[2].TestName); Assert.AreEqual("test passing the longest", actualLatestTestResults[3].TestName); }
public override TestResult CreateActualTestResult(CustomerEventScreeningTestsEntity customerEventScreeningTestEntity) { var customerEventReadingEntities = customerEventScreeningTestEntity.CustomerEventReading.ToList(); var testResult = new QualityMeasuresTestResult(customerEventScreeningTestEntity.CustomerEventScreeningTestId); var customerEventTestStandardFindingEntities = customerEventScreeningTestEntity.CustomerEventTestStandardFinding.ToList(); var standardFindingTestReadingEntities = customerEventScreeningTestEntity.StandardFindingTestReadingCollectionViaCustomerEventTestStandardFinding.ToList(); if (customerEventTestStandardFindingEntities.Any()) { var testResultService = new TestResultService(); var functionalAssessmentScore = testResultService.GetAllStandardFindings <int?>((int)TestType.QualityMeasures, (int)ReadingLabels.FunctionalAssessmentScore); var painAssessmentScore = testResultService.GetAllStandardFindings <int?>((int)TestType.QualityMeasures, (int)ReadingLabels.PainAssessmentScore); customerEventTestStandardFindingEntities.ForEach(customerEventTestStandardFindingEntity => { var standardFindingTestReadingEntity = standardFindingTestReadingEntities.Find(entity => entity.StandardFindingTestReadingId == customerEventTestStandardFindingEntity.StandardFindingTestReadingId); if (standardFindingTestReadingEntity == null) { return; } var finding = CreateFindingObject(customerEventTestStandardFindingEntity, functionalAssessmentScore, standardFindingTestReadingEntity, (int)ReadingLabels.FunctionalAssessmentScore); if (finding != null) { testResult.FunctionalAssessmentScore = finding; return; } finding = CreateFindingObject(customerEventTestStandardFindingEntity, painAssessmentScore, standardFindingTestReadingEntity, (int)ReadingLabels.PainAssessmentScore); if (finding != null) { testResult.PainAssessmentScore = finding; return; } }); } testResult.MemoryRecallScore = CreateResultReadingforNullableInt((int)ReadingLabels.MemoryRecallScore, customerEventReadingEntities); testResult.ClockPass = CreateResultReading((int)ReadingLabels.ClockPass, customerEventReadingEntities); testResult.ClockFail = CreateResultReading((int)ReadingLabels.ClockFail, customerEventReadingEntities); testResult.GaitPass = CreateResultReading((int)ReadingLabels.GaitPass, customerEventReadingEntities); testResult.GaitFail = CreateResultReading((int)ReadingLabels.GaitFail, customerEventReadingEntities); testResult.TechnicallyLimitedbutReadable = CreateResultReading((int)ReadingLabels.TechnicallyLimitedbutReadable, customerEventReadingEntities); testResult.RepeatStudy = CreateResultReading((int)ReadingLabels.RepeatStudy, customerEventReadingEntities); return(testResult); }
public void UserWithTwoCorrectAnswersForOneTestInSecondWeekShouldHaveCalculatedResultsForJustFirstAnswer() { //Arrange var service = new TestResultService(testResultRepository, new CorrectAnswerPointsRule(), new BonusPointsRule(), new AnsweringTimePlaceRule(), GetTestSettings()); //Act service.CalculateWeeklyResults(2); var results = testResultRepository.GetFinalResults(); //Assert Assert.Equal( 130, results.FirstOrDefault(x => x.UserId == UserModel.userI.Id).Week2Points.Value); }
public void UserWithCorrectAnswerAfterRankingPerionShouldHaveZeroPoints() { //Arrange var service = new TestResultService(testResultRepository, new CorrectAnswerPointsRule(), new BonusPointsRule(), new AnsweringTimePlaceRule(), GetTestSettings()); //Act service.CalculateWeeklyResults(1); var results = testResultRepository.GetFinalResults(); //Assert Assert.Equal( 0, results.FirstOrDefault(x => x.UserId == UserModel.userI.Id).Week1Points.Value); }
public PhysicianPartnerResultExportFactory(ILogger logger, string destinationDirectory, ISettings settings) { _logger = logger; _destinationDirectory = destinationDirectory; _settings = settings; _testResultService = new TestResultService(); _eventRepository = new EventRepository(); _hostRepository = new HostRepository(); _organizationRepository = new OrganizationRepository(); _echoFactory = new PhysicianPartnerResultExportEchoFactory(); _aaaFactory = new PhysicianPartnerResultExportAaaFactory(); _leadFactory = new PhysicianPartnerResultExportLeadFactory(); _spiroFactory = new PhysicianPartnerResultExportSpiroFactory(); }
public override TestResult CreateActualTestResult(CustomerEventScreeningTestsEntity customerEventScreeningTestEntity) { var testResult = new PulmonaryFunctionTestResult(customerEventScreeningTestEntity.CustomerEventScreeningTestId); var customerEventTestStandardFindingEntities = customerEventScreeningTestEntity.CustomerEventTestStandardFinding.ToList(); var standardFindingTestReadingEntities = customerEventScreeningTestEntity.StandardFindingTestReadingCollectionViaCustomerEventTestStandardFinding.ToList(); if (customerEventTestStandardFindingEntities.Count() > 0) { var testResultService = new TestResultService(); var standardFindings = testResultService.GetAllStandardFindings <int?>((int)TestType.PulmonaryFunction); customerEventTestStandardFindingEntities.ForEach(customerEventTestStandardFindingEntity => { var standardFindingTestReadingEntity = standardFindingTestReadingEntities.Find(entity => entity.StandardFindingTestReadingId == customerEventTestStandardFindingEntity.StandardFindingTestReadingId); if (standardFindingTestReadingEntity == null) { return; } var finding = CreateFindingObject(customerEventTestStandardFindingEntity, standardFindings, standardFindingTestReadingEntity, null); if (finding != null) { testResult.Finding = finding; return; } }); } if (customerEventScreeningTestEntity.TestMedia != null && customerEventScreeningTestEntity.TestMedia.Count > 0) { var fileEntityCollection = customerEventScreeningTestEntity.FileCollectionViaTestMedia.ToList(); var testMediaEntity = customerEventScreeningTestEntity.TestMedia.FirstOrDefault(); testResult.ResultImage = new ResultMedia(testMediaEntity.MediaId) { File = GetFileObjectfromEntity(testMediaEntity.FileId, fileEntityCollection), Thumbnail = testMediaEntity.ThumbnailFileId != null ? new File(testMediaEntity.ThumbnailFileId.Value) : null, ReadingSource = testMediaEntity.IsManual ? ReadingSource.Manual : ReadingSource.Automatic }; } return(testResult); }
// private readonly string _destinationDirectory; public WellmedResultExportFactory(ILogger logger) { _logger = logger; _testResultService = new TestResultService(); _eventRepository = new EventRepository(); _hostRepository = new HostRepository(); _organizationRepository = new OrganizationRepository(); _awvAaaFactory = new PcpResultExportAwvAaaFactory(); _awvEchoFactory = new PcpResultExportAwvEchoFactory(); _awvCarotidFactory = new PcpResultExportAwvCarotidFactory(); _awvSpiroFactory = new PcpResultExportAwvSpiroFactory(); _awvAbiFactory = new PcpResultExportAwvAbiFactory(); _awvEkgFactory = new PcpResultExportAwvEkgFactory(); _visionFactory = new PcpResultExportVisionFactory(); _hypertensionFactory = new PcpResultExportHypertensionFactory(); }
public void ZeroTestResults() { var latestTestResultDtos = new List <LatestTestResultDto>(); var mockLatestTestResultsService = new Mock <ILatestTestResultService>(); mockLatestTestResultsService.Setup(s => s.Get(1)).Returns(latestTestResultDtos); var mockTestFailureDurationService = new Mock <ITestFailureDurationService>(); mockTestFailureDurationService.Setup(f => f.GetAll()).Returns(new List <TestFailureDurationDto>()); var testResultService = new TestResultService(new Mock <IDbContext>().Object, mockLatestTestResultsService.Object, mockTestFailureDurationService.Object, new Mock <ISuiteService>().Object); var actualLatestTestResults = testResultService.GetLatest(1).ToList(); Assert.AreEqual(0, actualLatestTestResults.Count); }
public void UsersWithAllCorrectAnswersAndNoWrongAnswersHaveMaximumPoints() { //Arrange var service = new TestResultService(testResultRepository, new CorrectAnswerPointsRule(), new BonusPointsRule(), new AnsweringTimePlaceRule(), GetTestSettings()); //Act service.CalculateWeeklyResults(1); var results = testResultRepository.GetFinalResults(); //Assert Assert.Equal( results.Where(x => x.UserId == UserModel.userD.Id).Select(x => x.Week1Points).FirstOrDefault(), 2 * (100 + 30)); Assert.Equal( results.Where(x => x.UserId == UserModel.userC.Id).Select(x => x.Week1Points).FirstOrDefault(), 2 * (100 + 30)); }
public async Task UserWithWrongAnswerButNoCorrectAnswerShouldHaveZeroPoints() { //Arrange TestResultServiceTestBase testBase = new TestResultServiceTestBase(); TestResultRepository testResultRepository = await testBase.GetTestResultRepositoryAsync(); var service = new TestResultService(testResultRepository, new CorrectAnswerPointsRule(), new BonusPointsRule(), new AnsweringTimePlaceRule()); //Act service.CalculateWeeklyResults(1); var results = testResultRepository.GetFinalResults(); //Assert Assert.Equal( 0, results.FirstOrDefault(x => x.UserId == UserModel.userE.Id).Week1Points.Value); }