Ejemplo n.º 1
0
        public void NoFieldIsSet()
        {
            ZipCodeLocationSearchParams locParam = new ZipCodeLocationSearchParams();

            Assert.False(locParam.IsFieldSet("ZipCode"));
            Assert.False(locParam.IsFieldSet("ZipRadius"));
        }
Ejemplo n.º 2
0
        public void GetAndSetZipRadius()
        {
            ZipCodeLocationSearchParams locParam = new ZipCodeLocationSearchParams();

            locParam.ZipRadius = 100;
            Assert.True(locParam.IsFieldSet("ZipRadius"));
            Assert.Equal("100", locParam.GetFieldAsString("ZipRadius"));
        }
Ejemplo n.º 3
0
        public void GetAndSetZipCode()
        {
            ZipCodeLocationSearchParams locParam = new ZipCodeLocationSearchParams();

            locParam.ZipCode = "20852";
            Assert.True(locParam.IsFieldSet("ZipCode"));
            Assert.Equal("20852", locParam.GetFieldAsString("ZipCode"));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Get all Locations, but filtered by location parameters.
        /// NOTE: LocationTypes for Hospital and None will not be filtered, but will be sorted.
        /// </summary>
        /// <returns></returns>
        public ClinicalTrial.StudySite[] GetFilteredLocations(IEnumerable <ClinicalTrial.StudySite> sites, CTSSearchParams searchParams)
        {
            IEnumerable <ClinicalTrial.StudySite> rtnSites = sites;

            switch (searchParams.Location)
            {
            case LocationType.AtNIH:
            {
                rtnSites = rtnSites.Where(s => s.PostalCode == "20892");
                break;
            }

            case LocationType.CountryCityState:
            {
                CountryCityStateLocationSearchParams locParams = (CountryCityStateLocationSearchParams)searchParams.LocationParams;

                if (locParams.IsFieldSet(FormFields.Country))
                {
                    rtnSites = rtnSites.Where(s => StringComparer.CurrentCultureIgnoreCase.Equals(s.Country, locParams.Country));
                }

                if (locParams.IsFieldSet(FormFields.City))
                {
                    rtnSites = rtnSites.Where(s => StringComparer.CurrentCultureIgnoreCase.Equals(s.City, locParams.City));
                }

                if (locParams.IsFieldSet(FormFields.State))
                {
                    var states = locParams.State.Select(s => s.Key);         //Get Abbreviations
                    rtnSites = rtnSites.Where(s => states.Contains(s.StateOrProvinceAbbreviation));
                }

                break;
            }

            case LocationType.Zip:
            {
                ZipCodeLocationSearchParams locParams = (ZipCodeLocationSearchParams)searchParams.LocationParams;

                rtnSites = rtnSites.Where(site =>
                                          site.Coordinates != null &&
                                          locParams.GeoLocation.DistanceBetween(new GeoLocation(site.Coordinates.Latitude, site.Coordinates.Longitude)) <= locParams.ZipRadius &&
                                          site.Country == "United States"
                                          );

                break;
            }

            default:
            {
                //Basically we can't/shouldn't filter.
                break;
            }
            }

            //Filter out non-va sites if this is a VA only search
            if (searchParams.IsVAOnly && searchParams.Location != LocationType.Hospital)
            {
                rtnSites = rtnSites.Where(site => site.IsVA);
            }

            //Now that we have the sites filtered, now we need to sort.
            return(rtnSites.ToArray());
        }
Ejemplo n.º 5
0
        public void BogusField()
        {
            ZipCodeLocationSearchParams locParam = new ZipCodeLocationSearchParams();

            Assert.Equal("Error Retrieving Field", locParam.GetFieldAsString("None"));
        }