Iterate though Dicom tag & change to uppercase #4591
-
Trying to modify each instance of ROIObservationLabel to uppercase using Javascript, but having issues as its not chaning the tags in the dicom file. The following code is in the Source Transformer (Type Javascript) of a DICOM Listener;
tried this also, as its I'm unsure its able to read the sub tag30060085 of tag30060080
thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
There's lots of stuff that won't work in there.
I took a stab at a solution based on the examples in your question. I have no idea if this will actually work. // find any tag30060085 in the document tree rather than only direct descendants
for each (var tag in msg..tag30060085) {
// get string value of the tag
var value = tag.toString();
var uppercase = value.toUpperCase();
if (value != uppercase) {
// replace only the child text node instead of the entire tag to preserve attributes
tag.setChildren(uppercase);
}
} It might help to put your channel storage setting in development mode, and then look at the transformed content of one of your messages in the message browser. This can help you see how the XML is actually being structured. |
Beta Was this translation helpful? Give feedback.
There's lots of stuff that won't work in there.
msg['tag30060085']
means to return a list of all child elements ofmsg
namedtag30060085
. Taking thetoString()
value of that means you now have a string instead of an XMLList, so you can't iterate over it with thefor each
.msg
as your loop variable is going to overwrite your actualmsg
.tag30060085
is a sub-tag as you indicated in your second code block, it would not be found bymsg['tag30060085']
.tstr.toString()
becausetstr
is already a string, so you can just use it directly.I took a stab at a solution based on …