如何使用Mirth Connect 3.4.1将json转换为HL7?

时间:2016-08-10 06:55:09

标签: javascript json mirth hl7-v3

我现在定义了一个javascript变换器,但在转换时总是提示失败,代码如下:

var input = JSON.parse(connectorMessage.getRawData());
var patienId = input.PATIENT_ID;
var patientName = input.PATIENT_NAME;
var idCard = input.ID_NO;
var i = 1;
createSegment("MSH", msg, i++);
msg['MSH']['MSH.1']['MSH.1.1'] = '|';
msg['MSH']['MSH.2']['MSH.2.1'] = '^~\\&';
msg['MSH']['MSH.3']['MSH.3.1'] = patienId;
msg['MSH']['MSH.4']['MSH.4.2'] = patientName;
msg['MSH']['MSH.5']['MSH.5.1'] = idCard;

和例外情况如下:

Transformer error
ERROR MESSAGE: Error evaluating transformer
com.mirth.connect.server.MirthJavascriptTransformerException: 
CHANNEL:    WsToHttpTest
CONNECTOR:  sourceConnector
SCRIPT SOURCE:  TRANSFORMER
LINE NUMBER:    31
 DETAILS:   TypeError: Cannot set property "1" of undefined to ""
    at f4645dbe-9637-415e-ae39-f3dce72d6eaa:31 (createSegment)
    at f4645dbe-9637-415e-ae39-f3dce72d6eaa:53 (doTransform)
    at f4645dbe-9637-415e-ae39-f3dce72d6eaa:80 (doScript)
    at f4645dbe-9637-415e-ae39-f3dce72d6eaa:82
    at                       com.mirth.connect.server.transformers.JavaScriptFilterTransformer$FilterTransformerTask.doCall(JavaScriptFilterTransformer.java:154)
at com.mirth.connect.server.transformers.JavaScriptFilterTransformer$FilterTransformerTask.doCall(JavaScriptFilterTransformer.java:119)
at com.mirth.connect.server.util.javascript.JavaScriptTask.call(JavaScriptTask.java:113)
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)

[enter image description here][1]

0 个答案:

没有答案