Skip to content

Commit

Permalink
excluding a code doesn't exclude it's children.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsmits committed Jul 24, 2024
1 parent 7738a9e commit aada9f1
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,12 @@ public static ValueSet.ContainsComponent Add(this List<ValueSet.ContainsComponen

public static void Remove(this List<ValueSet.ContainsComponent> dest, string system, string code)
{
var children = dest.Where(c => c.System == system && c.Code == code).SelectMany(c => c.Contains).ToList();
dest.RemoveAll(c => c.System == system && c.Code == code);

//add children back to the list, they do not necessarily need to be removed when the parent is removed.
dest.AddRange(children);

// Look for this code in children too
foreach (var component in dest)
{
Expand All @@ -334,9 +338,15 @@ public static void Remove(this List<ValueSet.ContainsComponent> dest, string sys

public static void Remove(this List<ValueSet.ContainsComponent> dest, List<ValueSet.ContainsComponent> source)
{
//TODO: Pretty unclear what to do with child concepts in the source - they all need to be removed from dest?
foreach (var sourceConcept in source)
{
dest.Remove(sourceConcept.System, sourceConcept.Code);

//check if there are children that need to be removed too.
if (sourceConcept.Contains.Any())
dest.Remove(sourceConcept.Contains);
}

}

internal static ValueSet.ContainsComponent ToContainsComponent(this CodeSystem.ConceptDefinitionComponent source, CodeSystem system, ValueSetExpanderSettings settings)
Expand Down

0 comments on commit aada9f1

Please sign in to comment.