private static void TransformTypeRulesToPathRules(ElementNode node, Dictionary <string, string> typeRules, List <AnonymizerRule> rules, HashSet <string> rulePaths)
        {
            if (node.IsContainedNode() || node.IsEntryNode())
            {
                return;
            }

            string path = node.GetFhirPath();

            if (rulePaths.Contains(path))
            {
                return;
            }

            if (typeRules.ContainsKey(node.InstanceType))
            {
                var rule = new AnonymizerRule(path, typeRules[node.InstanceType], AnonymizerRuleType.TypeRule, node.InstanceType);

                rules.Add(rule);
                rulePaths.Add(rule.Path);
            }

            var children = node.Children().Cast <ElementNode>();

            foreach (var child in children)
            {
                TransformTypeRulesToPathRules(child, typeRules, rules, rulePaths);
            }
        }
Beispiel #2
0
        public override void EndVisit(ElementNode node)
        {
            if (node.IsFhirResource())
            {
                Tuple <ElementNode, ProcessResult> context = _contextStack.Pop();
                ProcessResult result = context.Item2;

                if (context.Item1 != node)
                {
                    // Should never throw exception here. In case any bug happen, we can get clear message for this exception.
                    throw new ConstraintException("Internal error: access wrong context.");
                }

                if (_contextStack.Count() > 0)
                {
                    _contextStack.Peek().Item2.Update(result);
                }

                if (AddSecurityTag && !node.IsContainedNode())
                {
                    node.AddSecurityTag(result);
                }
            }
        }