Get values from repeated parameter in query string accessing 'parameters' in sourceMap

112 views Asked by At

I'm facing a newbie to Mirth and I'm struggling against an easy problem I think, but I cannot find the solution. I'm using mirth v3.12.0 and I set an http listener channel that received a GET request with some paramters like this http://localhost:38081/Observation?identifier=2230106554&issued=ge[2023-07-08 10:00:02.345678]&issued=le[2023-07-08 12:00:02.345678] At the destination channel, in the transformer, I want to manage the values associated to the two parameters named 'issued'.

In the mapping I saw that parameters are stored in a variable 'parameters' that looks like an object and every parameter in it looks like an array, but when I try to accesso the 'issued' parameter array I obtain errors.

The code:

var issued0;
var issued1;
var issued = sourceMap.get('parameters').get('issued');
issued0 = issued[0];
issued1 = issued[1];

the error:

478:    issued0 = issued[0];
479:    issued1 = issued[1];
480:    var ge;
481:    var le;
482:    var headIssued0 = issued0.substring(0,2);
483:    var headIssued1 = issued1.substring(0,2);
LINE NUMBER:    479
DETAILS:    Java class "java.lang.String" has no public instance field or method named "0".
    at e0fc6857-357d-4eda-8525-556ac60bba77:479 (doTransform)
    at e0fc6857-357d-4eda-8525-556ac60bba77:788 (doScript)
    at e0fc6857-357d-4eda-8525-556ac60bba77:790
    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.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)

Any suggestion will be appreciated!

0

There are 0 answers