SendCGetRequest Example for VB.NET
'LEADDICOMNet1 is a predefined LEADDicomNet object
'LEADDICOM1 is a DICOM Dataset defined outside this method
'This example uses the predefined variable "gszGetFile" of type
"String"
Private Sub TestSendCGetRequest ( )
Const UID_SC_IMAGE_STORAGE As String = "1.2.840.10008.5.1.4.1.1.7"
' Secondary Capture Image Storage
Dim nRet As Short
Dim szClassUID As String
Dim nVR As Short
Dim hPDU As Integer
Dim nID As Short
'send a get request to the server
'gszGetFile will be used when this AE receives the NetReceiveCStoreRequest
'associated with this CGetRequest to save the data set
gszGetFile = InputBox("Select filename for retrieved data set",
"Get Request", "d:\temp\get_request.dic")
If (Len(gszGetFile) < 1) Then Exit Sub
szClassUID = InputBox("What class do you wish to get?", "Get
Request", UID_SC_IMAGE_STORAGE)
If (Len(szClassUID) < 1) Then Exit Sub
'create the data set that encodes the identifier to be matched
LEADDICOM1.InitDS(LTDICLib.DicomClassConstants.DICOM_CLASS_UNKNOWN,
0)
'add the required elements
LEADDICOM1.FindTag(LTDICLib.DicomDataSetTagConstants1.TAG_QUERY_RETRIEVE_LEVEL)
nVR = LEADDICOM1.CurrentTag.VR
LEADDICOM1.InsertElement(False,
LTDICLib.DicomDataSetTagConstants1.TAG_QUERY_RETRIEVE_LEVEL, nVR, False,
0)
LEADDICOM1.StringValueCount
= 1
LEADDICOM1.StringValues(0)
= "PATIENT"
LEADDICOM1.SetStringValue(1)
LEADDICOM1.FindTag(LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_NAME)
LEADDICOM1.InsertElement(False,
LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_NAME, LEADDICOM1.CurrentTag.VR,
False, 0)
LEADDICOM1.StringValueCount
= 1
LEADDICOM1.StringValues(0)
= "*"
'get all patients
LEADDICOM1.SetStringValue(1)
'add the optional fields that we want returned
LEADDICOM1.FindTag(LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_ID)
LEADDICOM1.InsertElement(False,
LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_ID, LEADDICOM1.CurrentTag.VR,
False, 0)
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.FindTag(LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_SEX)
nVR = LEADDICOM1.CurrentTag.VR
LEADDICOM1.InsertElement(False,
LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_SEX, nVR, False, 0)
LEADDICOM1.FindTag(LTDICLib.DicomDataSetTagConstants5.TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES)
nVR = LEADDICOM1.CurrentTag.VR
LEADDICOM1.InsertElement(False,
LTDICLib.DicomDataSetTagConstants5.TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES,
nVR, False, 0)
hPDU = LEADDICOMNet1.GetAssociate(LEADDICOMNet1.hNet)
'now, send a request
nID = LEADDICOMNet1.FindPresentationAbstract(hPDU,
szClassUID)
If (nID = 0) Then
nRet = LEADDICOM1.FindUID(szClassUID)
If (nRet = 0) Then
MessageBox.Show("Abstract Syntax, " & LEADDICOM1.CurrentUID.Name
& ", Not Supported by Association!")
Else
MessageBox.Show("Abstract Syntax, " & szClassUID & ",
Not Supported by Association!")
End If
Exit Sub
End If
LEADDICOMNet1.SendCGetRequest(LEADDICOMNet1.hNet,
nID, 999, szClassUID, LTDICLib.DicomCommandSetMessagePriorities.COMMAND_PRIORITY_MEDIUM,
LEADDICOM1.hDicomDS)
'we now must wait for the response and for the C-STORE sub-operations
End Sub