DicomKeyAttribute Constructor (original) (raw)

Syntax

Parameters

key
The key.

Example

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; using Leadtools.Codecs; [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); } } }

Leadtools.Dicom.Common Assembly