Ejemplo n.º 1
0
        public ReportModel GetCustomizationModel(Guid workflowKey, string reportName)
        {
            var reportModel = _workflowMessageRepository.GetByKey(workflowKey).WorkflowReports.FirstOrDefault(r => r.Name == reportName);

            if (reportModel != null)
            {
                NidaPatientSummaryReportModelBuilder.FillDefaults(reportModel);
            }
            return(reportModel);
        }
Ejemplo n.º 2
0
        public IReport Generate(Guid workflowKey, string reportName)
        {
            var workflow    = _workflowMessageRepository.GetByKey(workflowKey);
            var reportModel = workflow.WorkflowReports.FirstOrDefault(r => r.Name == reportName);

            if (reportModel != null)
            {
                NidaPatientSummaryReportModelBuilder.FillDefaults(reportModel);
            }
            //todo: get report data from event store
            var nidaReportDataCollection = new NidaReportDataCollection
            {
                reportModel == null ? new NidaReportData() : new NidaReportData(reportModel)
            };
            var report = new NidaReport
            {
                DataSource = nidaReportDataCollection,
            };

            return(report);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NidaWorkflowRuleCollection"/> class.
        /// </summary>
        /// <param name="assessmentDefinitionRepository">The assessment definition repository.</param>
        /// <param name="repository">The repository.</param>
        /// <param name="assessmentInstanceRepository">The assessment instance repository.</param>
        /// <param name="resourcesManager">The resources manager.</param>
        public NidaWorkflowRuleCollection(
            IAssessmentDefinitionRepository assessmentDefinitionRepository,
            IWorkflowMessageRepository repository,
            IAssessmentInstanceRepository assessmentInstanceRepository,
            IResourcesManager resourcesManager = null)
        {
            _resourcesManager = resourcesManager;
            NewRule(() => ShouldRecommendDastRule).When(assessment => (int)assessment.Score.Value > 0)
            .Then(
                (assessment, ctx) =>
            {
                var messageReporter =
                    ctx.WorkingMemory.GetContextObject <IMessageCollector> ("MessageCollector");
                var assessmentDefinitionKey =
                    assessmentDefinitionRepository.GetKeyByCode(DrugAbuseScreeningTest.AssessmentCodedConcept.Code);
                WorkflowMessage message = null;
                if (assessment.WorkflowKey.HasValue)
                {
                    message = repository.GetByKey(assessment.WorkflowKey.Value);
                }
                message = message ?? new WorkflowMessage(
                    assessment.PatientKey,
                    assessment.Key,
                    NidaSingleQuestionScreener.AssessmentCodedConcept.Code,
                    assessmentDefinitionKey,
                    DrugAbuseScreeningTest.AssessmentCodedConcept.Code,
                    assessment.Score);
                if (assessment.CanSelfAdminister)
                {
                    message.AllowSelfAdministration();
                }
                assessment.AddToWorkflow(message.Key);
                messageReporter.AddMessage(message);
            })
            .ElseThen(
                (assessment, ctx) =>
            {
                WorkflowMessage message = null;
                if (assessment.WorkflowKey.HasValue)
                {
                    message = repository.GetByKey(assessment.WorkflowKey.Value);
                }
                message = message ?? new WorkflowMessage(
                    assessment.PatientKey,
                    assessment.Key,
                    NidaSingleQuestionScreener.AssessmentCodedConcept.Code,
                    Guid.Empty,
                    null,
                    assessment.Score);

                if (assessment.CanSelfAdminister)
                {
                    message.AllowSelfAdministration();
                }

                message.Complete(NidaPatientSummaryReportModelBuilder.GetGreenReportModel());
            });

            NewRuleSet(() => NidaSingleQuestionScreenerRuleSet, ShouldRecommendDastRule);

            NewRule(() => ShouldRecommendNidaAssessFurtherRule).When(assessment => assessment.WorkflowKey.HasValue)
            .Then(
                (assessment, ctx) =>
            {
                var messageReporter =
                    ctx.WorkingMemory
                    .GetContextObject <IMessageCollector> ("MessageCollector");
                var assessmentDefinitionKey =
                    assessmentDefinitionRepository.GetKeyByCode(NidaAssessFurther.AssessmentCodedConcept.Code);
                var message = repository.GetByKey(assessment.WorkflowKey.Value);
                message.Advance(
                    assessment.Key,
                    DrugAbuseScreeningTest.AssessmentCodedConcept.Code,
                    assessmentDefinitionKey,
                    NidaAssessFurther.AssessmentCodedConcept.Code,
                    assessment.Score);
                messageReporter.AddMessage(message);
            });

            NewRuleSet(() => DrugAbuseScreeningTestRuleSet, ShouldRecommendNidaAssessFurtherRule);

            NewRule(() => ShouldCompleteWorkflowStatusRule).When(assessment => assessment.WorkflowKey.HasValue)
            .Then(
                (assessment, ctx) =>
            {
                var message      = repository.GetByKey(assessment.WorkflowKey.Value);
                var dastKey      = message.GetAssessmentKeyforCodeInWorkflow(DrugAbuseScreeningTest.AssessmentCodedConcept.Code);
                var dastInstance = assessmentInstanceRepository.GetByKey(dastKey.Value);
                ReportModel reportModel;
                if (((long)dastInstance.Score.Value) <= 2 && !(((NidaAssessFurtherScoring)assessment.Score.Value).TotalScore))
                {
                    reportModel = NidaPatientSummaryReportModelBuilder.GetAmberReportModel(
                        _resourcesManager,
                        dastInstance,
                        assessment);
                }
                else
                {
                    reportModel = NidaPatientSummaryReportModelBuilder.GetRedReportModel(
                        _resourcesManager,
                        dastInstance,
                        assessment);
                }
                message.Complete(reportModel);
            });
            NewRuleSet(() => NidaAssessFurtherRuleSet, ShouldCompleteWorkflowStatusRule);
        }