Ejemplo n.º 1
0
 public void SaveAnestheticInhalantPlans(AnestheticPlanInhalant inhalants)
 {
     service.DeleteAnestheticPlanInjection(inhalants.PatientId);
     if (service.UpdateAnestheticPlanInhalant(inhalants) == 0)
         service.CreateAnestheticPlanInhalant(inhalants);
 }
Ejemplo n.º 2
0
        public int UpdateAnestheticPlanInhalant(AnestheticPlanInhalant inhalant)
        {
            int returnNum = 0;
            using (SqlConnection conn = new SqlConnection(connString))
            {
                string sql = @"UPDATE dbo.Anesthetic_Plan_Inhalant SET
                            DrugId = @DrugId, Percentage =  @Percentage, FlowRate = @FlowRate
                            WHERE
                            PatientId = @PatientId";

                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.Add("@PatientId", SqlDbType.Int).Value = inhalant.PatientId;
                if (inhalant.Drug.Id == -1)
                    cmd.Parameters.Add("@DrugId", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@DrugId", SqlDbType.Int).Value = inhalant.Drug.Id;
                if (inhalant.Percentage == 0.0M)
                    cmd.Parameters.Add("@Percentage", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@Percentage", SqlDbType.Decimal).Value = inhalant.Percentage;
                if (inhalant.FlowRate == 0.0M)
                    cmd.Parameters.Add("@FlowRate", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@FlowRate", SqlDbType.Decimal).Value = inhalant.FlowRate;
                try
                {
                    conn.Open();
                    returnNum = cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    conn.Close();
                }
            }
            return returnNum;
        }
Ejemplo n.º 3
0
        public void CreateAnestheticPlanInhalant(AnestheticPlanInhalant inhalant)
        {
            using (SqlConnection conn = new SqlConnection(connString))
            {
                string sql = @"INSERT INTO dbo.Anesthetic_Plan_Inhalant (
                            PatientId, DrugId, Percentage, FlowRate
                            ) VALUES (
                            @PatientId, @DrugId, @Percentage, @FlowRate
                            )";

                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.Add("@PatientId", SqlDbType.Int).Value = inhalant.PatientId;
                if (inhalant.Drug.Id == -1)
                    cmd.Parameters.Add("@DrugId", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@DrugId", SqlDbType.Int).Value = inhalant.Drug.Id;
                if (inhalant.Percentage == 0.0M)
                    cmd.Parameters.Add("@Percentage", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@Percentage", SqlDbType.Decimal).Value = inhalant.Percentage;
                if (inhalant.FlowRate == 0.0M)
                    cmd.Parameters.Add("@FlowRate", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@FlowRate", SqlDbType.Decimal).Value = inhalant.FlowRate;
                try
                {
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    conn.Close();
                }
            }
        }
Ejemplo n.º 4
0
        public AnestheticPlanInhalant GetAnestheticPlanInhalant(int patientId, params AnestheticPlanInhalant.LazyComponents[] lazyComponents)
        {
            AnestheticPlanInhalant anesPlanInhalant = new AnestheticPlanInhalant();
            using (SqlConnection conn = new SqlConnection(connString))
            {

                string sql = BuildAnestheticPlanInhalantSQL();

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

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

                foreach (AnestheticPlanInhalant.LazyComponents a in lazyComponents)
                {
                    if (a == AnestheticPlanInhalant.LazyComponents.LOAD_DRUG_WITH_DETAILS)
                    {
                        sql += @", b.CategoryId as 'b.CategoryId', b.Label as 'b.Label', b.OtherFlag as 'b.OtherFlag', b.Description as 'b.Description',
                                b.Concentration as 'b.Concentration', b.MaxDosage as 'b.MaxDosage' ";
                        from += @" INNER JOIN dbo.Dropdown_Types as b ON a.DrugId = b.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())
                    {
                        anesPlanInhalant = new AnestheticPlanInhalantCallback().ProcessRow(read, lazyComponents);
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    conn.Close();
                }
            }
            return anesPlanInhalant;
        }
Ejemplo n.º 5
0
 public AnestheticPlan()
 {
     _inhalantPlan = new AnestheticPlanInhalant();
     _injectionPlan = new AnestheticPlanInjection();
     _preMedications = new AnestheticPlanPremedication();
 }