예제 #1
0
        /// <summary>
        /// Get common order results.
        /// </summary>
        /// <param name="drugId">The drug identifier.</param>
        /// <param name="productId">The product identifier.</param>
        /// <param name="localDataSetId">The local data set identifier.</param>
        /// <param name="passKey">The pass key.</param>
        /// <returns>List&lt;LexiData.CommonOrderResult&gt;.</returns>
        public List <CommonOrderResult> rx_GetCommonOrderResults(string drugId, int productId, int localDataSetId, string passKey)
        {
            if (!ValidationAndEncryptDecrypt.ValidateKey(passKey))
            {
                return(null);
            }

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

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

                var result = myDal.GetCommonOrderResults(drugId, productId, localDataSetId);

                return(result);
            }
            catch (Exception e)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Method: rx_GetCommonOrderResults");
                sb.AppendLine(drugId == null ? "DrugId is null" : "DrugId: " + drugId);
                sb.AppendLine(productId == 0 ? "productId is zero" : "productId: " + productId);
                sb.AppendLine(localDataSetId == 0 ? "localDataSetID is zero" : "localDataSetID: " + localDataSetId);
                sb.AppendLine("");
                sb.AppendLine(e.ExceptionToString());
                WriteEventLogEntry(sb.ToString());
                sb.Clear();
                sb.Destroy();
                throw;
            }
            finally
            {
                myDal.Destroy();
                CloseConnection(dbConn);
            }
        }
예제 #2
0
        /// <summary>
        /// Search generic drug.
        /// </summary>
        /// <param name="searchText">The search text.</param>
        /// <param name="searchCriteria">The search criteria.</param>
        /// <param name="drugFilter">The drug filter.</param>
        /// <param name="passKey">The pass key.</param>
        /// <returns>List&lt;LexiData.GenericDrug&gt;.</returns>
        public List <GenericDrug> rx_SearchGenericDrug(string searchText, SearchCriteria searchCriteria, DrugFilter drugFilter, string passKey)
        {
            if (!ValidationAndEncryptDecrypt.ValidateKey(passKey))
            {
                return(null);
            }

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

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

                var genericDrug = myDal.SearchGenericDrug(searchText, searchCriteria, drugFilter);

                return(genericDrug);
            }
            catch (Exception e)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Method: rx_SearchGenericDrug");
                sb.AppendLine(searchText == null ? "searchText is null" : "searchText: " + searchText);
                sb.AppendLine(searchCriteria == null ? "searchCriteria is null" : "searchCriteria: " + searchCriteria);
                sb.AppendLine(drugFilter == null ? "drugFilter is null" : "drugFilter: " + drugFilter.RxOTCStatus);
                sb.AppendLine("");
                sb.AppendLine(e.ExceptionToString());
                WriteEventLogEntry(sb.ToString());
                sb.Clear();
                sb.Destroy();
                throw;
            }
            finally
            {
                myDal.Destroy();
                CloseConnection(dbConn);
            }
        }
예제 #3
0
        /// <summary>
        /// Get generic drug products.
        /// </summary>
        /// <param name="genericDrugId">The generic drug identifier.</param>
        /// <param name="df">The df.</param>
        /// <param name="passKey">The pass key.</param>
        /// <returns>List&lt;LexiData.GenericProduct&gt;.</returns>
        public List <GenericProduct> rx_GetGenericDrugProducts(string genericDrugId, DrugFilter df, string passKey)
        {
            if (!ValidationAndEncryptDecrypt.ValidateKey(passKey))
            {
                return(null);
            }

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

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

                var result = myDal.GetGenericDrugProducts(genericDrugId, df);

                return(result);
            }
            catch (Exception e)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Method: rx_GetGenericDrugProducts");
                sb.AppendLine(genericDrugId == null ? "genericDrugId is null" : "genericDrugId: " + genericDrugId);
                sb.AppendLine(df == null ? "df is null" : "df: " + df);
                sb.AppendLine("");
                sb.AppendLine(e.ExceptionToString());
                WriteEventLogEntry(sb.ToString());
                sb.Clear();
                sb.Destroy();
                throw;
            }
            finally
            {
                myDal.Destroy();
                CloseConnection(dbConn);
            }
        }
예제 #4
0
        /// <summary>
        /// Get generic product.
        /// </summary>
        /// <param name="genericProductId">The generic product identifier.</param>
        /// <param name="passKey">The pass key.</param>
        /// <returns>LexiData.GenericProduct.</returns>
        public GenericProduct rx_GetGenericProduct(int genericProductId, string passKey)
        {
            if (!ValidationAndEncryptDecrypt.ValidateKey(passKey))
            {
                return(null);
            }

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

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

                var genericProduct = myDal.GetGenericProduct(genericProductId);

                return(genericProduct);
            }
            catch (Exception e)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Method: rx_GetGenericProduct");
                sb.AppendLine(genericProductId == 0 ? "genericProductId is null" : "genericProductId: " + genericProductId);
                sb.AppendLine("");
                sb.AppendLine(e.ExceptionToString());
                WriteEventLogEntry(sb.ToString());
                sb.Clear();
                sb.Destroy();
                throw;
            }
            finally
            {
                myDal.Destroy();
                CloseConnection(dbConn);
            }
        }
예제 #5
0
        /// <summary>
        /// Get dose route all.
        /// </summary>
        /// <param name="passKey">The pass key.</param>
        /// <returns>List&lt;LexiData.DoseRoute&gt;.</returns>
        public List <DoseRoute> rx_GetDoseRouteAll(string passKey)
        {
            if (!ValidationAndEncryptDecrypt.ValidateKey(passKey))
            {
                return(null);
            }

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

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

                var route = myDal.GetDoseRouteAll();

                return(route);
            }
            catch (Exception e)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Method: rx_GetDoseRouteAll");
                sb.AppendLine("");
                sb.AppendLine(e.ExceptionToString());
                WriteEventLogEntry(sb.ToString());
                sb.Clear();
                sb.Destroy();
                throw;
            }
            finally
            {
                myDal.Destroy();
                CloseConnection(dbConn);
            }
        }
예제 #6
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);
            }
        }
예제 #7
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);
            }
        }
예제 #8
0
        /// <summary>
        /// Get drug allergy interactions.
        /// </summary>
        /// <param name="genericDrugIds">The generic drug ids.</param>
        /// <param name="allergyClassIds">The allergy class ids.</param>
        /// <param name="testDrugId">The test drug identifier.</param>
        /// <param name="passKey">The pass key.</param>
        /// <returns>List&lt;DrugAllergyInterResult&gt;.</returns>
        public List <DrugAllergyInterResult> rx_GetDrugAllergyInteractions(string[] genericDrugIds, int[] allergyClassIds, string testDrugId, string passKey)
        {
            if (!ValidationAndEncryptDecrypt.ValidateKey(passKey))
            {
                return(null);
            }

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

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

                sc = new ScreeningContext();

                foreach (string gdi in genericDrugIds)
                {
                    GenericDrug drugAllergen = myDal.GetGenericDrug(gdi);
                    sc.Allergies.Add(drugAllergen);
                }

                AllergyClass classAllergen = myDal.GetAllergyClass(3);
                sc.Allergies.Add(classAllergen);

                GenericDrug drug1 = myDal.GetGenericDrug(testDrugId);
                sc.Drugs.Add(drug1);


                List <DrugAllergyResult> results = myDal.GetDrugAllergyInteractions(sc, false);

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

                foreach (DrugAllergyResult ir in results)
                {
                    DrugAllergyInterResult newR = new DrugAllergyInterResult
                    {
                        Drug1     = { GenDrugId = ir.Drug.GenDrugID, GenericName = ir.Drug.GenericName },
                        Allergen1 =
                        {
                            AllergySeverity = ir.Allergen.AllergySeverity,
                            ConceptType     = ir.Allergen.ConceptType.ToString(),
                            Reaction        = ir.Allergen.Reaction
                        },
                        AllergyMessage            = ir.AllergyMessage,
                        AllergySeverity           = ir.AllergySeverity,
                        AllergyXrGroupDescription = ir.AllergyXRGroupDescription,
                        AllergyXrGroupId          = ir.AllergyXRGroupID,
                        ClassDescription          = ir.ClassDescription,
                        ClassDescriptionPlural    = ir.ClassDescriptionPlural,
                        ClassId = ir.ClassID,
                        MatchTypeDescription = ir.MatchTypeDescription,
                        MatchTypeId          = ir.MatchTypeID,
                        Reaction             = ir.Reaction
                    };

                    r.Add(newR);
                }

                return(r);
            }
            catch (Exception e)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Method: rx_GetDrugAllergyInteractions");
                if (genericDrugIds == null)
                {
                    sb.AppendLine("genericDrugIds array is null");
                }
                else
                {
                    foreach (string gdi in genericDrugIds)
                    {
                        sb.AppendLine(gdi == null ? "genericDrugId is null" : "genericDrugId: " + gdi);
                    }
                }
                if (allergyClassIds == null)
                {
                    sb.AppendLine("allergyClassIds array is null");
                }
                else
                {
                    foreach (int adi in allergyClassIds)
                    {
                        sb.AppendLine(adi == 0 ? "allergyClassId is zero" : "allergyClassId: " + adi);
                    }
                }
                sb.AppendLine(testDrugId == null ? "testDrugId is null" : "DrugId: " + testDrugId);
                sb.AppendLine("");
                sb.AppendLine(e.ExceptionToString());
                WriteEventLogEntry(sb.ToString());
                sb.Clear();
                sb.Destroy();
                throw;
            }
            finally
            {
                sc.Destroy();
                myDal.Destroy();
                CloseConnection(dbConn);
            }
        }