Mirth Community

Mirth Community (http://www.mirthcorp.com/community/forums/index.php)
-   Support (http://www.mirthcorp.com/community/forums/forumdisplay.php?f=6)
-   -   Edit DICOM / XML in foreach (http://www.mirthcorp.com/community/forums/showthread.php?t=221760)

V3nn3tj3 11-21-2019 05:16 AM

Edit DICOM / XML in foreach
 
Hi,

I'm trying to change some DICOM information from images recieved by our MR.
The images contain special vendor specific tags, which have the datatype 'UN'. This is not a problem for 'normal' tags, but when having UN as type for lists, dcm4che2 does not want to compile XML to DICOM. What i want to do is to change all 'UN' types that have lists under them to the type 'SQ'. Lists in lists also exist. I wrote the following code, which works but not as expected:

Code:

for each (var node in msg.descendants()) {
        if (node['@vr'].toString() == "UN" && node['@len'].toString() == "-1") {
                node['@vr'] = 'SQ';
        }
}

This changes the message correctly, but the data that is send away from the source to the destination gets 'UN' again on these tags. I can solve this by using the following code. But only when the tag is directly underneath the root, i can not access child lists from tags.

Code:

for each (var node in msg.children()) {
        if (node['@vr'].toString() == "UN" && node['@len'].toString() == "-1") {
                msg[node.name()]['@vr'] = 'SQ';
        }
}

I'm guessing that when i'm directly writing to msg, the data itself is changed (reference), when using node, i'm working on a copy? I cannot work on msg using descendants, as i'm unable to construct the parent tag from the data i've got.

Any ideas?

(atm i'm using the following code which just removes all the lists with datatype 'UN')

Code:

for each (var node in msg.descendants()) {
        if (node['@vr'].toString() == "UN" && node['@len'].toString() == "-1") {
                delete msg[node.name()];
        }
}

Thanks

stormcel 11-22-2019 04:05 PM

Do you have a destination template that is overwriting those values?

schillert 12-27-2019 05:55 AM

I've had the same problem. My working solution involver recursion.
That's my step:

Code:

putseq(msg);

function putseq(xxx) {
        for each (seg in xxx.children()) {
                if (seg.hasComplexContent()) {
                        if(seg.@vr=="UN") {
                                seg.@vr="SQ";
                        }
                        putseq(seg);
                }
        }
}

The argument concerning outbound message templates is valid though...


All times are GMT -8. The time now is 04:14 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Mirth Corporation