/// <summary> /// Creates the custom scope values. /// </summary> /// <param name="scope">The scope.</param> /// <param name="name">The name.</param> /// <param name="column">The column.</param> public static void CreateCustomScopeValues(this Scope scope, string name, DynamicTargetColumn column) { if (column.Scope == DynamicScopeEnum.None) { return; } if (scope.IsCustom) { // TODO: FINISH CUSTOM SCOPE VALUES. JASON } else { if (!string.IsNullOrEmpty(scope.ClrType)) { try { var scopeType = Type.GetType(scope.ClrType); var enumValues = Enum.GetValues(scopeType); // IList<System.Tuple<string, string, object>> enumValuDescList = new List<System.Tuple<string, string, object>>(); foreach (var value in enumValues) { var fi = value.GetType().GetField(value.ToString()); if (null == fi) { continue; // Next } var attrs = fi.GetCustomAttributes(typeof(WingScopeValueAttribute), true).OfType <WingScopeValueAttribute>().ToArray(); if (attrs.Length == 0) { continue; // Next } var item = new ScopeValue(scope, attrs[0].Name) { Description = attrs[0].Description, Value = attrs[0].Value }; if (!item.Owner.Name.EqualsIgnoreCase(scope.Name)) { } if (!scope.Values.Any(sv => sv.Name.EqualsIgnoreCase(item.Name))) { scope.Values.Add(item); } } } catch (Exception) { } } } }
/// <summary> /// Creates the scope. /// </summary> /// <param name="target">The target.</param> /// <param name="column">The column.</param> /// <returns></returns> private static Scope CreateScope(Target target, DynamicTargetColumn column) { if (column == null || column.Scope == DynamicScopeEnum.None) { return(default(Scope)); } Scope scope; switch (column.Scope) { case DynamicScopeEnum.Race: scope = new Scope(target, column.Name, typeof(Race)); break; case DynamicScopeEnum.PrimaryPayer: scope = new Scope(target, column.Name, typeof(PrimaryPayer)); break; case DynamicScopeEnum.Sex: scope = new Scope(target, column.Name, typeof(Sex)); break; case DynamicScopeEnum.AdmissionSource: scope = new Scope(target, column.Name, typeof(AdmissionSource)); break; case DynamicScopeEnum.AdmissionType: scope = new Scope(target, column.Name, typeof(AdmissionType)); break; case DynamicScopeEnum.DischargeDisposition: scope = new Scope(target, column.Name, typeof(DischargeDisposition)); break; case DynamicScopeEnum.EDServices: scope = new Scope(target, column.Name, typeof(EDServices)); break; case DynamicScopeEnum.PointOfOrigin: scope = new Scope(target, column.Name, typeof(PointOfOrigin)); break; case DynamicScopeEnum.HospitalTraumaLevel: scope = new Scope(target, column.Name, typeof(HospitalTraumaLevel)); break; case DynamicScopeEnum.Custom: scope = new Scope(target, column.Name) { IsCustom = true }; break; default: scope = default(Scope); break; } var element = target.Elements.FirstOrDefault(e => e.Name.EqualsIgnoreCase(column.Name)); if (element != null && element.Scope == null) { element.Scope = scope; } scope.Description = column.Description; scope.CreateCustomScopeValues(scope.Name, column); return(scope); }