Пример #1
0
        public ProcessResult Process(ElementNode node, ProcessContext context = null,
                                     Dictionary <string, object> settings     = null)
        {
            if (string.IsNullOrEmpty(node?.Value?.ToString()))
            {
                return(new ProcessResult());
            }

            if (node.IsDateNode())
            {
                return(DateTimeUtility.RedactDateNode(node, EnablePartialDatesForRedact));
            }

            if (node.IsDateTimeNode() || node.IsInstantNode())
            {
                return(DateTimeUtility.RedactDateTimeAndInstantNode(node, EnablePartialDatesForRedact));
            }

            if (node.IsAgeDecimalNode())
            {
                return(DateTimeUtility.RedactAgeDecimalNode(node, EnablePartialAgesForRedact));
            }

            if (node.IsPostalCodeNode())
            {
                return(PostalCodeUtility.RedactPostalCode(node, EnablePartialZipCodesForRedact,
                                                          RestrictedZipCodeTabulationAreas));
            }

            node.Value = null;
            var result = new ProcessResult();

            result.AddProcessRecord(AnonymizationOperations.Redact, node);
            return(result);
        }
Пример #2
0
        public void GivenAPostalCode_WhenRedact_ThenDigitsShouldBeRedacted(string postalCode)
        {
            var node = ElementNode.FromElement(new FhirString(postalCode).ToTypedElement());

            node.Name = "postalCode";
            PostalCodeUtility.RedactPostalCode(node, false, null);

            Assert.Null(node.Value);
        }
Пример #3
0
        public void GivenAPostalCode_WhenPartialRedact_ThenPartialDigitsShouldBeRedacted(string postalCode, string expectedPostalCode)
        {
            var node = ElementNode.FromElement(new FhirString(postalCode).ToTypedElement());

            node.Name = "postalCode";
            PostalCodeUtility.RedactPostalCode(node, true, new List <string>()
            {
                "203", "556"
            });

            Assert.Equal(expectedPostalCode.ToString(), node.Value);
        }
Пример #4
0
 public void Process(ElementNode node)
 {
     if (node.IsDateNode())
     {
         DateTimeUtility.RedactDateNode(node, EnablePartialDatesForRedact);
     }
     else if (node.IsDateTimeNode() || node.IsInstantNode())
     {
         DateTimeUtility.RedactDateTimeAndInstantNode(node, EnablePartialDatesForRedact);
     }
     else if (node.IsAgeDecimalNode())
     {
         DateTimeUtility.RedactAgeDecimalNode(node, EnablePartialAgesForRedact);
     }
     else if (node.IsPostalCodeNode())
     {
         PostalCodeUtility.RedactPostalCode(node, EnablePartialZipCodesForRedact, RestrictedZipCodeTabulationAreas);
     }
     else
     {
         node.Value = null;
     }
 }