SendNReportRequest Example for VB.NET

'LEADDICOMNet1 is a predefined LEADDicomNet object
'LEADDICOM1 is a DICOM Dataset defined outside this method
Private Sub TestSendNReportRequest ( )
   Const UID_US_IMAGE_STORAGE As String = "1.2.840.10008.5.1.4.1.1.6.1"
   ' Ultrasound Image Storage
   Dim x As Integer
   Dim hClient As Integer
   Dim nVR As Short
   Dim szClass As String
   Dim szInstance As String
   Dim hPDU As Integer
   Dim nID As Short
   Dim nRet As Short

   '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(LTDICLib.DicomClassConstants.DICOM_CLASS_UNKNOWN, 0)
   LEADDICOM1.ResetDS()

   'add the required elements
   LEADDICOM1.FindTag(LTDICLib.DicomDataSetTagConstants1.TAG_SPECIFIC_CHARACTER_SET)
   nVR = LEADDICOM1.CurrentTag.VR LEADDICOM1.InsertElement(False, LTDICLib.DicomDataSetTagConstants1.TAG_SPECIFIC_CHARACTER_SET, nVR, False, 0)
   LEADDICOM1.FindTag(LTDICLib.DicomDataSetTagConstants1.TAG_INSTANCE_CREATION_DATE)
   nVR = LEADDICOM1.CurrentTag.VR LEADDICOM1.InsertElement(False, LTDICLib.DicomDataSetTagConstants1.TAG_INSTANCE_CREATION_DATE, nVR, False, 0)

   LEADDICOM1.DateValueCount = 1
   LEADDICOM1.DateValues(0).Day = 31
   LEADDICOM1.DateValues(0).Month = 12
   LEADDICOM1.DateValues(0).Year = 1999
   LEADDICOM1.SetDateValue(1)

   LEADDICOM1.FindTag(LTDICLib.DicomDataSetTagConstants1.TAG_INSTANCE_CREATION_TIME)
   nVR = LEADDICOM1.CurrentTag.VR
   LEADDICOM1.InsertElement(False, LTDICLib.DicomDataSetTagConstants1.TAG_INSTANCE_CREATION_TIME, nVR, False, 0)
   LEADDICOM1.TimeValueCount = 1
   LEADDICOM1.TimeValues(0).Hours = 12 LEADDICOM1.TimeValues(0).Minutes = 30
   LEADDICOM1.SetTimeValue(1)

   LEADDICOM1.FindTag(LTDICLib.DicomDataSetTagConstants1.TAG_INSTANCE_CREATOR_UID)
   nVR = LEADDICOM1.CurrentTag.VR
   LEADDICOM1.InsertElement(False, LTDICLib.DicomDataSetTagConstants1.TAG_INSTANCE_CREATOR_UID, nVR, False, 0)
   LEADDICOM1.StringValueCount = 1
   LEADDICOM1.StringValues(0) = "9.9.9999.9" 'some unique value
   LEADDICOM1.SetStringValue(1)

   LEADDICOM1.FindTag(LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_NAME)
   nVR = LEADDICOM1.CurrentTag.VR
   LEADDICOM1.InsertElement(False, LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_NAME, nVR, False, 0)
   LEADDICOM1.StringValueCount = 1
   LEADDICOM1.StringValues(0) = "dummy_patient_name"
   LEADDICOM1.SetStringValue(1)

   'add the optional fields that we want returned
   LEADDICOM1.FindTag(LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_ID)
   nVR = LEADDICOM1.CurrentTag.VR
   LEADDICOM1.InsertElement(False, LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_ID, nVR, False, 0)
   LEADDICOM1.StringValueCount = 1
   LEADDICOM1.StringValues(0) = "dummy_patient_id"
   LEADDICOM1.SetStringValue(1)
   LEADDICOM1.FindTag(LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_BIRTH_DATE)
   nVR = LEADDICOM1.CurrentTag.VR
   LEADDICOM1.InsertElement(False, LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_BIRTH_DATE, nVR, False, 0)
   LEADDICOM1.DateValueCount = 1
   LEADDICOM1.DateValues(0).Day = 31
   LEADDICOM1.DateValues(0).Month = 12
   LEADDICOM1.DateValues(0).Year = 1999
   LEADDICOM1.SetDateValue(1)
 
  LEADDICOM1.FindTag(LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_SEX)
   nVR = LEADDICOM1.CurrentTag.VR
   LEADDICOM1.InsertElement(False, LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_SEX, nVR, False, 0)
   LEADDICOM1.StringValueCount = 1
   LEADDICOM1.StringValues(0) = "M"
   LEADDICOM1.SetConvertValue()

   For x = 0 To LEADDICOMNet1.GetClientCount(LEADDICOMNet1.hNet) - 1
      hClient = LEADDICOMNet1.GetClient(LEADDICOMNet1.hNet, x)
      hPDU = LEADDICOMNet1.GetAssociate(hClient)
      nID = LEADDICOMNet1.FindPresentationAbstract(hPDU, szClass)
      If (nID = 0) Then
         nRet = LEADDICOM1.FindUID(szClass)
         If (nRet = 0) Then
            MessageBox.Show("Abstract Syntax, " & LEADDICOM1.CurrentUID.Name & ", Not Supported by Association!")
         Else
            MessageBox.Show("Abstract Syntax, " & szClass & ", Not Supported by Association!")
         End If
         System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
      End If
      'now, send the message
      LEADDICOMNet1.SendNReportRequest(hClient, nID, 1, szClass, szInstance, 1, LEADDICOM1.hDicomDS)
   Next
End Sub