Retrieving by Accession Number

We are sometimes asked how to retrieve as study based on the accession number. This is only possible by doing an initial query to find the study UID(s) then using those in a retrieval.

The explanation is that the DICOM rules allow only the instance UID, series UID, study UID and Patient ID to be used in MOVE/GET requests, so if you wish to retrieve a study based on accession number (or anything else except those 4 identifiers), then you must first do a C-FIND query (e.g. using DoRawQuery) to identify the study or studies with that accession number then use the Study UID returned to you by the query to pass on to the retrieve request (GetImages, MoveImages, MoveSync or GetUsingMove).

To query by accession number, you need to use the DoRawQuery (COM) or Find(dataset) (.NET) method, as below. Note that accession number is a STUDY level attribute so the code below will only work for STUDY level queries.

COM Version

The method needed is DicomQuery.DoRawQuery, but to make life easier, and avoid the need to make your own query from scratch, you can use the default query as a starting point, using the QueryDataSet method. e.g. to query for studies with accession number 12345 then you would replace this line:

set results = query.DoQuery()

by this:

set queryDS = query.QueryDataSet() ' queryDS is a DicomDataSet
queryDS.Attributes.Add(&h0008,&h0050,"12345")
set results = query.DoRawQuery(queryDS)

.NET Version

The method needed is DicomQuery.Find(dataset) but to make life easier, and avoid the need to make your own query from scratch, you can use the default query as a starting point, using the QueryDataSet method. e.g. to query for studies with accession number 12345 then you would replace this line:

set results = query.Find()

by this:

queryDS = query.QueryDataSet() ' queryDS is a DicomDataSet
queryDS.Add(&h0080,&h0050,"12345")
results = query.Find(queryDS)
Relevance: