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); }
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); }
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); }
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; } }