Пример #1
0
        /// <summary>
        /// This method will assign a sequence number and add the alerts to the tracking context but will not commit changes to the DB so that it can be used in another transaction
        /// </summary>
        /// <param name="alerts"></param>
        /// <returns></returns>
        public async Task DispatchAlerts(IEnumerable <EmailQueue> alerts)
        {
            await Task.WhenAll(alerts
                               .Select(async alert => alert.IdEmail = (int)await sequenceGenerator.GetNextAsync(SequenceType.EmailQueue)));

            await writeContext.EmailQueue.AddRangeAsync(alerts);
        }
Пример #2
0
        public async Task <string> Execute(CreateQuestion command)
        {
            var nextQuestionSequence = await sequenceGenerator.GetNextAsync(SequenceType.SurveyQuestionBank);

            string questionId = $"{config["EnvironmentName"][0]}{nextQuestionSequence}";

            var question = new SurveyQuestionBank
            {
                UID            = Guid.NewGuid(), //remove
                IdQuestion     = questionId,
                DsQuestion     = command.QuestionText,
                CdQuestionType = command.QuestionType,
                CdCodeType     = command.CodeType,
                InBankQuestion = command.SaveToBank,
                InAnswered     = false,
                DtAdded        = DateTime.Now,
                IdAdded        = command.UserId
            };

            await writeContext.SurveyQuestionBank.AddAsync(question);

            await writeContext.SaveChangesAsync();

            return(questionId);
        }
Пример #3
0
        public async Task Execute(AttachSurveys command)
        {
            HashSet <Data.Survey> surveysToAdd = new HashSet <Data.Survey>();

            foreach (var icd9 in command.ICD9Code)
            {
                surveysToAdd.Add(new Data.Survey
                {
                    IdSurvey        = (int)await sequencerGenerator.GetNextAsync(SequenceType.Survey),
                    UID             = Guid.NewGuid(),
                    CdIcd9          = icd9,
                    IdSurveyVersion = 1,
                    CdSurveyType    = command.SurveyType,
                    DtEffective     = command.EffectiveDate,
                    UidLayout       = command.LayoutId,
                    NmSurvey        = command.Name
                });
            }

            foreach (var outbreakId in command.OutbreakId)
            {
                surveysToAdd.Add(new Data.Survey
                {
                    IdSurvey        = (int)await sequencerGenerator.GetNextAsync(SequenceType.Survey),
                    UID             = Guid.NewGuid(),
                    IdOutbreak      = outbreakId,
                    CdSurveyType    = command.SurveyType,
                    DtEffective     = command.EffectiveDate,
                    IdSurveyVersion = 1,
                    UidLayout       = command.LayoutId,
                    NmSurvey        = command.Name
                });
            }

            await writeContext.Survey.AddRangeAsync(surveysToAdd);

            await writeContext.SaveChangesAsync();
        }
Пример #4
0
        private async Task ReplaceEvents(
            Data.Outbreak outbreak,
            string outbreakEventType,
            IEnumerable <string> eventData,
            DateTime eventDate,
            params string[] codeType
            )
        {
            outbreak.OutbreakEvents
            .Where(e => e.CdEventType == outbreakEventType)
            .ToList()
            .ForEach(e => writeContext.OutbreakEvents.Remove(e));

            if (eventData == null)
            {
                return;
            }

            var tasks = eventData
                        .Select(async e => new OutbreakEvents
            {
                IdOutbreak  = outbreak.IdOutbreak,
                CdEventType = outbreakEventType,
                CdSubType   = e,
                DsDesc      = await codeRepository.GetDescription(e, codeType),
                DtEvent     = eventDate,
                IdEvent     = (int)await sequenceGenerator.GetNextAsync(SequenceType.OutbreakEventId),
            })
                        .ToArray();

            await Task.WhenAll(tasks);

            foreach (var task in tasks)
            {
                outbreak.OutbreakEvents.Add(task.Result);
            }
        }