public void ShouldApplyScoredEvent() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup SetupServiceLocatorFixture(serviceLocatorFixture); var events = new List <IDomainEvent>(); CommitEvent.RegisterAll(events.Add); // Exercise Guid defGuid = CombGuid.NewCombGuid(); Guid patientGuid = CombGuid.NewCombGuid(); var source = new AssessmentInstance(defGuid, patientGuid, assessmentName); source.ScoreComplete(new CodedConcept(CodeSystems.Obhita, "dummayCode", ""), "result"); // Verify Assert.AreEqual(2, events.Count); var scoredEvent = events[1]; Assert.IsNotNull(scoredEvent); Assert.AreEqual(typeof(AssessmentScoredEvent), scoredEvent.GetType()); Assert.AreEqual((scoredEvent as AssessmentScoredEvent).Value, "result"); Assert.AreEqual((scoredEvent as AssessmentScoredEvent).ScoreCode.Code, "dummayCode"); Assert.IsNull((scoredEvent as AssessmentScoredEvent).Guidance); Assert.AreEqual(2, source.Version); } }
public void ExecuteShouldRecommendDastRuleThenClause_WorkflowMessageCreated() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup SetupServiceLocatorFixture(serviceLocatorFixture); var assessmentDefKey = Guid.NewGuid(); var ruleCollection = new NidaWorkflowRuleCollection( BuildIAssessmentDefinitionRepositoryMock(assessmentDefKey).Object, BuildIRepositoryMock(null).Object, new Mock <IAssessmentInstanceRepository>().Object); var assessmentInstance = new AssessmentInstance(Guid.NewGuid(), Guid.NewGuid(), ""); assessmentInstance.ScoreComplete(new CodedConcept(new CodeSystem("", "", ""), "", ""), "test"); var messageCollector = new MessageCollector(); var ruleEngineContext = new RuleEngineContext <AssessmentInstance>(assessmentInstance); ruleEngineContext.WorkingMemory.AddContextObject <IMessageCollector>(messageCollector, "MessageCollector"); foreach (var action in ruleCollection.ShouldRecommendDastRule.ThenClauses) { action(ruleEngineContext); } Assert.AreEqual(1, messageCollector.Messages.Count(), "Incorrect Number of messages."); Assert.AreEqual(typeof(WorkflowMessage), messageCollector.Messages.First().GetType()); var workflowMessage = messageCollector.Messages.First() as WorkflowMessage; Assert.AreEqual(assessmentInstance.Key, workflowMessage.InitiatingAssessmentKey); Assert.AreEqual(DrugAbuseScreeningTest.AssessmentCodedConcept.Code, workflowMessage.RecommendedAssessmentDefinitionCode); } }
/// <summary> /// Calculates the score. /// </summary> /// <param name="assessment">The assessment.</param> public void CalculateScore(AssessmentInstance assessment) { var value = int.Parse(assessment.ItemInstances.First().Value.ToString()); var guidance = value > 0 ? new CodedConcept(CodeSystems.Obhita, "guidance_1_and_up", "guidance_1_and_up") : new CodedConcept(CodeSystems.Obhita, "guidance_0", "guidance_0"); assessment.ScoreComplete(new CodedConcept(CodeSystems.Obhita, string.Empty, string.Empty), value, false, guidance); }
public void CalculateScore(AssessmentInstance assessment) { var value = assessment.ItemInstances.Count(i => (bool.Parse(i.Value.ToString()))); var guidance = value <= 2 ? new CodedConcept(CodeSystems.Obhita, "guidance_0_to_2", "guidance_0_to_2") : new CodedConcept(CodeSystems.Obhita, "guidance_3_and_up", "guidance_3_and_up"); assessment.ScoreComplete(new CodedConcept(CodeSystems.Obhita, "", ""), value, guidance); }
public void CalculateScore(AssessmentInstance assessment) { //• No daily use of any substance //• No weekly use of opioids, cocaine, or methamphetamine //• No injection drug use in the past three months //• Not currently in drug abuse treatment var value = false; var dailyUseSubstances = new List <string> { "3269979", "3269980", "3269981", "3269982", "3269983", "3269985", "3269984" }; var weeklyUseOpioidsCocaineMethamphetamine = new List <string> { "3269981", "3269980", "3269982" }; value = assessment.ItemInstances.Any( i => dailyUseSubstances.Contains(i.ItemDefinitionCode) && i.Value != null && Equals(double.Parse((i.Value as Lookup).Value.ToString()), Frequency.DailyOrAlmostDaily.Value)) || assessment.ItemInstances.Any( i => weeklyUseOpioidsCocaineMethamphetamine.Contains(i.ItemDefinitionCode) && i.Value != null && Equals(double.Parse((i.Value as Lookup).Value.ToString()), Frequency.Weekly.Value)) || ( assessment.ItemInstances.Any( i => i.ItemDefinitionCode == "3269978" && bool.Parse(i.Value.ToString())) && assessment.ItemInstances.Any( i => i.ItemDefinitionCode == "3269986" && Equals(double.Parse((i.Value as Lookup).Value.ToString()), Frequency.InThePast90Days.Value)) ) || assessment.ItemInstances.Any( i => i.ItemDefinitionCode == "3269976" && bool.Parse(i.Value.ToString())); assessment.ScoreComplete(new CodedConcept(CodeSystems.Obhita, "", ""), value); }
/// <summary> /// Calculates the score. /// </summary> /// <param name="assessment">The assessment.</param> public void CalculateScore(AssessmentInstance assessment) { var dast = new DrugAbuseScreeningTest(assessment); var count = assessment.ItemInstances.Count(i => (bool.Parse(i.Value.ToString()))); if (dast.SubstanceAbusePrescriptionIllicitSubstanceOvertheCounterProductCessationAbilityPersonalMedicalHistoryInd2) { count--; } var guidance = count <= 2 ? new CodedConcept(CodeSystems.Obhita, "guidance_0_to_2", "guidance_0_to_2") : new CodedConcept(CodeSystems.Obhita, "guidance_3_and_up", "guidance_3_and_up"); assessment.ScoreComplete(new CodedConcept(CodeSystems.Obhita, string.Empty, string.Empty), count, false, guidance); }
/// <summary> /// Calculates the score. /// </summary> /// <param name="assessment">The assessment.</param> public void CalculateScore(AssessmentInstance assessment) { var total = (assessment.ItemInstances.Where(item => item.Value.GetType() == typeof(TimeFrequency)) .Select(item => (TimeFrequency)item.Value) .Select(tf => int.Parse(tf.Value.ToString()))).Sum(); var patient = _patientRepository.GetByKey(assessment.PatientKey); var youthPediatricSymptonChecklist = new YouthPediatricSymptonChecklist(assessment); var values = new List <TimeFrequency> { youthPediatricSymptonChecklist.YouthChildsEmotionalAndBehaviorProblemsGroup.HasTroubleWithTeacher, youthPediatricSymptonChecklist.YouthChildsEmotionalAndBehaviorProblemsGroup.LessInterestedInSchool, youthPediatricSymptonChecklist.YouthChildsEmotionalAndBehaviorProblemsGroup.AbsentFromSchool, youthPediatricSymptonChecklist.YouthChildsEmotionalAndBehaviorProblemsGroup.SchoolGradesDropping }; total -= Common.AdjustScoreBasedOnAge(patient, values); assessment.ScoreComplete(new CodedConcept(CodeSystems.Obhita, string.Empty, string.Empty), total, true); }
public void AssessmentScoredEventIsRaisedWhenScoreComplete() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { //Setup SetupServiceLocatorFixture(serviceLocatorFixture); bool eventRaised = false; DomainEvent.Register <AssessmentScoredEvent>(s => eventRaised = true); // Exercise Guid defGuid = CombGuid.NewCombGuid(); Guid patientGuid = CombGuid.NewCombGuid(); var source = new AssessmentInstance(defGuid, patientGuid, "testName"); source.ScoreComplete(new CodedConcept(CodeSystems.Obhita, "dummayCode", ""), "result"); // Verify Assert.IsTrue(eventRaised); } }
/// <summary> /// Calculates the score. /// </summary> /// <param name="assessment">The assessment.</param> public void CalculateScore(AssessmentInstance assessment) { var gainShortScreener = new GainShortScreener(assessment); int pastMonth, past90Days, pastYear, lifetime; GetInternalDisorderScreenerScore(gainShortScreener, out pastMonth, out past90Days, out pastYear, out lifetime); var internalizingDisorderScore = new GainGroupScore(pastMonth, past90Days, pastYear, lifetime); GetExternalDisorderScreenerScore(gainShortScreener, out pastMonth, out past90Days, out pastYear, out lifetime); var externalizingDisorderScore = new GainGroupScore(pastMonth, past90Days, pastYear, lifetime); GetSubstanceDisorderScreenerScore(gainShortScreener, out pastMonth, out past90Days, out pastYear, out lifetime); var substanceDisorderScore = new GainGroupScore(pastMonth, past90Days, pastYear, lifetime); GetCriminalViolenceScreenerScore(gainShortScreener, out pastMonth, out past90Days, out pastYear, out lifetime); var criminalViolenceScore = new GainGroupScore(pastMonth, past90Days, pastYear, lifetime); var gainShortScreenerScoring = new GainShortScreenerScore(internalizingDisorderScore, externalizingDisorderScore, substanceDisorderScore, criminalViolenceScore); assessment.ScoreComplete( new CodedConcept(CodeSystems.Obhita, string.Empty, string.Empty), gainShortScreenerScoring, true); }
/// <summary>Calculates the score.</summary> /// <param name="assessment">The assessment.</param> public void CalculateScore(AssessmentInstance assessment) { assessment.ScoreComplete(new CodedConcept(CodeSystems.Obhita, string.Empty, string.Empty), 100); }
/// <summary> /// Calculates the score. /// </summary> /// <param name="assessment">The assessment.</param> public void CalculateScore(AssessmentInstance assessment) { var total = TotalScore(assessment); assessment.ScoreComplete(new CodedConcept(CodeSystems.Obhita, string.Empty, string.Empty), total, true); }
/// <summary> /// Calculates the score. /// </summary> /// <param name="assessment">The assessment.</param> public void CalculateScore(AssessmentInstance assessment) { var nidaAssessFurtherScoring = new NidaAssessFurtherScoring(assessment); assessment.ScoreComplete(new CodedConcept(CodeSystems.Obhita, string.Empty, string.Empty), nidaAssessFurtherScoring); }