Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello! Welcome to the OPD searcher.");
            Console.WriteLine("Attempting to acquire report and data dictionary");
            try
            {
                //Here we get all of the authors from the RedCap report.
                authors = (List <Person>)AcquireData.GetData.CreatePeopleList();
                AcquireData.GetData.CreateDictionaries();
            }
            catch (ArgumentException e)
            {
                Console.WriteLine("Error in acquiring Data. Printing error message" + e.Message);
            }

            Console.WriteLine("Successfully acquired Authors and Data Dictionary.");
            //foreach(Person author in authors)
            for (int i = 486; i < authors.Count; i++)
            {
                searchResults = new List <String[]>();

                Person author = authors[i];

                Console.WriteLine("Author #" + (i + 1) + ": " + author.first + " " + author.last + " - " + author.cities + "," + author.states + " Authorship #: " + author.authorshipNumber + " Receive Date: " + author.receiveddate);
                //Console.WriteLine(author.first + " " + author.last + " - " + author.city + "," + GetData.stateDictionary[int.Parse(author.state)]);
                List <String[]> results = new List <String[]>();
                try
                {
                    //While all of these threads are commented out, I will keep them in just in case we need to abandon the SQL method,
                    //At which point threads are the best way of searching all of the years.
                    string[] dates = author.receiveddate.Split('-');
                    int      year  = int.Parse(dates[0]);

                    //This is to try and find the PhysicianID before doing any major searching.
                    for (int currentYear = year; currentYear >= year - 4; currentYear--)
                    {
                        //If the Physician ID has been found, break out of the loop
                        if (GetOPDAndSQLData.PhysicianID != null)
                        {
                            break;
                        }

                        GetOPDAndSQLData.AcquirePhysicianID(author.first, author.last, author.cities, author.states, $"OPD_GNRL_{currentYear}");
                    }
                    //If we find the Physician ID, then we begin searching through all of the tables.
                    if (GetOPDAndSQLData.PhysicianID != null)
                    {
                        if (year == 2018)
                        {
                            OPDYearSearch(2018, author);
                            OPDYearSearch(2017, author);
                            OPDYearSearch(2016, author);
                            OPDYearSearch(2015, author);
                        }
                        else if (year == 2017)
                        {
                            OPDYearSearch(2017, author);
                            OPDYearSearch(2016, author);
                            OPDYearSearch(2015, author);
                            OPDYearSearch(2014, author);
                        }
                        else if (year == 2016)
                        {
                            OPDYearSearch(2016, author);
                            OPDYearSearch(2015, author);
                            OPDYearSearch(2014, author);
                            OPDYearSearch(2013, author);
                        }
                        else if (year == 2015)
                        {
                            OPDYearSearch(2015, author);
                            OPDYearSearch(2014, author);
                            OPDYearSearch(2013, author);
                        }
                        else if (year == 2014)
                        {
                            OPDYearSearch(2014, author);
                            OPDYearSearch(2013, author);
                        }
                        else if (year == 2013)
                        {
                            OPDYearSearch(2013, author);
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                //This was just for testing purposes.
                //OutputToCSV(searchResults);
                if (searchResults.Count > 0)
                {
                    AnalyzeOPDList(searchResults, author);
                }
                else
                {
                    // Console.WriteLine($"Could not find {author.first}, {author.last} at location {author.city}, {author.state}.");
                    string[] row = { author.first, author.last, author.authorshipNumber.ToString(), "Not Found", author.cities.Replace(',', ';'), author.states.Replace(',', ';'), " ", GetOPDAndSQLData.FindAuthorPosition(author.first, author.last), author.articleNumber, author.journal, author.receiveddate, "N/A" };
                    OutputToCSV(row, authoroutputFilePath);
                }
                //We reset the PhysicianID to null here so that the next author has to do the process at least once.
                GetOPDAndSQLData.PhysicianID = null;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// this method is used by the threads to search the OPD. right now it is not being used but if the threads have to
 /// be used again this is the method they use.
 /// </summary>
 /// <param name="year">the year to search</param>
 /// <param name="author">the author being searched</param>
 private static void VoidSearchOPD(int year, Person author)
 {
     searchResults.AddRange(GetOPDAndSQLData.FindPeopleFromOPD(author.first, author.last, author.middle, author.cities, GetData.stateDictionary[int.Parse(author.states)],
                                                               @$ "C:\Users\devin\OneDrive\Documents\COI Report\OPD CSVs\{year}\OP_DTL_GNRL_PGYR{year}_P01172020.csv"));