web stats
Mirth Newbie: OBX5 to include Patient Identifier information & HL7 - Page 4 - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #31  
Old 09-09-2015, 06:37 AM
Murph1 Murph1 is offline
OBX.1 Kenobi
 
Join Date: Dec 2014
Posts: 27
Murph1 is on a distinguished road
Default Could someone teach me how to do this?

Hello again,

I admit I don't know enough about JS to figure this out on my own. The script works great except I can't figure out how to do the date format. My date comes in as 199707190000 and I would like it to be mm/dd/yyyy.
I've tried many different things and I don't know where to put the code.
I tried many different codes but they all error out. I would really appreciate some help.
Thank you.

Original Code:
var PatientDOB = new XML("<OBX.5/>")
PatientDOB['OBX.5.1'] = "DATE OF BIRTH: " +msg['PID']['PID.7']['PID.7.1'].toString();
msg['OBX']['OBX.5'][i] += PatientDOB;

Latest date format try (obviously in the wrong place)
var PatientDOB = new XML("<OBX.5/>")
PatientDOB['OBX.5.1'] = "DATE OF BIRTH: " +msg['PID']['PID.7']['PID.7.1'].toString();
var objRegExp = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/;
var result = PatientDOB.replace(objRegExp, "$2-$3-$1");
msg['OBX']['OBX.5'][i] += PatientDOB;
Reply With Quote
  #32  
Old 09-09-2015, 06:47 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

Search the forums first please. Not only do we have this in a sticky at the top of these forums, but in fact someone else has a similar thread that was just updated today! Not to mention there are literally dozens of threads created in the past that deal with date conversion.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #33  
Old 09-10-2015, 05:34 AM
Murph1 Murph1 is offline
OBX.1 Kenobi
 
Join Date: Dec 2014
Posts: 27
Murph1 is on a distinguished road
Default I got it!!!

I figured it out!!
I created a code template from the sticky link you provided and then modified my transformer to include the 'convertDate' function.

I ended up with:

var PatientDT = new XML("<OBX.5/>")
PatientDT['OBX.5.1'] = "ADMIT DATE: " +convertDate(msg['PV1']['PV1.44']['PV1.44.1'].toString(), 'MM-dd-yyyy');
msg['OBX']['OBX.5'][i] += PatientDT;


Thank you so much for your assistance.
Reply With Quote
  #34  
Old 09-11-2015, 01:10 PM
Murph1 Murph1 is offline
OBX.1 Kenobi
 
Join Date: Dec 2014
Posts: 27
Murph1 is on a distinguished road
Default

This is in response to Wing's response:

because you have insert \.br\ on every 55th segment first
and then replace the "~" to \.br\ in the second step
The output contains some double or triple sequential \.br\

MRN: MRN8888\.br\VISIT NUMBER: ABCD56789992234\.br\DATE OF BIRTH: 19880712\.br\ADMIT DATE: 201505051011\.br\\.br\\.br\56\.br\57\.br\58\

You may want to check it this triple "\.br\ breaking your receiving application?


After talking to support on my receiving application, you are correct in this. MIRTH is adding extra /.br/'s and that is what is pushing the patient identifiers further down the page. I looked all over the forums this afternoon and I couldn't find any help.
How do I remove those extra breaks?
I have 3 steps. 1). Replace TX with FT in OBX 5.2.1; 2). Loop through document every 54 lines; 3). Replace the '~' with '\.br\' in the OBX5.5 segment.
If I move the third step up, there are no breaks inserted with the patient identifiers at all. I was hoping to move it up one step it would remove those extra breaks but that doesn't happen.
I've attached that code and I've also attached my transformer steps on an earlier post.

Would it be better to split out the OBX segment?
Thank you for your assistance.
Attached Files
File Type: xml MPF-PIDTest.xml (11.0 KB, 3 views)
Reply With Quote
  #35  
Old 09-13-2015, 06:05 PM
flyerman flyerman is offline
OBX.2 Kenobi
 
Join Date: May 2015
Posts: 68
flyerman is on a distinguished road
Default

I did not change your code, but just add a few ESCAPE to it........




//Replace TX with FT in OBX 5.2.1

msg['OBX']['OBX.2']['OBX.2.1'] = "FT"


//Replace the '~' with '\.br\' in the OBX5.5 segment

//Insert a whitespace in empty field

var i = msg['OBX']['OBX.5'].length();
while(i--)
{
if (msg['OBX']['OBX.5'][i]['OBX.5.1'].toString() == "" )
{ msg['OBX']['OBX.5'][i]['OBX.5.1'] =" ";
}
}



//Loop through document every 55 lines</name>

var obx5RepeatSegCount=msg.OBX['OBX.5'].length();

for each(seg in msg..OBX)
{
{
//iterating backwards to prevent adding the segment changing the indexing

for (var i = obx5RepeatSegCount-1; i >= 0; i--)
{ var j = i+1
//modulus % operator
if (j % 54==0)
{
//var newBreak = new XML("<OBX.5/>")
//newBreak['OBX.5.1'] += '\\.br\\';
//msg['OBX']['OBX.5'][i] += newBreak;

var PatientDT = new XML("<OBX.5/>")
PatientDT['OBX.5.1'] = "ADMIT DATE: " +msg['PV1']['PV1.44']['PV1.44.1'].toString();
msg['OBX']['OBX.5'][i] += PatientDT;
var PatientDOB = new XML("<OBX.5/>")
PatientDOB['OBX.5.1'] = "DATE OF BIRTH: " +msg['PID']['PID.7']['PID.7.1'].toString();
msg['OBX']['OBX.5'][i] += PatientDOB;
var visitNum = new XML("<OBX.5/>")
visitNum['OBX.5.1'] = "VISIT NUMBER: " +
msg['PV1']['PV1.19']['PV1.19.1'].toString();
msg['OBX']['OBX.5'][i] += visitNum;
var PatientMRN = new XML("<OBX.5/>")
PatientMRN['OBX.5.1'] = "MRN: " +msg['PID']['PID.2']['PID.2.1'].toString();
msg['OBX']['OBX.5'][i] += PatientMRN;
var PatientName = new XML("<OBX.5/>")
PatientName['OBX.5.1'] = "PATIENT NAME: " +
msg['PID']['PID.5']['PID.5.1'].toString()+ ", " + msg['PID']['PID.5']['PID.5.2'].toString() ;
msg['OBX']['OBX.5'][i] += PatientName;
//var page_break= new XML("<OBX.5/>");
//page_break['OBX.5.1'] = "\\.br\\";
//msg['OBX']['OBX.5'][i] += page_break;

}
}
}
}

//\.br\

for each (obx in msg.OBX)
{
var newObx5 = '';
for each (obx5 in obx['OBX.5'].children())
{ newObx5 += obx5 + '\\.br\\';
//logger.info(newObx5)
}

newObx5 = newObx5.toString().substring(0,newObx5.length - 5); //removes the last \.br\

obx['OBX.5'] = newObx5;
}
Reply With Quote
  #36  
Old 09-14-2015, 04:45 AM
Murph1 Murph1 is offline
OBX.1 Kenobi
 
Join Date: Dec 2014
Posts: 27
Murph1 is on a distinguished road
Default

Thank you for that but all that did was jumble everything together. It did not address the issue of the PID moving down the page.
Maybe I should look into separating the OBX out into separate segments and inserting the PID that way.
Reply With Quote
  #37  
Old 09-14-2015, 05:56 AM
flyerman flyerman is offline
OBX.2 Kenobi
 
Join Date: May 2015
Posts: 68
flyerman is on a distinguished road
Default

can you give a sample input HL7

and a PERFECT output you want HL7

no one understand what exactly you want

the last code will already insert name, DOB, etc to every 54 lines, with no duplication of \.br\,

what do u mean "jumble together"?

please EXPLAIN clearly.

Last edited by flyerman; 09-14-2015 at 06:00 AM.
Reply With Quote
  #38  
Old 09-14-2015, 07:50 AM
Murph1 Murph1 is offline
OBX.1 Kenobi
 
Join Date: Dec 2014
Posts: 27
Murph1 is on a distinguished road
Default

I have attached a notepad doc with the Sample (incoming), Perfect and Incorrect HL7's.
MC needs to loop thru the OBX and at the 54th line, insert the PID at the top of the page. Then, beginning with the inserted PID, count again 54 lines and insert the PID again, continuing the sequence until there isn't a 54th line and stopping the script.
My receiver has the ability to add a page break every 54th line, which it does effectively.
But in my code I must be adding too many breaks (\.br\) and because of that my line count is incorrect and that messes up the document.
What I meant by 'jumbled' is that there were no breaks from the PID to the rest of the document so everything ran together. I've also attached that one too.
Thank you again for your help. I really do appreciate it.
Attached Files
File Type: txt HL7 Format.txt (13.7 KB, 3 views)
File Type: txt HL7 Jumbled.txt (4.9 KB, 0 views)
Reply With Quote
  #39  
Old 09-14-2015, 08:09 AM
Murph1 Murph1 is offline
OBX.1 Kenobi
 
Join Date: Dec 2014
Posts: 27
Murph1 is on a distinguished road
Default

I also understand that I should be able to run this code (previously included in prior messages):
  1. Replace TX with FT in OBX 5.2.1
  2. Replace the '~' with '\.br\' in the OBX5.5 segment
  3. Loop through document every 54 lines
  4. Add white space

But when I run it this way, it strips the PID out of the message.

So I have to run the loop first to get the PID to show up. And I know that is why it adds the additional breaks. If I could get it to run correctly as shown above, I think that would solve the issue I'm having.
Reply With Quote
  #40  
Old 09-15-2015, 04:44 AM
Murph1 Murph1 is offline
OBX.1 Kenobi
 
Join Date: Dec 2014
Posts: 27
Murph1 is on a distinguished road
Default

This is getting confusing!!

Attached is the code that I just ran and the results.
Notice there is no pid in the message.
Attached Files
File Type: txt pidChannelTest.txt (2.0 KB, 3 views)
File Type: txt sourcedestination.txt (8.3 KB, 1 views)

Last edited by Murph1; 09-15-2015 at 05:06 AM.
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 03:08 AM.


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