web stats
Removing M and leading zeros from PID.3 - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 03-21-2018, 04:00 AM
Rubicon Rubicon is offline
OBX.2 Kenobi
 
Join Date: Feb 2013
Posts: 98
Rubicon is on a distinguished road
Default Removing M and leading zeros from PID.3

Hello All,
Some of our medical record numbers from a legacy system has a M and leading zeros before the actual medical record number.
I need to strip the M and any zeros using Mirth Connect version 2.2.1

I tried:
msg.PID['PID']['PID.3']['PID.3.1'] = msg.PID['PID']['PID.3']['PID.3.1'].toString().replace(/^0+/g,'');

But doesn't work.....Any ideas?

Thanks,
Rubi
Reply With Quote
  #2  
Old 03-21-2018, 06:03 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,181
agermano is on a distinguished road
Default

You forgot the M before the 0s.
Reply With Quote
  #3  
Old 03-21-2018, 06:08 AM
Rubicon Rubicon is offline
OBX.2 Kenobi
 
Join Date: Feb 2013
Posts: 98
Rubicon is on a distinguished road
Default

Still doesn't work. But thanks anyway.
Reply With Quote
  #4  
Old 03-21-2018, 06:38 AM
aTom aTom is offline
OBX.3 Kenobi
 
Join Date: Feb 2016
Location: Lake Geneva Area
Posts: 115
aTom is on a distinguished road
Default

You set PID twice ...

msg.PID['PID']['PID.3']['PID.3.1']
__________________
Tom
Reply With Quote
  #5  
Old 03-21-2018, 07:50 AM
Rubicon Rubicon is offline
OBX.2 Kenobi
 
Join Date: Feb 2013
Posts: 98
Rubicon is on a distinguished road
Default

I guess I don't understand.

I have it set twice.
msg.PID['PID']['PID.3']['PID.3.1'] = msg.PID['PID']['PID.3']['PID.3.1'].toString().replace(/^0+/g,'');
Reply With Quote
  #6  
Old 03-21-2018, 08:34 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,181
agermano is on a distinguished road
Default

Code:
msg['PID']['PID.3']['PID.3.1'] = msg['PID']['PID.3']['PID.3.1'].toString().replace(/^M0*/,'');
Reply With Quote
  #7  
Old 04-10-2018, 12:25 PM
mhaase mhaase is offline
OBX.2 Kenobi
 
Join Date: Dec 2015
Posts: 62
mhaase is on a distinguished road
Default

Another way to skin this cat:

Assuming you want just the last 8 numbers -
msg['PID']['PID.3']['PID.3.1'] = msg['PID']['PID.3']['PID.3.1'].toString().match(/\d{8}$/);
Reply With Quote
  #8  
Old 04-10-2018, 03:12 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,181
agermano is on a distinguished road
Default

You are correct that will return the last 8 digits, but it won't strip leading zeroes, and if it's shorter than 8 digits it won't return anything.
Reply With Quote
  #9  
Old 04-11-2018, 05:42 AM
mhaase mhaase is offline
OBX.2 Kenobi
 
Join Date: Dec 2015
Posts: 62
mhaase is on a distinguished road
Default

True, but in a scenario where they are the same length then it would :^)

Another example that should work:

msg['PID']['PID.3']['PID.3.1'] = msg['PID']['PID.3']['PID.3.1'].toString().match(/^M0*(.*)/);

Rubicon - where is 'msg.PID' coming from? If I put an HL7 message in the template tree and pull it over I don't see that. I get the standard msg['PID']['PID.3']['PID.3.1'] line.
Reply With Quote
  #10  
Old 04-12-2018, 10:13 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,181
agermano is on a distinguished road
Default

It doesn't work. You'd need to do
Code:
msg['PID']['PID.3']['PID.3.1'] = msg['PID']['PID.3']['PID.3.1'].toString().match(/^M0*(.*)/)[1];
And then, if something was sent that didn't match the pattern, it would return undefined instead of leaving what was sent.
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 01:55 PM.


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