Exemplo n.º 1
0
 // Parameter va (VA Only Search)
 private void ParseIsVAOnly(NciUrl url, CTSSearchParams searchParams)
 {
     if (IsInUrl(url, "va"))
     {
         int va = url.CTSParamAsInt("va", -1);
         if (va == -1)
         {
             LogParseError(FormFields.IsVAOnly, "Please enter a valid VA facility search parameter.", searchParams);
         }
         else if (va > 1)
         {
             LogParseError(FormFields.IsVAOnly, "Please enter a valid VA facility search parameter.", searchParams);
         }
         else
         {
             if (va == 0)
             {
                 searchParams.IsVAOnly = false;
             }
             else
             {
                 searchParams.IsVAOnly = true;
             }
         }
     }
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes the CTSManager and Parses the Query Params
        /// </summary>
        protected override void Init()
        {
            base.Init();

            ParsedReqUrlParams = new NciUrl(true, true, true);  //We need this to be lowercase and collapse duplicate params. (Or not use an NCI URL)
            ParsedReqUrlParams.SetUrl(this.Request.Url.Query);

            //////////////////////////////
            // Create an instance of a BasicCTSManager.
            ClinicalTrialsAPIClient apiClient = APIClientHelper.GetV1ClientInstance();

            CTSManager = new BasicCTSManager(apiClient);

            /////////////////////////////
            // Parse the Query to get the search params.
            try
            {
                // Get mapping file names from configuration
                TrialTermLookupConfig mappingConfig = new TrialTermLookupConfig();
                mappingConfig.MappingFiles.AddRange(Config.MappingFiles.Select(fp => HttpContext.Current.Server.MapPath(fp)));

                CTSSearchParamFactory factory = new CTSSearchParamFactory(new TrialTermLookupService(mappingConfig, apiClient), new ZipCodeGeoLookup());
                SearchParams = factory.Create(ParsedReqUrlParams);
            }
            catch (Exception ex)
            {
                log.Error("could not parse the CTS search parameters", ex);
                throw ex;
            }

            ///////////////////////////
            // Parse the page specific parameters
            if (IsInUrl(ParsedReqUrlParams, "pn"))
            {
                this._pageNum = ParsedReqUrlParams.CTSParamAsInt("pn", 1);
            }

            _itemsPerPage = Config.DefaultItemsPerPage;
            if (IsInUrl(ParsedReqUrlParams, "ni"))
            {
                this._itemsPerPage = ParsedReqUrlParams.CTSParamAsInt("ni", _itemsPerPage);
            }
        }
Exemplo n.º 4
0
        // Parameter loc (Location, and AtNIH if loc=nih)
        private void ParseLocation(NciUrl url, CTSSearchParams searchParams)
        {
            if (searchParams.ResultsLinkFlag == ResultsLinkType.Advanced)
            {
                if (url.QueryParameters.ContainsKey("loc"))
                {
                    int locType = url.CTSParamAsInt("loc", -1);
                    if (locType == 0 || locType == 1 || locType == 2 || locType == 3 || locType == 4)
                    {
                        searchParams.Location = (LocationType)locType;

                        switch (searchParams.Location)
                        {
                        case LocationType.AtNIH:
                        {
                            searchParams.LocationParams = new AtNIHLocationSearchParams();
                            break;
                        }

                        case LocationType.Zip:
                        {
                            ParseZipCode(url, searchParams);
                            break;
                        }

                        case LocationType.CountryCityState:
                        {
                            ParseCountryCityState(url, searchParams);
                            break;
                        }

                        case LocationType.Hospital:
                        {
                            ParseHospital(url, searchParams);
                            break;
                        }
                        }
                    }
                    else
                    {
                        LogParseError(FormFields.Location, "Please enter a valid location type.", searchParams);
                    }
                }
            }
            else if (searchParams.ResultsLinkFlag == ResultsLinkType.Basic && IsInUrl(url, "z"))
            {
                searchParams.Location = LocationType.Zip;
                ParseZipCode(url, searchParams);
            }
        }
Exemplo n.º 5
0
 // Parameter hv (HealthyVolunteers)
 private void ParseHealthyVolunteers(NciUrl url, CTSSearchParams searchParams)
 {
     if (IsInUrl(url, "hv"))
     {
         int hvType = url.CTSParamAsInt("hv", -1);
         if (hvType == 0 || hvType == 1 || hvType == 2)
         {
             searchParams.HealthyVolunteer = (HealthyVolunteerType)hvType;
         }
         else
         {
             LogParseError(FormFields.HealthyVolunteers, "Please enter a valid healthy volunteer indicator.", searchParams);
         }
     }
 }
Exemplo n.º 6
0
 // Parameter a (Age)
 private void ParseAge(NciUrl url, CTSSearchParams searchParams)
 {
     if (IsInUrl(url, "a"))
     {
         int age = url.CTSParamAsInt("a", 0);
         if (age <= 0)
         {
             LogParseError(FormFields.Age, "Please enter a valid age parameter.", searchParams);
         }
         else if (age > 120)
         {
             LogParseError(FormFields.Age, "Please enter a valid age parameter.", searchParams);
         }
         else
         {
             searchParams.Age = age;
         }
     }
 }
Exemplo n.º 7
0
        // Parameter rl (Results Link Flag)
        private void ParseResultsLinkFlag(NciUrl url, CTSSearchParams searchParams)
        {
            if (IsInUrl(url, "rl"))
            {
                int resLinkFlag = url.CTSParamAsInt("rl", 0);


                if (resLinkFlag == 1 || resLinkFlag == 2)
                {
                    searchParams.ResultsLinkFlag = (ResultsLinkType)resLinkFlag;
                }
                else
                {
                    LogParseError("ResultsLinkFlag", "Results Link Flag can only equal 1 or 2.", searchParams);
                }
            }
            else
            {
                searchParams.ResultsLinkFlag = ResultsLinkType.Basic;
            }
        }