public ProcessResult Process(ElementNode node) { var processResult = new ProcessResult(); if (string.IsNullOrEmpty(node?.Value?.ToString())) { return(processResult); } if (node.IsDateNode()) { return(DateTimeUtility.ShiftDateNode(node, DateShiftKey, DateShiftKeyPrefix, EnablePartialDatesForRedact)); } else if (node.IsDateTimeNode() || node.IsInstantNode()) { return(DateTimeUtility.ShiftDateTimeAndInstantNode(node, DateShiftKey, DateShiftKeyPrefix, EnablePartialDatesForRedact)); } return(processResult); }
public static void RedactDateNode(ElementNode node, bool enablePartialDatesForRedact = false) { if (!node.IsDateNode()) { return; } if (enablePartialDatesForRedact) { var matchedGroups = s_dateRegex.Match(node.Value.ToString()).Groups; if (matchedGroups[s_yearIndex].Captures.Any()) { string yearOfDate = matchedGroups[s_yearIndex].Value; node.Value = IndicateAgeOverThreshold(matchedGroups) ? null : yearOfDate; } } else { node.Value = null; } }
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; } }
public static ProcessResult ShiftDateNode(ElementNode node, string dateShiftKey, string dateShiftKeyPrefix, bool enablePartialDatesForRedact = false) { var processResult = new ProcessResult(); if (!node.IsDateNode() || string.IsNullOrEmpty(node?.Value?.ToString())) { return(processResult); } var matchedGroups = s_dateRegex.Match(node.Value.ToString()).Groups; if (matchedGroups[s_dayIndex].Captures.Any() && !IndicateAgeOverThreshold(matchedGroups)) { int offset = GetDateShiftValue(node, dateShiftKey, dateShiftKeyPrefix); node.Value = DateTime.Parse(node.Value.ToString()).AddDays(offset).ToString(s_dateFormat); processResult.AddProcessRecord(AnonymizationOperations.Perturb, node); } else { processResult = RedactDateNode(node, enablePartialDatesForRedact); } return(processResult); }
public ProcessResult Process(ElementNode node, ProcessContext context = null, Dictionary <string, object> settings = null) { var processResult = new ProcessResult(); if (string.IsNullOrEmpty(node?.Value?.ToString())) { return(processResult); } if (node.IsDateNode()) { return(DateTimeUtility.ShiftDateNode(node, DateShiftKey, DateShiftKeyPrefix, EnablePartialDatesForRedact)); } if (node.IsDateTimeNode() || node.IsInstantNode()) { return(DateTimeUtility.ShiftDateTimeAndInstantNode(node, DateShiftKey, DateShiftKeyPrefix, EnablePartialDatesForRedact)); } return(processResult); }