How to implement C-Find in .NET

C-Find in the new .NET version of DicomOjects can be done via DicomQuery object or DicomConnection object:

  • DicomQuery.Find ( 2 Overload Methods )
  • DicomConnection.Find

Following are sample VB.NET code to show how to implement C-Find using DicomQuery and DicomConnection Objects.

DicomQuery.Find()

Dim q As New DicomObjects.DicomQuery
Dim results As DicomObjects.DicomDataSetCollection
q.Node = "localhost"   ' the IP address of SCP
q.Port = 105           ' the port number of SCP
q.Root = "PATIENT"     ' 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
' other matching criteria ...

results = q.Find()     ' q.Find returns a DicomDataSetCollection Object,
                       ' which contains the C-FIND results
MsgBox(results.Count)

Note: this method is equivalent to DicomQuery.DoQuery() method in the COM version of DicomObjects.

 

DicomQuery.Find(Request)

This method takes one argument as the C-FIND matching criteria.

Dim q As New DicomObjects.DicomQuery
Dim results As DicomObjects.DicomDataSetCollection
Dim Request As New DicomObjects.DicomDataSet
q.Node = "localhost"        ' the IP address of SCP
q.Port = 105                ' the port number of SCP
q.Root = "PATIENT"          ' 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
         
Request.Add(&H10, &H10, "") ' Patient Name
Request.Add(&H10, &H20, "") ' Patient ID
Request.Add(&H8, &H50, "")  ' Accession Number
' other matching criteria ...

Request = q.QueryDataSet()  ' Set the QueryDataSet
results = q.Find(Request)   ' q.Find returns a DicomDataSetCollection Object, which contains the C-FIND results
MsgBox(results.Count)

Notes:

  1. This method is equivalent to DicomQuery.DoRawQuery() method in the COM version of DicomObjects.
  2. The QueryLevel property is ignored when using this overload , as the level is required to be within the parameter dataset. If you populate the dataset using the QueyDataSet() method, and then apply small customisations, then this is no problem, as the QueryDataSet method uses the QueryLevel property and therefore sets 0008,0052 appropriately, but if you are making your dataset from scratch, then you do need to add the level yourself explicitly.

DicomAssociation.Find()

This method requires user to establish a connection to the remote SCP (by calling DicomConnection.Open) before doing any queries.

Dim cn As DicomObjects.DicomAssociation
Dim Request As New DicomObjects.DicomDataSet
cn.Open("localhost", 105, "client", "server")' Connect to remote SCP
Request.Add(&H8, &H52, "STUDY") ' Query Level

Request.Add(&H10, &H10, "")     ' Patient Name
Request.Add(&H10, &H20, "")     ' Patient ID
Request.Add(&H8, &H50, "")      ' Accession Number
' other matching criteria ...

results = cn.Find("PATIENT", Request)  
MsgBox(cn.ReturnedDataSets.Count) 'C-FIND results can be found in ReturnedDatasets property

Note:

  • This method is similar to 'DicomQuery.Find(Request)', as all query parameters, including 'Level', are set in the Request dataset, but it uses an existing association rather than creating one for asingle operation.
Relevance: