using cfindrq.xsl to coerce query results

1,661 views
Skip to first unread message

danny....@gmail.com

unread,
Jan 13, 2014, 3:53:24 AM1/13/14
to dcm...@googlegroups.com
Hello

So far, I've been using cfindrq.xsl to coerce query results based on CALLING_AET (see below example code.)

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>


 
<xsl:param name="calling" select="'AE_CALLING'"/>
 
<xsl:param name="called" select="'DCM4CHEE'"/>
 
<xsl:param name="date" select="'20051206'"/>
 
<xsl:param name="time" select="'115600.000'"/>
 
<xsl:template match="/">
   
<dataset>
       
<xsl:choose>


               
<xsl:when test="starts-with($calling, ‘AET1’)”>
                       
<attr tag="00100010" vr="PN">AAA*</attr>
               
</xsl:when>


               
<xsl:when test="starts-with($calling, ‘AET2’)”>
                       
<attr tag="00100010" vr="PN">BBB*</attr>
               
</xsl:when>


               
<xsl:when test="starts-with($calling, ‘AET3’)”>
                       
<attr tag="00100010" vr="PN">CCC*</attr>
               
</xsl:when>


               
<xsl:otherwise>
                       
<attr tag="00100010" vr="PN">Nothing Is Shown</attr>
               
</xsl:otherwise>


       
</xsl:choose>


   
</dataset>
 
</xsl:template>


</xsl:stylesheet>

So the above code will allow AET1 to only query studies with patient name starting with AAA, AET2 can only query names starting with BBB, AET3 can query names starting with CCC and everyone else can query nothing.

How can I code this so that AET1 can see both studies with patient name starting with AAA and BBB?

Is there a way to allow an OR operator such that AAA* || BBB* is able for querying when CALLING_AET is AET1?

Any suggestions would be greatly appreciated!

Many thanks!


Danny Kim

fleetwoodfc

unread,
Jan 13, 2014, 3:43:05 PM1/13/14
to dcm...@googlegroups.com
Do not think that an OR operator is supported in DICOM queries. However, you can filter on the response side using cfindrsp.xsl.

danny....@gmail.com

unread,
Jan 17, 2014, 3:17:12 PM1/17/14
to dcm...@googlegroups.com
Hi fleetwoodfc

Thanks for your reply.
I experimented with cfindrsp.xsl and still having some troubles with it.

I created a subdirectory after the AE Title that I want the coercion rule to apply (e.g.dcm4chee-ae/AET1/)
Then, created cfindrsp.xsl for that AE.

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>

 
<xsl:param name="calling" select="'AE_CALLING'"/>
 
<xsl:param name="called" select="'DCM4CHEE'"/>
 
<xsl:param name="date" select="'20051206'"/>
 
<xsl:param name="time" select="'115600.000'"/>
 
<xsl:template match="/">
   
<dataset>

       
<attr tag="00100010" vr="PN">AAA</attr>

   
</dataset>
 
</xsl:template>

</xsl:stylesheet>

But this only renames the query results to AAA and does not actually filter out other results.
Again, what I'm hoping to achieve is for example: AET1, Query results are filtered to AAA and BBB.


Forgive my limited knowledge of writing xslt scripts.


Best,

Danny Kim

David Davies

unread,
Jan 17, 2014, 3:41:47 PM1/17/14
to dcm...@googlegroups.com
To filter out a result you would need to set all attr to no value.
So you need some logic that says:
if patient name startswith AAA || BBB then 
pass the result on thru 
else
clear the result


--
You received this message because you are subscribed to a topic in the Google Groups "dcm4che" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dcm4che/X43VjG8Pi1E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dcm4che+u...@googlegroups.com.
To post to this group, send email to dcm...@googlegroups.com.
Visit this group at http://groups.google.com/group/dcm4che.
For more options, visit https://groups.google.com/groups/opt_out.

danny....@gmail.com

unread,
Jan 20, 2014, 1:29:02 PM1/20/14
to dcm...@googlegroups.com
Hi fleetwoodfc

Thanks for the advice. I got my cfindrsp.xsl working to the point where search results are limited by patient name or id (AAA || BBB)

For everyone's interest here's a sample code:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>

 
<xsl:param name="calling" select="'AE_CALLING'"/>
 
<xsl:param name="called" select="'DCM4CHEE'"/>
 
<xsl:param name="date" select="'20051206'"/>
 
<xsl:param name="time" select="'115600.000'"/>
 
<xsl:template match="/dataset">

   
<dataset>
       
<!-- Patient Name Coerce-->
       
<attr tag="00100010">
               
<xsl:choose>
                       
<xsl:when test="starts-with(attr[@tag=00100010],'AAA') or starts-with(attr[@tag=00100010],'BBB')">
                               
<xsl:copy-of select="attr[@tag='00100010']"/>
                       
</xsl:when>

                       
<xsl:otherwise>

                       
</xsl:otherwise>
               
</xsl:choose>
       
</attr>

       
<!-- Patient ID Coerce-->
       
<attr tag="00100020">
               
<xsl:choose>
                       
<xsl:when test="starts-with(attr[@tag=00100010],'AAA') or starts-with(attr[@tag=00100010],'BBB')"> <!-- Coercion rule by patient name-->
                               
<xsl:copy-of select="attr[@tag='00100020']"/>
                       
</xsl:when>

                       
<xsl:otherwise>

                       
</xsl:otherwise>
               
</xsl:choose>
       
</attr>

       
<!-- Patient DOB Coerce-->

       
<attr tag="00100030">
               
<xsl:choose>
                       
<xsl:when test="starts-with(attr[@tag=00100010],'AAA') or starts-with(attr[@tag=00100010],'BBB')"> <!-- Coercion rule by patient name-->
                               
<xsl:copy-of select="attr[@tag='00100030']"/>
                       
</xsl:when>

                       
<xsl:otherwise>

                       
</xsl:otherwise>

               
</xsl:choose>
       
</attr>

       
<!-- Study Description Coerce-->

       
<attr tag="00081030">
               
<xsl:choose>
                       
<xsl:when test="starts-with(attr[@tag=00100010],'AAA') or starts-with(attr[@tag=00100010],'BBB')"> <!-- Coercion rule by patient name-->
                               
<xsl:copy-of select="attr[@tag='00081030']"/>
                       
</xsl:when>

                       
<xsl:otherwise>

                       
</xsl:otherwise>

               
</xsl:choose>

       
</attr>

   
</dataset>
 
</xsl:template>
</xsl:stylesheet>


I noticed though that I can still RETRIEVE the data even though I can't "see" it - on OsiriX, I can query and then select a blank line (blanked out by cfindrsp) in the search results pane and click the retrieve arrow and it will still retrieve.
Is this because I haven't cleared out all the necessary DICOM information? What needs to be cleared for the unwanted data to be non-retrievable?

Thanks very much for all your help thus far.



Sincerely,

Danny Kim

Jeff Garrett

unread,
Jan 20, 2014, 8:17:24 PM1/20/14
to dcm...@googlegroups.com
I'm not familiar with XML so not sure if this proper code. Could you add two XML:when statements for AET1 so that if the first one fails, for AAA, the second one would catch BBB?

Jeff

Jeff Garrett

unread,
Jan 20, 2014, 8:19:02 PM1/20/14
to dcm...@googlegroups.com
I meant xsl.

Jeff

fleetwoodfc

unread,
Jan 21, 2014, 6:41:25 AM1/21/14
to dcm...@googlegroups.com
Some comments that might help:
As far as I know the cfindrsp.xsl is intended to allow for anonymization or corrections to individual tags and not to filter out a whole result. It would be good if the xsl could just say "if AAA OR BBB" then block the result - but I don't think this feature exists.
DCM4CHEE does have the Study Permissions system that applies access permissions as a study is received - this might also be an option for you. Otherwise you are left with designing a xsl file to set all atts to empty in a filtered result. Note also that some attributes cannot be coerced by default e.g Study UID. This is controlled by the dcm4chee-attribute-filter.xml file located in the conf directory. This file also specifies what attributes are returned by default in a query result (I think this is correct but test and report back).

danny....@gmail.com

unread,
Mar 13, 2014, 5:38:12 PM3/13/14
to dcm...@googlegroups.com
Sorry for not following through here for almost two months. I've been busy with other stuff.

Jeff - if you add two AET1 if statements in cfindrq.xsl, then the coercion goes by the second if statement rule. The first if statement seems to be ignored. Seems that whatever is the last if statement, that's the rule the coercion will go by. For cfindrsp.xsl, this simply does not work at all.

Study permission seems promising. Are there any example xsl files that we can go by such that whenever files are stored in the dcm4chee PACS, Query/Retrieve permissions are designated to respective research groups?

Other than that, I found a way to blank out query results and make them non-retrievable (code below for those who are interested).
The trick was study instance UID. If that's blank, then at least in OsiriX, you can't retrieve a blank query result.
When this cfindrsp.xsl is placed under dcm4che-ae/someaetitle then "someaetitle" can only see and retrieve studies with patient id or name starting with "AAA" or "BBB"

Thanks for all the help.

Cheers,

Danny Kim

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>

 
<xsl:param name="calling" select="'AE_CALLING'"/>
 
<xsl:param name="called" select="'DCM4CHEE'"/>
 
<xsl:param name="date" select="'20051206'"/>
 
<xsl:param name="time" select="'115600.000'"/>
 
<xsl:template match="/dataset">
   
<dataset>
   
<!-- Patient Name Coerce-->
       
<attr tag="00100010">
       
<xsl:choose>
           
<xsl:when test="starts-with(attr[@tag=00100010],'AAA') or starts-with(attr[@tag=00100010],'BBB')">
               
<xsl:copy-of select="attr[@tag='00100010']"/>
           
</xsl:when>

           
<xsl:otherwise>
               
           
</xsl:otherwise>
       
</xsl:choose>
   
</attr>

   
<!-- Patient ID Coerce-->
       
<attr tag="00100020">
               
<xsl:choose>
                       
<xsl:when test="starts-with(attr[@tag=00100010],'AAA') or starts-with(attr[@tag=00100010],'BBB')">

                               
<xsl:copy-of select="attr[@tag='00100020']"/>
                       
</xsl:when>

                       
<xsl:otherwise>

                       
</xsl:otherwise>
               
</xsl:choose>
       
</attr>

   
<!-- Patient DOB Coerce-->
   
       
<attr tag="00100030">
               
<xsl:choose>    
                       
<xsl:when test="starts-with(attr[@tag=00100010],'AAA') or starts-with(attr[@tag=00100010],'BBB')">

                               
<xsl:copy-of select="attr[@tag='00100030']"/>
                       
</xsl:when>

                       
<xsl:otherwise>
               
                       
</xsl:otherwise>
                                                 
               
</xsl:choose>
       
</attr>

   
<!-- Study Description Coerce-->

       
<attr tag="00081030">
               
<xsl:choose>
                       
<xsl:when test="starts-with(attr[@tag=00100010],'AAA') or starts-with(attr[@tag=00100010],'BBB')">

                               
<xsl:copy-of select="attr[@tag='00081030']"/>
                       
</xsl:when>

                       
<xsl:otherwise>

                       
</xsl:otherwise>

               
</xsl:choose>
       
</attr>

   
   
<!-- Study number of images -->
   
<attr tag="00201208">

       
<xsl:choose>
                       
<xsl:when test="starts-with(attr[@tag=00100010],'AAA') or starts-with(attr[@tag=00100010],'BBB')">

                               
<xsl:copy-of select="attr[@tag='00201208']"/>

                       
</xsl:when>

                       
<xsl:otherwise>

                       
</xsl:otherwise>

               
</xsl:choose>
       
   
</attr>


   
<!-- Study date -->
       
<attr tag="00080020">

               
<xsl:choose>
                       
<xsl:when test="starts-with(attr[@tag=00100010],'AAA') or starts-with(attr[@tag=00100010],'BBB')">

                               
<xsl:copy-of select="attr[@tag='00080020']"/>

                       
</xsl:when>

                       
<xsl:otherwise>

                       
</xsl:otherwise>

               
</xsl:choose>

       
</attr>

   
<!-- Study time -->
       
<attr tag="00080030">

               
<xsl:choose>
                       
<xsl:when test="starts-with(attr[@tag=00100010],'AAA') or starts-with(attr[@tag=00100010],'BBB')">

                               
<xsl:copy-of select="attr[@tag='00080030']"/>

                       
</xsl:when>
                       
                       
<xsl:otherwise>
                       
                       
</xsl:otherwise>
                       
               
</xsl:choose>
                       
       
</attr>

   
<!-- Study Instance UID -->
       
<attr tag="0020000D">

               
<xsl:choose>
                       
<xsl:when test="starts-with(attr[@tag=00100010],'AAA') or starts-with(attr[@tag=00100010],'BBB')">

                               
<xsl:copy-of select="attr[@tag='0020000D']"/>

                       
</xsl:when>
                       
                       
<xsl:otherwise>
                       
                       
</xsl:otherwise>
                       
               
</xsl:choose>
                       
       
</attr>    
   
   
</dataset>                
                     
 
</xsl:template>
</xsl:stylesheet>
Reply all
Reply to author
Forward
0 new messages