Ejemplo n.º 1
0
 private void Apply(AssessmentSubmittedEvent assessmentSubmittedEvent)
 {
     IsSubmitted = assessmentSubmittedEvent.Submit;
     if (!IsSubmitted)
     {
         Score = null;
     }
 }
Ejemplo n.º 2
0
 private void Apply(AssessmentSubmittedEvent assessmentSubmittedEvent)
 {
     IsSubmitted = assessmentSubmittedEvent.Submit;
     if (!IsSubmitted)
     {
         Score = null;
     }
     SubmittedDate = DateTime.Now;
 }
Ejemplo n.º 3
0
        public void Handle(AssessmentSubmittedEvent message)
        {
            const string cmd =
                @"UPDATE AssessmentModule.AssessmentInstance SET IsSubmitted = @IsSubmitted
                where AssessmentInstanceKey = @AssessmentInstanceKey";

            using (IDbConnection connection = _connectionFactory.CreateConnection())
            {
                connection.Execute(cmd, new
                {
                    AssessmentInstanceKey = message.Key,
                    IsSubmitted           = message.Submit,
                });
            }
        }
Ejemplo n.º 4
0
        private void InsertResponses(AssessmentSubmittedEvent message)
        {
            var          instance = _assessmentInstanceRepository.GetByKey(message.Key);
            const string Cmd      =
                @"INSERT [AssessmentModule].[AssessmentInstanceResponse]
                    ([AssessmentInstanceKey]
                    ,[AssessmentName]
                    ,[AssessmentCode]
                    ,[AssessmentDefinitionKey]
                    ,[OrganizationKey]
                    ,[PatientKey]
                    ,[ItemDefinitionCode]
                    ,[ResponseType]
                    ,[ResponseValue]
                    ,[IsCode]
                    ,[CodeValue]) VALUES ( ";

            using (var connection = _connectionFactory.CreateConnection())
            {
                var assessmentCode          = string.Empty;
                var assessmentDefinitionKey = string.Empty;
                var sql = "SELECT AssessmentDefinitionKey AS [Key], AssessmentCode FROM [AssessmentModule].[AssessmentDefinition] WHERE [AssessmentDefinitionKey]='"
                          + message.AssessmentDefinitionKey + "'";
                var rows = connection.Query <AssessmentDefinitionDto>(sql).ToList();
                if (rows.Any())
                {
                    assessmentCode          = rows.ElementAt(0).AssessmentCode;
                    assessmentDefinitionKey = rows.ElementAt(0).Key.ToString();
                }
                var assessmentDefinition = _assessmentDefinitionRepository.GetByKey(_assessmentDefinitionRepository.GetKeyByCode(assessmentCode));
                var items = assessmentDefinition.GetAllItemDefinitionsOfType(ItemType.Question).ToList();
                foreach (var item in instance.ItemInstances)
                {
                    var isCode       = false;
                    var val          = item.Value;
                    int intVal       = 0;
                    var responseType = GetTemplateName(items, item);
                    switch (responseType)
                    {
                    case "LookupDto":
                        int.TryParse(((Lookup)item.Value).Value.ToString(), out intVal);
                        val          = ((Lookup)item.Value).CodedConcept.Code;
                        responseType = item.Value.GetType().Name;
                        isCode       = true;
                        break;

                    case "MultipleSelect":
                        foreach (var option in (IEnumerable <Lookup>)item.Value)
                        {
                            if (((IEnumerable <Lookup>)item.Value).Any())
                            {
                                responseType = ((IEnumerable <Lookup>)item.Value).ElementAt(0).GetType().Name;
                                int.TryParse(option.Value.ToString(), out intVal);
                            }
                            var fullQueryOption = Cmd
                                                  + "'" + message.Key + "',"
                                                  + "'" + instance.AssessmentName + "',"
                                                  + "'" + assessmentCode + "',"
                                                  + "'" + assessmentDefinitionKey + "',"
                                                  + "'" + message.OrganizationKey + "',"
                                                  + "'" + instance.PatientKey + "',"
                                                  + "'" + item.ItemDefinitionCode + "'," +
                                                  "'" + responseType + "',"
                                                  + "'" + option.CodedConcept.Code + "',"
                                                  + "'" + true + "',"
                                                  + intVal + ")";
                            _logger.Info("InsertResponses Query: {0}", fullQueryOption);
                            connection.Execute(fullQueryOption);
                        }
                        continue;
                    }
                    var fullQuery = Cmd
                                    + "'" + message.Key + "',"
                                    + "'" + instance.AssessmentName + "',"
                                    + "'" + assessmentCode + "',"
                                    + "'" + assessmentDefinitionKey + "',"
                                    + "'" + message.OrganizationKey + "',"
                                    + "'" + instance.PatientKey + "',"
                                    + "'" + item.ItemDefinitionCode + "'," +
                                    "'" + responseType + "',"
                                    + "'" + val + "',"
                                    + "'" + isCode + "',"
                                    + intVal + ")";
                    _logger.Info("InsertResponses Query: {0}", fullQuery);
                    connection.Execute(fullQuery);
                }
            }
        }