The IDLffDicomExQuery::Retrieve function method moves a DICOM file or files from a source node to a destination node. The source node is the remote Query/Retrieve SCP Application Entity that is queried. The destination node is a local or remote Storage SCP Application Entity. To accomplish the retrieval, the local Query/Retrieve SCU issues a move request to the remote Query/Retrieve SCP, which moves the file to the destination node.
In DICOM terminology, the process of transferring data from a Query/Retrieve SCP to a Storage SCP is called a move. Note, however, that this process actually places a copy of the data on the destination node, leaving the original data intact.
This method does not return to the caller until one of the following occurs:
- The retrieve is complete (all matches have been returned)
- The retrieve encounters an error condition
- The callback function defined by the CALLBACK_FUNCTION property returns zero
Properties Required by a Retrieve
The following properties must be defined in order for the Retrieve method to succeed:
- The QUERY_SCP property must contain the name of a valid Query/Retrieve SCP node.
- The STORAGE_SCP property must contain the name of a valid Storage SCP node.
All other properties used by the Retrieve method have usable default values. If no properties other than QUERY_SCP and STORAGE_SCP are set, this method will perform a Patient Root / Patient Level retrieve, retrieving all patients on the remote node.
Retrieval Specification
Specify which files to retrieve using the PATIENT_ID, STUDY_INSTANCE_UID, SERIES_INSTANCE_UID, and SOP_INSTANCE_UID keywords.
Query field properties are not used by the Retrieve method to specify which files should be retrieved.
- If you specify a Patient ID, all of the DICOM files or images associated with the specified patient are retrieved.
- If you specify a Study Instance UID, only DICOM files or images associated with the specified study and its associated series are retrieved.
- If you specify a Series Instance UID, only DICOM files or images associated with the specified series are retrieved.
- If you specify an SOP Instance UID, a single DICOM file or image is retrieved.
Callbacks and Retrieval Status Information
If the CALLBACK_FUNCTION property contains the name of an IDL function, that function is called in the following circumstances:
- If the source node (the remote Query/Retrieve SCP) implements the optional response mechanism, the callback function is called each time a DICOM file is moved from the source node to the destination node.
- If the source node (the remote Query/Retrieve SCP) does not implement the optional response mechanism, the callback function is called every 3 seconds.
The function is called with an array of strings containing status information about the query as its first parameter. See Using Callbacks with the IDLffDicomExQuery Object for a discussion of callback functions.
Canceling a Retrieve
To cancel a retrieve before all matches are returned, the callback function specified by the CALLBACK_FUNCTION property must return zero.
Syntax
Result = Obj->[IDLffDicomExQuery::]Retrieve( [, COUNT=variable] [, PATIENT_ID=string] [, STUDY_INSTANCE_UID=string] [, SERIES_INSTANCE_UID=string] [, SOP_INSTANCE_UID=string] )
Return Value
This method returns one (success) if the retrieval operation completes successfully or if the retrieval is cancelled based on the return value of the callback function. This method returns zero (failure) if the retrieve does not complete because an error is encountered.
Arguments
None
Keywords
COUNT
Set this keyword equal to a named variable that will contain an integer representing the number of files successfully retrieved as reported by the remote Query SCP node.
PATIENT_ID
Set this keyword equal to a scalar string containing the value of the Patient ID attribute (0010,0020) for the DICOM files to be retrieved.
The combination of query model and query level determine whether this keyword is required. See Unique ID Keyword Interactions With Query Model/Level for details.
STUDY_INSTANCE_UID
Set this keyword equal to a scalar string containing the value of the Study Instance UID attribute (0020,000D) for the DICOM files to be retrieved.
The combination of query model and query level determine whether this keyword is required. See Unique ID Keyword Interactions With Query Model/Level for details.
SERIES_INSTANCE_UID
Set this keyword equal to a scalar string containing the value of the Series Instance UID attribute (0020,000E) for the DICOM files to be retrieved.
The combination of query model and query level determine whether this keyword is required. See Unique ID Keyword Interactions With Query Model/Level for details.
SOP_INSTANCE_UID
Set this keyword equal to a scalar string containing the value of the SOP Instance UID attribute (0008,0018) for the DICOM files to be retrieved.
The combination of query model and query level determine whether this keyword is required. See Unique ID Keyword Interactions With Query Model/Level for details.
Unique ID Keyword Interactions With Query Model/Level
The following table defines which unique ID keywords are required for different combinations of query model and query level. An "x" in the column indicates that the keyword is required when retrieving files using the specified combination of QUERY_MODEL and QUERY_LEVEL properties.
|
Patient_ID |
Study_Instance_UID
|
Series_Instance_UID
|
SOP_Instance_UID
|
Patient Root / Patient Level
|
x
|
|
|
|
Patient Root / Study Level
|
x
|
x
|
|
|
Patient Root / Series Level
|
x
|
x
|
x
|
|
Patient Root / Image Level
|
x
|
x
|
x
|
x
|
Study Root / Study Level
|
|
x
|
|
|
Study Root / Series Level
|
|
x
|
x
|
|
Study Root / Image Level
|
|
x
|
x
|
x
|
Patient Study Only Root
|
x
|
x
|
|
|
Example
The following example code shows how to programmatically configure a Query/Retrieve SCP Application Entity and retrieve files.
To run this code, you must supply values for the REMOTE_AET, REMOTE_HOST, REMOTE_PORT, and PATIENT_ID variables. You must also have a local storage SCP configured on a remote query/retrieve SCP node.
To run the example, do the following:
- Copy the example code and paste it into an IDL editor window or another text editor of your choice.
- Edit the text to supply the values for the four required variables.
- Save the file as retrieve_dicom_patient_files.pro.
- Execute retrieve_dicom_patient_files.pro in IDL.
PRO retrieve_dicom_patient_files
REMOTE_AET = 'remote_aet'
REMOTE_HOST = 'remote_host_name'
REMOTE_PORT = 'remote_port_number'
PATIENT_ID = 000001
ocfg = OBJ_NEW('IDLffDicomExCfg')
ocfg->SetApplicationEntity, 'remote_qr_scp_aen', $
REMOTE_AET, REMOTE_HOST, REMOTE_PORT, $
'Query_SCP_Service_List', 'Query_SCP'
origStorScpAEname = ocfg->GetValue('StorScpServiceAE')
origStorScpAE = ocfg->GetApplicationEntity(origStorScpAEname)
ocfg->SetApplicationEntity, 'my_stor_scp_aen', $
'my_stor_scp', 'localhost', 2510, $
'Storage_SCP_Service_List', 'Storage_SCP'
ocfg->SetValue, 'StorScpServiceAE', 'my_stor_scp_aen'
ocfg->Commit
OBJ_DESTROY, ocfg
ocfg = OBJ_NEW('IDLffDicomExCfg', /SYSTEM)
status = ocfg->StorageScpService('stop')
PRINT, 'Stopping Storage SCP. Status: ', status
WAIT, 5
ocfg->SetApplicationEntity, 'my_stor_scp_aen', $
'my_stor_scp', 'localhost', 2510, $
'Storage_SCP_Service_List', 'Storage_SCP'
ocfg->SetValue, 'StorScpServiceAE', 'my_stor_scp_aen'
origStorScpDir = ocfg->GetValue('StorScpDir')
tmpDir = FILEPATH('', /TMP)
ocfg->SetValue, 'StorScpDir', tmpDir
storScpDir = ocfg->GetValue('StorScpDir')
PRINT, 'Setting Storage SCP Directory to: ', storScpDir
ocfg->Commit
status = ocfg->StorageScpService('start')
PRINT, 'Starting Storage SCP. Status: ', status
WAIT, 5
status = ocfg->StorageScpService('status')
PRINT, 'Storage SCP Status: ', status
WAIT, 5
OBJ_DESTROY, ocfg
oqr = OBJ_NEW('IDLffDicomExQuery')
oqr->SetProperty, QUERY_SCP = 'remote_qr_scp_aen'
oqr->SetProperty, STORAGE_SCP = 'my_stor_scp_aen'
res = oqr->Retrieve(PATIENT_ID=PATIENT_ID, COUNT=cnt )
PRINT, 'Retrieve Status: ', cnt, ' files retrieved into ', storScpDir
OBJ_DESTROY, oqr
PRINT, ''
PRINT, 'Restoring original Storage SCP configuration.'
ocfg = OBJ_NEW('IDLffDicomExCfg')
ocfg->SetApplicationEntity, origStorScpAE.APPLENTITYNAME, $
origStorScpAE.AET, origStorScpAE.HOSTNAME, $
origStorScpAE.PORT, origStorScpAE.SERVICELISTNAME, $
origStorScpAE.SERVICETYPE
ocfg->SetValue, 'StorScpServiceAE', origStorScpAE.APPLENTITYNAME
ocfg->Commit
OBJ_DESTROY, ocfg
ocfg = OBJ_NEW('IDLffDicomExCfg', /SYSTEM)
status = ocfg->StorageScpService('stop')
PRINT, 'Stopping Storage SCP. Status: ', status
WAIT, 5
ocfg->SetApplicationEntity, origStorScpAE.APPLENTITYNAME, $
origStorScpAE.AET, origStorScpAE.HOSTNAME, $
origStorScpAE.PORT, origStorScpAE.SERVICELISTNAME, $
origStorScpAE.SERVICETYPE
ocfg->SetValue, 'StorScpServiceAE', origStorScpAE.APPLENTITYNAME
ocfg->SetValue, 'StorScpDir', origStorScpDir
PRINT, 'Storage SCP Directory is now ', $
ocfg->GetValue('StorScpDir')
status = ocfg->StorageScpService('start')
PRINT, 'Starting Storage SCP. Status: ', status
WAIT, 5
status = ocfg->StorageScpService('status')
PRINT, 'Storage SCP Status: ', status
WAIT, 5
ocfg->Commit
OBJ_DESTROY, ocfg
END
Version History