web stats
CreateSegmentAfter Errors 1.8.0 - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 10-21-2008, 09:33 AM
zzoubian zzoubian is offline
OBX.1 Kenobi
 
Join Date: Oct 2008
Location: Vancouver, BC
Posts: 35
zzoubian
Default CreateSegmentAfter Errors 1.8.0

I can't seem to get createSegmentAfter function to work in 1.8.0 RC2. I would like to create HL7 messages from scratch.

I have the following in the destination transformer:

Code:
var MSH = createSegment('MSH', tmp);
MSH['MSH.1'] = "|";						
MSH['MSH.2'] = "^~\&";

var PID = createSegment('PID', tmp);
PID['PID.1'] = "";

var ORC = createSegment('ORC', tmp);
ORC['ORC.1']['ORC.1.1'] = "BLA";

var OBR = createSegment('OBR', tmp);
OBR['OBR.3']['OBR.3.1'] = "123456789";

var OBX = createSegment('OBX', tmp);

for (var i=0; i<3; i++){
	OBX['OBX.1'] = "";
	OBX['OBX.1']['OBX.1.1'] = i+2;
	OBX['OBX.2'] = "";
	OBX['OBX.2']['OBX.2.1'] = "2";
	OBX['OBX.3'] = "";
	OBX['OBX.3']['OBX.3.1'] = i;
	tmp['OBX'][i] = OBX;
}
How do I insert for example a ZZ segment after ORC?
The following works:
Code:
var ZZ = createSegment('ZZ');
ZZ['ZZ.1']['ZZ.1.1'] = "Hello World";
tmp['ORC'] +=  ZZ;
However, the following doesn't:
Code:
var ZZ = createSegmentAfter('ZZ', 'ORC');
ZZ['ZZ.1']['ZZ.1.1'] = "Hello World"

Error: TypeError: Cannot read property "ZZ.1" from undefined
Am I using the function properly?
Reply With Quote
  #2  
Old 10-21-2008, 12:21 PM
jacobb jacobb is offline
Mirth Employee
 
Join Date: Aug 2006
Location: Irvine, CA
Posts: 1,218
jacobb is an unknown quantity at this point
Default Re:CreateSegmentAfter Errors 1.8.0

Create segment *was* changed in version 1.8, so I'm wondering if your code worked in a previous version. Let me know if it did or not.

Either way though, you are using it incorrectly. You should do something like:
Code:
var ZZ = createSegmentAfter('ZZ', msg['ORC']);
__________________
Jacob Brauer
Director, Software Development
NextGen Healthcare

Reply With Quote
  #3  
Old 10-21-2008, 12:45 PM
zzoubian zzoubian is offline
OBX.1 Kenobi
 
Join Date: Oct 2008
Location: Vancouver, BC
Posts: 35
zzoubian
Default Re:CreateSegmentAfter Errors 1.8.0

I haven't tried that code on the previous version. So, I am not sure. Hmm, still can't get it to work. I tried two ways below, but no luck.

I tried:
Code:
var ZZ = createSegmentAfter('ZZ', msg['ORC']);
ZZ['ZZ.1']['ZZ.1.1'] = "Hello World";

TypeError: Cannot read property "ZZ.1" from undefined
and I thought it would be more like, so then I tried:
Code:
var ZZ = createSegmentAfter('ZZ', tmp['ORC']);
ZZ['ZZ.1']['ZZ.1.1'] = "Hello World";

Error: java.lang.IllegalArgumentException: Cursors not in same document
Reply With Quote
  #4  
Old 10-21-2008, 12:59 PM
albertosaez albertosaez is offline
 
Join Date: Sep 2006
Location: Valladolid, Spain
Posts: 842
albertosaez is an unknown quantity at this point
Default Re:CreateSegmentAfter Errors 1.8.0

żDoes exist the ORC segment in the template ?

If you're having problems with the createSegment function, you could try adding the ZZ segment in the template (and if you doesn't neeed it, you can remove it with "delete tmp['ZZ']; command)
Reply With Quote
  #5  
Old 10-21-2008, 01:08 PM
jacobb jacobb is offline
Mirth Employee
 
Join Date: Aug 2006
Location: Irvine, CA
Posts: 1,218
jacobb is an unknown quantity at this point
Default Re:CreateSegmentAfter Errors 1.8.0

Create segment doesn't return anything. It modifies the current msg object, so you would have to say msg['ZZ'] afterward to use your added segment.

See http://www.mirthproject.org/fisheye/...ansformer.java for further reference.
__________________
Jacob Brauer
Director, Software Development
NextGen Healthcare

Reply With Quote
  #6  
Old 10-21-2008, 01:18 PM
jacobb jacobb is offline
Mirth Employee
 
Join Date: Aug 2006
Location: Irvine, CA
Posts: 1,218
jacobb is an unknown quantity at this point
Default Re:CreateSegmentAfter Errors 1.8.0

In addition to my last post, we are adding a parameter right now for you to pass in the msg object that it adds the new segment to. This way you will be able to pass in either msg or tmp.
__________________
Jacob Brauer
Director, Software Development
NextGen Healthcare

Reply With Quote
  #7  
Old 10-21-2008, 01:34 PM
zzoubian zzoubian is offline
OBX.1 Kenobi
 
Join Date: Oct 2008
Location: Vancouver, BC
Posts: 35
zzoubian
Default Re:CreateSegmentAfter Errors 1.8.0

No, the ORC segment didn't exist in the template. My template was empty. Also, deleting the segments that I don't need from a template, is a good idea. I'll keep that in mind. That's great if you are adding that parameter. I'll look forward to seeing it in one of your future releases. For the time being, I'll just stick with what works for me now.

Anywhoo, thank you for your quick responses. I'd like to add that I'm quite pleased with Mirth so far. I've tried other open source applications and this one in particular is one of my favourites. It's well written. Great work!
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Channel errors For Jbartels From IRC siliconburn Support 0 09-10-2008 10:14 AM
XML with 0a 0a in text errors jamesa Support 4 08-02-2007 06:20 AM
Getting message regarding too many errors kevspett Support 7 07-27-2007 08:45 AM
1.5 was reinstalled, but i keep getting errors gazetaj Support 5 06-05-2007 09:51 AM
How are messages with errors handled? kbobba Development 1 10-23-2006 01:23 PM


All times are GMT -8. The time now is 08:55 PM.


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