示例#1
0
        /// <summary>
        /// The rx_GetDrugInteractions.
        /// </summary>
        /// <param name="patientId">The patientId<see cref="int"/>.</param>
        /// <param name="genDrugId">The genDrugId<see cref="string"/>.</param>
        /// <param name="passKey">The passKey<see cref="string"/>.</param>
        /// <returns>The <see cref="List{DrugDrugInterResult}"/>.</returns>
        public List <DrugDrugInterResult> rx_GetDrugInteractions(int patientId, string genDrugId, string passKey)
        {
            if (!ValidationAndEncryptDecrypt.ValidateKey(passKey))
            {
                return(null);
            }

            if (patientId == 0)
            {
                return(null);
            }

            SqlConnection dbConn = new SqlConnection();
            GenericDAL    myDal  = null;

            try
            {
                dbConn = OpenLexidataConnection();
                myDal  = GetLexidataDAL(dbConn);

                ScreeningContext interactionScreening = new ScreeningContext();



                // add existing drugs
                SqlCommand cmd = XSql1.CreateStoredProcedureCommand("rx_SelectPatientInteractionData");
                cmd.AddParameter("@PatientId", patientId);
                DataSet interactDs = XSql1.GetDataSet(cmd);

                foreach (DataRow row in interactDs.Tables[0].Rows)
                {
                    int productId = row["RootProductId"].ToString().ToInt(0);

                    if (productId > 0)
                    {
                        GenericDrug gd = myDal.GetGenericDrug((myDal.GetGenericProduct(productId)).GenDrugID);
                        if (gd != null)
                        {
                            interactionScreening.Drugs.Add(gd);
                        }
                    }
                }
                // Add new drug
                GenericDrug newGd = myDal.GetGenericDrug(genDrugId);
                if (newGd != null)
                {
                    interactionScreening.Drugs.Add(newGd);
                }

                var drugInteractions = myDal.GetDrugDrugInteractions(interactionScreening, false, 0);

                List <DrugDrugInterResult> ddirList = new List <DrugDrugInterResult>();

                foreach (DrugDrugInteractionResult ddir in drugInteractions)
                {
                    DrugDrugInterResult newDdir = new DrugDrugInterResult
                    {
                        Drug1 = { GenDrugId = ddir.Drug1.GenDrugID, GenericName = ddir.Drug1.GenericName },
                        Drug2 = { GenDrugId = ddir.Drug2.GenDrugID, GenericName = ddir.Drug2.GenericName },
                        InteractionDescription = ddir.InteractionDescription,
                        SeverityDescription    = ddir.SeverityDescription
                    };

                    ddirList.Add(newDdir);
                }

                return(ddirList);
            }
            catch (Exception e)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Method: rx_GetDrugInteractions");
                sb.AppendLine("PatientId: " + patientId);
                sb.AppendLine(genDrugId == null ? "genDrugId is null" : "genDrugId: " + genDrugId);
                sb.AppendLine("");
                sb.AppendLine(e.ExceptionToString());
                WriteEventLogEntry(sb.ToString());
                sb.Clear();
                sb.Destroy();
                throw;
            }
            finally
            {
                myDal.Destroy();
                CloseConnection(dbConn);
            }
        }
示例#2
0
        /// <summary>
        /// Get drug 2 drug interactions.
        /// </summary>
        /// <param name="productId">The product identifier.</param>
        /// <param name="genDrugId">The gen drug identifier.</param>
        /// <param name="passKey">The pass key.</param>
        /// <returns>List&lt;DrugDrugInterResult&gt;.</returns>
        public List <DrugDrugInterResult> rx_GetDrugDrugInteractions(int productId, string genDrugId, string passKey)
        {
            if (!ValidationAndEncryptDecrypt.ValidateKey(passKey))
            {
                return(null);
            }

            if (productId == 0)
            {
                return(null);
            }

            SqlConnection dbConn = new SqlConnection();
            GenericDAL    myDal  = null;

            try
            {
                dbConn = OpenLexidataConnection();
                myDal  = GetLexidataDAL(dbConn);

                ScreeningContext screen = new ScreeningContext();

                GenericDrug gd = myDal.GetGenericDrug((myDal.GetGenericProduct(productId)).GenDrugID);
                if (gd != null)
                {
                    screen.Drugs.Add(gd);
                }

                GenericDrug newGd = myDal.GetGenericDrug(genDrugId);
                if (gd != null)
                {
                    screen.Drugs.Add(newGd);
                }

                var drugInteractions = myDal.GetDrugDrugInteractions(screen, false, 0);

                List <DrugDrugInterResult> r = new List <DrugDrugInterResult>();

                foreach (DrugDrugInteractionResult ir in drugInteractions)
                {
                    DrugDrugInterResult newR = new DrugDrugInterResult
                    {
                        Drug1 = { GenDrugId = ir.Drug1.GenDrugID, GenericName = ir.Drug1.GenericName },
                        Drug2 = { GenDrugId = ir.Drug2.GenDrugID, GenericName = ir.Drug2.GenericName },
                        InteractionDescription = ir.InteractionDescription,
                        SeverityDescription    = ir.SeverityDescription
                    };

                    r.Add(newR);
                }

                return(r);
            }
            catch (Exception e)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Method: rx_GetDrugDrugInteractions");
                sb.AppendLine("ProductId: " + productId);
                sb.AppendLine(genDrugId == null ? "genDrugId is null" : "genDrugId: " + genDrugId);
                sb.AppendLine("");
                sb.AppendLine(e.ExceptionToString());
                WriteEventLogEntry(sb.ToString());
                sb.Clear();
                sb.Destroy();
                throw;
            }
            finally
            {
                myDal.Destroy();
                CloseConnection(dbConn);
            }
        }