Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting SyntaxError: Empty JSON string in Mirth while passing the message #10

Open
Anuragkurve opened this issue Dec 6, 2023 · 0 comments

Comments

@Anuragkurve
Copy link

ERROR

ERROR OUTPUT

Transformer error
ERROR MESSAGE: Error evaluating transformer
com.mirth.connect.server.MirthJavascriptTransformerException:
CHANNEL: HTTP_HWSAFE_DOCUMENT_TO_HL7_ORU_AHC
CONNECTOR: sourceConnector
SCRIPT SOURCE:
SOURCE CODE:
1649: }
1650: eval('importPackage(' + Packages.java.lang.Class.forName(className).getPackage().getName() + ')');
1651: }
1652: }
1653: function doScript() {
1654: msg = JSON.parse(connectorMessage.getTransformedData());
1655: tmp = new XML(template);
1656: function filterRule1() {
1657: if(connectorMessage.getRawData().toString().length() > 0 ) {
1658: return true;
LINE NUMBER: 1654
DETAILS: SyntaxError: Empty JSON string
at e31fd331-0a80-41b3-9971-afd75e1760c3_JavaScript_Filter_Transformer_0:1654 (doScript)
at e31fd331-0a80-41b3-9971-afd75e1760c3_JavaScript_Filter_Transformer_0:1752
at com.mirth.connect.server.transformers.JavaScriptFilterTransformer$FilterTransformerTask.doCall(JavaScriptFilterTransformer.java:235)
at com.mirth.connect.server.transformers.JavaScriptFilterTransformer$FilterTransformerTask.doCall(JavaScriptFilterTransformer.java:187)
at com.mirth.connect.server.util.javascript.JavaScriptTask.call(JavaScriptTask.java:114)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:831)


The error message indicates that there is an empty JSON string on line 1654 of the code. This error is preventing the transformer from being evaluated properly. It seems that the transformer is part of a channel called HTTP_HWSAFE_DOCUMENT_TO_HL7_ORU_AHC, and the error is occurring in the source connector. The error message also includes a stack trace that shows the sequence of events leading up to the error.


Transformer Code we Using

var messageType = "";
var messageEvent = "";
var objJson = JSON.parse(messageObject.getRawData());

channelMap.put('messageDateTime', DateUtil.getCurrentDate("yyyyMMddHHmmss"));
channelMap.put('accessionId', msg['accessionId']);
channelMap.put('patientName', msg['patientName']);
channelMap.put('patientId', msg['patientId']);
channelMap.put('patientAccNum', msg['patientAccountNumber']);

if (msg['OrganizationID'] !== "") {
    if (msg['OrganizationID'] === "Athens Medical Center") {
        messageType = "ORU";
        messageEvent = "R01";
        channelMap.put('messageEventType', messageType + "^" + messageEvent);
    }
}

channelMap.put('date', DateUtil.getCurrentDate('yyyyMMdd'));
channelMap.put('fileName', msg['patientId'] + "_" + msg['patientName'] + ".json");

Filter logic I'm Applying to resolve this Error


if(connectorMessage.getRawData().toString().length() > 0 ) {
return true;
} else {
return false;
}

But Still getting the Same error

can anyone help me to resolve that error or explain me how to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant