Esempio n. 1
0
 /// <summary>
 /// Creates a list of actively recruiting sites only
 /// </summary>
 /// <param name="trial">Clinical trial</param>
 private void RemoveNonRecruitingSites(ClinicalTrial trial)
 {
     if (trial.Sites != null)
     {
         trial.Sites = new List <ClinicalTrial.StudySite>(trial.Sites.Where(site => IsActivelyRecruiting(site)));
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Returns a Clinical Trial
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public ClinicalTrial Get(string id)
        {
            ClinicalTrial trial = Client.Get(id);

            RemoveNonRecruitingSites(trial);
            return(trial);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the Primary Purpose and formats text
        /// </summary>
        /// <param name="trial"></param>
        /// <returns>String - purpose</returns>
        public string GetTrialType(ClinicalTrial trial)
        {
            ///TODO: Verify if we need to add other_text and additioncal_qualifier_code to this text
            string purpose = trial.GetPrimaryPurpose();

            return(GetFormattedString(purpose));
        }
        public void FilterByHospital(ClinicalTrial trial, CTSSearchParams searchParams, IEnumerable <ClinicalTrial.StudySite> expectedSites)
        {
            SnippetControls.TrialVelocityTools    tvt    = new SnippetControls.TrialVelocityTools();
            IEnumerable <ClinicalTrial.StudySite> actual = tvt.GetFilteredLocations(trial, searchParams);

            Assert.Equal(expectedSites, actual, new ClinicalTrialsAPI.Test.StudySiteComparer());
        }
Esempio n. 5
0
        private void SetupFieldAndUrlFilters(ClinicalTrial trial)
        {
            // Copying the Title & Short Title logic from Advanced Form
            //set the page title as the protocol title
            PageInstruction.AddFieldFilter("long_title", (fieldName, data) =>
            {
                data.Value = trial.BriefTitle;
            });

            PageInstruction.AddFieldFilter("short_title", (fieldName, data) =>
            {
                data.Value = trial.BriefTitle;

                //Eh, When would this happen???
                if (!string.IsNullOrWhiteSpace(trial.NCTID))
                {
                    data.Value += " - " + trial.NCTID;
                }
            });


            PageInstruction.AddFieldFilter("meta_description", (fieldname, data) =>
            {
                data.Value = trial.BriefTitle;
            });



            PageInstruction.AddUrlFilter("CurrentUrl", (name, url) =>
            {
                //Copy the params
                //TODO: Really determine what to do with these params.  If the search is invalid, we probably
                //hsould not show them all.
                foreach (KeyValuePair <string, string> param in this.ParsedReqUrlParams.QueryParameters)
                {
                    url.QueryParameters.Add(param.Key, param.Value);
                }
            });

            PageInstruction.AddUrlFilter("CanonicalUrl", (name, url) =>
            {
                // only the id should be provided for the canonical URL, so clear all query parameters and
                // then add back id
                url.QueryParameters.Clear();
                url.QueryParameters.Add("id", trial.NCIID);
                //url.QueryParameters.Add("id", TrialID);
            });

            // Override the social media URL (og:url)
            PageInstruction.AddFieldFilter("og:url", (fieldName, data) =>
            {
                //Ok, this is weird, but...  The OpenGraph URL is actually a field. It kind of makes sense,
                //and it kind of does not.  Really it should be a field that gets the og:url instead of the
                //pretty URL.
                //BUt here we are, and it is what we have.  So let's replace the og:url with the canonical URL.

                data.Value = PageInstruction.GetUrl(NCI.Web.CDE.PageAssemblyInstructionUrls.CanonicalUrl).ToString();
            });
        }
 public static object GetAllSortedLocations(this ClinicalTrial trial)
 {
     return(new
     {
         USA = GetUSASortedLocations(trial),
         Canada = GetCanadianSortedLocations(trial),
         Other = GetOtherSortedLocations(trial)
     });
 }
        /// <summary>
        /// Loads a test trial from TrialExamples folder.
        /// </summary>
        /// <param name="trialName">The name of the file to load.</param>
        /// <returns></returns>
        public static ClinicalTrial LoadTrial(string trialName)
        {
            string        path  = Path.Combine(AssemblyPath, "TrialExamples", trialName);
            ClinicalTrial trial = JsonConvert.DeserializeObject <ClinicalTrial>(
                File.ReadAllText(path)
                );

            return(trial);
        }
Esempio n. 8
0
        /// <summary>
        /// Gets the Phase number from the API and formats it for presentation
        /// </summary>
        /// <param name="trial"></param>
        /// <returns>String </returns>
        public string GetPhase(ClinicalTrial trial)
        {
            string phase = trial.GetTrialPhase();

            if (!String.IsNullOrWhiteSpace(phase))
            {
                phase = "Phase " + phase.Replace("_", "/");
            }
            return(phase);
        }
        /// <summary>
        /// Gets the Lead Organization
        /// </summary>
        /// <param name="trial"></param>
        /// <returns></returns>
        public static string GetLeadOrg(this ClinicalTrial trial)
        {
            string leadOrg = String.Empty;

            if (!String.IsNullOrEmpty(trial.LeadOrganizationName))
            {
                leadOrg = trial.LeadOrganizationName;
            }
            return(leadOrg);
        }
Esempio n. 10
0
        public void TestDeserialize()
        {
            string        path  = Path.Combine(AssemblyPath, "TrialExamples", "NCT02194738.json");
            ClinicalTrial trial = JsonConvert.DeserializeObject <ClinicalTrial>(
                File.ReadAllText(path)
                );

            Assert.Equal("NCT02194738", trial.NCTID);
            //TODO: Check all the fields.
        }
        /// <summary>
        /// Gets the Principal Investigator
        /// </summary>
        /// <param name="trial"></param>
        /// <returns>string - principal</returns>
        public static string GetPrincipalInvestigator(this ClinicalTrial trial)
        {
            string principal = String.Empty;

            if (!String.IsNullOrEmpty(trial.PrincipalInvestigator))
            {
                principal = trial.PrincipalInvestigator;
            }
            return(principal);
        }
Esempio n. 12
0
        /// <summary>
        /// Get formatted age range string. Based on the max and min age for the trial, display the
        /// resulting age in a pretty format and with units specified.
        /// TODO: Handle any edge cases with redundant units
        /// </summary>
        /// <param name="trial"></param>
        /// <returns></returns>
        public String GetAgeString(ClinicalTrial trial)
        {
            int    minAgeNum  = trial.GetMinAgeNum();
            int    maxAgeNum  = trial.GetMaxAgeNum();
            string minAgeUnit = trial.GetMinAgeUnit().ToLower();
            string maxAgeUnit = trial.GetMaxAgeUnit().ToLower();
            string minAgeText = CleanAgeText(minAgeNum, minAgeUnit);
            string maxAgeText = CleanAgeText(maxAgeNum, maxAgeUnit);
            string ageRange   = minAgeText + " to " + maxAgeText;

            // Set age range string for years if both max and min units are years
            if ((maxAgeUnit == "years") && (minAgeUnit == "years"))
            {
                ageRange = minAgeNum.ToString() + " to " + maxAgeNum.ToString() + " years";
                if (minAgeNum < 1 && maxAgeNum <= 120)
                {
                    ageRange = maxAgeText + " and under";
                }
                else if (minAgeNum > 0 && maxAgeNum > 120)
                {
                    ageRange = minAgeText + " and over";
                }
                else if (minAgeNum < 1 && maxAgeNum > 120)
                {
                    ageRange = "Not specified";
                }
            }

            // Set age range string for max and min if units match
            else if (maxAgeUnit == minAgeUnit)
            {
                ageRange = minAgeNum.ToString() + " to " + maxAgeNum.ToString() + maxAgeUnit;
                if (minAgeNum < 1 && maxAgeNum <= 999)
                {
                    ageRange = maxAgeText + " and under";
                }
                else if (minAgeNum > 0 && maxAgeNum >= 999)
                {
                    ageRange = minAgeText + " and over";
                }
            }

            // Set age range string if units do not match
            else
            {
                if (maxAgeNum > 120 && maxAgeUnit == "years")
                {
                    ageRange = minAgeText + " and over";
                }
            }

            ageRange = ageRange.Replace("year to", "to").Replace("years to", "to");
            return(GetFormattedString(ageRange));
        }
Esempio n. 13
0
        /// <summary>
        /// Get formatted gender string
        /// </summary>
        /// <param name="trial"></param>
        /// <returns></returns>
        public string GetGenderString(ClinicalTrial trial)
        {
            String gender = trial.GetGender();

            if (gender.ToLower() == "both")
            {
                gender = "Male or Female";
                return(gender);
            }
            return(GetFormattedString(gender));
        }
Esempio n. 14
0
 /// <summary>
 /// Gets the list of secondary IDs from extension method as comma separated string
 /// </summary>
 /// <param name="trial"></param>
 /// <returns></returns>
 public string GetSecondaryIDsString(ClinicalTrial trial)
 {
     string[] ids = trial.GetSecondaryIDs();
     if (ids.Length == 0)
     {
         return(string.Empty);
     }
     else
     {
         return(string.Join(", ", ids));
     }
 }
        /// <summary>
        /// Gets an array of all of the collaborator names
        /// </summary>
        /// <param name="trial"></param>
        /// <returns>string[] collaborators</returns>
        public static string[] GetCollaborators(this ClinicalTrial trial)
        {
            List <String> collaborators = new List <String>();

            if (trial.Collaborators != null)
            {
                collaborators.AddRange(
                    from collab in trial.Collaborators
                    select collab.Name
                    );
            }
            return(collaborators.ToArray());
        }
        /// <summary>
        /// Gets the phase number only
        /// </summary>
        /// <param name="trial"></param>
        /// <returns>String - phase</returns>
        public static String GetTrialPhase(this ClinicalTrial trial)
        {
            string rtnPhase = String.Empty;

            if (trial.TrialPhase != null)
            {
                if (!String.IsNullOrEmpty(trial.TrialPhase.PhaseNumber))
                {
                    rtnPhase = trial.TrialPhase.PhaseNumber;
                }
            }
            return(rtnPhase);
        }
 /// <summary>
 /// Gets the eligibility criteria for exclusion form this trial
 /// </summary>
 /// <param name="trial"></param>
 /// <returns></returns>
 public static string[] GetExclusionCriteria(this ClinicalTrial trial)
 {
     if (trial.EligibilityInfo != null && trial.EligibilityInfo.UnstructuredCriteria != null)
     {
         return((
                    from criterion in trial.EligibilityInfo.UnstructuredCriteria
                    where !criterion.IsInclusionCriterion
                    select criterion.Description
                    ).ToArray());
     }
     else
     {
         return(new string[0]);
     }
 }
Esempio n. 18
0
        internal void SeedDoctorsClinicalTrialsAndSpecialties(ApplicationDbContext context)
        {
            if (!context.Doctors.Any() || !context.ClinicalTrials.Any() || !context.Specialities.Any())
            {
                for (int i = 1; i < 5; i++)
                {
                    var clinicalTrial = new ClinicalTrial
                    {
                        Title       = "Trial - " + i + ".1",
                        Price       = random.RandomDataInt(25, 4587),
                        IsAvailable = IsAvailable.Yes,
                    };

                    var clinicalTrial2 = new ClinicalTrial
                    {
                        Title       = "Trial - " + i + ".2",
                        Price       = random.RandomDataInt(48, 565),
                        IsAvailable = IsAvailable.No,
                    };

                    var listDoctors = new List <Doctor>();
                    for (int j = 0; j < random.RandomDataInt(2, 6); j++)
                    {
                        var doctor = new Doctor
                        {
                            Name        = "Doctor - " + random.RandomDataString(6, 10) + " " + random.RandomDataString(10, 13),
                            Image       = CreateImage(),
                            Description = random.RandomDataString(400, 1000)
                        };
                        listDoctors.Add(doctor);
                    }

                    var specialty = new Speciality
                    {
                        Title          = "Specialty - " + i,
                        Description    = random.RandomDataString(200, 500),
                        ClinicalTrials = new HashSet <ClinicalTrial>()
                        {
                            clinicalTrial,
                            clinicalTrial2
                        },
                        Doctors = listDoctors
                    };
                    context.Specialities.Add(specialty);
                    context.SaveChanges();
                }
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Gets Principal Investigator strings and joins them into an array
        /// </summary>
        /// <param name="trial"></param>
        /// <returns>string - principal</returns>
        public string[] GetPrincipalArray(ClinicalTrial trial)
        {
            List <String> principal = new List <String>();

            if (!String.IsNullOrWhiteSpace(trial.GetPrincipalInvestigator()))
            {
                principal.Add(trial.GetPrincipalInvestigator());
            }

            /* TODO - Verify if there actually any instances where we
             * have more than one Principal Investigator - OR if there
             * is another value from the API that we should combine with
             * this
             */
            // principal.Add(trial.GetSomeOtherValue());
            return(principal.ToArray());
        }
        /// <summary>
        /// Gets the Primary Purpose
        /// </summary>
        /// <param name="trial"></param>
        /// <returns>String - purpose</returns>
        public static String GetPrimaryPurpose(this ClinicalTrial trial)
        {
            string purpose = String.Empty;

            if (trial.PrimaryPurpose != null)
            {
                if (!String.IsNullOrEmpty(trial.PrimaryPurpose.Code))
                {
                    purpose = trial.PrimaryPurpose.Code;
                    if (purpose.ToLower() == "other")
                    {
                        purpose = trial.PrimaryPurpose.OtherText;
                    }
                }
            }
            return(purpose);
        }
Esempio n. 21
0
        public void TestGet()
        {
            string baseUrl = "https://example.org/v1/";
            string trialID = "NCT02194738";

            string trialFilePath = TestFileTools.GetPathToTestFile(typeof(ClinicalTrialsAPIClientTests), Path.Combine(new string[] { "TrialExamples", trialID + ".json" }));

            HttpClient mockedClient = HttpClientMockHelper.GetClientMockForURLWithFileResponse(String.Format("{0}clinical-trial/{1}", baseUrl, trialID), trialFilePath);

            mockedClient.BaseAddress = new Uri(baseUrl);

            ClinicalTrialsAPIClient client = new ClinicalTrialsAPIClient(mockedClient);


            ClinicalTrial trial = client.Get(trialID);

            Assert.Equal(trialID, trial.NCTID);
        }
Esempio n. 22
0
        /// <summary>
        /// Gets the Phase number and adds glossification markup
        /// </summary>
        /// <param name="trial"></param>
        /// <returns>String glossifedPhase</returns>
        public string GetGlossifiedPhase(ClinicalTrial trial)
        {
            string phase = trial.GetTrialPhase();
            string cdrID = "";
            string htmlBlobOpen;
            string htmlBlobClose;

            // Check the API trial values and assign to a CDR ID if valid
            switch (phase)
            {
            case "I": cdrID = "45830";
                break;

            case "I_II": cdrID = "45832";
                break;

            case "II": cdrID = "45831";
                break;

            case "II_III": cdrID = "45834";
                break;

            case "III": cdrID = "45833";
                break;

            case "IV": cdrID = "45835";
                break;
            }

            if (String.IsNullOrEmpty(cdrID))
            {
                phase = "No phase specified";
            }
            else
            {
                htmlBlobOpen = @"<a onclick=""javascript:popWindow('defbyid','CDR00000" + cdrID +
                               @"&amp;version=Patient&amp;language=English'); return false;"" href=""/Common/PopUps/popDefinition.aspx?id=CDR00000" + cdrID +
                               @"45830&amp;version=Patient&amp;language=English"" class=""definition"">";
                htmlBlobClose = @"</a>";
                phase         = htmlBlobOpen + "Phase " + phase.Replace("_", "/") + htmlBlobClose;
            }
            return(phase);
        }
Esempio n. 23
0
        /// <summary>
        /// Send 404 error if the trial is invalid or does not have a view-able status.
        /// </summary>
        /// <param name="trial">The trial to check</param>
        private void RedirectIfTrialNotValid(ClinicalTrial trial)
        {
            // If trial value is null, redirect to the 404 page
            //TODO: Determine if a null trial should be a 404, or redirect to CT.gov
            if (trial == null)
            {
                throw new HttpException(404, "Trial cannot be found.");
            }

            if (Config.RedirectIfInactive)
            {
                string[] actives = CTSConstants.ActiveTrialStatuses;
                if (Array.IndexOf(actives, trial.CurrentTrialStatus) < 0)
                {
                    throw new HttpException(404, "Trial status is not active.");
                }
                if (string.IsNullOrWhiteSpace(trial.NCTID))
                {
                    throw new HttpException(404, "Trial does not have an NCT ID.");
                }
            }
        }
        /// <summary>
        /// Gets an array of all of the secondary IDs, which are those that are not the NCT ID or the Primary ID
        /// </summary>
        /// <param name="trial"></param>
        /// <returns></returns>
        public static string[] GetSecondaryIDs(this ClinicalTrial trial)
        {
            List <String> rtnIds = new List <String>();

            String[] secIds = { trial.CTEPID, trial.DCPID, trial.CCRID, trial.NCIID };
            String   dupe   = "";

            // Add secondary IDs (NCI, CCR, CTEP, DCP) to list
            foreach (String sid in secIds)
            {
                if (!String.IsNullOrEmpty(sid))
                {
                    rtnIds.Add(sid);
                }
            }

            // Add other secondary IDs to list
            if (trial.OtherTrialIDs != null)
            {
                rtnIds.AddRange(
                    from id in trial.OtherTrialIDs
                    where !String.IsNullOrEmpty(id.Value)
                    select id.Value
                    );
            }

            // Remove any duplicate found in Primary or Secondary IDs
            foreach (String rtnid in rtnIds.ToList())
            {
                if (rtnid == trial.NCTID || rtnid == trial.ProtocolID || rtnid == dupe)
                {
                    rtnIds.Remove(rtnid);
                }
                dupe = rtnid;
            }

            return(rtnIds.ToArray());
        }
Esempio n. 25
0
        public IEnumerable <ClinicalTrial.StudySite> GetAllStudySites(ClinicalTrial trial)
        {
            IEnumerable <ClinicalTrial.StudySite> sites = null;

            //BasicCTSManager mgr = new BasicCTSManager();

            // Assemble list of trial sites to be printed by the Velocity template:
            // 1. Filter inactive study sites out of our sites list
            // 2. Make a list of USA sites, sorted by state, then city
            // 3. Make a list of Canada sites, sorted by province, then city
            // 4. Make a list of international sites, sorted by country, then city
            // 5. Join the lists with USA as the first group of items and all other countries alphabetized afterward
            if (trial.Sites != null)
            {
                trial.Sites = new List <ClinicalTrial.StudySite>(trial.Sites.Where(site => CTSConstants.ActiveRecruitmentStatuses.Any(status => status.ToLower() == site.RecruitmentStatus.ToLower())));
                var usaSites    = trial.Sites.Where(s => s.Country == "United States").OrderBy(s => s.StateOrProvince).ThenBy(s => s.City).ThenBy(s => s.Name).ToArray();
                var canadaSites = trial.Sites.Where(s => s.Country == "Canada").OrderBy(s => s.StateOrProvince).ThenBy(s => s.City).ThenBy(s => s.Name).ToArray();
                var otherSites  = trial.Sites.Where(s => s.Country != "United States" && s.Country != "Canada").OrderBy(s => s.City).ThenBy(s => s.Name).ToArray();
                sites = canadaSites.Concat(otherSites).OrderBy(s => s.Country);
                sites = usaSites.Concat(sites);
            }
            return(sites);
        }
Esempio n. 26
0
 /// <summary>
 /// Checks whether the given trial ID exists in the API.
 /// </summary>
 /// <param name="idString">NCT ID</param>
 /// <returns>True if trial is found in API.</returns>
 private bool IsValidTrial(string idString)
 {
     // If the ID is a valid NCTID, go to web service and see if trial exists
     try
     {
         ClinicalTrialsAPIClient client = APIClientHelper.GetV1ClientInstance();
         ClinicalTrial           trial  = client.Get(idString);
         if (trial != null)
         {
             return(true);
         }
     }
     catch (ArgumentNullException nx)
     {
         log.DebugFormat("Error retrieving trial - value cannot be null. idString = " + idString, nx);
         return(false);
     }
     catch (Exception ex)
     {
         log.Error("Error retrieving trial object from API", ex);
         return(false);
     }
     return(false);
 }
        private static object GetOtherSortedLocations(ClinicalTrial trial)
        {
            OrderedDictionary locations = new OrderedDictionary();

            if (trial.Sites != null)
            {
                var sortedSites = from site in trial.Sites
                                  where (site.Country != "United States" &&
                                         site.Country != "Canada")
                                  orderby site.Country, site.StateOrProvince, site.Name
                select site;

                foreach (ClinicalTrial.StudySite site in sortedSites)
                {
                    if (!locations.Contains(site.Country))
                    {
                        locations.Add(site.Country, new List <ClinicalTrial.StudySite>());
                    }

                    ((List <ClinicalTrial.StudySite>)locations[site.Country]).Add(site);
                }
            }
            return(locations);
        }
        private static object GetNASortedLocations(ClinicalTrial trial, string country)
        {
            OrderedDictionary locations = new OrderedDictionary();

            if (trial.Sites != null)
            {
                var sortedSites = from site in trial.Sites
                                  where site.Country == country
                                  orderby site.StateOrProvince, site.Name
                select site;

                foreach (ClinicalTrial.StudySite site in sortedSites)
                {
                    if (!locations.Contains(site.StateOrProvince))
                    {
                        locations.Add(site.StateOrProvince, new List <ClinicalTrial.StudySite>());
                    }

                    ((List <ClinicalTrial.StudySite>)locations[site.StateOrProvince]).Add(site);
                }
            }

            return(locations);
        }
        /// <summary>
        /// Get min age unit info for trial
        /// </summary>
        /// <param name="site"></param>
        /// <returns></returns>
        public static String GetMinAgeUnit(this ClinicalTrial trial)
        {
            string unit = trial.EligibilityInfo.StructuredCriteria.MinAgeUnits;

            return(unit);
        }
        /// <summary>
        /// Get min age eligibility info for trial
        /// </summary>
        /// <param name="site"></param>
        /// <returns></returns>
        public static int GetMinAgeNum(this ClinicalTrial trial)
        {
            int age = trial.EligibilityInfo.StructuredCriteria.MinAgeInt;

            return(age);
        }