Beispiel #1
0
        public async Task <Result> Handle(PerformSingleCheck request, CancellationToken cancellationToken)
        {
            _integrityCheckRepository.ClearById(request.IntegrityCheckId);


            var runs       = new List <IntegrityCheckRun>();
            var checks     = _integrityCheckRepository.GetAll().Where(x => x.EmrSystemId == request.EmrSystemId).ToList();
            var indicators = _integrityCheckRepository.LoadIndicators().ToList();

            if (indicators.Any())
            {
                //    App Ver

                var appVersionCheck = checks.FirstOrDefault(x => x.Name == "AppVersion");
                if (null != appVersionCheck)
                {
                    var run = appVersionCheck.Run(request.Version);
                    runs.Add(run);
                }

                _integrityCheckRepository.Create(runs);
            }

            return(Result.Success());
        }
Beispiel #2
0
        public async Task <Result> Handle(InitAppVerCheck request, CancellationToken cancellationToken)
        {
            var current = await _mediator.Send(new CheckLiveUpdate(string.Empty));

            if (current.IsSuccess)
            {
                if (!string.IsNullOrWhiteSpace(current.Value.LiveVersion))
                {
                    var check = _integrityCheckRepository.GetAll().ToList().FirstOrDefault(x => x.Name == "AppVersion");
                    if (null != check)
                    {
                        check.UpdateLogic(current.Value.LiveVersion.Trim());
                        _integrityCheckRepository.Update <IntegrityCheck>(new List <IntegrityCheck> {
                            check
                        });
                        return(Result.Success());
                    }
                }
            }

            return(Result.Failure("Unkown error"));
        }
Beispiel #3
0
        public async Task <Result> Handle(PerformCheck request, CancellationToken cancellationToken)
        {
            _integrityCheckRepository.Clear();

            var runs       = new List <IntegrityCheckRun>();
            var checks     = _integrityCheckRepository.GetAll().Where(x => x.EmrSystemId == request.EmrSystemId).ToList();
            var indicators = _integrityCheckRepository.LoadIndicators().ToList();
            var metrics    = _integrityCheckRepository.LoadEmrMetrics().ToList();

            if (indicators.Any())
            {
                //    App Ver

                var appVersionCheck = checks.FirstOrDefault(x => x.Name == "AppVersion");
                if (null != appVersionCheck)
                {
                    var run = appVersionCheck.Run(request.Version);
                    runs.Add(run);
                }

                //    ETL  EMR_ETL_Refresh
                var emrEtlRefresh = indicators.FirstOrDefault(x => x.Indicator == "EMR_ETL_Refresh");
                if (null != emrEtlRefresh)
                {
                    var check = checks.FirstOrDefault(x => x.Name == "EMR_ETL_Refresh");
                    if (null != check)
                    {
                        var run = check.Run(emrEtlRefresh.IndicatorValue);
                        runs.Add(run);
                    }
                }

                //    Last Encounter date
                var lastEncounter = indicators.FirstOrDefault(x => x.Indicator == "LAST_ENCOUNTER_CREATE_DATE");

                if (null != lastEncounter)
                {
                    var check = checks.FirstOrDefault(x => x.Name == "LAST_ENCOUNTER_CREATE_DATE");
                    if (null != check)
                    {
                        var run = check.Run(lastEncounter.IndicatorValue);
                        runs.Add(run);
                    }
                }

                //TODO:  Last Log in Date from Indicator

                var emrLogin = metrics.FirstOrDefault();
                if (null != emrLogin && emrLogin.LastLoginDate.HasValue)
                {
                    var check = checks.FirstOrDefault(x => x.Name == "LastLoginDate");
                    if (null != check)
                    {
                        var run = check.Run(emrLogin.LastLoginDate.Value);
                        runs.Add(run);
                    }
                }

                // TX Curr

                var txCurr = indicators.FirstOrDefault(x => x.Indicator == "TX_CURR");

                if (null != txCurr)
                {
                    var check = checks.FirstOrDefault(x => x.Name == "TX_CURR");
                    if (null != check)
                    {
                        var run = check.Run(txCurr.IndicatorValue);
                        runs.Add(run);
                    }
                }

                // MFL Codes

                var siteCodes = indicators.Where(x => x.Indicator == "MFL_CODE").ToList();

                if (siteCodes.Any())
                {
                    var check = checks.FirstOrDefault(x => x.Name == "MFL_CODE");
                    if (null != check)
                    {
                        var run = check.Run(siteCodes);
                        runs.Add(run);
                    }
                }

                _integrityCheckRepository.Create(runs);
            }

            return(Result.Success());
        }