Beispiel #1
0
 public void SaveAnestheticInjectionPlans(AnestheticPlanInjection injects)
 {
     service.DeleteAnestheticPlanInhalant(injects.PatientId);
     if (service.UpdateAnestheticPlanInjection(injects) == 0)
         service.CreateAnestheticPlanInjection(injects);
 }
Beispiel #2
0
        public int UpdateAnestheticPlanInjection(AnestheticPlanInjection injection)
        {
            int returnNum = 0;
            using (SqlConnection conn = new SqlConnection(connString))
            {
                string sql = @"UPDATE dbo.Anesthetic_Plan_Injection SET
                            DrugId = @DrugId, RouteId = @RouteId, Dosage = @Dosage
                            WHERE
                            PatientId = @PatientId";

                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.Add("@PatientId", SqlDbType.Int).Value = injection.PatientId;
                if (injection.Drug.Id == -1)
                    cmd.Parameters.Add("@DrugId", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@DrugId", SqlDbType.Int).Value = injection.Drug.Id;
                if (injection.Route.Id == -1)
                    cmd.Parameters.Add("@RouteId", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@RouteId", SqlDbType.Decimal).Value = injection.Route.Id;
                if (injection.Dosage == 0.0M)
                    cmd.Parameters.Add("@Dosage", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@Dosage", SqlDbType.Decimal).Value = injection.Dosage;
                try
                {
                    conn.Open();
                    returnNum = cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    conn.Close();
                }
            }
            return returnNum;
        }
Beispiel #3
0
        public AnestheticPlanInjection GetAnestheticPlanInjection(int patientId, params AnestheticPlanInjection.LazyComponents[] lazyComponents)
        {
            AnestheticPlanInjection anesPlanInject = new AnestheticPlanInjection();
            using (SqlConnection conn = new SqlConnection(connString))
            {

                string sql = BuildAnestheticPlanInjectionSQL();

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

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

                foreach (AnestheticPlanInjection.LazyComponents a in lazyComponents)
                {
                    if (a == AnestheticPlanInjection.LazyComponents.LOAD_DRUG_INFORMATION)
                    {
                        sql += @", b.Id as 'b.Id', b.DoseMinRange as 'b.DoseMinRange', b.DoseMaxRange as 'b.DoseMaxRange', b.DoseMax as 'b.DoseMax',
                              b.DoseUnits as 'b.DoseUnits', b.Route as 'b.Route', b.Concentration as 'b.Concentration', b.ConcentrationUnits as 'b.ConcentrationUnits',
                                    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.Drug_Information as b ON a.DrugId = b.DrugId
                                   LEFT OUTER JOIN dbo.Dropdown_Types d on d.Id = b.DrugId";
                    }

                    else if (a == AnestheticPlanInjection.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())
                    {
                        anesPlanInject = new AnestheticPlanInjectionCallback().ProcessRow(read, lazyComponents);
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    conn.Close();
                }
            }
            return anesPlanInject;
        }
Beispiel #4
0
        public void CreateAnestheticPlanInjection(AnestheticPlanInjection injection)
        {
            using (SqlConnection conn = new SqlConnection(connString))
            {
                string sql = @"INSERT INTO dbo.Anesthetic_Plan_Injection (
                            PatientId, DrugId, RouteId, Dosage
                            ) VALUES (
                            @PatientId, @DrugId, @RouteId, @Dosage
                            )";

                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.Add("@PatientId", SqlDbType.Int).Value = injection.PatientId;
                if (injection.Drug.Id == -1)
                    cmd.Parameters.Add("@DrugId", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@DrugId", SqlDbType.Int).Value = injection.Drug.Id;
                if (injection.Route.Id == -1)
                    cmd.Parameters.Add("@RouteId", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@RouteId", SqlDbType.Decimal).Value = injection.Route.Id;
                if (injection.Dosage == 0.0M)
                    cmd.Parameters.Add("@Dosage", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@Dosage", SqlDbType.Decimal).Value = injection.Dosage;
                try
                {
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    conn.Close();
                }
            }
        }
Beispiel #5
0
 public AnestheticPlan()
 {
     _inhalantPlan = new AnestheticPlanInhalant();
     _injectionPlan = new AnestheticPlanInjection();
     _preMedications = new AnestheticPlanPremedication();
 }