NetReceiveNGetRequest Example for Visual Basic
Private Sub LEADDICOMNet1_NetReceiveNGetRequest(ByVal hNet As Long, ByVal nPresentationID As Integer, ByVal nMessageID As Integer, ByVal pszClass As String, ByVal pszInstance As String)
Dim nRet As Integer
Dim NewNode As Node
Dim szReply As String
Dim lParent As Long
Dim szName As String
Set NewNode = TreeView1.Nodes.Add(, , , "Command Set - " & "N-GET-REQUEST")
NewNode.EnsureVisible
lParent = NewNode.Index
Set NewNode = TreeView1.Nodes.Add(lParent, tvwChild, , "Presentation ID: " & CStr(nPresentationID))
Set NewNode = TreeView1.Nodes.Add(lParent, tvwChild, , "Message ID: " & CStr(nMessageID))
nRet = LEADDICOM1.FindUID(pszClass)
If (nRet = 0) Then
szName = LEADDICOM1.CurrentUID.Name
Set NewNode = TreeView1.Nodes.Add(lParent, tvwChild, , "Affected SOP Class: " & szName & " - " & pszClass)
Else
Set NewNode = TreeView1.Nodes.Add(lParent, tvwChild, , "Affected SOP Class: " & pszClass)
End If
Set NewNode = TreeView1.Nodes.Add(lParent, tvwChild, , "Affected SOP Instance: " & pszInstance)
'this function will fill the values the data set elements in LEADDICOM2.hDicomDS
nRet = PerformNGETCommand(pszClass, pszInstance)
If (nRet <> DICOM_SUCCESS) Then nRet = COMMAND_STATUS_NO_SUCH_OBJECT_INSTANCE
'send a response
LEADDICOMNet1.SendNGetResponse hNet, nPresentationID, nMessageID, pszClass, pszInstance, nRet, LEADDICOM2.hDicomDS
End Sub
Private Function PerformNGETCommand(pszClass As String, pszInstance As String)
Dim nRet As Integer
Dim nTag As Long
Dim x As Long
Dim nVR As Integer
'this sample simply loads a fixed data set
'here, a server should check the class and instance against
'all SOP classes it manages, and then fill out hDS from the
'correctly matching instance, if one is found
nRet = LEADDICOM1.LoadDS ("e:\images\dicom16.dic", 0)
LEADDICOM2.InitDS DICOM_CLASS_UNKNOWN, 0
LEADDICOM2.ResetDS
If (nRet = 0) Then
LEADDICOM1.MoveFirstElement False
Else
PerformNGETCommand = nRet
Exit Function
End If
For x = 0 To LEADDICOMNet1.RequestAttributeCount - 1
'get each element
nTag = LEADDICOMNet1.RequestAttributes(x)
LEADDICOM1.FindTag nTag
nVR = LEADDICOM1.CurrentTag.VR
nRet = LEADDICOM1.FindFirstElement (nTag, False)
'in this sample, if we don't find the requested tag, we
'do not return an empty element!
If (nRet = 0) Then
'copy the element value
LEADDICOM1.GetConvertValue
LEADDICOM2.InsertElement False, nTag, nVR, False, 0
LEADDICOM2.StringValueCount = 1
LEADDICOM2.StringValues (0) = LEADDICOM1.StringValues (0)
LEADDICOM2.SetConvertValue
End If
Next
PerformNGETCommand = DICOM_SUCCESS
End Function