Why does movescu retrieve images with no Unique Keys in the query ?

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Abdallah Maouche
Posts: 12
Joined: Mon, 2021-11-08, 10:25

Why does movescu retrieve images with no Unique Keys in the query ?

#1 Post by Abdallah Maouche »

Hello everyone!

I am trying to replace index file code with SQL code in the dcmqrdb module and now I'm stuck in the part where I have to parse Dicom queries into SQL. I'm using movescu and findscu along with the Dicom Standard to understand the specifications of the query. The problem is that the Dicom Standard and even movescu documentation specifies that the C-MOVE query should contain at least one of the four Unique Keys of the Query/Retrieve Level, but when I use movescu on a running dcmqrscp I can successfully retrieve images using a simple query as the following :

Code: Select all

movescu localhost 22222 -d +P 33333 -P -k QueryRetrieveLevel=PATIENT -k PatientName=ANON* 
I thought that movescu might be using an underlying C-FIND to complete the query with the missing Unique Keys, but I can't find any trace of that , besides it would be very obvious just looking at the logs. Also dcmqrdb doesn't seem to accept queries that do not contain a Unique Key as shown in the following code from dcmqrdbi.cc version 3.6.6

Code: Select all

OFCondition DcmQueryRetrieveIndexDatabaseHandle::hierarchicalCompare (
                DB_Private_Handle       *phandle,
                IdxRecord               *idxRec,
                DB_LEVEL                level,
                DB_LEVEL                infLevel,
                int                     *match,
                CharsetConsideringMatcher& dbmatch)
{
    int                 i ;
    DcmTagKey   XTag ;
    DB_ElementList *plist ;
    DB_LEVEL    XTagLevel  = PATIENT_LEVEL; // DB_GetTagLevel() will set this correctly

    /**** If current level is above the QueryLevel
    ***/

    if (level < phandle->queryLevel) {

        /** Get UID Tag for current level
         */

        DB_GetUIDTag (level, &XTag) ;

        /** Find Element with this XTag in Identifier list
         */

        for (plist = phandle->findRequestList ; plist ; plist = plist->next)
            if (plist->elem. XTag == XTag)
                break ;

        /** Element not found
         */

        if (plist == NULL) {
            *match = OFFalse ;
            DCMQRDB_WARN("hierarchicalCompare : No UID Key found at level " << (int) level);
            return QR_EC_IndexDatabaseError ;
        }
        ...
I'm probably missing something here and I don't know what it is :?

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Why does movescu retrieve images with no Unique Keys in the query ?

#2 Post by J. Riesmeier »

As far as I remember, dcmqrscp is not very strict by default (which is also true for many PAC systems in the real world). You could use dcmqrscp's option -XM (--check-move) to perform additional checks on the C-MOVE request data set received (including a check on the presence of Unique Keys).

Abdallah Maouche
Posts: 12
Joined: Mon, 2021-11-08, 10:25

Re: Why does movescu retrieve images with no Unique Keys in the query ?

#3 Post by Abdallah Maouche »

J. Riesmeier wrote: Mon, 2022-02-07, 11:32 As far as I remember, dcmqrscp is not very strict by default (which is also true for many PAC systems in the real world). You could use dcmqrscp's option -XM (--check-move) to perform additional checks on the C-MOVE request data set received (including a check on the presence of Unique Keys).
Oh I see, it makes more sense now.
Thanks for the quick answer :D

Abdallah Maouche
Posts: 12
Joined: Mon, 2021-11-08, 10:25

Re: Why does movescu retrieve images with no Unique Keys in the query ?

#4 Post by Abdallah Maouche »

Is it okay if the C-MOVE request succeeds even when one of the top level unique keys isn't specified ? Like in this example (dcmqrscp is used with -XM option) :

Code: Select all

movescu localhost 22222 +P 33333 -S -k QueryRetrieveLevel=SERIES -k StudyInstanceUID= -k SeriesInstanceUID=2.25.119454506713869452552520000681617121422
Even when the SeriesInstanceUID isn't specified the C-MOVE still succeeds.
The Dicom Standard says a single value shall be supplied https://dicom.nema.org/medical/dicom/cu ... _C.4.2.2.1
When I checked the code of the function that tests the validity of the identifiers, it does sure check for the validity of the keys but never checks whether the keys are empty or not.

I didn't want to make a new topic for this because it seems related.

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Why does movescu retrieve images with no Unique Keys in the query ?

#5 Post by J. Riesmeier »

Thank you for the report. This seems to be a bug. The move request even works if both StudyInstanceUID and SeriesInstanceUID have an empty value, but the DICOM standard (see e.g. PS3.4 Section C.2.2.1.1 and C.4.2.2.1) is clear on this.

I will create an issue in the DCMTK bug tracker.

Abdallah Maouche
Posts: 12
Joined: Mon, 2021-11-08, 10:25

Re: Why does movescu retrieve images with no Unique Keys in the query ?

#6 Post by Abdallah Maouche »

J. Riesmeier wrote: Wed, 2022-02-09, 10:15 Thank you for the report. This seems to be a bug. The move request even works if both StudyInstanceUID and SeriesInstanceUID have an empty value, but the DICOM standard (PS3.4 Section C.2.2.1.1 and C.4.2.2.1) is clear on this.

I will create an issue in the DCMTK bug tracker.
Alright, I might submit a fix later today.

Abdallah Maouche
Posts: 12
Joined: Mon, 2021-11-08, 10:25

Re: Why does movescu retrieve images with no Unique Keys in the query ?

#7 Post by Abdallah Maouche »

I think there's also a similar bug related to findscu, according to the standard the C-FIND request shall contain single value for the unique key attribute for each level above the query level. (https://dicom.nema.org/medical/dicom/cu ... _C.4.1.2.1)
The following command succeeds even when no value is specified for the unique key above the query level :

Code: Select all

findscu localhost 22222 -S -k QueryRetrieveLevel=SERIES -k StudyInstanceUID= -k SeriesInstanceUID=
I would like to fix these two issues since I'm currently working on this part of the code. You can assign them to me if that's possible.

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Why does movescu retrieve images with no Unique Keys in the query ?

#8 Post by J. Riesmeier »

I think there's also a similar bug related to findscu, according to the standard the C-FIND request shall contain single value for the unique key attribute for each level above the query level.
I suspected that. I guess you've started dcmqrscp also with option -XF (--check-find), right?
I would like to fix these two issues since I'm currently working on this part of the code. You can assign them to me if that's possible.
Thank you for working on these issues. You mean the bug entry? See: https://support.dcmtk.org/redmine/issues/1015

Assigning this bug entry to you would require to have a login for the Redmine system that is hosted by OFFIS. You could send an email to dicom/at/offis/de and ask for it (by referring to this forum discussion). But of course, this only makes sense if you would report and/or fix issue regularly.

In any case, if you come up with a patch, your name will be mentioned in the commit message ("Thanks to ...") :)

Abdallah Maouche
Posts: 12
Joined: Mon, 2021-11-08, 10:25

Re: Why does movescu retrieve images with no Unique Keys in the query ?

#9 Post by Abdallah Maouche »

J. Riesmeier wrote: Wed, 2022-02-09, 11:07 I suspected that. I guess you've started dcmqrscp also with option -XF (--check-find), right?
Yes indeed, the code was very similar when I read it so I did expect a similar behaviour.
J. Riesmeier wrote: Wed, 2022-02-09, 11:07 But of course, this only makes sense if you would report and/or fix issue regularly.
I'm working on a project based on DCMTK so i might only fix problems that I encounter (if I had enough knowledge to do so)

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Why does movescu retrieve images with no Unique Keys in the query ?

#10 Post by J. Riesmeier »

This issue is solved now (see commit). Thanks again for your report and for your proposed patch.

Abdallah Maouche
Posts: 12
Joined: Mon, 2021-11-08, 10:25

Re: Why does movescu retrieve images with no Unique Keys in the query ?

#11 Post by Abdallah Maouche »

Looking forward to make more contributions in the future :D

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 1 guest