Ejemplo n.º 1
0
        public async Task <bool> Handle(RunADTMessageRulesCommand message, CancellationToken cancellationToken)
        {
            RuleEngineInRule ruleEngine = new RuleEngineInRule();

            ruleEngine._authorizationKey = _settings.Value.AuthorizationKey;
            ruleEngine._password         = _settings.Value.Password;
            ruleEngine._restClient       = _settings.Value.RestClient;
            ruleEngine._ruleRepository   = _settings.Value.RegistrationRuleRepository;
            ruleEngine._userName         = _settings.Value.UserName;
            string            entity  = JsonConvert.SerializeObject(message);
            QAExecutionResult results = ruleEngine.ExecuteRules("Patient", entity);


            var ruleExecution = new RuleExecution();

            ruleExecution.AccountId = 1;
            ruleExecution.ClientId  = 1;
            ruleExecution.Event     = "RegistrationReceived";

            foreach (var item in results.RuleErrors)
            {
                ruleExecution.RuleExecutionErrors
                .Add(new RuleExecutionError()
                {
                    RuleId = item.RuleId,
                    RuleErrorDescription = item.RuleErrorDescription,
                    RuleType             = item.RuleType
                }
                     );
            }

            _ruleExecutionContext.Add(ruleExecution);

            return(await _ruleExecutionContext.SaveEntitiesAsync(cancellationToken));
        }
        public async Task <bool> Handle(RecordQAResultsCommand message, CancellationToken cancellationToken)
        {
            var ruleExecution = new RuleExecution();

            ruleExecution.AccountId = message.AccountId;
            ruleExecution.ClientId  = message.ClientId;
            ruleExecution.Event     = message.Event;

            foreach (var item in message.ExecutionErrors)
            {
                ruleExecution.RuleExecutionErrors
                .Add(new RuleExecutionError()
                {
                    RuleId = item.RuleId,
                    RuleErrorDescription = item.RuleErrorDescription,
                    RuleType             = item.RuleType
                }
                     );
            }

            _ruleExecutionContext.Add(ruleExecution);

            return(await _ruleExecutionContext.SaveEntitiesAsync(cancellationToken));
        }