web stats
Replacing a character in multiple OBX lines - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 05-24-2012, 11:07 AM
wit-man wit-man is offline
OBX.2 Kenobi
 
Join Date: Apr 2012
Posts: 80
wit-man is on a distinguished road
Default Replacing a character in multiple OBX lines

First, forgive me if I use the wrong terminology or process as this is my first attempt at modifying a transformer.

I am trying to use javascript to remove a carat character in the OBX|5 field. So, for example, I want to change the following lines:

OBX|1|ST|BT^BLOOD TYPE^B^BLD TYPE^B||^OP|
OBX|2|ST|ABSGEL^ANTIBODY SCREEN GEL^B^ABS GEL^ABS||^NEGATIVE|

In this, I want to replace "^OP" with "OP" in the first line and I want to replace "^NEGATIVE" with "NEGATIVE" in the second line. Can someone assist.

I haven't tried it yet but can someone tell me if this looks correct:

-----------------------------------------

var str

for(var i=0;i<msg['OBX'].length()
{
str = msg['OBX'][i]['OBX.5'].toString()
msg['OBX'][i]['OBX.5'].toString() = str.replace("^", "");
i++;
}

-----------------------------------------

Thanks.
Reply With Quote
  #2  
Old 05-24-2012, 11:22 AM
wit-man wit-man is offline
OBX.2 Kenobi
 
Join Date: Apr 2012
Posts: 80
wit-man is on a distinguished road
Default

Sorry, I think this should be:

Code:
var str

for(var i=0;i<msg['OBX'].length();)
{

str = msg['OBX'][i]['OBX.5']
msg['OBX'][i]['OBX.5'] = str.replace("^","");

i++;
}

Emoticons are replacing some of the text.

Last edited by narupley; 05-24-2012 at 11:27 AM. Reason: Putting code in CODE block...
Reply With Quote
  #3  
Old 05-24-2012, 11:23 AM
wit-man wit-man is offline
OBX.2 Kenobi
 
Join Date: Apr 2012
Posts: 80
wit-man is on a distinguished road
Default

OK, where do I disable the emoticons???
Reply With Quote
  #4  
Old 05-24-2012, 11:26 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

If that's a sample message from your client, then they're sending you messages with the observation value in OBX.5.2 rather than OBX.5.1.

If that caret is meant to be literal, then the client is sending you technically invalid HL7 (they should be sending the caret as \S\ instead). In this case the best course of action (though not always feasible) is to go back to the client and get them to send you proper HL7.

Otherwise, it sounds like you just want the observation value to come in OBX.5.1 right? If so, do this:

Code:
for each (obx in msg.OBX)
	for each (obx5 in obx['OBX.5'])
		if (!obx5['OBX.5.1'].toString() && obx5['OBX.5.2'].toString()) {
			obx5['OBX.5.1'] = obx5['OBX.5.2'].toString();
			delete obx5['OBX.5.2'];
		}
Note: If you want the above code to work for messages that have repeating OBX.5 fields, remember to check Parse Field Repetitions in the protocol settings.

Last edited by narupley; 05-24-2012 at 11:30 AM.
Reply With Quote
  #5  
Old 05-24-2012, 11:27 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

Quote:
Originally Posted by wit-man View Post
OK, where do I disable the emoticons???
Just use CODE tags.
Reply With Quote
  #6  
Old 05-24-2012, 11:34 AM
wit-man wit-man is offline
OBX.2 Kenobi
 
Join Date: Apr 2012
Posts: 80
wit-man is on a distinguished road
Default

Thanks for the reply. Where are the code tags?

This was the response from the vendor:

"Yes. The standard functionality of this interface feed is to always send a caret within OBX|5. Would you like to submit a custom request to have the caret removed? Are you running this feed through an interface engine? If so, can the engine reformat this field to be a single component?"

They have said that this is standard and not including it would not be normal.

Can you explain your script? Sorry, I come from a vbscript background, not javascript so I get some of it but not all. Still new to HL7 but yes, you are probably correct about it going in 5.1. Thanks again.
Reply With Quote
  #7  
Old 05-24-2012, 12:25 PM
wit-man wit-man is offline
OBX.2 Kenobi
 
Join Date: Apr 2012
Posts: 80
wit-man is on a distinguished road
Default

OK, let me take a stab at your script.

The ^ symbol is a separator(is that right?) so basically what you are doing is setting 5.1 equal to 5.2, then deleting 5.2? So something like this (using the example above):

Original:
^OP
5.1 = nothing
5.2 = OP

Now:
5.1 = OP
5.2 is deleted

Is that correct? I still don't know what some of the syntax equals but this looks like what you are doing.
Reply With Quote
  #8  
Old 05-24-2012, 12:35 PM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

Quote:
Originally Posted by wit-man View Post
Thanks for the reply. Where are the code tags?
When you submit a reply on this forum, press the # button in the editing panel.

Quote:
Originally Posted by wit-man View Post
This was the response from the vendor:

"Yes. The standard functionality of this interface feed is to always send a caret within OBX|5. Would you like to submit a custom request to have the caret removed? Are you running this feed through an interface engine? If so, can the engine reformat this field to be a single component?"

They have said that this is standard and not including it would not be normal.
The representative you talked to may have a somewhat na´ve understanding of HL7 v2.x. Carets (or whatever gets placed in the first character position of MSH.2) represent field component separators. Saying "We always send a caret in OBX.5" doesn't clarify anything, because the exact position of component separators can change the entire meaning of a field. I think what the vendor representative meant to say is "We always send the observation value in OBX.5.2 rather than OBX.5.1." If that's the case, then the code example I shared should remedy the issue for you.

If, however, the vendor meant to say "We always include a literal caret at the beginning of the observation value in OBX.5.1", then the appropriate response would be "In that case, you should be escaping that literal caret, otherwise it's ambiguous and improper HL7, but we can fix it for you anyway." Here's an example of how you would fix that literal caret problem:

Code:
for each (obx in msg.OBX)
	for each (obx5 in obx['OBX.5']) {
		obx5['OBX.5.1'] = obx5['OBX.5.1'].toString() + (obx5['OBX.5.2'].toString()?'\\S\\'+obx5['OBX.5.2'].toString():'');
		delete obx5['OBX.5.2'];
	}
Or, if you're worried about other literal carets besides the first one, you could do this:

Code:
for each (obx in msg.OBX)
	for each (obx5 in obx['OBX.5']) {
		var newNode = <OBX.5/>;
		newNode['OBX.5.1'] = XMLtoHL7(obx5).replace('^','\\S\\');
		obx.children()[obx5.childIndex()] = newNode;
	}
Look here for more info: http://www.mirthcorp.com/community/f...58&postcount=6
Reply With Quote
  #9  
Old 05-24-2012, 12:36 PM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

Quote:
Originally Posted by wit-man View Post
OK, let me take a stab at your script.

The ^ symbol is a separator(is that right?) so basically what you are doing is setting 5.1 equal to 5.2, then deleting 5.2? So something like this (using the example above):

Original:
^OP
5.1 = nothing
5.2 = OP

Now:
5.1 = OP
5.2 is deleted

Is that correct? I still don't know what some of the syntax equals but this looks like what you are doing.
Yep, that's exactly right.
Reply With Quote
  #10  
Old 05-24-2012, 12:48 PM
wit-man wit-man is offline
OBX.2 Kenobi
 
Join Date: Apr 2012
Posts: 80
wit-man is on a distinguished road
Default

This still doesn't seem to be working. Here is my raw and encoded message:

Raw:
OBX|1|NM|K^POTASSIUM^L^POTASSIUM^T^100.0450^Potass ium Level^CHEM^CHEMISTRY^CHEM^C|1.1|^2.8|

Encoded:
OBX|1|NM|K^POTASSIUM^L^POTASSIUM^T^100.0450|1.1||

It looks like it is removing it completely. I tried:

Code:
for each (obx in msg.OBX)
	for each (obx5 in obx['OBX.5']) {
		obx5['OBX.5.1'] = obx5['OBX.5.1'].toString() + (obx5['OBX.5.2'].toString()?'\\S\\'+obx5['OBX.5.2'].toString():'');
		delete obx5['OBX.5.2'];
	}
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 02:26 PM.


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