/// <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 KeyValuePair <string, bool> GetFriendlyNameForURL(DynamicTrialListingFriendlyNameMapper FriendlyNameMapping, DynamicTrialListingFriendlyNameMapper FriendlyNameWithOverridesMapping, string param) { bool needsRedirect = false; 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(new KeyValuePair <string, bool>(FriendlyNameWithOverridesMapping.GetFriendlyNameFromCode(param, true), needsRedirect)); } else { if (FriendlyNameMapping.MappingContainsCode(param, false)) { // If an exact match is found in the Friendly Name mapping (without overrides), return the friendly name and set redirection bool // Also if matches are found that contain the given codes and all have the same friendly name, return that friendly name and set redirection bool needsRedirect = true; string evsFriendlyName = FriendlyNameMapping.GetFriendlyNameFromCode(param, false); string codesToOverride = FriendlyNameMapping.GetCodeFromFriendlyName(evsFriendlyName); if (FriendlyNameWithOverridesMapping.MappingContainsCode(codesToOverride, true)) { // If an exact match is found in the Friendly Name With Overrides mapping, return the friendly name and set redirection bool return(new KeyValuePair <string, bool>(FriendlyNameWithOverridesMapping.GetFriendlyNameFromCode(codesToOverride, true), needsRedirect)); } else { return(new KeyValuePair <string, bool>(FriendlyNameMapping.GetFriendlyNameFromCode(param, false), needsRedirect)); } } else { if (FriendlyNameMapping.MappingContainsFriendlyName(param)) { string codesToOverride = FriendlyNameMapping.GetCodeFromFriendlyName(param); if (FriendlyNameWithOverridesMapping.MappingContainsCode(codesToOverride, true)) { // If an exact match is found in the Friendly Name With Overrides mapping, return the friendly name and set redirection bool if (!string.Equals(param, FriendlyNameWithOverridesMapping.GetFriendlyNameFromCode(codesToOverride, true))) { needsRedirect = true; return(new KeyValuePair <string, bool>(FriendlyNameWithOverridesMapping.GetFriendlyNameFromCode(codesToOverride, true), needsRedirect)); } } } } } return(new KeyValuePair <string, bool>(param, needsRedirect)); }
/// <summary> /// Gets the friendly name that maps to the given C-code(s). /// </summary> /// <param name="value"></param> /// <returns>The friendly name</returns> public string GetFriendlyNameFromCode(string value, bool hasExactMatch) { return(_mapper.GetFriendlyNameFromCode(value, hasExactMatch)); }
public void LoadEVSFriendlyNameMapping() { DynamicTrialListingFriendlyNameMapper mapper = GetMappingService("DLPFriendlyNameMapping.txt", "DLPFriendlyNameOverrideMapping.txt", false); Assert.Equal("thyroid-gland-cancer", mapper.GetFriendlyNameFromCode("c118827,c4815", true), new MappingsComparer()); }