Example #1
0
        /// <summary>
        /// Builds a list of SearchTerms from a string array
        /// </summary>
        /// <param name="terms">The string array</param>
        /// <returns>A list of SearchTerms</returns>
        public static List <SearchTerm> GetSearchTerms(string[] terms)
        {
            List <SearchTerm> returnValue = new List <SearchTerm>();

            foreach (string term in terms)
            {
                SearchTerm st = GetSearchTerm(term);
                returnValue.Add(st);
            }
            return(returnValue);
        }
Example #2
0
 /// <summary>
 /// Pulls the specified search term
 /// </summary>
 /// <param name="id">The Component ID to pull</param>
 /// <returns>The Search Term that was found</returns>
 private SearchTerm GetSearchQueryItem(string id)
 {
     try
     {
         SearchTerm st = searchGroup.Find(delegate(SearchTerm s) { return(s.ID == id); });
         return(st);
     }
     catch (Exception ex)
     {
         Log.LogException(ex).ShowDialog();
         return(null);
     }
 }
Example #3
0
 /// <summary>
 /// Add Button Click Event: Adds a new search query group to the search query string builder.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         searchGroup          = new List <SearchTerm>();
         txtCurrentQuery.Text = SearchTerm.BuildSearchQueryString(searchQuery) + "|";
         dgvComponents.Rows.Clear();
         bgw.RunWorkerAsync();
     }
     catch (Exception ex)
     {
         Log.LogException(ex).ShowDialog();
     }
 }
Example #4
0
 /// <summary>
 /// Removes a search term from the list with the specified component id
 /// </summary>
 /// <param name="id">The component ID to remove</param>
 private void RemoveSearchQueryItem(string id)
 {
     try
     {
         SearchTerm st = GetSearchQueryItem(id);
         if (st != null)
         {
             searchGroup.Remove(st);
         }
     }
     catch (Exception ex)
     {
         Log.LogException(ex).ShowDialog();
     }
 }
Example #5
0
        /// <summary>
        /// Gets the search term from the specified search string
        /// </summary>
        /// <param name="term">The term to get</param>
        /// <returns>Returns the SearchTerm</returns>
        public static SearchTerm GetSearchTerm(string term)
        {
            SearchTerm st = new SearchTerm();

            if (term.Contains("]"))
            {
                Regex idReg   = new Regex("(?<=\\[)[A-Za-z0-9]+-[0-9]+.[0-9]+(?=\\])");
                Match idMatch = idReg.Match(term);
                st.ID    = idMatch.Value;
                st.Value = idReg.Replace(term, "");
                st.Value = st.Value.Replace("[", "");
                st.Value = st.Value.Replace("]", "");
            }
            return(st);
        }
Example #6
0
        /// <summary>
        /// SearchTerm Constructor
        /// </summary>
        /// <param name="term"></param>
        public SearchTerm(string term)
        {
            SearchTerm st = GetSearchTerm(term);

            if (st != null)
            {
                ID    = st.ID;
                Value = st.Value;
            }
            else
            {
                ID    = "";
                Value = "";
            }
        }
Example #7
0
 /// <summary>
 /// Adds a search item to the search query
 /// </summary>
 /// <param name="id">The ID of the component to set a value for</param>
 /// <param name="v">The value to use in the search term</param>
 private void AddSearchQueryItem(string id, string v)
 {
     try
     {
         SearchTerm old = GetSearchQueryItem(id);
         if (old != null)
         {
             RemoveSearchQueryItem(id);
         }
         SearchTerm st = new SearchTerm();
         st.ID    = id;
         st.Value = v;
         searchGroup.Add(st);
     }
     catch (Exception ex)
     {
         Log.LogException(ex).ShowDialog();
     }
 }
Example #8
0
        /// <summary>
        /// Form Load Event: Loads settings and sets up Background Worker.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmSearch_Load(object sender, EventArgs e)
        {
            try
            {
                Settings s = new Settings();
                s.GetSettings();
                txtSearchPath.Text = s.SearchPath;
                Extensions         = s.Extensions;

                PreviousSearches = SearchTerm.PullPreviousQueries();
                txtSearchTerms.AutoCompleteCustomSource.AddRange(PreviousSearches.ToArray());

                bgw.WorkerSupportsCancellation = true;
                bgw.WorkerReportsProgress      = true;
                bgw.DoWork += new DoWorkEventHandler(bgw_DoWork);
            }
            catch (Exception ex)
            {
                Log.LogException(ex).ShowDialog();
            }
        }
Example #9
0
        /// <summary>
        /// Gets the search terms from a string of search terms
        /// </summary>
        /// <param name="terms">The string of terms to search</param>
        /// <returns>The double list of search terms and search term groups</returns>
        public static List <List <SearchTerm> > GetSearchTerms(string terms)
        {
            List <List <SearchTerm> > returnValue = new List <List <SearchTerm> >();

            if (terms.Length > 0)
            {
                foreach (string term in terms.Split('|'))
                {
                    List <SearchTerm> searchGroup = new List <SearchTerm>();
                    foreach (string t in term.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        SearchTerm st = GetSearchTerm(t);
                        searchGroup.Add(st);
                    }
                    returnValue.Add(searchGroup);
                }
            }
            else
            {
                returnValue = new List <List <SearchTerm> >();
            }
            return(returnValue);
        }
Example #10
0
        /// <summary>
        /// Searches the message using the search query.
        /// </summary>
        /// <param name="m">The message to search</param>
        /// <returns>Returns true if the message matches the search query</returns>
        private bool SearchMessage(HL7Lib.Base.Message m)
        {
            try
            {
                bool returnValue = false;

                foreach (string item in txtSearchTerms.Text.Split('|'))
                {
                    bool allMatched = false;
                    List <SearchTerm> searchTerms = SearchTerm.GetSearchTerms(item.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries));
                    foreach (SearchTerm st in searchTerms)
                    {
                        HL7Lib.Base.Component c = m.GetByID(st.ID, st.Value.ToUpper());
                        if (!String.IsNullOrEmpty(c.ID))
                        {
                            allMatched = true;
                        }
                        else
                        {
                            allMatched = false;
                            break;
                        }
                    }
                    if (allMatched)
                    {
                        returnValue = true;
                        break;
                    }
                }
                return(returnValue);
            }
            catch (Exception ex)
            {
                Log.LogException(ex).ShowDialog();
                return(false);
            }
        }
Example #11
0
 /// <summary>
 /// Initialization Method: Sets the current search query for display
 /// </summary>
 /// <param name="query">The current search query</param>
 public frmBuildSearch(string query)
 {
     InitializeComponent();
     searchQuery          = SearchTerm.GetSearchTerms(query);
     txtCurrentQuery.Text = SearchTerm.BuildSearchQueryString(searchQuery);
 }
Example #12
0
 private void frmSearch_FormClosed(object sender, FormClosedEventArgs e)
 {
     SearchTerm.SavePreviousQueries(PreviousSearches);
 }