Is an "OR" query condition possible?

  • We have modalities that are configured to query conquest by today's date by default, and some modalities allow users to change this when querying but some don't. For those that don't it creates a situation around midnight each night where things get a little unpredictable and very time dependant, for example if a scan is scheduled for 00:10 the following day but it's only 23:50 at the moment then the operator has to wait until midnight to see the entry. Things also become very sensitive to how correct the clocks are on each modality and on conquest, and a difference of a few minutes or more will cause similar mismatching effects. To further complicate things, some modalities implement a feature where they can search for studies "within X hours of now" but in practice it's not always implemented correctly and if this window of time crosses over into a different day it results in a query to conquest like "date>=today AND time>=21:00 AND date<=tomorrow AND time<= 03:00". When this happens this query returns no results, because of the way the times are ANDed (eg >=21:00 AND <= 03:00).

    To avoid these issues I'm exploring the possibility of using a WorkListQueryConverter0 to override all date and time queries that a modality may have set, and instead set it to a rolling window that I can apply to all incoming queries, for example filter to all studies from 24 hours in the past to 24 hours in the future no matter what time/date was queried for. However to do this without falling into the wierdness around midnight mentioned above I need an OR clause, for example "(date >=today AND time>=21:00) OR (date<=tomorrow AND time<= 03:00)".

    I've tried searching in the code to see if it's possible to do an OR instead of an AND when setting fields in the query but I don't think I found the right place. I've also tried searching to see if it's even possible to define an OR in these queries but also couldn't find any guidance from the standard.

    Is this possible? Any suggestions or pointers would be greatly appreciated, thanks in advance!

  • Hi,

    the code to create the queries is hardcoded in vrtosql.cpp. Time is indeed processed as you mentioned. Even though SQL provides OR, the C code does not provide options to insert an OR. Queries are produced by concatenating the results of BuildSearchString for each search tag, so there is no easy way to make it combine date and time. I also noted it does not process the DT_TIME in any way.

    WorkListQueryConverter0 can only change the passed DICOM tags, but what you are looking for may not achievable that way. One potential option could be suppress time in the input query (but store it in a local variable) and then add a script in WorkListQueryResultConverter0 do the correct filtering (you can destroy() individual responses). Since worklist queries are not huge this may be workable.


  • Hi Marcel,

    Thanks a mill for that. I ended up with exactly as you said, I'll put the scripts below for anyone else in a similar situation.

    Here is WorkListQueryConverter0:

    And here is ModalityWorklistQueryResultConverter0:

    I'm more than happy to hear any improvements to these, so far it looks like it will do the trick quite nicely.

    Thanks again marcelvanherk !

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!