web stats
Duplicate Patient ID Number - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 10-09-2019, 12:13 PM
rreese rreese is offline
Mirth Newb
 
Join Date: Sep 2019
Posts: 7
rreese is on a distinguished road
Exclamation Duplicate Patient ID Number

I have a HL7 message and on the PID line, the patient ID number is shown three times. When you pull it up on the message tree, there is a duplicate PID.4 line. I included the JavaScript below and I put in Bold and Underline the error that comes back in the message sent. any help would be great. If you need the whole JavaScript for this to help me, please let me know. Thanks.

//Add SRH to PID, ACC, Procedure Code
msg['PID']['PID.3']['PID.3.1'] = 'SRH' + msg['PID']['PID.3']['PID.3.1'].toString();

msg['PID']['PID.4']['PID.4.1'] = 'SRH' + msg['PID']['PID.4']['PID.4.1'].toString();

//msg['ORC']['ORC.3']['ORC.3.1'] = 'SRH' + msg['ORC']['ORC.3']['ORC.3.1'].toString();

msg['OBR']['OBR.3']['OBR.3.1'] = 'SRH' + msg['OBR']['OBR.3']['OBR.3.1'].toString();
Reply With Quote
  #2  
Old 10-09-2019, 01:45 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 964
agermano is on a distinguished road
Default

When fields repeat you have to handle each repetition. In order to change all occurances, change your bolded line to:

Code:
for each (var pid4 in msg['PID']['PID.4']) {
    pid4['PID.4.1'] = 'SRH' + pid4['PID.4.1'].toString();
}
Reply With Quote
  #3  
Old 10-10-2019, 03:46 AM
rreese rreese is offline
Mirth Newb
 
Join Date: Sep 2019
Posts: 7
rreese is on a distinguished road
Default

Thank you so much agermano. A Mirth Guru you truly are!
Reply With Quote
  #4  
Old 10-10-2019, 06:35 AM
rreese rreese is offline
Mirth Newb
 
Join Date: Sep 2019
Posts: 7
rreese is on a distinguished road
Default

Alright, so when i entered in that code you suggested, this is the output that now shows in the HL7 message. The patient ID number still shows three times.

PID|1||SRH142067|SRH142067^^^FLSR_MRN^Account Number~SRH142067^^^FLSR_MRN^Account Number


Maybe i'm missing something....
Reply With Quote
  #5  
Old 10-10-2019, 07:01 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,277
cory_cole is on a distinguished road
Default

If you are wanting only 1 then do....

msg['PID']['PID.4']['PID.4.1'] = 'SRH' + msg['PID']['PID.4'][0]['PID.4.1'].toString();

If you are wanting to remove duplicates, it a combination of the two answers. What are you wanting? You need to be a little more specific.
Reply With Quote
  #6  
Old 10-10-2019, 07:22 AM
rreese rreese is offline
Mirth Newb
 
Join Date: Sep 2019
Posts: 7
rreese is on a distinguished road
Default

I just need to remove so there is only one.
Reply With Quote
  #7  
Old 10-10-2019, 09:24 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 964
agermano is on a distinguished road
Default

This will keep only the first repetition, assuming they are always all the same.

Code:
msg['PID']['PID.4'] = msg['PID']['PID.4'][0];
You can stick that before your original code, and it should work.
Reply With Quote
  #8  
Old 10-10-2019, 09:43 AM
rreese rreese is offline
Mirth Newb
 
Join Date: Sep 2019
Posts: 7
rreese is on a distinguished road
Default

Thank you both so much. Now i can quit pulling my hair out.
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 08:58 PM.


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