DicomKeyAttribute Class

Summary
Specifies what DICOMDIR key this class/property is associated with.
Syntax
C#
C++
public class DicomKeyAttribute : Attribute 
vb[VB Syntax] 
Public Class DicomKeyAttribute  
   Inherits System.Attribute 
   Implements System.Runtime.InteropServices._Attribute 
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.

C#
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; 
   } 
} 
 
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

Help Version 22.0.2022.4.4
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2022 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Dicom.Common Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2022 LEAD Technologies, Inc. All Rights Reserved.