public void Process(DicomDataset dicomDataset, DicomItem item, ProcessContext context = null) { EnsureArg.IsNotNull(dicomDataset, nameof(dicomDataset)); EnsureArg.IsNotNull(item, nameof(item)); var redactedValues = new List <string>(); if (item.ValueRepresentation == DicomVR.AS) { var values = ((DicomAgeString)item).Get <string[]>(); foreach (var value in values) { var result = _redactFunction.Redact(DicomUtility.ParseAge(value)); if (result != null) { redactedValues.Add(DicomUtility.GenerateAgeString(result)); } } } else if (item.ValueRepresentation == DicomVR.DA) { var values = DicomUtility.ParseDicomDate((DicomDate)item); foreach (var value in values) { var result = _redactFunction.Redact(value); if (result != null) { redactedValues.Add(DicomUtility.GenerateDicomDateString((DateTimeOffset)result)); } } } else if (item.ValueRepresentation == DicomVR.DT) { DateTimeObject[] values = DicomUtility.ParseDicomDateTime((DicomDateTime)item); foreach (var value in values) { DateTimeObject result = _redactFunction.Redact(value); if (result != null) { redactedValues.Add(DicomUtility.GenerateDicomDateTimeString(result)); } } } else if (item.ValueRepresentation == DicomVR.SQ) { dicomDataset.AddOrUpdate <DicomDataset>(DicomVR.SQ, item.Tag); return; } if (redactedValues.Count != 0) { dicomDataset.AddOrUpdate(item.ValueRepresentation, item.Tag, redactedValues.ToArray()); } else { dicomDataset.AddOrUpdate <string>(item.ValueRepresentation, item.Tag, values: null); } _logger.LogDebug($"The value of DICOM item '{item}' is redacted."); }
public void GivenAPostalCode_WhenRedact_ThenDigitsShouldBeRedacted(string postalCode) { var redactFunction = new RedactFunction(new RedactSetting()); var processResult = redactFunction.Redact(postalCode, AnonymizerValueTypes.PostalCode); Assert.Null(processResult); }
public void GivenAnAge_WhenRedact_ThenAgeShouldBeRedacted(uint age) { var redactFunction = new RedactFunction(new RedactSetting()); var processResult = redactFunction.Redact(age, AnonymizerValueTypes.Age); Assert.Null(processResult); }
public void GivenADate_WhenRedact_ThenDateShouldBeRedacted(string date) { var redactFunction = new RedactFunction(new RedactSetting()); var processResult = redactFunction.Redact(date, AnonymizerValueTypes.Date); Assert.Null(processResult); }
public void GivenAnInstant_WhenRedact_ThenInstantShouldBeRedacted(string instant, string expectedInstantString) { var redactFunction = new RedactFunction(new RedactSetting() { EnablePartialDatesForRedact = true }); var processResult = redactFunction.Redact(instant, AnonymizerValueTypes.DateTime); Assert.Equal(expectedInstantString ?? null, processResult); }
public void GivenADateTime_WhenRedact_ThenDateTimeShouldBeRedacted(string dateTime, string expectedDateTime) { var redactFunction = new RedactFunction(new RedactSetting() { EnablePartialDatesForRedact = true }); var processResult = redactFunction.Redact(dateTime, AnonymizerValueTypes.DateTime); Assert.Equal(expectedDateTime, processResult); }
public void GivenAPostalCode_WhenPartialRedact_ThenPartialDigitsShouldBeRedacted(string postalCode, string expectedPostalCode) { var redactFunction = new RedactFunction(new RedactSetting() { EnablePartialZipCodesForRedact = true, RestrictedZipCodeTabulationAreas = new List <string>() { "203", "556" } }); var processResult = redactFunction.Redact(postalCode, AnonymizerValueTypes.PostalCode); Assert.Equal(expectedPostalCode, processResult); }
public void GivenAnAge_WhenPartialRedact_ThenAgeOver89ShouldBeRedacted(uint age) { var redactFunction = new RedactFunction(new RedactSetting() { EnablePartialAgesForRedact = true }); var processResult = redactFunction.Redact(age, AnonymizerValueTypes.Age); if (age > 89) { Assert.Null(processResult); } else { Assert.Equal(age, processResult); } }