SendNReportRequest Example for C#

//LEADDICOMNet1 is a predefined LEADDicomNet object
//LEADDICOM1 is a DICOM Dataset defined outside this method
private void TestSendNReportRequest ( )
{
   const string UID_US_IMAGE_STORAGE = "1.2.840.10008.5.1.4.1.1.6.1";
   // Ultrasound Image Storage
   int x = 0;
   int hClient = 0;
   short nVR = 0;
   string szClass = null;
   string szInstance = null;
   int hPDU = 0;
   short nID = 0;
   short nRet = 0;
   //send an event report message to all clients
   //let them know a new patient was created
   //this sample just uses a made up instance
   szClass = UID_US_IMAGE_STORAGE;
   szInstance = "1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1";
   //create the data set
   LEADDICOM1.InitDS((int)LTDICLib.DicomClassConstants.DICOM_CLASS_UNKNOWN, 0);
   LEADDICOM1.ResetDS();

   //add the required elements
   LEADDICOM1.FindTag((int)LTDICLib.DicomDataSetTagConstants1.TAG_SPECIFIC_CHARACTER_SET);
   nVR = LEADDICOM1.get_CurrentTag().VR;
   LEADDICOM1.InsertElement(false, (int)LTDICLib.DicomDataSetTagConstants1.TAG_SPECIFIC_CHARACTER_SET, nVR, false, 0);
   LEADDICOM1.FindTag((int)LTDICLib.DicomDataSetTagConstants1.TAG_INSTANCE_CREATION_DATE);
   nVR = LEADDICOM1.get_CurrentTag().VR;
   LEADDICOM1.InsertElement(false, (int)LTDICLib.DicomDataSetTagConstants1.TAG_INSTANCE_CREATION_DATE, nVR, false, 0);
   LEADDICOM1.DateValueCount = 1;
   LEADDICOM1.get_DateValues(0).Day = 31;
   LEADDICOM1.get_DateValues(0).Month = 12;
   LEADDICOM1.get_DateValues(0).Year = 1999;
   LEADDICOM1.SetDateValue(1);
   LEADDICOM1.FindTag((int)   LTDICLib.DicomDataSetTagConstants1.TAG_INSTANCE_CREATION_TIME);
   nVR = LEADDICOM1.get_CurrentTag().VR;
   LEADDICOM1.InsertElement(false, (int)LTDICLib.DicomDataSetTagConstants1.TAG_INSTANCE_CREATION_TIME, nVR, false, 0);
   LEADDICOM1.TimeValueCount = 1;
   LEADDICOM1.get_TimeValues(0).Hours = 12;
   LEADDICOM1.get_TimeValues(0).Minutes = 30;
   LEADDICOM1.SetTimeValue(1);
   LEADDICOM1.FindTag((int)LTDICLib.DicomDataSetTagConstants1.TAG_INSTANCE_CREATOR_UID);
   nVR = LEADDICOM1.get_CurrentTag().VR;
   LEADDICOM1.InsertElement(false, (int)LTDICLib.DicomDataSetTagConstants1.TAG_INSTANCE_CREATOR_UID, nVR, false, 0);
   LEADDICOM1.StringValueCount = 1;
   LEADDICOM1.set_StringValues(0,"9.9.9999.9");
   //some unique value

   LEADDICOM1.SetStringValue(1);
   LEADDICOM1.FindTag((int)LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_NAME);
   nVR = LEADDICOM1.get_CurrentTag().VR;
   LEADDICOM1.InsertElement(false, (int)LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_NAME, nVR, false, 0);
   LEADDICOM1.StringValueCount = 1;
   LEADDICOM1.set_StringValues(0, "dummy_patient_name");
   LEADDICOM1.SetStringValue(1);

   //add the optional fields that we want returned
   LEADDICOM1.FindTag((int)LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_ID);
   nVR = LEADDICOM1.get_CurrentTag().VR;

   LEADDICOM1.InsertElement(false, (int)LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_ID, nVR, false, 0);
   LEADDICOM1.StringValueCount = 1;
   LEADDICOM1.set_StringValues(0,"dummy_patient_id");
   LEADDICOM1.SetStringValue(1);
   LEADDICOM1.FindTag((int)LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_BIRTH_DATE);
   nVR = LEADDICOM1.get_CurrentTag().VR;

   LEADDICOM1.InsertElement(false, (int)LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_BIRTH_DATE, nVR, false, 0);
   LEADDICOM1.DateValueCount = 1;
   LEADDICOM1.get_DateValues(0).Day = 31;
   LEADDICOM1.get_DateValues(0).Month = 12;
   LEADDICOM1.get_DateValues(0).Year = 1999;
   LEADDICOM1.SetDateValue(1);
   LEADDICOM1.FindTag((int)LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_SEX);
   nVR = LEADDICOM1.get_CurrentTag().VR;

   LEADDICOM1.InsertElement(false, (int)LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_SEX, nVR, false, 0);
   LEADDICOM1.StringValueCount = 1;
   LEADDICOM1.set_StringValues(0,"M");
   LEADDICOM1.SetConvertValue();
   for (x = 0; x < LEADDICOMNet1.GetClientCount(LEADDICOMNet1.hNet); x++)
   {
      hClient = LEADDICOMNet1.GetClient(LEADDICOMNet1.hNet, x);
      hPDU = LEADDICOMNet1.GetAssociate(hClient);
      nID = LEADDICOMNet1.FindPresentationAbstract(hPDU, szClass);
      if (nID == 0)
      {
         nRet = LEADDICOM1.FindUID(szClass);
         if (nRet == 0)
            MessageBox.Show("Abstract Syntax, " + LEADDICOM1.get_CurrentUID().Name + ", Not Supported by Association!");
         else
            MessageBox.Show("Abstract Syntax, " + szClass + ", Not Supported by Association!");
         System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
      }
      //now, send the message
      LEADDICOMNet1.SendNReportRequest(hClient, nID, 1, szClass, szInstance, 1, LEADDICOM1.hDicomDS);
   }
}