简体   繁体   中英

HL7 with Mirth: How to avoid Segments with double sequence numbers?

Using the Mirth Connect Interoperability server 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:

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:

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:

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:

//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:

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!

Try this:

createSegment('OBX', tmp, 1);
tmp['OBX'][1]['OBX.1']['OBX.1.1'] = 2;
tmp['OBX'][1]['OBX.2']['OBX.2.1'] = "ST";
createSegment('OBX', tmp, 2);
tmp['OBX'][2]['OBX.1']['OBX.1.1'] = 3;
tmp['OBX'][2]['OBX.2']['OBX.2.1'] = "ST";

The first OBX is tmp['OBX'][0]['OBX.1']['OBX.1.1'] = 1; It's that [0] which is the first OBX instance. so when you added "tmp['OBX'][1]['OBX.1']['OBX.1.1'] = 1;" you added the second OBX|1| when it should have been coded like above.

createSegment(segmentName, msg, i) where i is the segment instance.

You could also just create the XML element directly and append the segment to the end of your message http://wso2.com/project/mashup/0.2/docs/e4xquickstart.html

var obx = <OBX/>;
obx['OBX.1']['OBX.1.1'] = 2;
obx['OBX.2']['OBX.2.1'] = "ST";
tmp.appendChild(obx);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM