Example #1
0
 public void SaveMaintenanceInhalantDrugs(MaintenanceInhalantDrug drugs)
 {
     service.DeleteMaintenanceInjectionDrug(drugs.PatientId);
     if (service.UpdateMaintenanceInhalantDrug(drugs) == 0)
         service.CreateMaintenanceInhalantDrug(drugs);
 }
Example #2
0
        public void CreateMaintenanceInhalantDrug(MaintenanceInhalantDrug maintInhalant)
        {
            using (SqlConnection conn = new SqlConnection(connString))
            {
                string sql = @"INSERT INTO dbo.Maintenance_Inhalant_Drugs_To_Patient (
                            PatientId, DrugId, InductionDose, InductionOxygenFlowRate,
                            MaintenanceDose, MaintenanceOxygenFlowRate, BreathingSystemId, BreathingBagSizeId
                            ) VALUES (
                            @PatientId, @DrugId, @InductionDose, @InductionOxygenFlowRate,
                            @MaintenanceDose, @MaintenanceOxygenFlowRate, @BreathingSystemId, @BreathingBagSizeId
                            )";

                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.Add("@PatientId", SqlDbType.Int).Value = maintInhalant.PatientId;
                if (maintInhalant.Drug.Id == -1)
                    cmd.Parameters.Add("@DrugId", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@DrugId", SqlDbType.Int).Value = maintInhalant.Drug.Id;
                if (maintInhalant.InductionPercentage == 0.0M)
                    cmd.Parameters.Add("@InductionDose", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@InductionDose", SqlDbType.Decimal).Value = maintInhalant.InductionPercentage;
                if (maintInhalant.InductionOxygenFlowRate == 0.0M)
                    cmd.Parameters.Add("@InductionOxygenFlowRate", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@InductionOxygenFlowRate", SqlDbType.Decimal).Value = maintInhalant.InductionOxygenFlowRate;
                if (maintInhalant.MaintenancePercentage == 0.0M)
                    cmd.Parameters.Add("@MaintenanceDose", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@MaintenanceDose", SqlDbType.Decimal).Value = maintInhalant.MaintenancePercentage;
                if (maintInhalant.MaintenanceOxygenFlowRate == 0.0M)
                    cmd.Parameters.Add("@MaintenanceOxygenFlowRate", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@MaintenanceOxygenFlowRate", SqlDbType.Decimal).Value = maintInhalant.MaintenanceOxygenFlowRate;
                if (maintInhalant.BreathingSystem.Id == -1)
                    cmd.Parameters.Add("@BreathingSystemId", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@BreathingSystemId", SqlDbType.Int).Value = maintInhalant.BreathingSystem.Id;
                if (maintInhalant.BreathingBagSize.Id == -1)
                    cmd.Parameters.Add("@BreathingBagSizeId", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@BreathingBagSizeId", SqlDbType.Int).Value = maintInhalant.BreathingBagSize.Id;
                try
                {
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    conn.Close();
                }
            }
        }
Example #3
0
        public MaintenanceInhalantDrug GetMaintenanceInhalantDrugs(int patientId, params MaintenanceInhalantDrug.LazyComponents[] lazyComponents)
        {
            MaintenanceInhalantDrug maintInhalantDrugs = new MaintenanceInhalantDrug();
            using (SqlConnection conn = new SqlConnection(connString))
            {

                string sql = BuildMaintenanceInhalantDrugSQL();

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

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

                foreach (MaintenanceInhalantDrug.LazyComponents a in lazyComponents)
                {
                    if (a == MaintenanceInhalantDrug.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 += @" LEFT OUTER JOIN dbo.Dropdown_Types as b ON a.DrugId = b.Id ";
                    }
                    else if (a == MaintenanceInhalantDrug.LazyComponents.LOAD_BREATHING_BAG_SIZE_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.BreathingSystemId = c.Id ";
                    }
                    else if (a == MaintenanceInhalantDrug.LazyComponents.LOAD_BREATHING_SYSTEM_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' ";
                        from += @" LEFT OUTER JOIN dbo.Dropdown_Types as d ON a.BreathingBagSizeId = d.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())
                    {
                        maintInhalantDrugs = new MaintenanceInhalantDrugCallback().ProcessRow(read, lazyComponents);
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    conn.Close();
                }
            }
            return maintInhalantDrugs;
        }
Example #4
0
        public int UpdateMaintenanceInhalantDrug(MaintenanceInhalantDrug maintInhalant)
        {
            int returnNum = 0;
            using (SqlConnection conn = new SqlConnection(connString))
            {
                string sql = @"UPDATE dbo.Maintenance_Inhalant_Drugs_To_Patient SET
                            DrugId = @DrugId, InductionDose = @InductionDose, InductionOxygenFlowRate = @InductionOxygenFlowRate,
                            MaintenanceDose = @MaintenanceDose, MaintenanceOxygenFlowRate = @MaintenanceOxygenFlowRate,
                            BreathingSystemId = @BreathingSystemId, BreathingBagSizeId = @BreathingBagSizeId
                            WHERE
                            PatientId = @PatientId";

                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.Add("@PatientId", SqlDbType.Int).Value = maintInhalant.PatientId;
                if (maintInhalant.Drug.Id == -1)
                    cmd.Parameters.Add("@DrugId", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@DrugId", SqlDbType.Int).Value = maintInhalant.Drug.Id;
                if (maintInhalant.InductionPercentage == 0.0M)
                    cmd.Parameters.Add("@InductionDose", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@InductionDose", SqlDbType.Decimal).Value = maintInhalant.InductionPercentage;
                if (maintInhalant.InductionOxygenFlowRate == 0.0M)
                    cmd.Parameters.Add("@InductionOxygenFlowRate", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@InductionOxygenFlowRate", SqlDbType.Decimal).Value = maintInhalant.InductionOxygenFlowRate;
                if (maintInhalant.MaintenancePercentage == 0.0M)
                    cmd.Parameters.Add("@MaintenanceDose", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@MaintenanceDose", SqlDbType.Decimal).Value = maintInhalant.MaintenancePercentage;
                if (maintInhalant.MaintenanceOxygenFlowRate == 0.0M)
                    cmd.Parameters.Add("@MaintenanceOxygenFlowRate", SqlDbType.Decimal).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@MaintenanceOxygenFlowRate", SqlDbType.Decimal).Value = maintInhalant.MaintenanceOxygenFlowRate;
                if (maintInhalant.BreathingSystem.Id == -1)
                    cmd.Parameters.Add("@BreathingSystemId", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@BreathingSystemId", SqlDbType.Int).Value = maintInhalant.BreathingSystem.Id;
                if (maintInhalant.BreathingBagSize.Id == -1)
                    cmd.Parameters.Add("@BreathingBagSizeId", SqlDbType.Int).Value = DBNull.Value;
                else
                    cmd.Parameters.Add("@BreathingBagSizeId", SqlDbType.Int).Value = maintInhalant.BreathingBagSize.Id;
                try
                {
                    conn.Open();
                    returnNum = cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    conn.Close();
                }
            }
            return returnNum;
        }
Example #5
0
 public Maintenance()
 {
     _maintenanceInjectionDrug = new MaintenanceInjectionDrug();
     _maintenanceInhalantDrug = new MaintenanceInhalantDrug();
     _maintenanceOther = new MaintenanceOther();
 }