L_DicomSendCFindRequest

#include "ltdic.h"

L_LTDIC_API L_INT L_DicomSendCFindRequest(hNet, nPresentationID, nMessageID, pszClass, nPriority, hDS)

HDICOMNET hNet;

/* a DICOM Network handle */

L_UCHAR nPresentationID;

/* presentation ID */

L_UINT16 nMessageID;

/* message ID */

L_TCHAR * pszClass;

/* class type */

L_UINT16 nPriority;

/* priority of the message */

HDICOMDS hDS;

/* 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

hNet

A DICOM Network handle to the peer member of the connection.

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.

hDS

Pointer to the data set to be found.

Returns

DICOM_SUCCESS

The function was successful.

>0

An error occurred. Refer to Return Codes.

Comments

Calling this function generates a call to RECEIVECFINDREQUESTCALLBACK on the SCP. The SCP should respond by calling L_DicomSendCFindResponse which will generate a call to RECEIVECFINDRESPONSECALLBACK.

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

Platforms

Win32, x64

See Also

Functions:

L_DicomSendCFindResponse, RECEIVECFINDREQUESTCALLBACK, RECEIVECFINDRESPONSECALLBACK

Topics:

Working with DICOM Network Connections

Example

#include <windowsx.h>
#define FIND_TYPE_STUDY  1
#define FIND_TYPE_SERIES 2
#define FIND_TYPE_IMAGE  3
L_INT DicomSendCFindRequestExample(
   HWND hStudyList,
   HDICOMNET hNet,
   L_INT* gnFindType,
   L_INT* gnFindCount)
{
   HDICOMPDU hPDU;
   L_UCHAR nID;
   HDICOMDS hDS=NULL;
   L_TCHAR szUID[200];
   L_TCHAR szMsg[200];
   long x;
   long lCount;
   L_TCHAR szFile[L_MAXPATH];
   HANDLE hFile=NULL;
   pDICOMTAG pTag=NULL;
   pDICOMELEMENT pElement=NULL;
   L_INT nRet;
   
   /* this example sends a command that will find all STUDIES on a called AE that
      supports the Study Root Query/Retrieve Information Model - FIND SOP Class
      The results are stored in a ListBox named StudyList as each result
      is received in the NetReceiveCStoreRequest event */
   
   /* delete all previous find results */
   lCount = ListBox_GetCount(hStudyList);
   for(x=0; x<lCount; x++)
   {
      ListBox_GetText(hStudyList, x, szFile); 
      hFile = CreateFile(szFile, GENERIC_READ, 0, NULL,
                         OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE,
                         NULL);
      if(hFile)
         CloseHandle(hFile);
   }
   ListBox_ResetContent(hStudyList);
   
   *gnFindType = FIND_TYPE_STUDY; /* global variable used to distingish this find */
   
   /* send a Find request to the server */
   hPDU = L_DicomGetAssociate(hNet);
   lstrcpy(szUID, UID_STUDY_ROOT_QUERY_FIND);
   nID = L_DicomFindAbstract(hPDU, szUID);
   if(nID == 0)
   {
      wsprintf(szMsg, TEXT("Abstract Syntax %s Not Supported by Association!"), szUID);
      MessageBox(NULL, szMsg, TEXT("Error"), MB_OK);
   }
   else
   {
      /* create a find attribute data set */
      hDS = L_DicomCreateDS(NULL);
      L_DicomInitDS(hDS, CLASS_UNKNOWN, 0);
      L_DicomResetDS(hDS);
   
      /* add the required fields for this seach */
      pTag = L_DicomFindTag(TAG_QUERY_RETRIEVE_LEVEL);
      pElement = L_DicomInsertElement(hDS, NULL, FALSE, TAG_QUERY_RETRIEVE_LEVEL, pTag->nVR, FALSE, 0);
      if (pElement == NULL)
      {
         L_DicomFreeDS(hDS);
         return DICOM_ERROR_MEMORY;
      }
      /* we are searching at the study level */
      L_DicomSetStringValue(hDS, pElement, TEXT("STUDY "), 1, DICOM_CHARACTER_SET_DEFAULT);
      pTag = L_DicomFindTag(TAG_STUDY_DATE);
      pElement = L_DicomInsertElement(hDS, NULL, FALSE, TAG_STUDY_DATE, pTag->nVR, FALSE, 0);
      if (pElement == NULL)
      {
         L_DicomFreeDS(hDS);
         return DICOM_ERROR_MEMORY;
      }
      pTag = L_DicomFindTag(TAG_STUDY_TIME);
      pElement = L_DicomInsertElement(hDS, NULL, FALSE, TAG_STUDY_TIME, pTag->nVR, FALSE, 0);
      if (pElement == NULL)
      {
         L_DicomFreeDS(hDS);
         return DICOM_ERROR_MEMORY;
      }
      pTag = L_DicomFindTag(TAG_ACCESSION_NUMBER);
      pElement = L_DicomInsertElement(hDS, NULL, FALSE, TAG_ACCESSION_NUMBER, pTag->nVR, FALSE, 0);
      if (pElement == NULL)
      {
         L_DicomFreeDS(hDS);
         return DICOM_ERROR_MEMORY;
      }
      pTag = L_DicomFindTag(TAG_PATIENT_NAME);
      pElement = L_DicomInsertElement(hDS, NULL, FALSE, TAG_PATIENT_NAME, pTag->nVR, FALSE, 0);
      if (pElement == NULL)
      {
         L_DicomFreeDS(hDS);
         return DICOM_ERROR_MEMORY;
      }
      pTag = L_DicomFindTag(TAG_PATIENT_ID);
      pElement = L_DicomInsertElement(hDS, NULL, FALSE, TAG_PATIENT_ID, pTag->nVR, FALSE, 0);
      if (pElement == NULL)
      {
         L_DicomFreeDS(hDS);
         return DICOM_ERROR_MEMORY;
      }
      pTag = L_DicomFindTag(TAG_STUDY_ID);
      pElement = L_DicomInsertElement(hDS, NULL, FALSE, TAG_STUDY_ID, pTag->nVR, FALSE, 0);
      if (pElement == NULL)
      {
         L_DicomFreeDS(hDS);
         return DICOM_ERROR_MEMORY;
      }
      pTag = L_DicomFindTag(TAG_STUDY_INSTANCE_UID);
      pElement = L_DicomInsertElement(hDS, NULL, FALSE, TAG_STUDY_INSTANCE_UID, pTag->nVR, FALSE, 0);
      if (pElement == NULL)
      {
         L_DicomFreeDS(hDS);
         return DICOM_ERROR_MEMORY;
      }
   
      /* optional tags */
      pTag = L_DicomFindTag(TAG_STUDY_DESCRIPTION);
      pElement = L_DicomInsertElement(hDS, NULL, FALSE, TAG_STUDY_DESCRIPTION, pTag->nVR, FALSE, 0);
      if (pElement == NULL)
      {
         L_DicomFreeDS(hDS);
         return DICOM_ERROR_MEMORY;
      }
      pTag = L_DicomFindTag(TAG_PATIENT_BIRTH_DATE);
      pElement = L_DicomInsertElement(hDS, NULL, FALSE, TAG_PATIENT_BIRTH_DATE, pTag->nVR, FALSE, 0);
      if (pElement == NULL)
      {
         L_DicomFreeDS(hDS);
         return DICOM_ERROR_MEMORY;
      }
      pTag = L_DicomFindTag(TAG_PATIENT_SEX);
      pElement = L_DicomInsertElement(hDS, NULL, FALSE, TAG_PATIENT_SEX, pTag->nVR, FALSE, 0);
      if (pElement == NULL)
      {
         L_DicomFreeDS(hDS);
         return DICOM_ERROR_MEMORY;
      }
      pTag = L_DicomFindTag(TAG_OTHER_PATIENT_IDS);
      pElement = L_DicomInsertElement(hDS, NULL, FALSE, TAG_OTHER_PATIENT_IDS, pTag->nVR, FALSE, 0);
      if (pElement == NULL)
      {
         L_DicomFreeDS(hDS);
         return DICOM_ERROR_MEMORY;
      }
               
      /* now, send the command set and data set */
      *gnFindCount = 0; /* global variable to cound results */
      nRet = L_DicomSendCFindRequest(hNet, nID, 1, szUID, COMMAND_PRIORITY_MEDIUM, hDS);
      if (nRet != DICOM_SUCCESS)
      {
         L_DicomFreeDS(hDS);
         return nRet;
      }
      L_DicomFreeDS(hDS);
   }
   return DICOM_SUCCESS;
}