SendNReportRequest Example for Visual Basic
Dim x As Long
Dim hClient As Long
Dim nVR As Integer
Dim szClass As String
Dim szInstance As String
Dim hPDU As Long
Dim nID As Integer
Dim nRet As Integer
'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 DICOM_CLASS_UNKNOWN, 0
LEADDICOM1.ResetDS
'add the required elements
LEADDICOM1.FindTag TAG_SPECIFIC_CHARACTER_SET
nVR = LEADDICOM1.CurrentTag.VR
LEADDICOM1.InsertElement False, TAG_SPECIFIC_CHARACTER_SET, nVR, False, 0
LEADDICOM1.FindTag TAG_INSTANCE_CREATION_DATE
nVR = LEADDICOM1.CurrentTag.VR
LEADDICOM1.InsertElement False, 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 TAG_INSTANCE_CREATION_TIME
nVR = LEADDICOM1.CurrentTag.VR
LEADDICOM1.InsertElement False, 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 TAG_INSTANCE_CREATOR_UID
nVR = LEADDICOM1.CurrentTag.VR
LEADDICOM1.InsertElement False, 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 TAG_PATIENT_NAME
nVR = LEADDICOM1.CurrentTag.VR
LEADDICOM1.InsertElement False, 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 TAG_PATIENT_ID
nVR = LEADDICOM1.CurrentTag.VR
LEADDICOM1.InsertElement False, TAG_PATIENT_ID, nVR, False, 0
LEADDICOM1.StringValueCount = 1
LEADDICOM1.StringValues (0) = "dummy_patient_id"
LEADDICOM1.SetStringValue (1)
LEADDICOM1.FindTag TAG_PATIENT_BIRTH_DATE
nVR = LEADDICOM1.CurrentTag.VR
LEADDICOM1.InsertElement False, 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 TAG_PATIENT_SEX
nVR = LEADDICOM1.CurrentTag.VR
LEADDICOM1.InsertElement False, 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
MsgBox "Abstract Syntax, " & LEADDICOM1.CurrentUID.Name & ", Not Supported by Association!"
Else
MsgBox "Abstract Syntax, " & szClass & ", Not Supported by Association!"
End If
Screen.MousePointer = vbDefault
End If
'now, send the message
LEADDICOMNet1.SendNReportRequest hClient, nID, 1, szClass, szInstance, 1, LEADDICOM1.hDicomDS
Next
End Sub