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); }
private static string TryGetResourceId(ElementNode node) { while (node.Parent != null) { node = node.Parent; } return(node.GetNodeId()); }
private void LogProcessResult(ElementNode node, AnonymizationFhirPathRule rule, ProcessResult resultOnRule) { if (_logger.IsEnabled(LogLevel.Debug)) { string resourceId = node.GetNodeId(); foreach (var processRecord in resultOnRule.ProcessRecords) { foreach (var matchNode in processRecord.Value) { _logger.LogDebug($"[{resourceId}]: Rule '{rule.Path}' matches '{matchNode.Location}' and perform operation '{processRecord.Key}'"); } } } }