Error processing SSI file
Leadtools.Dicom.Common

Show in webframe

DicomKeyAttribute Class






Members 
Specifies what DICOMDIR key this class/property is associated with.
Object Model
Syntax
'Declaration
 
Public Class DicomKeyAttribute 
   Inherits System.Attribute
   Implements System.Runtime.InteropServices._Attribute 
'Usage
 
Dim instance As DicomKeyAttribute
public ref class DicomKeyAttribute : public System.Attribute, System.Runtime.InteropServices._Attribute  
Example

This example will show how to perform several different types of LINQ based queries on a DICOM basic directory.

Copy Code  
Imports Leadtools.Dicom
Imports Leadtools.Dicom.Common
Imports Leadtools.Dicom.Common.Extensions
Imports Leadtools.Dicom.Common.Linq
Imports Leadtools.Dicom.Common.Linq.BasicDirectory
Imports Leadtools
Imports Leadtools.Dicom.Common.DataTypes

<DicomKey(DicomDirKeyType.Patient)> _
Public Class PatientEntity
   <Element(DicomTag.PatientID)> _
   Public Property Id() As String
      Get
         Return m_Id
      End Get
      Set(ByVal value As String)
         m_Id = value
      End Set
   End Property
   Private m_Id As String

   <Element(DicomTag.PatientName)> _
   Public Property Name() As String
      Get
         Return m_Name
      End Get
      Set(ByVal value As String)
         m_Name = value
      End Set
   End Property
   Private m_Name As String
End Class

<DicomKey(DicomDirKeyType.Study)> _
Public Class StudyEntity
   <Element(DicomTag.PatientID)> _
   <DicomKey(DicomDirKeyType.Patient)> _
   Public Property PatientId() As String
      Get
         Return m_PatientId
      End Get
      Set(ByVal value As String)
         m_PatientId = value
      End Set
   End Property
   Private m_PatientId As String

   <Element(DicomTag.StudyDate)> _
   Public Property [Date]() As System.Nullable(Of DateTime)
      Get
         Return m_Date
      End Get
      Set(ByVal value As System.Nullable(Of DateTime))
         m_Date = value
      End Set
   End Property
   Private m_Date As System.Nullable(Of DateTime)

   <Element(DicomTag.StudyTime)> _
   Public Property Time() As System.Nullable(Of DateTime)
      Get
         Return m_Time
      End Get
      Set(ByVal value As System.Nullable(Of DateTime))
         m_Time = value
      End Set
   End Property
   Private m_Time As System.Nullable(Of DateTime)

   <Element(DicomTag.StudyDescription)> _
   Public Property Description() As String
      Get
         Return m_Description
      End Get
      Set(ByVal value As String)
         m_Description = value
      End Set
   End Property
   Private m_Description As String

   <Element(DicomTag.StudyInstanceUID)> _
   Public Property InstanceUID() As String
      Get
         Return m_InstanceUID
      End Get
      Set(ByVal value As String)
         m_InstanceUID = value
      End Set
   End Property
   Private m_InstanceUID As String

   <Element(DicomTag.StudyID)> _
   Public Property Id() As String
      Get
         Return m_Id
      End Get
      Set(ByVal value As String)
         m_Id = value
      End Set
   End Property
   Private m_Id As String

   <Element(DicomTag.AccessionNumber)> _
   Public Property AccessionNumber() As String
      Get
         Return m_AccessionNumber
      End Get
      Set(ByVal value As String)
         m_AccessionNumber = value
      End Set
   End Property
   Private m_AccessionNumber As String
End Class

<TestMethod()> _
Public Sub TestDicomLinq()
   DicomEngine.Startup()

   Using ds As New DicomDataSet()
      ds.Load(_DicomDirFile, DicomDataSetLoadFlags.None)
      FindPatients(ds)
      FindStudies(ds)
      FindPatientStudy(ds)
   End Using

   DicomEngine.Shutdown()
End Sub

Private Sub FindPatients(ByVal ds As DicomDataSet)
   Dim patients = From patient In ds.DirectoryRecord(Of PatientEntity)() _
                  Select Name = patient.Name, Id = patient.Id

   For Each patient In patients
      Console.WriteLine("Id: " & Convert.ToString(patient.Id))
      Console.WriteLine("Name: " & Convert.ToString(patient.Name))
   Next
End Sub

Private Sub FindStudies(ByVal ds As DicomDataSet)
   Dim studies = From study In ds.DirectoryRecord(Of StudyEntity)() _
         Select study

   For Each study In studies
      Console.WriteLine("Patient Id: " & Convert.ToString(study.PatientId))
      Console.WriteLine("Accession #: " & Convert.ToString(study.AccessionNumber))
      Console.WriteLine("Study Id: " & Convert.ToString(study.Id))
   Next
End Sub

Private Sub FindPatientStudy(ByVal ds As DicomDataSet)
   Dim query = From patient In ds.DirectoryRecord(Of PatientEntity)() _
               Select _
    patient, _
    Studies = From study In ds.DirectoryRecord(Of StudyEntity)() Where study.PatientId = patient.Id _
              Select study

   For Each item In query
      Console.WriteLine("Patient: " & Convert.ToString(item.patient.Id))
      For Each study As StudyEntity In item.Studies
         Console.WriteLine("    Instance UID: " + study.InstanceUID)
      Next
   Next
End Sub
using Leadtools.Dicom;
using Leadtools.Dicom.Common;
using Leadtools.Dicom.Common.Extensions;
using Leadtools;
using Leadtools.Dicom.Common.Linq.BasicDirectory;
using Leadtools.Dicom.Common.DataTypes;

[DicomKey(DicomDirKeyType.Patient)]
public class PatientEntity
{
    [Element(DicomTag.PatientID)]
    public string Id
    {
        get;
        set;
    }

    [Element(DicomTag.PatientName)]
    public string Name
    {
        get;
        set;
    }
}

[DicomKey(DicomDirKeyType.Study)]
public class StudyEntity
{
    [Element(DicomTag.PatientID)]
    [DicomKey(DicomDirKeyType.Patient)]
    public string PatientId
    {
        get;
        set;
    }

    [Element(DicomTag.StudyDate)]
    public DateTime? Date
    {
        get;
        set;
    }

    [Element(DicomTag.StudyTime)]
    public DateTime? Time
    {
        get;
        set;
    }

    [Element(DicomTag.StudyDescription)]
    public string Description
    {
        get;
        set;
    }

    [Element(DicomTag.StudyInstanceUID)]
    public string InstanceUID
    {
        get;
        set;
    }

    [Element(DicomTag.StudyID)]
    public string Id
    {
        get;
        set;
    }

    [Element(DicomTag.AccessionNumber)]
    public string AccessionNumber
    {
        get;
        set;
    }
}

[TestMethod]
public void TestDicomLinq()
{
    DicomEngine.Startup();

    using (DicomDataSet ds = new DicomDataSet())
    {
        ds.Load(_DicomDirFile, DicomDataSetLoadFlags.None);
        FindPatients(ds);
        FindStudies(ds);
        FindPatientStudy(ds);
    }

    DicomEngine.Shutdown();
}

private void FindPatients(DicomDataSet ds)
{
    var patients = from patient in ds.DirectoryRecord<PatientEntity>()
                   select new { Name = patient.Name, Id = patient.Id };

    foreach (var patient in patients)
    {
        Console.WriteLine("Id: " + patient.Id);
        Console.WriteLine("Name: " + patient.Name);
    }
}

private void FindStudies(DicomDataSet ds)
{
     var studies = from study in ds.DirectoryRecord<StudyEntity>()
                   select study;

     foreach (var study in studies)
     {
         Console.WriteLine("Patient Id: " + study.PatientId);
         Console.WriteLine("Accession #: " + study.AccessionNumber);
         Console.WriteLine("Study Id: " +study.Id);
     }
}

private void FindPatientStudy(DicomDataSet ds)
{
    var query = from patient in ds.DirectoryRecord<PatientEntity>()                      
                select new
                {
                    patient,
                    Studies = from study in ds.DirectoryRecord<StudyEntity>()
                              where study.PatientId == patient.Id
                              select study
                };

    foreach (var item in query)
    {
        Console.WriteLine("Patient: " + item.patient.Id);
        foreach (StudyEntity study in item.Studies)
        {
            Console.WriteLine("    Instance UID: " + study.InstanceUID);
        }
    }
}
Requirements

Target Platforms

See Also

Reference

DicomKeyAttribute Members
Leadtools.Dicom.Common.Linq.BasicDirectory Namespace

Error processing SSI file
   Leadtools.Dicom.Common requires a Medical toolkit license and unlock key. For more information, refer to: LEADTOOLS Toolkit Features