web stats
Read Inbound Serialization Properties in Transformer? - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 01-22-2020, 11:10 AM
PhilipJohnson PhilipJohnson is offline
What's HL7?
 
Join Date: Jan 2020
Location: New York City, NY, USA
Posts: 1
PhilipJohnson is on a distinguished road
Default Read Inbound Serialization Properties in Transformer?

Hi, first time posted, moderate time forum-searcher.

Quick Version : Is there a way to get the Inbound Serialization Properties set in the "Set Data Types" section of channel definition within a source or destination transformer?

The use case here is that I can reading in delimited files, processing those files row by row to generate HL7 messages. However there are times that a row may be missing required fields, or have a value that is not yet mapped, etc. And so those specific rows are getting logged out as having errors, while the valid rows are able to fully process.

Our current method is to generate the text to be logged out with the following code:

var logText = SerializerFactory.getSerializer('DELIMITED').fromX ML(row);

This mostly works, but it makes 2 changes to the row from what was in the original file:

1) Any unneeded " are lost. For instance in a CSV file, "1","2","3,4" will turn into just 1,2,"3,4". This is acceptable since the whole reason the " are lost in the conversion to XML and back is because they had no impact on the data.
2) The delimiters are changed to default of comma for column delimiter. So in a pipe delimited file, 1|2|3,4 becomes 1,2,"3,4". THIS change is much more impactful, as after maps have been updated in order to re-run these rows the delimiter must be updated in the channel, the files with the error-logged rows run, then the delimiter changed back. Obviously this is not idea.

I know that the second issue can be corrected though something like the following:

var properties = SerializerFactory.getDefaultDeserializationPropert ies('DELIMITED');
properties.put('columnDelimiter', '|');
properties.put('recordDelimiter', '\r');
var logText = SerializerFactory.getSerializer('DELIMITED', null, properties).fromXML(row);

However, this still involves the hardcoding within the transformer that the columnDelimiter is |. This is not the case for all of our delimited file interfaces, and we're trying to standardize and functionalize these setups as much as possible. Thus ideally so the code could be made universal we would be able to do something like the following:

var properties = SerializerFactory.getDefaultDeserializationPropert ies('DELIMITED');
var columnDel = Packages.com.mirth.connect.server.controllers.Chan nelController.getInstance().getDeployedChannelById (channelId).getInboundProperties().getSerializatio nproperties().getColumnDelimiter().toString();
var recordDel = Packages.com.mirth.connect.server.controllers.Chan nelController.getInstance().getDeployedChannelById (channelId).getInboundProperties().getSerializatio nproperties().getRecordDelimiter().toString();
properties.put('columnDelimiter', columnDel);
properties.put('recordDelimiter', recordDel);
var logText = SerializerFactory.getSerializer('DELIMITED', null, properties).fromXML(msg);

I know that when I take a backup of the channel config, the value that I need is at <channel><sourceConnector><transformer><inboundPro perties><serializationProperties><columnDelimiter> and <recordDelimiter> respectively. So I suspect there's going to be SOME set of calls along the lines of above that can get me this information. I've just not been able to find the correct documentation for the right series of methods to call to get to this information.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 03:36 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Mirth Corporation