Example #1
0
        //Parameter hos (Hospital)
        private void ParseHospital(NciUrl url, CTSSearchParams searchParams)
        {
            HospitalLocationSearchParams locParams = new HospitalLocationSearchParams();
            bool hasInvalidParam = false;

            if (IsInUrl(url, "hos"))
            {
                string hospital = url.CTSParamAsStr("hos");
                if (!string.IsNullOrWhiteSpace(hospital))
                {
                    locParams.Hospital = hospital;
                }
                else
                {
                    hasInvalidParam = true;
                    LogParseError(FormFields.Hospital, "Please enter a valid hospital/institution parameter.", searchParams);
                }
            }
            else
            {
                hasInvalidParam = true;
                LogParseError(FormFields.Hospital, "Please enter a valid hospital/institution parameter.", searchParams);
            }

            if (!hasInvalidParam)
            {
                searchParams.LocationParams = locParams;
            }
            else
            {
                searchParams.LocationParams = new HospitalLocationSearchParams();
            }
        }
Example #2
0
        // Parameter z (Zip Code) && zp (Zip Proximity)
        private void ParseZipCode(NciUrl url, CTSSearchParams searchParams)
        {
            ZipCodeLocationSearchParams locParams = new ZipCodeLocationSearchParams();

            searchParams.LocationParams = locParams;

            if (IsInUrl(url, "z"))
            {
                string zipCode = url.CTSParamAsStr("z");

                if (string.IsNullOrWhiteSpace(zipCode) || (zipCode.Length < 5))
                {
                    LogParseError(FormFields.ZipCode, "Please enter a valid zip code value.", searchParams);
                }

                string pattern = @"^[0-9]{5}$";
                if (Regex.IsMatch(zipCode, pattern))
                {
                    GeoLocation geolocation = this._zipLookupSvc.GetZipCodeGeoEntry(zipCode);
                    if (geolocation != null)
                    {
                        locParams.ZipCode     = zipCode;
                        locParams.GeoLocation = geolocation;

                        if (IsInUrl(url, "zp"))
                        {
                            int zipRadius = url.CTSParamAsInt("zp", -1);
                            if (zipRadius < 1 || zipRadius > 12451)
                            {
                                LogParseError(FormFields.ZipRadius, "Please enter a valid zip radius value.", searchParams);
                                searchParams.LocationParams = new ZipCodeLocationSearchParams();
                            }
                            else
                            {
                                locParams.ZipRadius         = zipRadius;
                                searchParams.LocationParams = locParams;
                            }
                        }
                        else
                        {
                            searchParams.LocationParams = locParams;
                        }
                    }
                    else
                    {
                        LogParseError(FormFields.ZipCode, "Please enter a valid zip code value.", searchParams);
                    }
                }
                else
                {
                    LogParseError(FormFields.ZipCode, "Please enter a valid zip code value.", searchParams);
                }
            }
            else
            {
                //Handle when zipcode has not been specified, but location type is zip code
                LogParseError(FormFields.ZipCode, "Please enter a valid zip code value.", searchParams);
            }
        }
Example #3
0
 // Parameter lo (Lead Org)
 private void ParseLeadOrg(NciUrl url, CTSSearchParams searchParams)
 {
     if (IsInUrl(url, "lo"))
     {
         string leadOrg = url.CTSParamAsStr("lo");
         if (!string.IsNullOrWhiteSpace(leadOrg))
         {
             searchParams.LeadOrg = leadOrg;
         }
         else
         {
             LogParseError(FormFields.LeadOrg, "Please enter a valid lead organization parameter.", searchParams);
         }
     }
 }
Example #4
0
 // Parameter in (Investigator)
 private void ParseInvestigator(NciUrl url, CTSSearchParams searchParams)
 {
     if (IsInUrl(url, "in"))
     {
         string investigator = url.CTSParamAsStr("in");
         if (!string.IsNullOrWhiteSpace(investigator))
         {
             searchParams.Investigator = investigator;
         }
         else
         {
             LogParseError(FormFields.Investigator, "Please enter a valid trial investigator parameter.", searchParams);
         }
     }
 }
Example #5
0
 //Parameter q (Keyword/Phrase)
 private void ParseKeyword(NciUrl url, CTSSearchParams searchParams)
 {
     if (IsInUrl(url, "q"))
     {
         string phrase = url.CTSParamAsStr("q");
         if (!string.IsNullOrWhiteSpace(phrase))
         {
             searchParams.Phrase = phrase;
         }
         else
         {
             LogParseError(FormFields.Phrase, "Please enter a valid keyword parameter.", searchParams);
         }
     }
 }
Example #6
0
 // Parameter g (Gender)
 private void ParseGender(NciUrl url, CTSSearchParams searchParams)
 {
     if (IsInUrl(url, "g"))
     {
         string gender = url.CTSParamAsStr("g");
         if (!string.IsNullOrWhiteSpace(gender))
         {
             if (gender == "male" || gender == "female")
             {
                 searchParams.Gender = gender;
             }
             else
             {
                 LogParseError(FormFields.Gender, "Please enter a valid gender.", searchParams);
             }
         }
         else
         {
             LogParseError(FormFields.Gender, "Please enter a valid gender.", searchParams);
         }
     }
 }
Example #7
0
        //Parameter lst (State) && Parameter lcty (City) && Parameter lcnty (Country)
        private void ParseCountryCityState(NciUrl url, CTSSearchParams searchParams)
        {
            CountryCityStateLocationSearchParams locParams = new CountryCityStateLocationSearchParams();
            bool hasInvalidParam = false;

            if (IsInUrl(url, "lst"))
            {
                locParams.State = GetLabelledFieldFromParam(url.QueryParameters["lst"], FormFields.State, searchParams);
                if (locParams.State.Length == 0)
                {
                    hasInvalidParam = true;
                }
            }

            if (IsInUrl(url, "lcty"))
            {
                if (!IsInUrl(url, "lcnty"))
                {
                    hasInvalidParam = true;
                    LogParseError(FormFields.Country, "Please enter a country parameter if entering a city parameter.", searchParams);
                }
                else
                {
                    string city = url.CTSParamAsStr("lcty");
                    if (!string.IsNullOrWhiteSpace(city))
                    {
                        locParams.City = city;
                    }
                    else
                    {
                        hasInvalidParam = true;
                        LogParseError(FormFields.City, "Please enter a valid city parameter.", searchParams);
                    }
                }
            }

            if (IsInUrl(url, "lcnty"))
            {
                string country = url.CTSParamAsStr("lcnty");
                if (!string.IsNullOrWhiteSpace(country))
                {
                    locParams.Country = country;
                }
                else
                {
                    hasInvalidParam = true;
                    LogParseError(FormFields.Country, "Please enter a valid country parameter.", searchParams);
                }
            }

            if (!IsInUrl(url, "lcty") && !IsInUrl(url, "lst") && !IsInUrl(url, "lcnty"))
            {
                hasInvalidParam = true;
                LogParseError(FormFields.Location, "You must enter either a valid country, city, or state parameter.", searchParams);
            }

            if (!hasInvalidParam)
            {
                searchParams.LocationParams = locParams;
            }
            else
            {
                searchParams.LocationParams = new CountryCityStateLocationSearchParams();
            }
        }