Ejemplo n.º 1
0
 public void SaveMaintenanceOther(MaintenanceOther drugs)
 {
     if (service.UpdateMaintenanceOther(drugs) == 0)
         service.CreateMaintenanceOther(drugs);
 }
Ejemplo n.º 2
0
        public void CreateMaintenanceOther(MaintenanceOther maintOther)
        {
            using (SqlConnection conn = new SqlConnection(connString))
            {
                string sql = @"INSERT INTO dbo.Maintenance_Other_To_Patient (
                            PatientId, OtherAnestheticDrugs, IntraoperativeAnalgesiaId, IVFluidTypeId
                            ) VALUES (
                            @PatientId, @OtherAnestheticDrugs, @IntraoperativeAnalgesiaId, @IVFluidTypeId
                            )";

                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.Add("@PatientId", SqlDbType.Int).Value = maintOther.PatientId;
                if (maintOther.OtherAnestheticDrug == null)
                    cmd.Parameters.Add("@OtherAnestheticDrugs", SqlDbType.NVarChar).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@OtherAnestheticDrugs", SqlDbType.NVarChar).Value = maintOther.OtherAnestheticDrug;
                if (maintOther.IntraoperativeAnalgesia.Id == -1)
                    cmd.Parameters.Add("@IntraoperativeAnalgesiaId", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@IntraoperativeAnalgesiaId", SqlDbType.Int).Value = maintOther.IntraoperativeAnalgesia.Id;
                if (maintOther.IVFluidType.Id == -1)
                    cmd.Parameters.Add("@IVFluidTypeId", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@IVFluidTypeId", SqlDbType.Decimal).Value = maintOther.IVFluidType.Id;
                try
                {
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    conn.Close();
                }
            }
        }
Ejemplo n.º 3
0
        public MaintenanceOther GetMaintenanceOther(int patientId, params MaintenanceOther.LazyComponents[] lazyComponents)
        {
            MaintenanceOther maintOther = new MaintenanceOther();
            using (SqlConnection conn = new SqlConnection(connString))
            {

                string sql = BuildMaintenanceOtherSQL();

                string from = @"FROM dbo.Maintenance_Other_To_Patient AS a";

                string where = @" WHERE a.PatientId = @PatientId ";

                foreach (MaintenanceOther.LazyComponents a in lazyComponents)
                {
                     if (a == MaintenanceOther.LazyComponents.LOAD_INTRAOP_WITH_DETAILS)
                    {
                        sql += @", e.CategoryId as 'e.CategoryId', e.Label as 'e.Label', e.OtherFlag as 'e.OtherFlag', e.Description as 'e.Description',
                                    e.Concentration as 'e.Concentration' ";
                        from += @" LEFT OUTER JOIN dbo.Dropdown_Types as e ON a.IntraoperativeAnalgesiaId = e.Id ";
                    }
                    else if (a == MaintenanceOther.LazyComponents.LOAD_IV_WITH_DETAILS)
                    {
                        sql += @", f.CategoryId as 'f.CategoryId', f.Label as 'f.Label', f.OtherFlag as 'f.OtherFlag', f.Description as 'f.Description',
                                    f.Concentration as 'f.Concentration' ";
                        from += @" LEFT OUTER JOIN dbo.Dropdown_Types as f ON a.IVFluidTypeId = f.Id ";
                    }
                }

                sql = sql + from + where;

                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.Add("@PatientId", SqlDbType.Int).Value = patientId;
                try
                {
                    conn.Open();
                    SqlDataReader read = cmd.ExecuteReader();
                    while (read.Read())
                    {
                        maintOther = new MaintenanceOtherCallback().ProcessRow(read, lazyComponents);
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    conn.Close();
                }
            }
            return maintOther;
        }
Ejemplo n.º 4
0
        public int UpdateMaintenanceOther(MaintenanceOther maintOther)
        {
            int returnNum = 0;
            using (SqlConnection conn = new SqlConnection(connString))
            {
                string sql = @"UPDATE dbo.Maintenance_Other_To_Patient SET
                            OtherAnestheticDrugs = @OtherAnestheticDrugs, IntraoperativeAnalgesiaId = @IntraoperativeAnalgesiaId, IVFluidTypeId = @IVFluidTypeId
                            WHERE
                            PatientId = @PatientId";

                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.Add("@PatientId", SqlDbType.Int).Value = maintOther.PatientId;
                if (maintOther.OtherAnestheticDrug == null)
                    cmd.Parameters.Add("@OtherAnestheticDrugs", SqlDbType.NVarChar).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@OtherAnestheticDrugs", SqlDbType.NVarChar).Value = maintOther.OtherAnestheticDrug;
                if (maintOther.IntraoperativeAnalgesia.Id == -1)
                    cmd.Parameters.Add("@IntraoperativeAnalgesiaId", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@IntraoperativeAnalgesiaId", SqlDbType.Int).Value = maintOther.IntraoperativeAnalgesia.Id;
                if (maintOther.IVFluidType.Id == -1)
                    cmd.Parameters.Add("@IVFluidTypeId", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@IVFluidTypeId", SqlDbType.Decimal).Value = maintOther.IVFluidType.Id;
                try
                {
                    conn.Open();
                    returnNum = cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    conn.Close();
                }
            }
            return returnNum;
        }
Ejemplo n.º 5
0
 public Maintenance()
 {
     _maintenanceInjectionDrug = new MaintenanceInjectionDrug();
     _maintenanceInhalantDrug = new MaintenanceInhalantDrug();
     _maintenanceOther = new MaintenanceOther();
 }