/// <summary>
        /// Gets the Friendly Name to replace a c-code in the URL for the dynamic trial listing page. If there is no exact override for that c-code,
        /// attempt to find a match that contains the given c-code in the EVS mappings.
        /// Sets needsRedirect to true if there is a friendly name override found.
        /// </summary>
        /// <returns>A string with the friendly name for the URL (replaces c-code) if the override exists, otherwise the given c-codes</returns>
        protected string GetFriendlyNameForURL(string param)
        {
            if (FriendlyNameWithOverridesMapping.MappingContainsCode(param, true))
            {
                // If an exact match is found in the Friendly Name With Overrides mapping, return the friendly name and set redirection bool
                needsRedirect = true;
                return(FriendlyNameWithOverridesMapping.GetFriendlyNameFromCode(param, true));
            }
            else if (FriendlyNameMapping.MappingContainsCode(param, true))
            {
                // If an exact match is found in the Friendly Name mapping, return the friendly name and set redirection bool
                needsRedirect = true;
                return(FriendlyNameMapping.GetFriendlyNameFromCode(param, true));
            }
            else
            {
                if (FriendlyNameMapping.MappingContainsCode(param, false))
                {
                    // If an exact match is found in the Friendly Name mapping (without overrides), or if matches are found that contain the given codes and all have the same friendly name,
                    // get the friendly name and set redirection bool.
                    needsRedirect = true;

                    string evsFriendlyName = FriendlyNameMapping.GetFriendlyNameFromCode(param, false);
                    string codesToOverride = FriendlyNameMapping.GetCodeFromFriendlyName(evsFriendlyName);

                    // If the found friendly name has code(s) that there is an entry in the override friendly name mapping for, return the override friendly name.
                    if (FriendlyNameWithOverridesMapping.MappingContainsCode(codesToOverride, true))
                    {
                        return(FriendlyNameWithOverridesMapping.GetFriendlyNameFromCode(codesToOverride, true));
                    }
                    // If the found friendly name do not have code(s) that there is an entry in the override friendly name mapping for, return the original friendly name.
                    else
                    {
                        return(FriendlyNameMapping.GetFriendlyNameFromCode(param, false));
                    }
                }
                else
                {
                    // If a user comes in with a friendly name, get the codes associated with that friendly name.
                    if (FriendlyNameMapping.MappingContainsFriendlyName(param))
                    {
                        string codesToOverride = FriendlyNameMapping.GetCodeFromFriendlyName(param);

                        // If the code(s) have an entry in the override friendly name mapping, and that new friendly name is not the same as the original,
                        // return the override friendly name and set redirection bool.
                        if (FriendlyNameWithOverridesMapping.MappingContainsCode(codesToOverride, true))
                        {
                            if (!string.Equals(param, FriendlyNameWithOverridesMapping.GetFriendlyNameFromCode(codesToOverride, true)))
                            {
                                needsRedirect = true;
                                return(FriendlyNameWithOverridesMapping.GetFriendlyNameFromCode(codesToOverride, true));
                            }
                        }
                    }
                }
            }

            return(param);
        }
        /// <summary>
        /// Gets the type specific query parameters to be sent to the API from the given URL params
        /// </summary>
        /// <returns>A JObject with all of the parameters converted to those needed by API</returns>
        protected override JObject GetTypeSpecificQueryParameters()
        {
            JObject queryParams = new JObject();

            // Get friendly name to c-code mapping
            string disIDs = this.DiseaseIDs;

            if (FriendlyNameWithOverridesMapping.MappingContainsFriendlyName(this.DiseaseIDs.ToLower()))
            {
                disIDs = FriendlyNameWithOverridesMapping.GetCodeFromFriendlyName(this.DiseaseIDs.ToLower());
            }
            else
            {
                if (FriendlyNameMapping.MappingContainsFriendlyName(this.DiseaseIDs.ToLower()))
                {
                    disIDs = FriendlyNameMapping.GetCodeFromFriendlyName(this.DiseaseIDs.ToLower());
                }
            }

            string[] diseaseIDsarr = disIDs.Split(new char[] { ',' });

            queryParams.Add("diseases.nci_thesaurus_concept_id", new JArray(diseaseIDsarr));

            if (!string.IsNullOrWhiteSpace(this.TrialType))
            {
                if (FriendlyNameWithOverridesMapping.MappingContainsFriendlyName(this.TrialType.ToLower()))
                {
                    queryParams.Add("primary_purpose.primary_purpose_code", FriendlyNameWithOverridesMapping.GetCodeFromFriendlyName(this.TrialType.ToLower()));
                }
                else
                {
                    queryParams.Add("primary_purpose.primary_purpose_code", this.TrialType);
                }
            }

            if (!string.IsNullOrWhiteSpace(this.InterventionIDs))
            {
                // Get friendly name to c-code mapping
                string ivIDs = this.InterventionIDs;
                if (FriendlyNameWithOverridesMapping.MappingContainsFriendlyName(this.InterventionIDs.ToLower()))
                {
                    ivIDs = FriendlyNameWithOverridesMapping.GetCodeFromFriendlyName(this.InterventionIDs.ToLower());
                }
                else
                {
                    if (FriendlyNameMapping.MappingContainsFriendlyName(this.InterventionIDs.ToLower()))
                    {
                        ivIDs = FriendlyNameMapping.GetCodeFromFriendlyName(this.InterventionIDs.ToLower());
                    }
                }


                string[] interventionIDsarr = ivIDs.Split(new char[] { ',' });
                queryParams.Add("arms.interventions.intervention_code", new JArray(interventionIDsarr));
            }

            return(queryParams);
        }
        /// <summary>
        /// Sets the Canonical Url of the Disease Page
        /// </summary>
        private void SetUpCanonicalUrl()
        {
            // We set the Canonical Url. We make sure that the Canonical URL has the following format disease/trial type instead of
            // disease/trial type/intervention
            string[] pathTokens = this.CurrAppPath.Split(new char[] { '/' });

            if (pathTokens != null && pathTokens.Length > 0)
            {
                string canonicalUrl = this.CurrentUrl.ToString().ToLower();

                // If there are disease IDs, we check if they have a friendly name for the canonical URL
                if (this.DiseaseIDs != null && this.DiseaseIDs.Length > 0)
                {
                    // Get c-code to friendly name mapping
                    if (FriendlyNameWithOverridesMapping.MappingContainsCode(this.DiseaseIDs.ToLower(), true))
                    {
                        canonicalUrl = canonicalUrl.Replace(this.DiseaseIDs, FriendlyNameWithOverridesMapping.GetFriendlyNameFromCode(this.DiseaseIDs, true));
                    }
                    else
                    {
                        if (FriendlyNameMapping.MappingContainsCode(this.DiseaseIDs.ToLower(), false))
                        {
                            canonicalUrl = canonicalUrl.Replace(this.DiseaseIDs, FriendlyNameMapping.GetFriendlyNameFromCode(this.DiseaseIDs, false));
                        }
                    }
                }

                if (this.TrialType != null)
                {
                    // Get trial type to friendly name mapping
                    if (FriendlyNameWithOverridesMapping.MappingContainsCode(this.TrialType.ToLower(), true))
                    {
                        canonicalUrl = canonicalUrl.Replace(this.TrialType, FriendlyNameWithOverridesMapping.GetFriendlyNameFromCode(this.DiseaseIDs, true));
                    }
                }

                // If there are intervention IDS we strip them from the canonical url
                if (this.InterventionIDs != null && this.InterventionIDs.Length > 0)
                {
                    canonicalUrl = canonicalUrl.Replace("/" + this.InterventionIDs + "/", "").Replace("/" + this.InterventionIDs, "");
                }


                this.PageInstruction.AddUrlFilter(PageAssemblyInstructionUrls.CanonicalUrl, (name, url) =>
                {
                    url.SetUrl(canonicalUrl);
                });
            }
        }
        /// <summary>
        /// Replaces the Placeholder Codes (or text) with Override Labels
        /// </summary>
        /// <param name="codes"></param>
        /// <returns>A string with the override text</returns>
        private string GetOverride(string valToOverride, bool needsTitleCase)
        {
            // Get friendly name to c-code mapping
            if (FriendlyNameWithOverridesMapping.MappingContainsFriendlyName(valToOverride.ToLower()))
            {
                valToOverride = FriendlyNameWithOverridesMapping.GetCodeFromFriendlyName(valToOverride);
            }
            else
            {
                if (FriendlyNameMapping.MappingContainsFriendlyName(valToOverride.ToLower()))
                {
                    valToOverride = FriendlyNameMapping.GetCodeFromFriendlyName(valToOverride);
                }
            }

            // Get label mappings
            var    labelMapping = DynamicTrialListingMappingService.Instance;
            string overrideText = "";

            // Add check for whether override/EVS mapping has all of the codes.
            // If so, keep as is. If not, split and find the first match.

            // If combination of codes is in label mappings, set override
            if (labelMapping.MappingContainsKey(valToOverride))
            {
                if (needsTitleCase)
                {
                    overrideText = labelMapping.GetTitleCase(valToOverride);
                }
                else
                {
                    overrideText = labelMapping.Get(valToOverride);
                }
            }
            // Raise 404 error if overrides aren't found
            else
            {
                Response.Headers.Add("X-CTSMap", "ID not found");
                LogManager.GetLogger(typeof(DynamicTrialListingPageDiseaseControl)).ErrorFormat("" +
                                                                                                "Invalid parameter in dynamic listing page: {0} does not have override", valToOverride);
                NCI.Web.CDE.Application.ErrorPageDisplayer.RaisePageByCode("DynamicTrialListingPageDiseaseControl", 404, "Invalid parameter in dynamic listing page: value given does not have override");
            }

            return(overrideText);
        }
示例#5
0
        /// <summary>
        /// Gets the type specific query parameters to be sent to the API from the given URL params
        /// </summary>
        /// <returns>A JObject with all of the parameters converted to those needed by API</returns>
        protected override JObject GetTypeSpecificQueryParameters()
        {
            JObject queryParams = new JObject();

            // Get friendly name to c-code mapping
            string ivIDs = this.InterventionIDs;

            if (FriendlyNameWithOverridesMapping.MappingContainsFriendlyName(this.InterventionIDs.ToLower()))
            {
                ivIDs = FriendlyNameWithOverridesMapping.GetCodeFromFriendlyName(this.InterventionIDs.ToLower());
            }
            else
            {
                if (FriendlyNameMapping.MappingContainsFriendlyName(this.InterventionIDs.ToLower()))
                {
                    ivIDs = FriendlyNameMapping.GetCodeFromFriendlyName(this.InterventionIDs.ToLower());
                }
            }

            // Add check for whether override/EVS mapping has all of the codes.
            // If so, keep as is. If not, split and find the first match.

            string[] interventionIDsarr = ivIDs.Split(new char[] { ',' });

            queryParams.Add("arms.interventions.intervention_code", new JArray(interventionIDsarr));

            if (!string.IsNullOrWhiteSpace(this.TrialType))
            {
                if (FriendlyNameWithOverridesMapping.MappingContainsFriendlyName(this.TrialType.ToLower()))
                {
                    queryParams.Add("primary_purpose.primary_purpose_code", FriendlyNameWithOverridesMapping.GetCodeFromFriendlyName(this.TrialType.ToLower()));
                }
                else
                {
                    queryParams.Add("primary_purpose.primary_purpose_code", this.TrialType);
                }
            }

            return(queryParams);
        }