LDicomNet::SendCFindRequest

#include "ltdic.h"

L_INT LDicomNet::SendCFindRequest(nPresentationID, nMessageID, pszClass, nPriority, pDS)

L_UCHAR nPresentationID;

/* presentation ID */

L_UINT16 nMessageID;

/* message ID */

L_TCHAR * pszClass;

/* class type */

L_UINT16 nPriority;

/* priority of the message */

LDicomDS * pDS;

/* data set to be found */

Sends a C-FIND-REQ message to a peer member of a connection. This function is available in the PACS Imaging Toolkit.

Parameter

Description

nPresentationID

Presentation ID. The presentation ID provides information about both the class type of the data and the transfer syntax to use when transferring the data.

nMessageID

Message ID. Each message sent by a member of a connection should have a unique ID. Since a member of a connection may send several messages, this ID allows that member to identify when a specific request has been completed.

pszClass

Class affected by the request. This will be an SOP Class or an SOP MetaClass.

nPriority

The priority level of the message. The Service Class Provider may or may not support priority. Therefore, setting this parameter may or may not have any effect. Possible values are:

 

Value

Meaning

 

COMMAND_PRIORITY_LOW

[0x0002] Low priority message.

 

COMMAND_PRIORITY_MEDIUM

[0x0000] Medium priority message.

 

COMMAND_PRIORTY_HIGH

[0x0001] High priority message.

pDS

Pointer to the data set to be found.

Returns

0

SUCCESS

>0

An error occurred. Refer to Return Codes.

Comments

Calling this function generates a call to LDicomNet::OnReceiveCFindRequest on the SCP. The SCP should respond by calling LDicomNet::SendCFindResponse which will generate a call to LDicomNet::OnReceiveCFindResponse.

You must create a data set and insert elements corresponding to the data you wish to find. A pointer to this data set is then passed as a parameter to this function.

Required DLLs and Libraries

LTDIC

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

See Also

Functions:

LDicomNet::SendCFindResponse, LDicomNet::OnReceiveCFindRequest, LDicomNet::OnReceiveCFindResponse

Topics:

Working with DICOM Network Connections

Example

void InsertNextElement(LDicomDS *pDicomDS, L_UINT32 nTag);
L_INT LDicomNet__SendCFindRequestExample(LMyDicomNet *m_pDicomNet)
{
   //This example sends a C-Find command that will find all STUDIES on a called AE
   //that support the Study Root Query/Retrieve Information Model - FIND SOP Class
   //The results are displayed  as each result s received in the NetReceiveCStoreRequest event
   //
   //In this example:
   //
   //1. LMyDicomNet is a class derived from LDicomNet
   //2. LMyDicomNet has the following member variables:
   //       m_nClientOrServer:  can be (STATUS_NONE, STATUS_SERVER, STATUS_CLIENT)
   //                           identifieds the LMyDicomNet object as a server or a client
   //       m_nDataCommand:     can be (COMMAND_C_MOVE,COMMAND_C_GET) 
   //                           set so the server knows how a C-Store Response was generated
   //
   //3. m_pDicomNet points to a valid LMyDicomNet object
   //      LMyDicomNet *m_pDicomNet
   // 
   //4. A connection exists between client and server
   //5. An association exists between the client and server
   L_INT nRet;
   CString strMsg = TEXT("C-Find\n");
   
   //Get the associate object
   LDicomAssociate *pDicomAssociate = m_pDicomNet->GetAssociate();
     
   //Choose an SOP Class to find--in this example, choose UID_SC_IMAGE_STORAGE
   CString strClassUID = UID_STUDY_ROOT_QUERY_FIND;
   
   //Is class supported in the assocation?
   L_UCHAR nPresentationID = pDicomAssociate->FindAbstract((L_TCHAR *)(LPCTSTR)strClassUID);
   
   //nPresentationID must be odd--0 indicates failure
   if (nPresentationID==0)
   {
      CString strTmp;
      strTmp.Format(TEXT("Abstract Syntax[%s] Not Included in the Association"), strClassUID);
      strMsg = strMsg + strTmp;
   }
   else 
      //success
   {
      //create a find attribute data set
      
      LDicomDS DicomDS;
      DicomDS.InitDS(CLASS_UNKNOWN, 0);
      
      //add the required fields for this seach
      pDICOMTAG pDicomTag = LDicomTag::Find(TAG_QUERY_RETRIEVE_LEVEL);
      pDICOMELEMENT pElement = DicomDS.InsertElement( 
                                                      NULL,                      //pDICOMELEMENT pNeighbor
                                                      FALSE,                     //L_BOOL bChild
                                                      TAG_QUERY_RETRIEVE_LEVEL,  //L_UINT32 nTag
                                                      pDicomTag->nVR,            //L_UINT16 nVR
                                                      FALSE,                     //L_BOOL bSequence,
                                                      0                          //L_UINT32 nIndex
                                                      );
      DicomDS.SetStringValue(pElement, TEXT("STUDY"),1, DICOM_CHARACTER_SET_DEFAULT);
     
      InsertNextElement(&DicomDS, TAG_STUDY_DATE);
      InsertNextElement(&DicomDS, TAG_STUDY_TIME);
      InsertNextElement(&DicomDS, TAG_ACCESSION_NUMBER);
      InsertNextElement(&DicomDS, TAG_PATIENT_NAME);
      InsertNextElement(&DicomDS, TAG_PATIENT_ID);
      InsertNextElement(&DicomDS, TAG_STUDY_ID);
      InsertNextElement(&DicomDS, TAG_STUDY_INSTANCE_UID);
      
      //optional tags
      InsertNextElement(&DicomDS, TAG_STUDY_DESCRIPTION);
      InsertNextElement(&DicomDS, TAG_PATIENT_BIRTH_DATE);
      InsertNextElement(&DicomDS, TAG_PATIENT_SEX);
      InsertNextElement(&DicomDS, TAG_OTHER_PATIENT_IDS);
      InsertNextElement(&DicomDS, TAG_PATIENT_BIRTH_DATE);
      InsertNextElement(&DicomDS, TAG_ADDITIONAL_PATIENT_HISTORY);
      InsertNextElement(&DicomDS, TAG_NUMBER_OF_STUDY_RELATED_INSTANCES);
      
      
      //global variable to count results
      m_pDicomNet->m_FileCount = 0;
      L_UINT16 uUniqueID = 99;
      nRet =m_pDicomNet->SendCFindRequest(nPresentationID, 
                                    uUniqueID, 
                                    (L_TCHAR *)(LPCTSTR)strClassUID, 
                                    COMMAND_PRIORITY_MEDIUM,
                                    &DicomDS
                                    );
      if(nRet > 0)
         return nRet;
      strMsg += TEXT("SendCFindRequest\n");
   }
   AfxMessageBox(strMsg);
   return DICOM_SUCCESS;
}
     
void InsertNextElement(LDicomDS *pDicomDS, L_UINT32 nTag)
{
    pDICOMTAG pDicomTag = LDicomTag::Find(nTag);
    pDicomDS->InsertElement( 
                           NULL,            //pDICOMELEMENT pNeighbor
                           FALSE,           //L_BOOL bChild
                           nTag,            //L_UINT32 nTag
                           pDicomTag->nVR,  //L_UINT16 nVR
                           FALSE,           //L_BOOL bSequence,
                           0                //L_UINT32 nIndex
                         );
}