/// <summary> /// Initialize the TabularAddCodes object by concatenating information from two previous objects /// </summary> /// <param name="codes1">First TabularAddCodes object to build off of</param> /// <param name="codes2">Second TabularAddCodes object to concatenate objects from</param> public TabularAddCodes(TabularAddCodes codes1, TabularAddCodes codes2) { if ((codes1 != null) || (codes2 != null)) { if (codes1 == null) { AdditionalCodes = codes2.AdditionalCodes; CodeAlso = codes2.CodeAlso; CodeFirst = codes2.CodeFirst; Excludes1 = codes2.Excludes1; Excludes2 = codes2.Excludes2; } else if (codes2 == null) { AdditionalCodes = codes1.AdditionalCodes; CodeAlso = codes1.CodeAlso; CodeFirst = codes1.CodeFirst; Excludes1 = codes1.Excludes1; Excludes2 = codes1.Excludes2; } else { AdditionalCodes = codes1.AdditionalCodes.Union(codes2.AdditionalCodes); CodeAlso = codes1.CodeAlso.Union(codes2.CodeAlso); CodeFirst = codes1.CodeFirst.Union(codes2.CodeFirst); Excludes1 = codes1.Excludes1.Union(codes2.Excludes1); Excludes2 = codes1.Excludes2.Union(codes2.Excludes2); } } else { AdditionalCodes = Enumerable.Empty <string>(); CodeAlso = Enumerable.Empty <string>(); CodeFirst = Enumerable.Empty <string>(); Excludes1 = Enumerable.Empty <string>(); Excludes2 = Enumerable.Empty <string>(); } }
private static IEnumerable <Models.IcdCmTabCodes> GetCodes(XElement parentXml, Models.IcdCmSection section, TabularAddCodes parentAddCodes, string parentCode = null) { var codes = from el in parentXml.Elements("diag") let addCodes = new TabularAddCodes(el) select new { Element = el, Code = new Models.IcdCmTabCodes() { SectionRange = section.CodeRange, Code = el.Element("name").Value, InclusionTerms = from inclusTerms in el.Elements("inclusionTerm") from notes in inclusTerms.Elements("note") select notes.Value.Replace("(", String.Empty) .Replace(")", String.Empty) .Replace("[", String.Empty) .Replace("]", String.Empty), AddCodes = new TabularAddCodes(parentAddCodes, addCodes), Title = el.Element("desc").Value, ParentCode = parentCode } }; var children = from code in codes from ret in GetCodes(code.Element, section, code.Code.AddCodes, code.Code.Code) select ret; return(codes.Select(c => c.Code).Concat(children)); }