Exemplo n.º 1
0
 public void SaveAnestheticPremedications(AnestheticPlanPremedication pat)
 {
     service.DeleteAnestheticPlanPremedication(pat.PatientId);
     if (service.UpdateAnestheticPlanPremedication(pat) == 0)
         service.CreateAnestheticPlanPremedication(pat);
 }
Exemplo n.º 2
0
        public int UpdateAnestheticPlanPremedication(AnestheticPlanPremedication premed)
        {
            int returnNum = 0;
            using (SqlConnection conn = new SqlConnection(connString))
            {
                string sql = @"UPDATE dbo.Anesthetic_Plan_Premed SET
                            RouteId = @RouteId, SedativeDosage = @SedativeDosage, SedativeDrugId = @SedativeDrugId, OpioidDosage = @OpioidDosage,
                            OpioidDrugId = @OpioidDrugId, AnticholinergicDosage = @AnticholinergicDosage, AnticholinergicDrugId = @AnticholinergicDrugId,
                            KetamineDosage = @KetamineDosage
                            WHERE
                            PatientId = @PatientId";

                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.Add("@PatientId", SqlDbType.Int).Value = premed.PatientId;
                if (premed.SedativeDrug.Id == -1)
                    cmd.Parameters.Add("@SedativeDrugId", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@SedativeDrugId", SqlDbType.Int).Value = premed.SedativeDrug.Id;
                if (premed.SedativeDosage == 0.0M)
                    cmd.Parameters.Add("@SedativeDosage", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@SedativeDosage", SqlDbType.Decimal).Value = premed.SedativeDosage;
                if (premed.OpioidDosage == 0.0M)
                    cmd.Parameters.Add("@OpioidDosage", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@OpioidDosage", SqlDbType.Decimal).Value = premed.OpioidDosage;
                if (premed.OpioidDrug.Id == -1)
                    cmd.Parameters.Add("@OpioidDrugId", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@OpioidDrugId", SqlDbType.Int).Value = premed.OpioidDrug.Id;
                if (premed.AnticholinergicDrug.Id == -1)
                    cmd.Parameters.Add("@AnticholinergicDrugId", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@AnticholinergicDrugId", SqlDbType.Int).Value = premed.AnticholinergicDrug.Id;
                if (premed.AnticholinergicDosage == 0.0M)
                    cmd.Parameters.Add("@AnticholinergicDosage", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@AnticholinergicDosage", SqlDbType.Decimal).Value = premed.AnticholinergicDosage;
                if (premed.KetamineDosage == 0.0M)
                    cmd.Parameters.Add("@KetamineDosage", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@KetamineDosage", SqlDbType.Decimal).Value = premed.KetamineDosage;
                if (premed.Route.Id == -1)
                    cmd.Parameters.Add("@RouteId", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@RouteId", SqlDbType.Decimal).Value = premed.Route.Id;
                try
                {
                    conn.Open();
                    returnNum = cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    conn.Close();
                }
            }
            return returnNum;
        }
Exemplo n.º 3
0
        public AnestheticPlanPremedication GetAnestheticPlanPremedication(int patientId, params AnestheticPlanPremedication.LazyComponents[] lazyComponents)
        {
            AnestheticPlanPremedication anesPlanPremed = new AnestheticPlanPremedication();
            using (SqlConnection conn = new SqlConnection(connString))
            {

                string sql = BuildAnestheticPlanPremedicationSQL();

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

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

                foreach (AnestheticPlanPremedication.LazyComponents a in lazyComponents)
                {
                    if (a == AnestheticPlanPremedication.LazyComponents.LOAD_SEDATIVE_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 += @" LEFT OUTER JOIN dbo.Dropdown_Types as b ON a.SedativeDrugId = b.Id ";
                    }
                    else if (a == AnestheticPlanPremedication.LazyComponents.LOAD_OPIOID_DRUG_WITH_DETAILS)
                        {
                            sql += @", d.CategoryId as 'd.CategoryId', d.Label as 'd.Label', d.OtherFlag as 'd.OtherFlag', d.Description as 'd.Description',
                                    d.Concentration as 'd.Concentration', d.MaxDosage as 'd.MaxDosage' ";
                            from += @" LEFT OUTER JOIN dbo.Dropdown_Types as d ON a.OpioidDrugId = d.Id ";
                        }

                    else if (a == AnestheticPlanPremedication.LazyComponents.LOAD_ANTICHOLINERGIC_DRUG_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', e.MaxDosage as 'e.MaxDosage' ";
                        from += @" LEFT OUTER JOIN dbo.Dropdown_Types as e ON a.AnticholinergicDrugId = e.Id ";
                    }
                    else if (a == AnestheticPlanPremedication.LazyComponents.LOAD_ROUTE_WITH_DETAILS)
                    {
                        sql += @", c.CategoryId as 'c.CategoryId', c.Label as 'c.Label', c.OtherFlag as 'c.OtherFlag', c.Description as 'c.Description',
                                    c.Concentration as 'c.Concentration' ";
                        from += @" LEFT OUTER JOIN dbo.Dropdown_Types as c ON a.RouteId = c.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())
                    {
                        anesPlanPremed = new AnestheticPlanPremedicationCallback().ProcessRow(read, lazyComponents);
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    conn.Close();
                }
            }
            return anesPlanPremed;
        }
Exemplo n.º 4
0
        public void CreateAnestheticPlanPremedication(AnestheticPlanPremedication premed)
        {
            using (SqlConnection conn = new SqlConnection(connString))
            {
                string sql = @"INSERT INTO dbo.Anesthetic_Plan_Premed (
                            PatientId, RouteId, SedativeDosage, SedativeDrugId, OpioidDosage, OpioidDrugId, AnticholinergicDrugId, AnticholinergicDosage, KetamineDosage
                            ) VALUES (
                            @PatientId, @RouteId, @SedativeDosage, @SedativeDrugId, @OpioidDosage, @OpioidDrugId, @AnticholinergicDrugId, @AnticholinergicDosage, @KetamineDosage
                            )";

                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.Add("@PatientId", SqlDbType.Int).Value = premed.PatientId;
                if (premed.SedativeDrug.Id == -1)
                    cmd.Parameters.Add("@SedativeDrugId", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@SedativeDrugId", SqlDbType.Int).Value = premed.SedativeDrug.Id;
                if (premed.SedativeDosage == 0.0M)
                    cmd.Parameters.Add("@SedativeDosage", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@SedativeDosage", SqlDbType.Decimal).Value = premed.SedativeDosage;
                if (premed.OpioidDosage == 0.0M)
                    cmd.Parameters.Add("@OpioidDosage", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@OpioidDosage", SqlDbType.Decimal).Value = premed.OpioidDosage;
                if (premed.OpioidDrug.Id == -1)
                    cmd.Parameters.Add("@OpioidDrugId", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@OpioidDrugId", SqlDbType.Int).Value = premed.OpioidDrug.Id;
                if (premed.AnticholinergicDrug.Id == -1)
                    cmd.Parameters.Add("@AnticholinergicDrugId", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@AnticholinergicDrugId", SqlDbType.Int).Value = premed.AnticholinergicDrug.Id;
                if (premed.AnticholinergicDosage == 0.0M)
                    cmd.Parameters.Add("@AnticholinergicDosage", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@AnticholinergicDosage", SqlDbType.Decimal).Value = premed.AnticholinergicDosage;
                if (premed.KetamineDosage == 0.0M)
                    cmd.Parameters.Add("@KetamineDosage", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@KetamineDosage", SqlDbType.Decimal).Value = premed.KetamineDosage;
                if (premed.Route.Id == -1)
                    cmd.Parameters.Add("@RouteId", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@RouteId", SqlDbType.Decimal).Value = premed.Route.Id;
                try
                {
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    conn.Close();
                }
            }
        }
Exemplo n.º 5
0
 public AnestheticPlan()
 {
     _inhalantPlan = new AnestheticPlanInhalant();
     _injectionPlan = new AnestheticPlanInjection();
     _preMedications = new AnestheticPlanPremedication();
 }