Example #1
0
 private Result <object> Validate()
 {
     if (String.IsNullOrEmpty(provider.LastName))
     {
         return(Result <object> .Failure(ErrorMsg.InvalidLastName));
     }
     else if (String.IsNullOrEmpty(provider.FirstName))
     {
         return(Result <object> .Failure(ErrorMsg.Custom("Invalid First Name")));
     }
     else if (String.IsNullOrEmpty(provider.GetData("orgName")))
     {
         return(Result <object> .Failure(ErrorMsg.Custom("Must include organization to perform search.")));
     }
     else
     {
         return(Result <object> .Success(String.Empty));
     }
 }
Example #2
0
        private Result <string> ParseResponse(List <String> response)
        {
            List <String> headers = new List <String>();

            headers.Add("LASTNAME");
            headers.Add("FIRSTNAME");
            headers.Add("INITIAL");
            headers.Add("LICENSE #");
            headers.Add("DATE ISSUED");
            headers.Add("EXPIRATION DATE");
            headers.Add("License/Certificate Status");
            headers.Add("Disciplined");

            try
            {
                // check discipline
                if (string.Equals(response[response.Count - 1], "Yes", StringComparison.OrdinalIgnoreCase))
                {
                    Sanction = SanctionType.Red;
                }
                else
                {
                    Sanction = SanctionType.None;
                }

                StringBuilder builder = new StringBuilder();

                for (var i = 0; i < response.Count; i++)
                {
                    builder.AppendFormat(TdPair, headers[i], response[i]);
                    builder.AppendLine();
                }

                return(Result <string> .Success(builder.ToString()));
            }
            catch
            {
                return(Result <string> .Failure(ErrorMsg.Custom("Error reading results")));
            }
        }
Example #3
0
        private Result <IRestResponse> Search()
        {
            // PARAMETERS AND COOKIES WE WILL GET WITH FIRST GET
            List <RestResponseCookie> allCookies = new List <RestResponseCookie>();
            string baseUrl = "https://hrlb.oregon.gov/oblpct/licenseelookup/";

            //Set up security protocol
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            //Set up client and request
            RestClient    client   = new RestClient(baseUrl + "index.asp");
            RestRequest   request  = new RestRequest(Method.GET);
            IRestResponse response = client.Execute(request);

            //Store new cookies
            allCookies.AddRange(response.Cookies);

            //Check that we accessed the site
            if (response.StatusCode != HttpStatusCode.OK)
            {
                return(Result <IRestResponse> .Failure(ErrorMsg.CannotAccessSite));
            }

            //Forming new get request with our parameters
            request = new RestRequest(Method.GET);

            string searchUrl = "searchdir.asp?";

            //We perform the search using license numbers if available, last names otherwise
            //Website does not allow both
            if (provider.LicenseNumber != "")
            {
                string licenseType = LicenseType(provider.LicenseNumber);

                if (licenseType == "")
                {
                    return(Result <IRestResponse> .Failure(ErrorMsg.InvalidLicense));
                }
                else if (licenseType == "lmftnum")
                {
                    return(Result <IRestResponse> .Failure(ErrorMsg.Custom("This website does not support LMFT license numbers")));
                }

                searchUrl += "searchby=" + licenseType;

                Match licenseNum = Regex.Match(provider.LicenseNumber, "\\d+");

                searchUrl += "&searchfor=" + licenseNum.Value;
            }
            else
            {
                searchUrl += "searchby=lastName";
                searchUrl += "&searchfor=" + provider.LastName;
            }

            searchUrl += "&stateselect=none&Submit=Search";
            client     = new RestClient(baseUrl + searchUrl);

            //Add cookies to our request
            foreach (RestResponseCookie c in allCookies)
            {
                request.AddCookie(c.Name, c.Value);
            }

            response = client.Execute(request);

            //Store new cookies
            allCookies.AddRange(response.Cookies);

            //Check that we accessed the site
            if (response.StatusCode != HttpStatusCode.OK && response.StatusCode != HttpStatusCode.Redirect)
            {
                return(Result <IRestResponse> .Failure(ErrorMsg.CannotAccessSite));
            }

            MatchCollection providerList = Regex.Matches(response.Content, "(<tr valign='Middle'>)", RegOpt);

            //Check if we have multiple providers
            if (providerList.Count > 1)
            {
                return(Result <IRestResponse> .Failure(ErrorMsg.MultipleProvidersFound));
            }

            //Check if we have no providers
            if (Regex.Match(response.Content, "No Records Found.", RegOpt).Success)
            {
                return(Result <IRestResponse> .Failure(ErrorMsg.NoResultsFound));
            }

            //We have been redirected to the details page
            return(Result <IRestResponse> .Success(response));
        }
Example #4
0
        public override string Fetch(DataRow dr)
        {
            Initialize(dr, true);

            string lic_no    = dr["lic_no"].ToString().Replace(".", "").Replace("-", "").Replace("_", "").Replace("/", "").Replace("\\", "").Replace(" ", "").Trim().ToUpper();
            string firstName = dr["dr_fname"].ToString().Trim();
            string lastName  = dr["dr_lname"].ToString().Trim();
            string org       = dr["orgName"].ToString().Trim();

            if (String.IsNullOrEmpty(org))
            {
                return(ErrorMsg.Custom("Invalid organization name"));
            }
            if (String.IsNullOrEmpty(lic_no))
            {
                return(ErrorMsg.InvalidLicense);
            }
            else if (String.IsNullOrEmpty(firstName) || String.IsNullOrEmpty(lastName))
            {
                return(ErrorMsg.InvalidFirstLastName);
            }

            ArrayList profsToQuery = GetProfsToQuery(dr["drtitle"].ToString().ToUpper());

            if (profsToQuery.Count == 0)
            {
                if (org == "Georgia State Board of Optometry")
                {
                    profsToQuery = GetProfsToQuery("OPT");
                }
                else if (org == "Georgia Board of Nursing")
                {
                    profsToQuery = GetProfsToQuery("RN");
                }
                else if (org == "Georgia State Board of Examiners of Psychologists")
                {
                    profsToQuery = GetProfsToQuery("PSY");
                }
                else if (org == "Georgia Board of Chiropractic Examiners")
                {
                    profsToQuery = GetProfsToQuery("CHIR");
                }
                else if (org == "Georgia Board of Marriage and Family Therapists")
                {
                    profsToQuery = GetProfsToQuery("MFT");
                }
                else if (org == "Georgia Board of Professional Counselors")
                {
                    profsToQuery = GetProfsToQuery("LPC");
                }
                else if (org == "Georgia State Board of Podiatry")
                {
                    profsToQuery = GetProfsToQuery("POD");
                }
                else if (org == "Georgia State Board of Physical Therapy")
                {
                    profsToQuery = GetProfsToQuery("PT");
                }
                //else if (org == "Georgia Secretary of State") { profsToQuery = GetProfsToQuery(""); }
                else
                {
                    Match match = Regex.Match(lic_no, "[a-zA-Z]+", RegexOptions.IgnoreCase);

                    if (match.Success)
                    {
                        profsToQuery = GetProfsToQuery(match.Value);

                        if (profsToQuery.Count == 0)
                        {
                            return(ErrorMsg.InvalidTitle);
                        }
                    }
                    else
                    {
                        return(ErrorMsg.InvalidTitle);
                    }
                }
            }

            HttpWebResponse objResponse = null;
            HttpWebRequest  objRequest  = null;
            //http://sos.ga.gov/myverification/;
            string basehref = "http://verify.sos.ga.gov/verification/";
            string url      = basehref;
            string url2     = basehref;
            string result   = String.Empty;

            //MT 04/23/2008 Hit the login page to get the cookies info
            if (WebFetch.IsError(result = WebFetch.ProcessGetRequest2(ref objRequest, ref objResponse, url, "", null, null)))
            {
                return(ErrorMsg.CannotAccessSite);
            }

            result += "\n\r-----------------------------------\n\r";

            foreach (Cookie c in objResponse.Cookies)
            {
                result += c.Name + ":::" + c.Value + ":::" + c.Expires + "\n\r";
            }

            //Use the cookieColl to hold every cookie from every objResponse that comes back
            string           pattern      = string.Empty;
            string           searchStatus = string.Empty;
            CookieCollection cookieColl   = new CookieCollection();

            //Add response cookies to cookieCollection
            cookieColl.Add(objResponse.Cookies);
            string theViewState  = getFieldVal("__VIEWSTATE", result);
            string eventTarget   = getFieldVal("__EVENTTARGET", result);
            string eventArgument = getFieldVal("__EVENTARGUMENT", result);

            // Since some of these potentially need to query against multiple providers, loop through the list and try each
            // For each of them, check whether there were 0, 1 or n results.  If 1 result, then abort loop, otherwise continue through profs
            foreach (string s in profsToQuery)
            {
                string[] profTypeSplit   = s.Split('|');
                string   professionName  = profTypeSplit[0].Replace(" ", "+");
                string   licenseTypeName = profTypeSplit[1].Replace(" ", "+");

                string
                    post = "__EVENTTARGET=" + eventTarget
                           + "&__EVENTARGUMENT=" + eventArgument
                           + "&__VIEWSTATE=" + theViewState
                           + "&t_web_lookup__profession_name=" + professionName
                           + "&t_web_lookup__license_type_name=" + licenseTypeName
                           + "&t_web_lookup__first_name=" //+ firstName
                           + "&t_web_lookup__last_name="  //+ lastName
                           + "&t_web_lookup__license_no=" + lic_no
                           + "&t_web_lookup__addr_county="
                           + "&sch_button=Search";

                //url = "http://secure.sos.state.ga.us/myverification/Search.aspx";
                url = "http://verify.sos.ga.gov/verification/";

                if (!WebFetch.IsError(result = WebFetch.ProcessPostRequest(ref objRequest, ref objResponse, url, post, "", null, cookieColl)))
                {
                    result = WebFetch.ProcessPostResponse(ref objResponse, ref objRequest);
                }
                else
                {
                    return(ErrorMsg.CannotAccessSearchResultsPage);
                }

                result += "\n\r-----------------------------------\n\r";

                foreach (Cookie c in objResponse.Cookies)
                {
                    result += c.Name + ":::" + c.Value + ":::" + c.Expires + "\n\r";
                }

                // var cookiessss = cookieColl.ToString().Split('/');
                //Add response cookies to cookieCollection
                cookieColl.Add(objResponse.Cookies);
                pattern = "(?<LINK>Details\\.aspx[^\"]*)\"";
                MatchCollection mc = Regex.Matches(result, pattern, RegexOptions.Singleline | RegexOptions.IgnoreCase);
                if (mc.Count < 1)
                {
                    searchStatus = "no matches found";
                }
                else if (mc.Count > 1)
                {
                    searchStatus = "multiple matches found";
                    break;
                }

                else
                {
                    string theLink = mc[0].Groups["LINK"].ToString().Trim();
                    theLink      = Regex.Replace(theLink, "&amp;", "&");
                    url          = httpPrefix(theLink, basehref);
                    searchStatus = "found";
                    break;
                }
            }

            if (searchStatus == "no matches found")
            {
                //return "no matches found";
                return(PlugIn4_5.ErrorMsg.NoResultsFound);
            }
            else if (searchStatus == "multiple matches found")
            {
                //return "multiple matches found";
                return(ErrorMsg.MultipleProvidersFound);
            }


            if (!WebFetch.IsError(result = WebFetch.ProcessGetRequest2(ref objRequest, ref objResponse, url, "", null, cookieColl)))
            {
                pdf.Html  = "<img id='banner_image' height='121' width='717' src='http://verify.sos.ga.gov/verification/images/banner.png' border='0' /><tr>" + Regex.Match(result, "<td class=\"pagetitle\".*?</div>.*?</tr>", RegexOptions.IgnoreCase | RegexOptions.Singleline).ToString();
                pdf.Html  = Regex.Replace(pdf.Html, "<td class=\".*?colspan=.*?\">", "<td>", RegexOptions.IgnoreCase | RegexOptions.Singleline);
                pdf.Html  = Regex.Replace(pdf.Html, "Licensee Details", "");
                pdf.Html += "This website is to be used as a primary source verification for licenses issued by the Professional Licensing Boards.  Paper verifications are available for a fee. Please contact the Professional Licensing Boards at 478-207-2440.";
                pdf.ConvertToABCImage(new ImageParameters()
                {
                    BaseUrl = url
                });
            }
            else
            {
                return(ErrorMsg.CannotAccessDetailsPage);
            }

            result = cleanAllTags(result);
            result = (getLicenseeInfo(result) + "\n" + getLicenseInfo(result) + "\n" + getAssocLics(result) + "\n" + getDiscipInfo(result));
            result = replaceStartTags(result, "br", "\n");
            result = replaceEndTags(result, "br", "");
            result = replaceStartTags(result, "p", "\n");
            result = replaceEndTags(result, "p", "");
            result = replaceStartTags(result, "b", "");
            result = replaceEndTags(result, "b", "");

            Match m = Regex.Match(result, "(No\\s+Discipline\\s+Info)|(No\\s+Other\\s+Documents)", RegexOptions.Singleline | RegexOptions.IgnoreCase);

            setSanction(!m.Success);

            if (this.expirable)
            {
                handleExpirable(result, dr["lic_exp"].ToString().Trim(), @"Expires\s*(:)*\s*</td>\s*<td>\s*(?<EXP>\d{1,2}(/|-)\d{1,2}(/|-)\d{2,4})\s*</td>", "EXP");
            }

            return(result);
        }
Example #5
0
        public override string Fetch(DataRow dr)
        {
            Initialize(dr, true);
            string url         = string.Empty;
            string output      = string.Empty;
            string message     = string.Empty;
            var    detailsPage = "";
            string code        = string.Empty;

            try
            {
                var fields = Validate();
                if (fields.IsValid)
                {
                    string firstpage = SiteCalling_HTTPPOSTANDGET("https://portalclient.echo-cloud.com/98059portal/VerifPortal/msltop.asp?id=", "GET", cookiesresponse, "");
                    if (firstpage != null && firstpage.Contains("*Required Fields"))
                    {
                        _htmlDocResults.LoadHtml(firstpage);
                        var secondpage = SiteCalling_HTTPPOSTANDGET("https://portalclient.echo-cloud.com/98059portal/VerifPortal/doclist.asp", "POST", cookiesresponse, GetParamm());
                        if (secondpage != null && !secondpage.Contains("No physicians"))
                        {
                            _htmlDocResults.LoadHtml(secondpage);
                            HtmlNodeCollection Temptrs = _htmlDocResults.DocumentNode.SelectNodes("//tr/td/a[contains(.," + provider.LastName + ")]");
                            if (Temptrs != null && Temptrs.Count() > 0)
                            {
                                int TotalRecords = Temptrs.Count();
                                foreach (HtmlNode Temptr in Temptrs)
                                {
                                    if (Temptr != null)
                                    {
                                        HtmlAttribute att = Temptr.Attributes["href"];
                                        if (att != null)
                                        {
                                            string GetUrlString = att.Value;
                                            if (!string.IsNullOrEmpty(GetUrlString))
                                            {
                                                GetUrlString = GetUrlString.Replace("JavaScript:SubmitVerif(", "").Replace(")", "").Replace("'", "");
                                                string[] Urlcode = GetUrlString.Split(',');
                                                if (Urlcode != null && Urlcode.Count() >= 4)
                                                {
                                                    var details = SiteCalling_HTTPPOSTANDGET("https://portalclient.echo-cloud.com/98059portal/VerifPortal/docset.asp?dr_id=" + HttpUtility.UrlEncode(Urlcode[0]) + "&standing=" + HttpUtility.UrlEncode(Urlcode[1]) + "&uname=Test&title=Test&org=Test&addr=Test&addr2=Test&reclink=" + HttpUtility.UrlEncode(Urlcode[2]) + "&recstat=" + HttpUtility.UrlEncode(Urlcode[3]), "GET", cookiesresponse, "");
                                                    if (details != null && details.Contains("Sentara Medical Staff Services"))
                                                    {
                                                        _TemphtmlDocResults.LoadHtml(details);
                                                        GetpageDetails();
                                                    }
                                                    else
                                                    {
                                                        message = ErrorMsg.CannotAccessDetailsPage;
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                message = ErrorMsg.Custom("JavaScript element not found");
                                            }
                                        }
                                        else
                                        {
                                            message = ErrorMsg.Custom("Error occurred while retrieving the Anchor Node");
                                        }
                                    }
                                    else
                                    {
                                        message = ErrorMsg.Custom("Error occurred while retrieving the data");
                                    }
                                }
                                if (_sbResponseHtmlCollection != null && _sbResponseHtmlCollection.Count() > 0 && _sbResponseHtmlCollection.Count() == _sbResponseTextCollection.Count())
                                {
                                    int SelectedRecords = _sbResponseHtmlCollection.Count();
                                    if (SelectedRecords > 1)
                                    {
                                        _sbResponseHtml.Append("<tr><td> --- Multiple Results Found </td><td>(Total: ");
                                        _sbResponseHtml.Append(SelectedRecords.ToString());
                                        _sbResponseHtml.Append(") --- </td></tr>");
                                        _sbResponseText.Append(" --- Multiple Result Found (Total: " + SelectedRecords + ") --- ");
                                        _sbResponseText.Append('\r');
                                        _sbResponseText.Append('\n');
                                    }
                                    int Count = 1;
                                    for (int i = 0; i < SelectedRecords; i++)
                                    {
                                        if (_sbResponseHtmlCollection[i] != null && _sbResponseTextCollection[i] != null)
                                        {
                                            if (SelectedRecords > 1)
                                            {
                                                _sbResponseHtml.Append("<tr><td>--- Result </td><td>(" + Count + " Of " + SelectedRecords + ") --- </td></tr>");
                                                _sbResponseText.Append("--- Result (" + Count + " Of " + SelectedRecords + ") --- ");
                                                _sbResponseText.Append('\r');
                                                _sbResponseText.Append('\n');
                                            }
                                            _sbResponseHtml.Append(_sbResponseHtmlCollection[i]);
                                            _sbResponseText.Append(_sbResponseTextCollection[i]);
                                            Count++;
                                        }
                                    }
                                    output  = _sbResponseHtml.ToString();
                                    message = _sbResponseText.ToString();
                                    try
                                    {
                                        pdf.Html = detailsPage;
                                        pdf.ConvertToABCImage(new ImageParameters {
                                            BaseUrl = "https://portalclient.echo-cloud.com/98059portal/VerifPortal/"
                                        });
                                    }
                                    catch { }
                                }
                                else
                                {
                                    message = ErrorMsg.Custom("Facility name not matching with user name");
                                }
                            }
                            else
                            {
                                message = ErrorMsg.NoResultsFound;
                            }
                        }
                        else
                        {
                            message = ErrorMsg.NoResultsFound;
                        }
                    }
                    else
                    {
                        message = ErrorMsg.CannotAccessSite;
                    }
                }
                else
                {
                    message = fields.Error.Message;
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }

            return(ProcessResults(output, message));
        }
Example #6
0
        private Result <IRestResponse> Search()
        {
            // PARAMETERS AND COOKIES WE WILL GET WITH FIRST GET
            List <RestResponseCookie> allCookies = new List <RestResponseCookie>();
            string baseUrl = "https://www.wvbdosteo.org/verify/";

            //Set up security protocol
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            //Set up client and request
            RestClient    client   = new RestClient(baseUrl);
            RestRequest   request  = new RestRequest(Method.GET);
            IRestResponse response = client.Execute(request);

            //Store new cookies
            allCookies.AddRange(response.Cookies);

            //Check that we accessed the site
            if (response.StatusCode != HttpStatusCode.OK)
            {
                return(Result <IRestResponse> .Failure(ErrorMsg.CannotAccessSite));
            }

            //Forming new post request with our parameters
            request = new RestRequest(Method.POST);

            //We perform the search using license numbers and last names, if available
            if (provider.LastName != "")
            {
                request.AddParameter("lName", provider.LastName);
            }

            string providerType = LicenseType();

            //The site will not let us perform a search without a provider type
            if (providerType == null)
            {
                return(Result <IRestResponse> .Failure(ErrorMsg.Custom("Unable to determine license type. Please input a provider title.")));
            }

            request.AddParameter("licType", providerType);
            request.AddParameter("licNo", provider.LicenseNumber);

            request.AddParameter("do", "submit");
            request.AddParameter("action", "submit");
            request.AddParameter("search", "Search");

            //Add cookies to our request
            foreach (RestResponseCookie c in allCookies)
            {
                request.AddCookie(c.Name, c.Value);
            }

            response = client.Execute(request);

            //Store new cookies
            allCookies.AddRange(response.Cookies);

            //Have we hit the request limit?
            if (Regex.Match(response.Content, "5 requests are permitted per 1 minute.", RegOpt).Success)
            {
                return(Result <IRestResponse> .Failure(ErrorMsg.Custom("This site caps at 5 requests a minute. Please try again later.")));
            }

            //Check that we accessed the site
            if (response.StatusCode != HttpStatusCode.OK && response.StatusCode != HttpStatusCode.Redirect)
            {
                return(Result <IRestResponse> .Failure(ErrorMsg.CannotAccessSite));
            }

            MatchCollection providerList = Regex.Matches(response.Content, "javascript:details", RegOpt);

            //Check if we have multiple providers
            if (providerList.Count > 1)
            {
                return(Result <IRestResponse> .Failure(ErrorMsg.MultipleProvidersFound));
            }

            //Check if we have no providers
            if (providerList.Count == 0)
            {
                return(Result <IRestResponse> .Failure(ErrorMsg.NoResultsFound));
            }

            //Navigate to the details page
            client = new RestClient(baseUrl + "details.asp");

            //Forming new post request with our parameters
            request = new RestRequest(Method.POST);

            //Calls redirect form
            request.AddParameter("t", "0");

            //Add cookies to our request
            foreach (RestResponseCookie c in allCookies)
            {
                request.AddCookie(c.Name, c.Value);
            }

            response = client.Execute(request);

            return(Result <IRestResponse> .Success(response));
        }