web stats
Mirth Community - View Single Post - CreateSegmentAfter Errors 1.8.0
View Single Post
  #1  
Old 10-21-2008, 10: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