private void RawScore_Unfocused(object sender, FocusEventArgs e) { if ((sender as Entry).BindingContext != null) { var testform = (sender as Entry).BindingContext as TestSessionModel; if (!string.IsNullOrEmpty(testform.RawScore)) { var bdi3ScoringParser = Bdi3ScoringParser.GetInstance(); var aescore = bdi3ScoringParser.GetAeFromRs(Convert.ToDouble(testform.RawScore), null, testform.Domain); testform.AE = aescore > 0 ? (aescore / 12 > 0 ? aescore / 12 + " yrs, " : "") + aescore % 12 + " mos" : "--"; var ss = bdi3ScoringParser.GetSsFromRs(Convert.ToDouble(testform.RawScore), testform.Domain, vM.commonDataService.TotalAgeinMonths); if (ss > ScoringParser.NO_SCORE) { testform.SS = ss.ToString(); testform.PR = bdi3ScoringParser.GetPrFromSs((double)ss)?.FirstOrDefault()?.StringValue; } else { testform.SS = "--"; testform.PR = "--"; } } else { testform.SS = ""; testform.PR = ""; testform.AE = ""; Focus(); } } }
private static void Main() { Bdi3ScoringParser parser; #if SERIALIZED_BUILD parser = Bdi3ScoringParser.GetInstance(); var res = parser.GetAeFromRs(12, "Communication", "Receptive Communication"); Console.WriteLine(9 == res); res = parser.GetAeFromRs(27, "Motor", "Gross Motor"); Console.WriteLine(8 == res); res = parser.GetAeFromRs(99, "Cognitive", "Perception and Concepts"); Console.WriteLine(95 == res); #else Bdi3ScoringParser parser; IFormatter formatter = new BinaryFormatter(); if (File.Exists("parserSerialized.bin")) { var readStream = new FileStream("parserSerialized.bin", FileMode.Open, FileAccess.Read, FileShare.None); parser = (Bdi3ScoringParser)formatter.Deserialize(readStream); readStream.Close(); var res = parser.GetAeFromRs(12, "Communication", "Receptive Communication"); Console.WriteLine(9 == res); res = parser.GetAeFromRs(27, "Motor", "Gross Motor"); Console.WriteLine(8 == res); res = parser.GetAeFromRs(99, "Cognitive", "Perception and Concepts"); Console.WriteLine(95 == res); } parser = new Bdi3ScoringParser(); Stream stream = new FileStream("parserSerialized.bin", FileMode.Create, FileAccess.Write, FileShare.None); formatter.Serialize(stream, parser); stream.Close(); //File.WriteAllText("scoringParserSerialized.json", JsonConvert.SerializeObject(parser, Formatting.Indented)); #endif }
public TestSessionOverViewModel(bool isReport = false) { IsDevelopmentalBasicReport = isReport; if (IsDevelopmentalBasicReport) { Title = "BDI-3 Developmental Complete Basic Report"; IsDateVisible = false; } else { Title = "Test Session Overview"; IsDateVisible = true; } commonDataService = DependencyService.Get <ICommonDataService>(); studentTestFormsService = DependencyService.Get <IStudentTestFormsService>(); LocalformInstanceId = commonDataService.LocaInstanceID; GetExaminerDetails(); clinicalTestFormService = DependencyService.Get <IClinicalTestFormService>(); ProgramLabel = "Select a program label"; GetProgramNotes(); if (IsDevelopmentalBasicReport) { if (ProgramLabel == "Select a program label") { ProgramLabel = string.Empty; } } var domains = default(List <ContentCategory>); if (commonDataService.IsCompleteForm) { domains = new List <ContentCategory>(commonDataService.BattleCategories); if (domains != null && domains.Any()) { var parentCategories = domains.Where(p => p.parentContentCategoryId == 0).OrderBy(p => p.sequenceNo); if (parentCategories != null && parentCategories.Any()) { var bdi3ScoringParser = Bdi3ScoringParser.GetInstance(); foreach (var parentCategory in parentCategories) { TestSessionRecords.Add(new TestSessionModel() { Domain = parentCategory.name, IsDateVisible = false }); var childCategories = domains.Where(p => p.parentContentCategoryId == parentCategory.contentCategoryId).OrderBy(p => p.sequenceNo); if (childCategories != null && childCategories.Any()) { foreach (var childCategory in childCategories) { var sessionmodel = new TestSessionModel() { ContentCategoryId = childCategory.contentCategoryId, ParentDomainCode = parentCategory.code, DomainCode = childCategory.code, LoadDomainBasedQuestionsAction = NavigateandRelaodQuestions, Domain = childCategory.name, TestDate = "mm/dd/yyyy", Examiner = "Select Examiner", Status = "Complete", IsDateVisible = true, DomainMargin = new Thickness(17, 0, 0, 0) }; if (commonDataService.StudentTestForms != null && commonDataService.StudentTestForms.Any()) { var testform = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == childCategory.contentCategoryId); if (testform != null) { sessionmodel.IsScoreSelected = testform.IsScoreSelected; sessionmodel.ContentCategoryId = childCategory.contentCategoryId; sessionmodel.TestDate = testform.testDate; sessionmodel.Notes = testform.Notes; sessionmodel.Status = testform.TSOStatus; sessionmodel.RawScore = testform.rawScore != null && testform.rawScore.HasValue ? testform.rawScore.Value.ToString() : ""; sessionmodel.PropertyChanged -= Sessionmodel_PropertyChanged; sessionmodel.PropertyChanged += Sessionmodel_PropertyChanged; sessionmodel.EnablerawScore = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == childCategory.contentCategoryId).rawScoreEnabled; if (testform.rawScore != null && testform.rawScore.HasValue) { var aescore = bdi3ScoringParser.GetAeFromRs(Convert.ToDouble(testform.rawScore), null, childCategory.name); sessionmodel.AE = aescore > 0 ? (aescore / 12 > 0 ? aescore / 12 + " yrs, " : "") + aescore % 12 + " mos" : "--"; var ss = bdi3ScoringParser.GetSsFromRs(Convert.ToDouble(testform.rawScore), childCategory.name, commonDataService.TotalAgeinMonths); if (ss > ScoringParser.NO_SCORE) { sessionmodel.SS = ss.ToString(); sessionmodel.PR = bdi3ScoringParser.GetPrFromSs((double)ss)?.FirstOrDefault()?.StringValue; } else { sessionmodel.SS = "--"; sessionmodel.PR = "--"; } } if (commonDataService.SearchStaffResponseModel != null && commonDataService.SearchStaffResponseModel.Any() && testform.examinerId != null && testform.examinerId.HasValue) { sessionmodel.ExaminerID = Convert.ToInt32(testform.examinerId); sessionmodel.Examiner = commonDataService.SearchStaffResponseModel.FirstOrDefault(p => p.UserID == testform.examinerId.Value.ToString()).FirstNameLastName; } } } TestSessionRecords.Add(sessionmodel); } } } bdi3ScoringParser = null; GC.Collect(); GC.Collect(); GC.SuppressFinalize(this); } } } else if (commonDataService.IsScreenerForm) { domains = new List <ContentCategory>(commonDataService.ScreenerCategories); foreach (var item in domains) { var sessionModel = new TestSessionModel() { ContentCategoryId = item.contentCategoryId, ParentDomainCode = item.code, DomainCode = item.code, Domain = item.name, TestDate = "mm/dd/yyyy", Examiner = "Select Examiner", Status = "Complete", RawScore = "23", IsDateVisible = true }; if (commonDataService.StudentTestForms != null && commonDataService.StudentTestForms.Any()) { var testform = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == item.contentCategoryId); if (testform != null) { sessionModel.IsScoreSelected = testform.IsScoreSelected; sessionModel.TestDate = testform.testDate; sessionModel.Notes = testform.Notes; sessionModel.Status = testform.TSOStatus; sessionModel.RawScore = testform.rawScore != null && testform.rawScore.HasValue ? testform.rawScore.Value.ToString() : ""; sessionModel.PropertyChanged -= Sessionmodel_PropertyChanged; sessionModel.PropertyChanged += Sessionmodel_PropertyChanged; sessionModel.EnablerawScore = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == item.contentCategoryId).rawScoreEnabled; if (commonDataService.SearchStaffResponseModel != null && commonDataService.SearchStaffResponseModel.Any() && testform.examinerId != null && testform.examinerId.HasValue) { sessionModel.ExaminerID = Convert.ToInt32(testform.examinerId); sessionModel.Examiner = commonDataService.SearchStaffResponseModel.FirstOrDefault(p => p.UserID == testform.examinerId.Value.ToString()).FirstNameLastName; } } } Records.Add(sessionModel); } } if (commonDataService.IsAcademicForm) { domains = domains = new List <ContentCategory>(commonDataService.AcademicCategories); var records = new List <TestSessionModel>(); if (domains != null && domains.Any()) { var parentDomains = domains.Where(p => p.parentContentCategoryId == 0).OrderBy(p => p.sequenceNo); if (parentDomains != null && parentDomains.Any()) { foreach (var item in parentDomains) { records.Add(new TestSessionModel() { Domain = item.name, IsDateVisible = false }); var childRecords = domains.Where(p => p.parentContentCategoryId == item.contentCategoryId).OrderBy(p => p.sequenceNo); if (childRecords != null && childRecords.Any()) { foreach (var subitem in childRecords) { var sessionmodel = new TestSessionModel() { DomainVisibility = true, ContentCategoryId = subitem.contentCategoryId, ParentDomainCode = item.code, DomainCode = subitem.code, LoadDomainBasedQuestionsAction = NavigateandRelaodQuestions, Domain = subitem.name, TestDate = "mm/dd/yyyy", Examiner = "Select Examiner", Status = "Complete", IsDateVisible = true, DomainMargin = new Thickness(17, 0, 0, 0) }; records.Add(sessionmodel); var testform = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == subitem.contentCategoryId); if (testform != null) { sessionmodel.IsScoreSelected = testform.IsScoreSelected; sessionmodel.ContentCategoryId = subitem.contentCategoryId; sessionmodel.TestDate = testform.testDate; sessionmodel.Notes = testform.Notes; sessionmodel.Status = testform.TSOStatus; if (sessionmodel.DomainCode == "PA" || sessionmodel.DomainCode == "PWR") { sessionmodel.RawScore = ""; } else { sessionmodel.RawScore = testform.rawScore != null && testform.rawScore.HasValue ? testform.rawScore.Value.ToString() : ""; } sessionmodel.PropertyChanged -= Sessionmodel_PropertyChanged; sessionmodel.PropertyChanged += Sessionmodel_PropertyChanged; sessionmodel.EnablerawScore = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == subitem.contentCategoryId).rawScoreEnabled; if (commonDataService.SearchStaffResponseModel != null && commonDataService.SearchStaffResponseModel.Any() && testform.examinerId != null && testform.examinerId.HasValue) { sessionmodel.ExaminerID = Convert.ToInt32(testform.examinerId); sessionmodel.Examiner = commonDataService.SearchStaffResponseModel.FirstOrDefault(p => p.UserID == testform.examinerId.Value.ToString()).FirstNameLastName; } if (sessionmodel.ContentCategoryId == 162 || sessionmodel.Domain.ToLower() == "fluency") { sessionmodel.IsFluency = true; if (testform.TimeTaken != null && testform.TimeTaken.HasValue) { sessionmodel.Timer = new TimeSpan(0, 0, 0, testform.TimeTaken.Value); } else { sessionmodel.Timer = new TimeSpan(0, 0, 0, 210); } } else { sessionmodel.IsNotFluency = true; } } var areas = domains.Where(p => p.parentContentCategoryId == subitem.contentCategoryId).OrderBy(p => p.sequenceNo); if (areas != null && areas.Any()) { sessionmodel.DomainColor = Color.Black; sessionmodel.IsDateVisible = false; sessionmodel.DomainVisibility = false; sessionmodel.LoadDomainBasedQuestionsAction = null; foreach (var area in areas) { var sessionmodel1 = new TestSessionModel() { DomainVisibility = true, ContentCategoryId = area.contentCategoryId, ParentDomainCode = subitem.code, DomainCode = area.code, LoadDomainBasedQuestionsAction = NavigateandRelaodQuestions, Domain = area.name, TestDate = "mm/dd/yyyy", Examiner = "Select Examiner", Status = "Complete", IsDateVisible = true, DomainMargin = new Thickness(27, 0, 0, 0) }; records.Add(sessionmodel1); var testform1 = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == area.contentCategoryId); if (testform1 != null) { sessionmodel1.IsScoreSelected = testform1.IsScoreSelected; sessionmodel1.ContentCategoryId = area.contentCategoryId; sessionmodel1.TestDate = testform1.testDate; sessionmodel1.Status = testform1.TSOStatus; sessionmodel1.Notes = testform1.Notes; sessionmodel1.IsNotFluency = true; sessionmodel1.RawScore = testform1.rawScore != null && testform1.rawScore.HasValue ? testform1.rawScore.Value.ToString() : ""; sessionmodel1.PropertyChanged -= Sessionmodel_PropertyChanged; sessionmodel1.PropertyChanged += Sessionmodel_PropertyChanged; sessionmodel1.EnablerawScore = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == area.contentCategoryId).rawScoreEnabled; if (commonDataService.SearchStaffResponseModel != null && commonDataService.SearchStaffResponseModel.Any() && testform1.examinerId != null && testform1.examinerId.HasValue) { sessionmodel1.ExaminerID = Convert.ToInt32(testform1.examinerId); sessionmodel1.Examiner = commonDataService.SearchStaffResponseModel.FirstOrDefault(p => p.UserID == testform1.examinerId.Value.ToString()).FirstNameLastName; } } } } } } } } } AcademicTestSessionRecords = new List <TestSessionModel>(records); /*foreach(var record in AcademicTestSessionRecords) * { * if(record.Domain == "Fluency") * { * record.IsFluency = true; * record.Timer = new TimeSpan(0,0,0,210); * } * else * { * record.IsNotFluency = true; * } * * }*/ } domains = null; }