how do I get Mirth connectorMessage.getRawData to return a string? - mirth

I am trying to get the string representation of the HL7 message input to a channel. Documentation says
var myMessage = connectorMessage.getRawData()
should give me the original unparsed HL7 message. However the type of the data returned is an object and not a string. I tried using .toString() but that doesn't work either. My javascript library code that expects a string and be able to split it fails because what's returned is not a string.
How do I get the original HL7 message string?

connectorMessage.getRawData() returns a Java string rather than a javascript string. You can convert to a javascript string by doing.
var myMessage = String(connectorMessage.getRawData())
This is true no matter what you have selected for your data type.

On the Summary tab, click on "set data types", and change your inbound connector to "Raw"....after this, connectorMessage.getRawData() should return to you a long string that is the incoming message.

Related

How to parse json in dart

I am receiving json string through an API from a website. However, the json format sent to me is not the format i want to work with. I want to change the received json string format to the desirable format.
This is the format i received:
{"symbols_returned":147,"base":"USD","data":{"AED":
3.673010,"AFN":75.392000,"ALL":109.685000}}
This however is the format i desire to have:
{"symbols_returned":147,"base":"USD","data":{"AED":"3.673010","AFN":"75.392000","ALL":"109.685000"}}
The difference between the former and latter is the presence of quotation marks on all the numeric currency values in the second json string. It can be seen that the first json string does not have quotes on the numeric currency values.
My question is how can i programmatically turn the first json string to the second json string format using dart programming language. Any help will be appreciated. Thanks
you need to parse the json data before you can use it.
you need to use the json package from dart:convert do do this
import 'dart:convert';
final yourResult = json.decode(API_RESULT);
print(yourResult) // {"symbols_returned":147,"base":"USD","data":{"AED":"3.673010","AFN":"75.392000","ALL":"109.685000"}}
will parse the json and preserve the data types and make that a Map

In Jmeter how to pass Date as String/text

I need to pass a date (12/12/2016) as a Text parameter to a Post request.
It picks %2f instead of '/'. how do i pass this as string with date having slash.
I tried to send date value as Text/string in parameters tab. whether I select/unselect Encode? parameter, sending by encoding the date value.
Keeping the value in Body Data section worked for me.
So, try by moving all the Post data into Body Data section instead of Parameters section.

How do output for tRESTClient

I read some param from JSON file and for each param i should send request.
That when i true move output to any element i get errors:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
statusCode cannot be resolved or is not a field
string cannot be resolved or is not a field
body cannot be resolved or is not a field
The method getHeaders() is undefined for the type Response
at pricing.pricing_0_1.Pricing.tFileInputJSON_1Process(Pricing.java:3334)
at pricing.pricing_0_1.Pricing.tREST_1Process(Pricing.java:1783)
at pricing.pricing_0_1.Pricing.runJobInTOS(Pricing.java:4634)
at pricing.pricing_0_1.Pricing.main(Pricing.java:4366)
I had the same error messages (also having JSON files as input and output) and I found that the solution is to leave the Input, Response and Error Schema with the structures they initially had in tRESTClient.
The Input Schema contains body and string. Here you can either use tXMLMap to define the body structure (this didn't work for me) or send the JSON file as a string with tMap directly into the tRESTClient.
The Response has the schema statusCode, body and string. Again, just retrieving the string with a tMap and tLogRow will get you the output of tRestClient.
I hope this helps.
Include the statusCode variable in the JSON
I too got the same error, what I came across is since trestclient is expecting the schema inputs in form of stausCode , body and String.
Whereas the input is fed as key and value pair of schema. So we are getting error as enter image description here
So I used a tconvertType and converted the outgoing row from tconverttype as stausCode , body and String, and it started working.
enter image description here
and all the errors went away.
Thanks,

Send a special parameter via RequestBuilder POST on GWT

I am a beginner of GWT.
In my application, i need to post parameter which of value is a URL such like a following string.
'http://h.com/a.php?code=186&cate_code=MV&album=acce'
As you can see it, it includes character sequences '&cat_code='.
As i know, &parametername=value is form of one parameter!...
Because of this, a PHP file on my server side, only receives a following string,
'http://hyangmusic.com/Ticket_View.php?code=186'
How could i do in this situation... i want to receive a full URL as parameter on the server side PHP.
Please help me.
Thanks in advance.
my code.
String name = "John";
String url = "http://h.com/a.php?code=186&cate_code=MV&album=acce";
String parameter = "name="+name+"&url="+url;
builder.setHeader("Content-Type","application/x-www-form-urlencoded");
builder.sendRequest(parameter,
new RequestCallback() {
}
Use URL.encodeQueryString(url) so that your & is turned into a %26 (26 being the hexadecimal representation of the UTF-8 encoding of &)

Mirth: overwriting msg object with contents in an XML object

The task is to send an XML object from Channel-A to Channel-B
<MyMessage>
<ID>42</ID>
<hl7v2>
MSH|^~\&|LAB|....
PID|1|....
</hl7v2>
</MyMessage>
The steps of the channel communication:
in the Channel-B's source transformer, extract the HL7v2 contents
OVERWRITE the current msg object in Channel-B with the extracted contents
continue in the other Channel-B source transformers and expecting to reference msg['PID']['PID.5'] as normal.
The good news is that I can extract the HL7v2 'payload' into a variable. The problem or difficulty is resetting the msg object, or any other object to be able to reference the HL7 properties as expected.
When I create a new variable with the SerializerFactory.getHL7Serializer, it wraps with the tags <HL7Message>.
channelMap.put('MessageID', msg['ID']); //successful
channelMap.put('v2payload',msg['HL7v2']); //also looks good
var v2Msg = SerializerFactory.getHL7Serializer(false,false,true).toXML(msg['HL7v2']);
channelMap.put('v2Msg', v2Msg );
link to full size image
Question: Do you have any suggestions on how to overwrite the msg object?
How can I start referencing the msg as such:
msg['PID']['PID.5']
Current Conditions
the receiving channel's input type is XML
the need is to take extract all the properties from that XML object; ID is a database PK to be used later in the destination.
I'm sorry my original answer was bogged down with the peculiarities of my own scenario. I have reworked and tested to ensure that this works in your scenario.
Sending Channel - wraps the raw hl7 into your xml structure, and forwards to a channel called ReceiveXML. I have coded this in the Source Transformer, but you should code it where it works for you.
var wrappedHL7 = <MyMessage><ID>123</ID>
<hl7v2>{messageObject.getRawData()}</hl7v2>
</MyMessage>;
router.routeMessage("ReceiveXML", wrappedHL7);
Receiving Channel - extracts the hl7 from the xml, converts it to xml, and assigns back to the msg object. I have coded this in the source Filter - hence "return true;"
msg = new XML(SerializerFactory.getHL7Serializer(false,false,true).toXML(msg['hl7v2'].toString()));
return true;
All you have to do is put your incoming xml message into the inbound template area in mirth and then use the message tree to drag and drop the info from the XML that you need to the javascript section of the connector.