1
votes

I am building a DICOM client using the dcm4che3 library and it's a bit confusing to me how I'm supposed to create the dicom query. I'm calling the CFIND method on the Association class.

I've figured out how to create a basic query (eg search by PatientID) as follows:

Attributes query = new Attributes();
query.setString(Tag.PatientID, VR.LO, "12345");

So far so good.

But when I want to query using something like ScheduledProcedureStepStartDate, I have to create a Sequence with a sub query something like this:

Attributes query = new Attributes();
Sequence sequence = query.newSequence(Tag.ScheduledProcedureStepSequence, 1);
Attributes subQuery = new Attributes();
subQuery.setDate(Tag.ScheduledProcedureStepStartDate, VR.DA, date);
sequence.add(subQuery);

I don't know the DICOM format in detail. So I figured this out quite by trial and error and using another DICOM client emulator and intercepting it's queries to try and figure out how it works.

So from this I have 3 questions:

  1. How can I query for ScheduledProcedureStepStartDate between two dates (i.e. using a From and To date).
  2. When creating the query, is it possible to have the dcm4che3 library figure out how to make the Sequences, so I can just specify the Tag, VR and value I want in the query?
  3. When I query using the Sequence elements (eg ScheduledProcedureStepSequence -> Modality) it doesn't seem to work. Is there any trick to make this work?
1

1 Answers

2
votes
  1. How can I query for ScheduledProcedureStepStartDate between two dates (i.e. using a From and To date).

The Scheduled Procedure Step Start Date (0040,0002) element is part of Scheduled Procedure Step Sequence (0040,0100). This supports Combined Range Matching.

Matching keys for Date and Time are combined. For example, a Study Date of "20060705-20060707" and a Study Time of "1000-1800" will match the time period of July 5, 10am until July 7, 6pm, rather than the three time periods of 10am until 6pm on each of July 5, July 6 and July 7.

So, you can specify two dates separated by dash (-) to search between two dates. Example is given in quote above.

  1. When creating the query, is it possible to have the dcm4che3 library figure out how to make the Sequences, so I can just specify the Tag, VR and value I want in the query?

DICOM element hierarchy is very simple; caller can easily create sequences as needed. In majority of the cases, MWL query contain only one sequence that you mentioned.

What you are asking needs a wrapper over basic Data Set class. Most widely used tool kits does not support wrapper over DICOM Data Set to simplify sequence handling; I know few does. I am not expert in the toolkit; but AFAIK, such wrapper does not exist for dcm4che. You have to create and manage sequence elements yourself.

  1. When I query using the Sequence elements (eg ScheduledProcedureStepSequence -> Modality) it doesn't seem to work. Is there any trick to make this work?

This is not clear; "it doesn't seem to work" does not explain it. Sequence element contains an Item. The Item contains further elements. Each Item can be treated as Data Set again.

Following is how your query should something look like:

MQL Query

The article from Roni may be helpful to you. The source code there does not use your toolkit; hope you will get an idea.