////Parameter lst (State) && Parameter lcty (City) && Parameter lcnty (Country)
        private static void AddAnalyticsCountryCityState(List <string> waList, CTSSearchParams searchParams)
        {
            CountryCityStateLocationSearchParams locParams = (CountryCityStateLocationSearchParams)searchParams.LocationParams;
            string valCountry = "none";
            string valState   = "none";
            string valCity    = "none";

            if (locParams.IsFieldSet(FormFields.State))
            {
                valState = string.Join(",", locParams.State.Select(lst => lst.Key));
            }
            if (locParams.IsFieldSet(FormFields.City))
            {
                valCity = locParams.City;
            }
            if (locParams.IsFieldSet(FormFields.Country))
            {
                valCountry = locParams.Country;
            }

            waList.Add(valCountry);
            waList.Add(valState);
            waList.Add(valCity);

            //TODO: add logic to draw state only if USA?
        }
Example #2
0
 //Parameter d (Drugs)
 private static void SerializeDrugs(NciUrl url, CTSSearchParams searchParms)
 {
     if (searchParms.IsFieldSet(FormFields.Drugs))
     {
         url.QueryParameters.Add("d", SerializeMultiTermFields(searchParms.Drugs));
     }
 }
        /// <summary>
        /// Get a list of Drug/Drug Family and Other Treatment values.
        /// </summary>
        /// <param name="searchParams"></param>
        /// <returns>A list of search parameter values</returns>
        public static String GetAnalyticsTmntDrugOther(CTSSearchParams searchParams)
        {
            List <string> waFieldsList = new List <string>();

            _waTmntDrugOtherFields(waFieldsList, searchParams);
            return(string.Join("|", waFieldsList.ToArray()));
        }
        /// <summary>
        /// Get a list of Trial Phase, Trial ID, Investigator, and Lead Organization values.
        /// </summary>
        /// <param name="searchParams"></param>
        /// <returns>A list of search parameter values</returns>
        public static String GetAnalyticsPhaseIdInvOrg(CTSSearchParams searchParams)
        {
            List <string> waFieldsList = new List <string>();

            _waPhaseIdInvOrgFields(waFieldsList, searchParams);
            return(string.Join("|", waFieldsList.ToArray()));
        }
Example #5
0
 //Parameter d (Drugs)
 private void ParseDrugs(NciUrl url, CTSSearchParams searchParams)
 {
     if (IsInUrl(url, "d"))
     {
         searchParams.Drugs = GetTermFieldFromParam(url.QueryParameters["d"], FormFields.Drugs, searchParams);
     }
 }
Example #6
0
        /// <summary>
        /// Performs a search against the Clinical Trials API
        /// </summary>
        /// <param name="searchParams">Search paramesters</param>
        /// <param name="dynamicFilterParams">Deserialized dynamic search parameters</param>
        /// <returns>Clinical Trials collection</returns>
        public ClinicalTrialsCollection Search(CTSSearchParams searchParams, int pageNumber = 0, int itemsPerPage = 10)
        {
            int from = GetPageOffset(pageNumber, itemsPerPage);

            Dictionary <string, object> filterCriteria = searchParams.ToFilterCriteria();

            //Get our list of trials from the API client
            ClinicalTrialsCollection rtnResults = new ClinicalTrialsCollection();

            //Fetch results
            rtnResults = Client.List(
                searchParams: filterCriteria,
                size: itemsPerPage,
                from: from,
                includeFields: CTSConstants.IncludeFields
                );

            //Remove all the inactive sites from all the trials.
            foreach (ClinicalTrial trial in rtnResults.Trials)
            {
                RemoveNonRecruitingSites(trial);
            }

            return(rtnResults);
        }
Example #7
0
 //Parameter i (Other treatments / interventions)
 private static void SerializeOtherTreatments(NciUrl url, CTSSearchParams searchParms)
 {
     if (searchParms.IsFieldSet(FormFields.OtherTreatments))
     {
         url.QueryParameters.Add("i", SerializeMultiTermFields(searchParms.OtherTreatments));
     }
 }
Example #8
0
        // Parameter loc (Location, and AtNIH if loc=nih)
        private static void SerializeLocation(NciUrl url, CTSSearchParams searchParams)
        {
            url.QueryParameters.Add("loc", searchParams.Location.ToString("d"));

            if (url.QueryParameters.ContainsKey("loc"))
            {
                switch (searchParams.Location)
                {
                //None needs not to be set
                //AtNIH is all that is needed for NIH
                case LocationType.Zip:
                {
                    SerializeZipCode(url, searchParams);
                    break;
                }

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

                case LocationType.Hospital:
                {
                    SerializeHospital(url, searchParams);
                    break;
                }
                }
            }
        }
Example #9
0
 //Parameter i (Other treatments / interventions)
 private void ParseOtherTreatments(NciUrl url, CTSSearchParams searchParams)
 {
     if (IsInUrl(url, "i"))
     {
         searchParams.OtherTreatments = GetTermFieldFromParam(url.QueryParameters["i"], FormFields.OtherTreatments, searchParams);
     }
 }
Example #10
0
 // Parameter hv (Healthy Volunteers)
 private static void SerializeHealthyVolunteers(NciUrl url, CTSSearchParams searchParams)
 {
     if (searchParams.IsFieldSet(FormFields.HealthyVolunteers))
     {
         url.QueryParameters.Add("hv", searchParams.HealthyVolunteer.ToString("d")); //Output the decimal value of the enum as a string.
     }
 }
Example #11
0
 // Parameter va (Search VA Only)
 private static void SerializeIsVAOnly(NciUrl url, CTSSearchParams searchParams)
 {
     if (searchParams.IsFieldSet(FormFields.IsVAOnly))
     {
         url.QueryParameters.Add("va", searchParams.IsVAOnly ? "1" : "0");
     }
 }
Example #12
0
 //Parameter q (Keyword/Phrase)
 private static void SerializeKeyword(NciUrl url, CTSSearchParams searchParams)
 {
     if (searchParams.IsFieldSet(FormFields.Phrase))
     {
         url.QueryParameters.Add("q", HttpUtility.UrlEncode(searchParams.Phrase));
     }
 }
Example #13
0
 // Parameter a (Age)
 private static void SerializeAge(NciUrl url, CTSSearchParams searchParams)
 {
     if (searchParams.IsFieldSet(FormFields.Age))
     {
         url.QueryParameters.Add("a", searchParams.Age.ToString());
     }
 }
Example #14
0
 //Parameter t (Main Cancer Type)
 private static void SerializeCancerType(NciUrl url, CTSSearchParams searchParams)
 {
     if (searchParams.IsFieldSet(FormFields.MainType))
     {
         url.QueryParameters.Add("t", string.Join("|", searchParams.MainType.Codes));
     }
 }
Example #15
0
 //Parameter tt (Trial Type)
 private void ParseTrialTypes(NciUrl url, CTSSearchParams searchParams)
 {
     if (IsInUrl(url, "tt"))
     {
         searchParams.TrialTypes = GetLabelledFieldFromParam(url.QueryParameters["tt"], FormFields.TrialTypes, searchParams);
     }
 }
Example #16
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 #17
0
 // Parameter in (Investigator)
 private static void SerializeInvestigator(NciUrl url, CTSSearchParams searchParams)
 {
     if (searchParams.IsFieldSet(FormFields.Investigator))
     {
         url.QueryParameters.Add("in", HttpUtility.UrlEncode(searchParams.Investigator));
     }
 }
Example #18
0
 //Parameter fin (Findings)
 private void ParseFindings(NciUrl url, CTSSearchParams searchParams)
 {
     if (IsInUrl(url, "fin"))
     {
         searchParams.Findings = GetTermFieldFromParam(url.QueryParameters["fin"], FormFields.Findings, searchParams);
     }
 }
Example #19
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;
             }
         }
     }
 }
Example #20
0
 //Parameter stg (Stages)
 private void ParseStages(NciUrl url, CTSSearchParams searchParams)
 {
     if (IsInUrl(url, "stg"))
     {
         searchParams.Stages = GetTermFieldFromParam(url.QueryParameters["stg"], FormFields.Stages, searchParams);
     }
 }
Example #21
0
 // Parameter r (Redirect Flag)
 private void ParseRedirectFlag(NciUrl url, CTSSearchParams searchParams)
 {
     if (IsInUrl(url, "r"))
     {
         searchParams.RedirectFlag = true;
     }
 }
Example #22
0
 // Parameter r (Redirect Flag)
 private static void SerializeRedirectFlag(NciUrl url, CTSSearchParams searchParams)
 {
     if (searchParams.RedirectFlag == true)
     {
         url.QueryParameters.Add("r", "1");
     }
 }
Example #23
0
 // Parameter lo (Lead Org)
 private static void SerializeLeadOrg(NciUrl url, CTSSearchParams searchParams)
 {
     if (searchParams.IsFieldSet(FormFields.LeadOrg))
     {
         url.QueryParameters.Add("lo", HttpUtility.UrlEncode(searchParams.LeadOrg));
     }
 }
Example #24
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 #25
0
        /// <summary>
        /// Logs an error in the ParseErrors array on the Search Params
        /// </summary>
        private void LogParseError(FormFields field, string errorMessage, CTSSearchParams searchParams)
        {
            CTSSearchFieldParamError error = new CTSSearchFieldParamError();

            error.Field        = field;
            error.ErrorMessage = errorMessage;
            searchParams.ParseErrors.Add(error);
        }
Example #26
0
        /// <summary>
        /// Serialize the parameters to a URL
        /// </summary>
        /// <param name="searchParams">The search parameters to serialize</param>
        /// <returns>A URL with query params.</returns>
        public static NciUrl ConvertParamsToUrl(CTSSearchParams searchParams)
        {
            NciUrl url = new NciUrl();

            _paramSerializers(url, searchParams);

            return(url);
        }
Example #27
0
        /// <summary>
        /// Gets an instance of a CTSSearchParams object based on params in URL.
        /// </summary>
        /// <param name="reqUrl">The URL to parse</param>
        /// <returns></returns>
        public CTSSearchParams Create(NciUrl reqUrl)
        {
            CTSSearchParams rtnParams = new CTSSearchParams();

            _parsers(reqUrl, rtnParams); //This calls each of the parsers, one chained after another.

            return(rtnParams);
        }
Example #28
0
        /// <summary>
        /// Logs an error in the ParseErrors array on the Search Params
        /// </summary>
        private void LogParseError(string param, string errorMessage, CTSSearchParams searchParams)
        {
            CTSSearchParamError error = new CTSSearchParamError();

            error.Param        = param;
            error.ErrorMessage = errorMessage;
            searchParams.ParseErrors.Add(error);
        }
 private static void AddAnalyticsHealthyVolunteers(List <string> waList, CTSSearchParams searchParams)
 {
     if (searchParams.IsFieldSet(FormFields.HealthyVolunteers))
     {
         //Only add a parameter if it was added.  Do not add anything unless this field was set.
         waList.Add("hv");
     }
 }
Example #30
0
        // Parameter tp (Trial Phase)
        private void ParseTrialPhases(NciUrl url, CTSSearchParams searchParams)
        {
            if (IsInUrl(url, "tp"))
            {
                searchParams.TrialPhases = GetLabelledFieldFromParam(url.QueryParameters["tp"], FormFields.TrialPhases, searchParams);
            }

            // TODO: Error handling
        }