web stats
Delete ~ in DG1 segment - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 10-30-2017, 08:18 AM
gojoshi gojoshi is offline
OBX.1 Kenobi
 
Join Date: Jul 2013
Posts: 36
gojoshi is on a distinguished road
Default Delete ~ in DG1 segment

I need to delete a ~ in the DG1 segment.The ~ is being populated in multiple DG1 segments.

Since it is an encoding character, Mirth is not finding it when I do a replace or an IndexOf script.

Below is an example of the DG1 segment:

DG1|||G89.28^~Other chronic postprocedural pain ~ page 28^0||201710300755|DDN

The ~ after the "G89.28^" and "pain" needs to be removed.

Any help would be greatly appreciated.

Thanks.
Reply With Quote
  #2  
Old 10-30-2017, 10:31 AM
appsbyaaron's Avatar
appsbyaaron appsbyaaron is offline
Mirth Guru
 
Join Date: Nov 2011
Location: Florida, USA
Posts: 377
appsbyaaron is on a distinguished road
Default

This is the scary way to do that in the Preprocessor. This will alter the ENTIRE message.

Code:
//There are &’s within the NTE segments.  These segments are comments so we need to replace the & with ‘and’
//The issue is that this will remove the $ from MSH.2 … which we don’t want to do.

message = message.replace(/~/,’*’);      //change the MSH 2 to *
message = message.replace(/~/g,’’);      //change ALL ~ in the message to null
message = message.replace(/\*/,’~’);      //change the MSH 2 back to ~ from *

// Modify the message variable below to pre process data
 return message;
Reply With Quote
  #3  
Old 10-30-2017, 11:17 AM
appsbyaaron's Avatar
appsbyaaron appsbyaaron is offline
Mirth Guru
 
Join Date: Nov 2011
Location: Florida, USA
Posts: 377
appsbyaaron is on a distinguished road
Default

Here's a specific (and pretty sloppy) fix for just the DG1 segment. This is assuming the ~ is in the same place each time. Anyway, that should give you some ideas.

Code:
tmp = msg.copy();

	delete tmp['DG1']['DG1.3'][0];
	delete tmp['DG1']['DG1.3'][1];
	delete tmp['DG1']['DG1.3'][2];

	var sample_value0 = msg['DG1']['DG1.3'][0]['DG1.3.1'].toString();
	var sample_value1 = msg['DG1']['DG1.3'][1]['DG1.3.1'].toString();
	var sample_value2 = msg['DG1']['DG1.3'][2]['DG1.3.1'].toString();
	var sample_value3 = msg['DG1']['DG1.3'][2]['DG1.3.2'].toString();

	var temp = sample_value1 + sample_value2;

	tmp['DG1']['DG1.3']['DG1.3.1'] = sample_value0;
	tmp['DG1']['DG1.3']['DG1.3.2'] = temp;
	tmp['DG1']['DG1.3']['DG1.3.3'] = sample_value3;

msg = tmp.copy();

return msg;

Before
Quote:
DG1|||G89.28^~Other chronic postprocedural pain ~ page 28^0||201710300755|DDN
After
Quote:
DG1|||G89.28^Other chronic postprocedural pain page 28^0||201710300755|DDN
Reply With Quote
  #4  
Old 10-31-2017, 03:54 AM
gojoshi gojoshi is offline
OBX.1 Kenobi
 
Join Date: Jul 2013
Posts: 36
gojoshi is on a distinguished road
Default This seems to work:

Thanks appsbyaaron . But I got the below script from a co-worker which is working without any issues:


for each(dg1 in msg.DG1)
{
var dg1append = '';
var dg13 = dg1['DG1.3'];
for (i = dg13.length()-1;i >= 0; i--)
{
if(i > 0)
{
dg1append = dg13[i]['DG1.3.1'].toString() + ' '+dg1append;
delete dg13[i];
}
}

dg1['DG1.3']['DG1.3.2'] = dg1append.toString();
}
Reply With Quote
Reply

Tags
encoding, encoding character, remove ~

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 01:09 PM.


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