Relational Queries have been in the DICOM standard since the start, but are supported by only about half the PACS in the world. They are negotiated using Extended Negotiation and if requested by the SCU and accepted by the SCP then they remove several of the normal C-FIND rules, namely:

  • It is no longer necessary to quote the unique identifiers for every level above the current query level
  • It is possible to use matching attributes at different levels of the hierarchy

e.g. with standard queries, it would not be possible to include series and study queries in the same request, but with hierarchical queries that is allowed.

In DicomObjects, to use these as an SCU:

  • Create and set up a DicomConnection/DicomAssociation object
  • Add the appropriate C-FIND Presentation Context
  • Set the ExtendedNegotiationValues COM/.NET property of that context to a one byte array containing the value 1
  • Use SetDestination/Open as normal
  • Check the ExtendedNegotiationValues COM/.NET property of the C-FIND context to see if it has been accepted by the SCP (and if not, then keep to normal DICOM query rules)

In DicomObjects, to use these as an SCP:

  • Set DicomGlobal.EnableExtendedNegotiation to true
  • If the AssociationRequest COM/.NET event, check the value of the ExtendedNegotiationValues COM/.NET property of the requested contexts, and leave at 1 if you accept, or set to 0 if you do not.

SCU use in DicomObjects

The following code is a simple example, which does a series level relational query against the Medical Connections Public DICOM Server. Note that the Patient ID and Study UID which would otherwise be required for a series level query are not specified.

DicomObjects.NET version

 DicomAssociation cn= new DicomAssociation();
 DicomContext ctx = cn.RequestedContexts.Add(SOPClasses.StudyRootQR_FIND);
 ctx.ExtendedNegotiationValues = new byte[]{1};
 cn.Open( "", 104, "CallingAE", "CalledAE");
 DicomDataSet ds = new DicomDataSet();
 ds.Add(Keyword.QueryRetrieveLevel, "SERIES");
 ds.Add(Keyword.StudyDate, "");
 ds.Add(Keyword.StudyDescription, ""); 
 ds.Add(Keyword.SeriesDescription, "OBL*");// series description must begin with "OBL" 
 ds.Add(Keyword.PatientName, "");
 ds.Add(Keyword.PatientID, "");
 ds.Add(Keyword.StudyID, "");
 ds.Add(Keyword.StudyInstanceUID, "");
 ds.Add(Keyword.SeriesInstanceUID, "");
 ds.Add(Keyword.SeriesNumber, "");
 cn.Find( QueryRoot.Study, ds);
 // res holds all response datasets
 DicomDataSetCollection res = cn.ReturnedIdentifiers;

DicomObjects.COM version

 Dim g As New DicomGlobal
 g.EnableExtendedNegotiation = True

 Dim cn As New DicomConnection
 Dim cxt As DicomContext
 Set cxt = cn.Contexts.Add(DicomObjects.Constants.doSOP_StudyRootQR_FIND)
 cxt.ExtendedNegotiationValues = 1

 cn.SetDestination "", 104, "CallingAE", "CalledAE"

 Dim ds As New DicomDataSet
 ds.Attributes.Add &H8, &H52, "SERIES"       ' all attributes must still be at or above the level used
 ds.Attributes.Add &H8, &H20, ""             ' Give me the study date.
 ds.Attributes.Add &H8, &H1030, ""           ' give me the Study name / description.
 ds.Attributes.Add &H8, &H103E, "OBL*"       ' series description must begin with....
 ds.Attributes.Add &H10, &H10, ""            ' Give me the patient name.
 ds.Attributes.Add &H10, &H20, "*"           ' Give me the patient id.
 ds.Attributes.Add &H20, &H10, ""            ' for this study ID.
 ds.Attributes.Add &H20, &HD, ""             ' give me the study instance UID.
 ds.Attributes.Add &H20, &HE, ""             ' give me the series instance UID.
 ds.Attributes.Add &H20, &H11, ""            ' give me the series number.

 cn.Find "STUDY", ds
 Set res = cn.ReturnedDataSets