How to implement C-GET with DicomObjects

There are 2 ways to send DICOM C-GET request in DicomObjects:

  1. Use DicomQuery object
  2. Use DicomAssociation (.NET) or DicomConnection (COM) object

DicomObjects.NET

DicomQuery

DicomQuery object is designed to be simple and easy to use as DicomObjects will handle all the Presentation Contexts in request as well as manage the open and close of the connection.

 DicomQuery q = new DicomQuery();
 DicomDataSetCollection results;
 q.Node = "dicomserver.co.uk"; // the IP address of SCP
 q.Port = 104;                 // the port number of SCP
 q.Root = QueryRoot.Study;     // the Root of the Request                    
 q.Level = QueryLevel.IMAGE;   // the Level of the Reqiest
 q.CallingAE = "client";       // SCU's AE Title
 q.CalledAE = "server";        // SCP's AE Title
  
 q.PatientID = "222.22.2222";  // Patient ID
 q.StudyUID = "999.999.2.19941105.112000";                  // Study UID
 q.SeriesUID = "1.2.826.0.1.3680043.4.1.19990124221049.3";  // Series UID
 q.InstanceUID = "1.2.826.0.1.3680043.4.1.19990124230602.1";// Instance UID
 
 results = q.Get(); // Send C-GET Request to Remote SCP
 foreach (var instance in results)
 {
   string name = instance.Name; // getting the patient Name, for example
   Viewer.Images.Add(new DicomImage(instance)); // display the retrieved Image, for example
 }

DicomAssociaiton

DicomAssociation object is designed for more advanced use where user can control exactly what to propose during connection request negotiation and have more access to the returned response(s) and status.

 DicomAssociation cn = new DicomAssociation();
 // add Study Root C-GET in the proposed presentation contexts list
 cn.RequestedContexts.Add(DicomObjects.DicomUIDs.SOPClasses.StudyRootQR_GET);
 cn.Open("dicomserver.co.uk", 104, "client", "server"); // open the DICOM connection
 
 DicomDataSet request = new DicomDataSet(); // request contains all UIDs 
 request.PatientID = "222.22.2222";
 request.StudyUID = "999.999.2.19941105.112000";
 request.SeriesUID = "1.2.826.0.1.3680043.4.1.19990124221049.3";
 request.InstanceUID = "1.2.826.0.1.3680043.4.1.19990124230602.1";
 request.Add(Keyword.QueryRetrieveLevel, "INSTANCE"); // Image/Instance level C-GET
 
 cn.Get(QueryRoot.Study, request); // send C-GET request

 // all images retrieved can be found here 
 DicomDataSetCollection instances = cn.ReturnedInstances; 
 // remember it is the SCU (client)'s job to close the connection
 cn.Close();

DicomObjects.COM

DicomQuery.GetImages()

 Dim q As New DicomQuery
 Dim results As DicomImages
 Dim result As DicomImage

 q.Root = "STUDY"              ' Root
 q.level = "IMAGE"             ' Level
 q.Node = "dicomserver.co.uk"  ' IP address of Remote SCP
 q.port = 104                  ' Port number of Remote SCP

 q.PatientID = "222.22.2222"                                ' Patient ID
 q.StudyUID = "999.999.2.19941105.112000"                   ' Study UID
 q.SeriesUID = "1.2.826.0.1.3680043.4.1.19990124221049.3"   ' Series UID
 q.InstanceUID = "1.2.826.0.1.3680043.4.1.19990124230602.1" ' Instance UID

 Set results = q.GetImages           ' Send C-GET Request to Remote SCP

 For Each result In results  ' C-GET results can be found in the returned DataSetCollection object
  MsgBox (result.Name)
 Next

DicomConnection.Get()

 Dim cn As New DicomConnection
 Dim Request As New DicomDataSet
 cn.Contexts.Add "1.2.840.10008.5.1.4.1.2.2.3" ' STUDY Root C-GET
 cn.SetDestination "dicomserver.co.uk", 104, "client", "server"
 Request.PatientID = "222.22.2222"                                ' Patient ID
 Request.StudyUID = "999.999.2.19941105.112000"                   ' Study UID
 Request.SeriesUID = "1.2.826.0.1.3680043.4.1.19990124221049.3"   ' Series UID
 Request.InstanceUID = "1.2.826.0.1.3680043.4.1.19990124230602.1" ' Instance UID
 Request.Attributes.Add &H8, &H52, "IMAGE"   ' Level
 Request.Attributes.Add &H8, &H60, "US"      ' Modality
 cn.Get "STUDY", Request          ' Send C-GET Request to Remote SCP
 MsgBox (cn.ReturnedDataSets.Count) ' C-GET results can be found in the ReturnedDataSets property

Note: C-GET request must be sent after the SetDestination method has been called.