public ElementNode AnonymizeResourceNode(ElementNode root) { EnsureArg.IsNotNull(root, nameof(root)); if (root.IsBundleNode()) { var entryResources = root.GetEntryResourceChildren(); AnonymizeInternalResourceNodes(entryResources); } if (root.HasContainedNode()) { var containedResources = root.GetContainedChildren(); AnonymizeInternalResourceNodes(containedResources); } var resourceContext = ResourceAnonymizerContext.Create(root, _configurationManger); foreach (var rule in resourceContext.RuleList) { var pathCompileExpression = new FhirPathCompiler().Compile($"{rule.Path}"); var matchedNodes = pathCompileExpression(root, EvaluationContext.CreateDefault()) .Cast <ElementNode>(); foreach (var node in matchedNodes) { AnonymizeChildNode(node, rule.Method, resourceContext.PathSet); } } return(root); }
public ElementNode AnonymizeResourceNode(ElementNode root) { EnsureArg.IsNotNull(root, nameof(root)); if (root.IsBundleNode()) { var entryResources = root.GetEntryResourceChildren(); AnonymizeInternalResourceNodes(entryResources); } if (root.HasContainedNode()) { var containedResources = root.GetContainedChildren(); AnonymizeInternalResourceNodes(containedResources); } var resourceContext = ResourceAnonymizerContext.Create(root, _configurationManger); var resourceId = root.GetNodeId(); foreach (var rule in resourceContext.RuleList) { var matchedNodes = root.Select(rule.Path).Cast <ElementNode>(); _logger.LogDebug(rule.Type == AnonymizerRuleType.PathRule ? $"Path {rule.Source} matches {matchedNodes.Count()} nodes in resource ID {resourceId}." : $"Type {rule.Source} matches {matchedNodes.Count()} nodes with path {rule.Path} in resource ID {resourceId}."); foreach (var node in matchedNodes) { AnonymizeChildNode(node, rule, resourceContext.PathSet, resourceId); } } return(root); }