/// <summary>
        /// This method is a public call
        /// It calls the database query and uses the preferred name to get the previous
        /// and next term names.
        /// </summary>
        /// <param name="di"></param>
        /// <param name="nRows"></param>
        public static void GetTermNeighbors(DrugDictionaryDataItem di, int nRows)
        {
            try
            {
                // Call the database layer and get data
                DataTable dt = DrugDictionaryQuery.GetTermNeighbors(
                    di.PreferredName, nRows);

                // use Linq to move information from the dataTable
                // into the DrugDictionaryDataItem
                di.PreviousNeighbors.AddRange(
                    from entry in dt.AsEnumerable()
                    where entry["isPrevious"].ToString() == "Y"
                    select GetEntryFromDR(entry)
                    );

                // use Linq to move information from the dataTable
                // into the DrugDictionaryDataItem
                di.NextNeighbors.AddRange(
                    from entry in dt.AsEnumerable()
                    where entry["isPrevious"].ToString() == "N"
                    select GetEntryFromDR(entry)
                    );
            }
            catch (Exception ex)
            {
                CancerGovError.LogError("DrugDictionatyManager", 2, ex);
                throw ex;
            }
        }
        /// <summary>
        /// This methods filters the information passed to it in order to refine the query
        /// that will be called in the database layer.
        /// </summary>
        /// <param name="criteria">The partial text used to query the database</param>
        /// <param name="maxRows">The maximum number of rows that the database will return. a value of zero will return the entire set</param>
        /// <param name="contains">indicator as to whether the text is to be searched starting from the beginning or anywhere
        ///                        in the string</param>
        /// <returns>Returns the search results</returns>
        public static DrugDictionaryCollection SearchNameOnly(string criteria, int maxRows, bool contains)
        {
            DrugDictionaryCollection dc = new DrugDictionaryCollection();

            // Find out how we should search for the string
            if (Strings.Clean(criteria) != null)
            {
                // put the '%' at the end to indicate that the search starts
                // with the criteria passed.
                criteria += "%";

                // put the '%' at the beginning to indicate that the search
                // data contains the criteria passed
                if (contains)
                {
                    criteria = "%" + criteria;
                }

                // The stored procedure needs to change to reflect a 0 number of
                // rows to mean the entire set.
                if (maxRows <= 0)
                {
                    maxRows = 9999;
                }

                try
                {
                    // Call the database layer and get data
                    DataTable dt = DrugDictionaryQuery.SearchNameOnly(criteria, maxRows);

                    // use Linq to move information from the dataTable
                    // into the DrugDictionaryCollection
                    dc.AddRange(
                        from entry in dt.AsEnumerable()
                        select GetEntryFromDR(entry)
                        );
                }
                catch (Exception ex)
                {
                    CancerGovError.LogError("DrugDictionatyManager", 2, ex);
                    throw ex;
                }
            }

            // return the collection
            return(dc);
        }
        /// <summary>
        /// This method calls the database layer for a single item and returns
        /// the drugDictionaryDataItem
        /// </summary>
        /// <param name="termID"></param>
        /// <returns></returns>
        public static DrugDictionaryDataItem GetDefinitionByTermID(int termID)
        {
            DrugDictionaryDataItem di = null;

            try
            {
                // Call the database layer and get data
                DataSet ds =
                    DrugDictionaryQuery.GetDefinitionByTermID(termID);

                // Only do something if we have data
                if (ds.Tables.Count > 0)
                {
                    // Get the entry record
                    if (ds.Tables[0].Rows.Count == 1)
                    {
                        DataRow dr = ds.Tables[0].Rows[0];
                        dr["TermID"] = termID;

                        // build the data item
                        di = GetEntryFromDR(ds.Tables[0].Rows[0]);

                        // Get the display names
                        if (ds.Tables.Count > 1)
                        {
                            GetDisplayNames(di, ds.Tables[1]);
                        }
                    }
                    else if (ds.Tables[0].Rows.Count > 0)
                    {
                        throw new Exception("GetDefinitionByTermID returned more than 1 record.");
                    }
                }
            }
            catch (Exception ex)
            {
                CancerGovError.LogError("DrugDictionaryManager", 2, ex);
                throw ex;
            }

            return(di);
        }
        /// <summary>
        /// This methods filters the information passed to it in order to refine the query
        /// that will be called in the database layer.
        /// </summary>
        /// <param name="criteria">The partial text used to query the database</param>
        /// <param name="maxRows">The maximum number of rows that the database will return. a value of zero will return the entire set</param>
        /// <param name="contains">indicator as to whether the text is to be searched starting from the beginning or anywhere
        ///                        in the string</param>
        /// <returns>Returns the search results</returns>
        public static DrugDictionaryCollection Search(string criteria, int maxRows, int curPage, bool bOtherNames, bool contains)
        {
            DrugDictionaryCollection dc = new DrugDictionaryCollection();

            // Find out how we should search for the string
            if (Strings.Clean(criteria) != null)
            {
                // replace any '[' with '[[]'
                //criteria = criteria.Replace("[", "[[]");

                // put the '%' at the end to indicate that the search starts
                // with the criteria passed.
                criteria += "%";

                // put the '%' at the beginning to indicate that the search
                // data contains the criteria passed
                if (contains)
                {
                    criteria = "%" + criteria;
                }

                // The stored procedure needs to change to reflect a 0 number of
                // rows to mean the entire set.
                if (maxRows <= 0)
                {
                    maxRows = 9999;
                }

                // The stored procedure need to reflect a cur pag of 0 to be 1
                if (curPage == 0)
                {
                    curPage = 1;
                }

                try
                {
                    int queryCount;

                    int matchCount = 0;

                    // Call the database layer and get data
                    DataTable dt = DrugDictionaryQuery.Search(
                        criteria,
                        maxRows,
                        curPage,
                        (bOtherNames ? 'Y' : 'N'),
                        out matchCount
                        );

                    // Set the value on the collection
                    dc.matchCount = matchCount;

                    // Now get a new collection with only one unique termIDs in the collection
                    if (bOtherNames)
                    {
                        concatenateDuplicateEntries(dt, dc);
                    }
                    else
                    {
                        // use Linq to move information from the dataTable
                        // into the DrugDictionaryCollection
                        dc.AddRange(
                            from entry in dt.AsEnumerable()
                            select GetEntryFromDR(entry)
                            );
                    }
                }
                catch (Exception ex)
                {
                    CancerGovError.LogError("DrugDictionatyManager", 2, ex);
                    throw ex;
                }
            }

            // return the collection
            return(dc);
        }