SendNReportRequest Example for C++ 6.0 or later
{
//The Server sends an N-Report message to all its clients
//
//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 = "N-Event Report\n";
//Choose a class
_bstr_t strClassUID = UID_US_IMAGE_STORAGE;
//Choose an instance
_bstr_t strInstance = "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1";
//create the data set
m_pLEADDicomDS->InitDS (DICOM_CLASS_UNKNOWN, 0);
//add the required elements
//Add the required elements
// TAG_QUERY_RETRIEVE_LEVEL
// TAG_PATIENT_NAME
m_pLEADDicomDS->FindTag(TAG_SPECIFIC_CHARACTER_SET);
m_pLEADDicomDS->InsertElement (FALSE, TAG_SPECIFIC_CHARACTER_SET,m_pLEADDicomDS->GetCurrentTag ()->VR,FALSE,0);
m_pLEADDicomDS->FindTag(TAG_INSTANCE_CREATION_DATE);
m_pLEADDicomDS->InsertElement (FALSE, TAG_INSTANCE_CREATION_DATE,m_pLEADDicomDS->GetCurrentTag ()->VR,FALSE,0);
//set the Date
m_pLEADDicomDS->DateValueCount = 1;
IDATEVALUEItemPtr pDateValue = m_pLEADDicomDS->GetDateValues (0);
pDateValue->Year = 1999;
pDateValue->Month = 12;
pDateValue->Day = 31;
m_pLEADDicomDS->SetDateValue (1);
m_pLEADDicomDS->FindTag(TAG_INSTANCE_CREATION_TIME);
m_pLEADDicomDS->InsertElement (FALSE, TAG_INSTANCE_CREATION_TIME, m_pLEADDicomDS->GetCurrentTag ()->VR, FALSE, 0);
m_pLEADDicomDS->TimeValueCount = 1;
ITIMEVALUEItemPtr pTimeValue = m_pLEADDicomDS->TimeValues [0];
pTimeValue->Hours = 12;
pTimeValue->Minutes = 30;
pTimeValue->Seconds = 25;
pTimeValue->Fractions = 0;
m_pLEADDicomDS->SetTimeValue(1);
m_pLEADDicomDS->FindTag(TAG_INSTANCE_CREATOR_UID);
m_pLEADDicomDS->InsertElement (FALSE, TAG_INSTANCE_CREATOR_UID, m_pLEADDicomDS->GetCurrentTag ()->VR, FALSE, 0);
m_pLEADDicomDS->StringValueCount = 1;
_bstr_t sUniqueValue("9.9.9999.9");
m_pLEADDicomDS->put_StringValues (0, sUniqueValue); //some unique value
m_pLEADDicomDS->SetStringValue (1);
_bstr_t sDummyPatientName("dummy_patient_name");
m_pLEADDicomDS->FindTag(TAG_PATIENT_NAME);
m_pLEADDicomDS->InsertElement (FALSE, TAG_PATIENT_NAME, m_pLEADDicomDS->GetCurrentTag ()->VR, FALSE, 0);
m_pLEADDicomDS->StringValueCount = 1;
m_pLEADDicomDS->put_StringValues (0,sDummyPatientName);
m_pLEADDicomDS->SetStringValue (1);
//add the optional fields that we want returned
_bstr_t sDummyPatientID("dummy_patient_id");
m_pLEADDicomDS->FindTag(TAG_PATIENT_ID);
m_pLEADDicomDS->InsertElement (FALSE, TAG_PATIENT_ID, m_pLEADDicomDS->GetCurrentTag ()->VR, FALSE, 0);
m_pLEADDicomDS->StringValueCount = 1;
m_pLEADDicomDS->put_StringValues (0,sDummyPatientID);
m_pLEADDicomDS->SetStringValue (1);
m_pLEADDicomDS->FindTag(TAG_PATIENT_BIRTH_DATE);
m_pLEADDicomDS->InsertElement (FALSE, TAG_PATIENT_BIRTH_DATE, m_pLEADDicomDS->GetCurrentTag ()->VR, FALSE, 0);
pDateValue = m_pLEADDicomDS->GetDateValues (0);
pDateValue->Year = 1999;
pDateValue->Month = 12;
pDateValue->Day = 31;
m_pLEADDicomDS->SetDateValue (1);
_bstr_t sMale = "M";
m_pLEADDicomDS->FindTag(TAG_PATIENT_SEX);
m_pLEADDicomDS->InsertElement (FALSE, TAG_PATIENT_SEX, m_pLEADDicomDS->GetCurrentTag ()->VR, FALSE, 0);
m_pLEADDicomDS->StringValueCount = 1;
m_pLEADDicomDS->put_StringValues (0,sMale);
m_pLEADDicomDS->SetConvertValue();
//iterate through all clients
for (long i=0; i<m_pLEADDicomNet->GetClientCount(m_pLEADDicomNet->GethNet()); i++)
{
long hNetClient = m_pLEADDicomNet->GetClient(m_pLEADDicomNet->GethNet(), i);
//Get the associate object of client[i]
long hAssociate = m_pLEADDicomNet->GetAssociate (hNetClient);
//Is class supported in the assocation?
short 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
{
//Send N-Report Request message
short uUniqueID = 99;
short nEvent = 1;
m_pLEADDicomNet->SendNReportRequest (
hNetClient,
nPresentationID,
uUniqueID,
strClassUID,
strInstance,
nEvent,
m_pLEADDicomDS->GethDicomDS()
);
}
}
AfxMessageBox(strMsg);
}