Exemple #1
0
        public int GetCountPatientId(ListPatientCriteria criteria)
        {
            int result = 0;

            try
            {
                using (SqlConnection connection = CommonUtils.GetBusinessObject <ConnectionService>().getLabconnectSqlConnection())
                {
                    connection.Open();
                    using (SqlCommand command = new SqlCommand(QueryPatientCount, connection))
                    {
                        ApplyQueryCriteria(command, criteria);
                        result = (int)command.ExecuteScalar();
                    }
                }
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception exception)
            {
                _logger.Error(string.Format("Iternal error {0}", exception));
                throw new BusinessException(ErrorCode.InternalErrorException, exception);
            }

            return(result);
        }
Exemple #2
0
        private void ApplyQueryCriteria(SqlCommand command, ListPatientCriteria criteria)
        {
            SqlParameter parameter = null;

            if (criteria.DateSearch != null)
            {
                const string startDateParamName = "startDate";
                const string endDateParamName   = "endDate";

                command.CommandText += QueryPatient_DateInSelect;

                parameter       = command.Parameters.Add(new SqlParameter(startDateParamName, SqlDbType.DateTime));
                parameter.Value = criteria.DateSearch;

                parameter       = command.Parameters.Add(new SqlParameter(endDateParamName, SqlDbType.DateTime));
                parameter.Value = criteria.DateSearch;
            }

            if (!string.IsNullOrEmpty(criteria.SID))
            {
                const string sidParamName = "sid";

                command.CommandText += QueryPatient_SIDSelect;

                parameter       = command.Parameters.Add(new SqlParameter(sidParamName, SqlDbType.NVarChar));
                parameter.Value = string.Format("%{0}%", criteria.SID);
            }

            if (!string.IsNullOrEmpty(criteria.PatientName))
            {
                const string patientNameParamName = "patientName";

                command.CommandText += QueryPatient_PatientName;

                parameter       = command.Parameters.Add(new SqlParameter(patientNameParamName, SqlDbType.NVarChar));
                parameter.Value = string.Format("%{0}%", criteria.PatientName);
            }

            if (!string.IsNullOrEmpty(criteria.Sequence))
            {
                const string sequenceParamName = "seq";

                command.CommandText += QueryPatient_Seq;

                parameter       = command.Parameters.Add(new SqlParameter(sequenceParamName, SqlDbType.NVarChar));
                parameter.Value = string.Format("{0}%", criteria.Sequence);
            }
        }
Exemple #3
0
        public List <LabConnSampleInfo> GetListPatientId(ListPatientCriteria criteria)
        {
            List <LabConnSampleInfo> result = new List <LabConnSampleInfo>();

            try
            {
                using (SqlConnection connection = CommonUtils.GetBusinessObject <ConnectionService>().getLabconnectSqlConnection())
                {
                    connection.Open();
                    using (SqlCommand command = new SqlCommand(QueryPatient, connection))
                    {
                        ApplyQueryCriteria(command, criteria);

                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                LabConnSampleInfo info = ConvertToLabConnSampleInfo(reader);
                                result.Add(info);
                            }
                            reader.Close();
                        }
                    }
                }
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception exception)
            {
                _logger.Error(string.Format("Iternal error {0}", exception));
                throw new BusinessException(ErrorCode.InternalErrorException, exception);
            }

            return(result);
        }