How to implement C-Find with DicomObjects

There are 2 ways to send DICOM C-Find 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 Query                    
 q.Level = QueryLevel.STUDY;   // the Level of the Query
 q.CallingAE = "client";       // SCU's AE Title
 q.CalledAE = "server";        // SCP's AE Title
 q.PatientID = "";             // Patient ID
 q.Name = "";                  // Patient Name
 
 // Add other matching criteria 
  
 results = q.Find(); // q.Find returns a DicomDataSetCollection Object, which contains the C-FIND results
	
 // if you want to add more shortcut-accessible properties like PatientID and Name,
 // you can define your own query dataSet like below  
 DicomDataSet queryDS = q.QueryDataSet();
 queryDS.Add(Keyword.PatientSex, "");
 queryDS.Add(Keyword.PatientBirthDate,"");
 results = q.Find(queryDS);	

DicomAssociaiton

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

 using DicomObjects.DicomUIDs;

 // setting up the Query
 DicomDataSet queryDS = new DicomDataSet();
 queryDS.Add(Keyword.PatientName, "");
 queryDS.Add(Keyword.PatientID, "");
 queryDS.Add(Keyword.PatientSex, "");
 queryDS.Add(Keyword.PatientBirthDate, "");
 queryDS.Add(Keyword.QueryRetrieveLevel, "STUDY");

 // define your own list of DICOM transfer syntaxes to use in C-FIND request
 string[] tsList = new string[] {TransferSyntaxes.ImplicitVRLittleEndian, 
                                 TransferSyntaxes.ExplicitVRLittleEndian };

 DicomAssociation cn = new DicomAssociation();
 // setting the Presentation Contexts for C-FIND
 cn.RequestedContexts.Add(DicomObjects.DicomUIDs.SOPClasses.StudyRootQR_FIND, tsList);
 // open the DICOM connection
 cn.Open("dicomserver.co.uk", 104, "client", "server");
 // send the C-FIND request
 cn.Find(QueryRoot.Study, queryDS);

 // this holds the returned C-FIND results
 DicomDataSetCollection results = cn.ReturnedIdentifiers; 
 // this holds the final C-FIND response, including the final status
 DicomDataSet finalC_Find_Status = cn.LastCommand; 
 // the final C-FIND status, 0 means Success
 int status = cn.LastStatus; 

 // Close the connection
 cn.Close();

Please download our Sample Viewer Program to see C-FIND in action.

DicomObjects.COM

DicomQuery

 Dim q As New DicomQuery
 Dim results As DicomDataSets
 q.Node = "dicomserver.co.uk"   ' the IP address of SCP
 q.Port = 104            ' the port number of SCP
 q.Root = "STUDY"        ' the Root of the Query
 q.level = "STUDY"       ' the Level of the Query
 q.CallingAE = "client"  ' SCU's AE Title
 q.CalledAE = "server"   ' SCP's AE Title
 q.PatientID = ""        ' Patient ID
 q.Name = ""             ' Patient Name
 ' Add other matching criteria
 Set results = q.DoQuery ' q.Find returns a DicomDataSetCollection Object, which contains the C-FIND results

 ' if you want to add more attributes that are not accessible
 ' via the shortcut properties like PatientID and Name, you can
 ' define your own query dataSet like below
 Dim queryDS As DicomDataSet
 Set queryDS = q.QueryDataSet()
 queryDS.Attributes.Add &H10, &H30, "" ' Patient Birth Date
 queryDS.Attributes.Add &H10, &H40, "" ' Patient Sex

 Set results = q.DoRawQuery(queryDS)   ' returns a DicomDataSets Object that contains the C-FIND results

DicomConnection

 ' set up the query dataset
 Dim queryDS As New DicomDataSet
 queryDS.Add &H10, &H10, "" ' patient name
 queryDS.Add &H10, &H20, "" ' PatientID
 queryDS.Add &H10, &H30, "" ' Patient Sex
 queryDS.AddToDirectory &H10, &H40, "" ' Patient Birth Date
 ' set up the presentation context for C-FIND with user defined Transfer Syntaxes
 Dim ctx As DicomContext
 Set ctx = cn.Contexts.Add("1.2.840.10008.5.1.4.1.2.2.1")
 Dim tsList(1) As String
 tsList(0) = "1.2.840.10008.1.2.1"
 tsList(1) = "1.2.840.10008.1.2"
 
 Dim cn As New DicomConnection
 ctx.OfferedTS = tsList
 
 ' open the connection
 cn.SetDestination "dicomserver.co.uk", 104, "client", "server"
 cn.Find "STUDY", queryDS
            
 ' this holds the C-FIND results
 Dim results As DicomDataSets
 Set results = cn.ReturnedDataSets
    
 ' this holds the final C-FIND response dataset, including the final status
 Dim resp As DicomDataSet
 Set resp = cn.ReturnedResponses(cn.ReturnedResponses.Count)
    
 ' this holds the final C-FIND status
 Dim status As Integer
 status = cn.LastStatus
    
 ' close the connection
 cn.Close

Please download our Sample Viewer Program to see C-FIND in action.


We use cookies to give you the best possible experience on our website. By continuing to use this website, you agree with our use of cookies. for more information please click HERE