SendCFindRequest Example for C++ 6.0 or later
{
//This example sends a C-Find Request to a server
//
//In this example:
//1. m_Dicom, m_Dicom2 are LEAD ActiveX Dicom objects (CLEADDICOM)
//
//2. m_DicomNet is LEAD ActiveX DicomNet object (CLEADDICOMNet)
//
//3. m_nClientOrServer: can be (STATUS_NONE, STATUS_SERVER, STATUS_CLIENT)
// identifieds the LMyDicomNet object as a server or a client
//4. m_nDataCommand: can be (COMMAND_C_MOVE,COMMAND_C_GET)
// set so the server knows how a C-Store Response was generated
//
//5. A connection exists between client and server
//6. An association exists between the client and server
CString strMsg = "C-Find\n";
_bstr_t strClassUID = UID_STUDY_ROOT_QUERY_FIND;
_bstr_t sStudyRoot("STUDY_ROOT");
//get the associate object for this client computer's connection
long hAssociate = m_pLEADDicomNet->GetAssociate (m_pLEADDicomNet->GethNet());
//find the id for UID_VERIFICATION_CLASS within this association
//if it is supported by the association
int nPresentationID = m_pLEADDicomNet->FindPresentationAbstract (hAssociate, strClassUID);
//nPresentationID must be odd--0 indicates failure
if (nPresentationID==0)
{
CString strTmp;
strTmp.Format("Abstract Syntax[%s] Not Included in the Association", (char *)strClassUID);
strMsg = strMsg + strTmp;
}
else
//success
{
//create a find attribute data set
m_pLEADDicomDS->InitDS (DICOM_CLASS_UNKNOWN, 0);
//add the required fields for this seach
m_pLEADDicomDS->FindTag(TAG_QUERY_RETRIEVE_LEVEL);
m_pLEADDicomDS->InsertElement (FALSE, TAG_QUERY_RETRIEVE_LEVEL, m_pLEADDicomDS->GetCurrentTag ()->VR, FALSE, 0);
m_pLEADDicomDS->StringValueCount = 1;
m_pLEADDicomDS->put_StringValues (0, sStudyRoot);
m_pLEADDicomDS->SetStringValue (1);
m_pLEADDicomDS->FindTag(TAG_STUDY_DATE);
m_pLEADDicomDS->InsertElement (FALSE, TAG_STUDY_DATE, m_pLEADDicomDS->GetCurrentTag ()->VR, FALSE, 0);
m_pLEADDicomDS->FindTag(TAG_STUDY_TIME);
m_pLEADDicomDS->InsertElement (FALSE, TAG_STUDY_TIME, m_pLEADDicomDS->GetCurrentTag ()->VR, FALSE, 0);
m_pLEADDicomDS->FindTag(TAG_ACCESSION_NUMBER);
m_pLEADDicomDS->InsertElement (FALSE, TAG_ACCESSION_NUMBER, m_pLEADDicomDS->GetCurrentTag ()->VR, FALSE, 0);
m_pLEADDicomDS->FindTag(TAG_PATIENT_NAME);
m_pLEADDicomDS->InsertElement (FALSE, TAG_PATIENT_NAME, m_pLEADDicomDS->GetCurrentTag ()->VR, FALSE, 0);
m_pLEADDicomDS->FindTag(TAG_PATIENT_ID);
m_pLEADDicomDS->InsertElement (FALSE, TAG_PATIENT_ID, m_pLEADDicomDS->GetCurrentTag ()->VR, FALSE, 0);
m_pLEADDicomDS->FindTag(TAG_STUDY_ID);
m_pLEADDicomDS->InsertElement (FALSE, TAG_STUDY_ID, m_pLEADDicomDS->GetCurrentTag ()->VR, FALSE, 0);
m_pLEADDicomDS->FindTag(TAG_STUDY_INSTANCE_UID);
m_pLEADDicomDS->InsertElement (FALSE, TAG_STUDY_INSTANCE_UID, m_pLEADDicomDS->GetCurrentTag ()->VR, FALSE, 0);
//optional tags
m_pLEADDicomDS->FindTag(TAG_STUDY_DESCRIPTION);
m_pLEADDicomDS->InsertElement (FALSE, TAG_STUDY_DESCRIPTION, m_pLEADDicomDS->GetCurrentTag ()->VR, FALSE, 0);
m_pLEADDicomDS->FindTag(TAG_PATIENT_SEX);
m_pLEADDicomDS->InsertElement (FALSE, TAG_PATIENT_SEX, m_pLEADDicomDS->GetCurrentTag ()->VR, FALSE, 0);
m_pLEADDicomDS->FindTag(TAG_OTHER_PATIENT_IDS);
m_pLEADDicomDS->InsertElement (FALSE, TAG_OTHER_PATIENT_IDS, m_pLEADDicomDS->GetCurrentTag ()->VR, FALSE, 0);
m_pLEADDicomDS->FindTag(TAG_PATIENT_BIRTH_DATE);
m_pLEADDicomDS->InsertElement (FALSE, TAG_PATIENT_BIRTH_DATE, m_pLEADDicomDS->GetCurrentTag ()->VR, FALSE, 0);
m_pLEADDicomDS->FindTag(TAG_ADDITIONAL_PATIENT_HISTORY);
m_pLEADDicomDS->InsertElement (FALSE, TAG_ADDITIONAL_PATIENT_HISTORY, m_pLEADDicomDS->GetCurrentTag ()->VR, FALSE, 0);
m_pLEADDicomDS->FindTag(TAG_NUMBER_OF_STUDY_RELATED_INSTANCES);
m_pLEADDicomDS->InsertElement (FALSE, TAG_NUMBER_OF_STUDY_RELATED_INSTANCES, m_pLEADDicomDS->GetCurrentTag ()->VR, FALSE, 0);
//global variable to count results
m_FileCount = 0;
short uUniqueID = 99;
m_pLEADDicomNet->SendCFindRequest (
m_pLEADDicomNet->GethNet(),
nPresentationID,
uUniqueID,
strClassUID,
COMMAND_PRIORITY_MEDIUM,
m_pLEADDicomDS->GethDicomDS()
);
strMsg = strMsg + "SendCFindRequest\n";
}
AfxMessageBox(strMsg);
}