Leadtools.Dicom.Common
LEAD Technologies, Inc

BeforeTagAnonymization Event

Example 





Occurs before a tag is anonymized.
Syntax
public event EventHandler<BeforeTagAnonymizationEventArgs> BeforeTagAnonymization
'Declaration
 
Public Event BeforeTagAnonymization As EventHandler(Of BeforeTagAnonymizationEventArgs)
'Usage
 
Dim instance As Anonymizer
Dim handler As EventHandler(Of BeforeTagAnonymizationEventArgs)
 
AddHandler instance.BeforeTagAnonymization, handler
public event EventHandler<BeforeTagAnonymizationEventArgs> BeforeTagAnonymization
add_BeforeTagAnonymization(function(sender, e))
remove_BeforeTagAnonymization(function(sender, e))

public:
event EventHandler<BeforeTagAnonymizationEventArgs^>^ BeforeTagAnonymization
Event Data

The event handler receives an argument of type BeforeTagAnonymizationEventArgs containing data related to this event. The following BeforeTagAnonymizationEventArgs properties provide information specific to this event.

PropertyDescription
Cancel (Inherited from System.ComponentModel.CancelEventArgs)Gets or sets a value indicating whether the event should be canceled.
CurrentValue Gets the current value of the DICOM element.
Element Gets the element in the DICOM dataset that is being anonymized.
NewValue Gets or sets the new value of the DICOM element.
Remarks
This event will occur after the tag has been processed with the MacroProcessor.
Example
Copy CodeCopy Code  
Public Sub AnonymizationSample()
      Dim anonymizer As New Anonymizer()
      Dim dicomFileNameIn As String = Path.Combine(LEAD_VARS.ImagesDir, "IMAGE3.dcm")

      AddHandler anonymizer.Progress, AddressOf anonymizer_Progress
      AddHandler anonymizer.BeforeTagAnonymization, AddressOf anonymizer_BeforeTagAnonymization
      Using source As New DicomDataSet()
         Dim oldPatientId As String = String.Empty

         source.Load(dicomFileNameIn, DicomDataSetLoadFlags.None)
         oldPatientId = source.GetValue(Of String)(DicomTag.PatientID, String.Empty)
         anonymizer.Anonymize(source)

         '
         ' The values should not be equal because the anonymizer has provide another patient ID using the Dicom Anonymization basic profile.
         ' By default the following macro is provided for patient id: ${random_string}
         '
         Debug.Assert(oldPatientId <> source.GetValue(Of String)(DicomTag.PatientID, String.Empty))
      End Using
   End Sub

   Private Sub anonymizer_BeforeTagAnonymization(ByVal sender As Object, ByVal e As BeforeTagAnonymizationEventArgs)
      Console.WriteLine(String.Format("Tag: {0}, Current Value: {1}, New Value: {0} ", e.Element.Tag, e.CurrentValue, e.NewValue))
   End Sub

   Private Sub anonymizer_Progress(ByVal sender As Object, ByVal e As ProgressEventArgs)
      Console.WriteLine("Progress: " + e.Progress.ToString())
   End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
public void AnonymizationSample()
   {
      Anonymizer anonymizer = new Anonymizer();
      string dicomFileNameIn = Path.Combine(LEAD_VARS.ImagesDir, "IMAGE3.dcm");

      anonymizer.Progress += new EventHandler<ProgressEventArgs>(anonymizer_Progress);
      anonymizer.BeforeTagAnonymization += new EventHandler<BeforeTagAnonymizationEventArgs>(anonymizer_BeforeTagAnonymization);
      using (DicomDataSet source = new DicomDataSet())
      {
         string oldPatientId = string.Empty;

         source.Load(dicomFileNameIn, DicomDataSetLoadFlags.None);
         oldPatientId = source.GetValue<string>(DicomTag.PatientID, string.Empty);
         anonymizer.Anonymize(source);

         //
         // The values should not be equal because the anonymizer has provide another patient ID using the Dicom Anonymization basic profile.
         // By default the following macro is provided for patient id: ${random_string}
         //

         Debug.Assert(oldPatientId != source.GetValue<string>(DicomTag.PatientID, string.Empty));
      }
   }

   void anonymizer_BeforeTagAnonymization(object sender, BeforeTagAnonymizationEventArgs e)
   {
      Console.WriteLine(string.Format("Tag: {0}, Current Value: {1}, New Value: {0} ",e.Element.Tag, e.CurrentValue, e.NewValue));
   }

   void anonymizer_Progress(object sender, ProgressEventArgs e)
   {
      Console.WriteLine("Progress: " + e.Progress.ToString());
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

Anonymizer Class
Anonymizer Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.

Leadtools.Dicom.Common requires a Document or Medical toolkit license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features