web stats
How to avoid Segments with double sequence numbers? - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 10-11-2016, 03:41 AM
kramer65 kramer65 is offline
Mirth Newb
 
Join Date: Oct 2016
Posts: 6
kramer65 is on a distinguished road
Default How to avoid Segments with double sequence numbers?

Using Mirth Connect I'm trying to construct a message in HL7. I'm trying to add a number of custom OBX segments to the message, but Mirth is giving me a hard time.

In my template I've got a line saying this:

Code:
OBX|1|ED|CODE^NAME^COMPANY||^application^pdf^Base64^VeryLongBase64String||||||F
and in a custom script I also want to add some more info manually:

Code:
createSegment('OBX', tmp, 1);
tmp['OBX'][1]['OBX.1']['OBX.1.1'] = 1;
tmp['OBX'][1]['OBX.2']['OBX.2.1'] = "ST";
createSegment('OBX', tmp, 2);
tmp['OBX'][2]['OBX.1']['OBX.1.1'] = 2;
tmp['OBX'][2]['OBX.2']['OBX.2.1'] = "ST";
This creates the following message:

Code:
MSH|^~\&|COMPANY|COMPANY|||20161011120822||ORU^R01|0000029|1|2.4|||AL|NE
PID|1||9999999^^^LOCAL^PI||||19861020|F|
STUFF^L|||20161011120822|20161011120822|
OBX|1|ED|Q001^121^THECOMPANY||^application^pdf^Base64^VeryLongBase64String||||||F
OBX|1|ST
OBX|2|ST
But as you can see I've got two lines which start with `OBX|1|`, so I changed commented out the first three lines of my script so that I start from `OBX|2|` with the extra information:

Code:
//createSegment('OBX', tmp, 1);
//tmp['OBX'][1]['OBX.1']['OBX.1.1'] = 1;
//tmp['OBX'][1]['OBX.2']['OBX.2.1'] = "ST";
createSegment('OBX', tmp, 2);
tmp['OBX'][2]['OBX.1']['OBX.1.1'] = 2;
tmp['OBX'][2]['OBX.2']['OBX.2.1'] = "ST";
but that gives me an error, saying:

Code:
Transformer error
ERROR MESSAGE: Error evaluating transformer
com.mirth.connect.server.MirthJavascriptTransformerException: 
CHANNEL:    test setup
CONNECTOR:  sourceConnector
SCRIPT SOURCE:  TRANSFORMER
SOURCE CODE:    
46: //createSegment('OBX', tmp, 1);
47: //tmp['OBX'][1]['OBX.1']['OBX.1.1'] = 1;
48: //tmp['OBX'][1]['OBX.2']['OBX.2.1'] = "ST";
49: createSegment('OBX', tmp, 2);
50: tmp['OBX'][2]['OBX.1']['OBX.1.1'] = 2;
51: tmp['OBX'][2]['OBX.2']['OBX.2.1'] = "ST";
52: 
LINE NUMBER:    50
DETAILS:    TypeError: Cannot read property "OBX.1" from undefined
    at 682bcffd-73bf-405b-af83-ba83b19d86ab:50 (doTransform)
    at 682bcffd-73bf-405b-af83-ba83b19d86ab:126 (doScript)
    at 682bcffd-73bf-405b-af83-ba83b19d86ab:128
    at com.mirth.connect.server.transformers.JavaScriptFilterTransformer$FilterTransformerTask.call(JavaScriptFilterTransformer.java:154)
    at com.mirth.connect.server.transformers.JavaScriptFilterTransformer$FilterTransformerTask.call(JavaScriptFilterTransformer.java:119)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Why can't I add new segments with sequence number 2 if 1 already exists? And why does it accept two OBX lines starting with the same sequence number?

All tips are welcome!
Reply With Quote
  #2  
Old 10-11-2016, 06:22 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,123
narupley is on a distinguished road
Default

That's not a set ID, it's an array index.
__________________
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
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 10:22 AM.


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