web stats
Channel receiving both XML and PDF message Like to bypass transformer - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 03-09-2016, 07:05 AM
tmcdevitt tmcdevitt is offline
OBX.3 Kenobi
 
Join Date: Oct 2014
Posts: 125
tmcdevitt is on a distinguished road
Smile Channel receiving both XML and PDF message Like to bypass transformer

Hi, I have one Channel receiving both XML and PDF and like to bypass the transformer that I am using for mapping the XML to HL7 fields. I have created a file extension filter in the source but I am not sure if I can bypass the transformer using router.routeMessage function. is there a better way to do this other then creating a new channel?


Code:
logger.info('FileName');
var FileUtil = new org.apache.commons.io.FilenameUtils;
var strFileExtenstion = FileUtil.getExtension(sourceMap.get('originalFilename').toString())
logger.info(strFileExtenstion);

switch(strFileExtenstion + '') {
    case 'pdf':
        logger.info('FileName PDF');
		router.routeMessage("PDF Destination",${message.raw});
        break;
    case 'xml':
        logger.info('FileName XML');
		router.routeMessage("HL7 Destination",${message.raw});
        break;
 default:
 logger.info('GRRR');
        break;
}
Reply With Quote
  #2  
Old 03-11-2016, 07:51 AM
rigved rigved is offline
OBX.1 Kenobi
 
Join Date: Jun 2014
Posts: 31
rigved is on a distinguished road
Default

I may be completely misunderstanding what you are looking for but this seems to be quite straightforward

Couple of points to begin with
1. Correct me if am wrong. As far as I know routing does not work for specific destinations within a channel. Routers exist to route messages to other channels.

2. You haven't indicated whether your transformer is at the source or destination.

Here is what I would suggest

1. Create a channel map variable to detect whether source in pdf or xml
2. Move the transformer that maps XML to HL7 to the XML Destination and not have it at the source.
3. Put a filter in PDF destination such that it will work only when the input is PDF, likewise for XML. This way the XML to HL7 transformer will only execute when the input in XML

Let me know if I haven't understood your requirement accurately.

Rig
Reply With Quote
  #3  
Old 03-11-2016, 08:43 AM
jackwhaines jackwhaines is offline
 
Join Date: May 2011
Location: Kansas City, Missouri
Posts: 168
jackwhaines is on a distinguished road
Send a message via Skype™ to jackwhaines
Default

Like rigved, I'm not sure I understand 100% either, but I've run into a similar situation. I have a channel that is a File Reader that reads a folder with both .hl7 and .pdf files. I set the source as RAW, then setup two destination connectors. One with a filter to only accept .pdf and the second to only accept .hl7. The files still get moved/deleted in the source like normal regardless of file type, and you can process each as needed. There is also the added benefit that if you (for example) process the .PDF destination first, you can base64-encode the PDF for inclusion into the HL7 that you process second.

Hope it helps...
__________________

-= Jack Haines : Healthcare Integrations, LLC
-= jack.haines@HealthcareIntegrations.com
-= Mirth Connect (Advanced)-certified
-= Gold member of HL7.org
-= Available for Mirth Connect channel development and consultation! Schedule a call with me at https://integrations.as.me

Last edited by jackwhaines; 03-11-2016 at 08:52 AM.
Reply With Quote
  #4  
Old 03-14-2016, 05:32 AM
tmcdevitt tmcdevitt is offline
OBX.3 Kenobi
 
Join Date: Oct 2014
Posts: 125
tmcdevitt is on a distinguished road
Default

I need to name the PDF and HL7 message base off of the value in MSH3. I was thinking that if the source transformer did the XML to HL7 then in the destination transformer I can pull the msh3 and name the HL7 message. I am not sure how to name the PDF any ideas? I been playing around with the globalMap but its not working.
Reply With Quote
  #5  
Old 03-14-2016, 06:19 AM
jackwhaines jackwhaines is offline
 
Join Date: May 2011
Location: Kansas City, Missouri
Posts: 168
jackwhaines is on a distinguished road
Send a message via Skype™ to jackwhaines
Default

I guess it would depend on how you built your channel/channels. If you do it with a single channel with multiple destinations, you can use a normal channelMap. If it goes across multiple channels, you would HAVE to use a globalMap. Decide on how you are going to make your channels work, and then let me know. We'll go from there!
__________________

-= Jack Haines : Healthcare Integrations, LLC
-= jack.haines@HealthcareIntegrations.com
-= Mirth Connect (Advanced)-certified
-= Gold member of HL7.org
-= Available for Mirth Connect channel development and consultation! Schedule a call with me at https://integrations.as.me
Reply With Quote
  #6  
Old 03-14-2016, 07:20 AM
rigved rigved is offline
OBX.1 Kenobi
 
Join Date: Jun 2014
Posts: 31
rigved is on a distinguished road
Default

I guess we need some more information here. Am still not certain what you are ultimately looking for.

Your original question was around bypassing a certain transformer when processing PDF which could be a simple if condition based on whether the extension is pdf or not. Not sure if that is answered yet.

If I understand correctly, actually based on Jack's response, your pdf and xml inputs are related and that you are looking to embed the pdf as Base64 in your xml. So basically you have two inputs for a single output. Let me know if that is correct.

In that case I would simply just read the XMLs in the source (using *.xml as filter) and not the PDFs and then have a transformer in the same channel that will read the corresponding PDF using FileUtil as Base64 and embed that data in the outbound. This is assuming that you have a way to match the xml and pdf either using the filename or the content of the xml. You can put some special handling in case the corresponding PDF is not found.

Within that same transformer or Post Processor you can either delete or move the pdf to some other location based on the same pattern you are following for xml archival or deletion.

One additional note, you need not always have to use globalMap to pass data among channels. If your channels are channel readers you can pass metadata and read them using source map. Similar concept for http listeners. You can also smartly embed metadata in your message and delete it in the receiving channel after consuming that data.
Reply With Quote
  #7  
Old 03-14-2016, 07:56 AM
tmcdevitt tmcdevitt is offline
OBX.3 Kenobi
 
Join Date: Oct 2014
Posts: 125
tmcdevitt is on a distinguished road
Default

I would like to use single channel with multiple destinations. Below is the code I been testing with. But in the source filter do I need it to send the HL7 or PDF to the correct Destination ?

HL7 Destination transformer:
var MSH5 =(msg['MSH']['MSH.5']['MSH.5.1'].toString());
var FileUtil = new org.apache.commons.io.FilenameUtils;
var strFileName = FileUtil.getBaseName(sourceMap.get('originalFilena me').toString())
globalMap.put(strFileName,MSH5)

PDF Destination transformer:
var FileUtil = new org.apache.commons.io.FilenameUtils;
var strFileName = FileUtil.getBaseName(sourceMap.get('originalFilena me').toString())
var MSH5 = globalMap.get(strFileName)
logger.info(String.format("MSH 5 %s",MSH5));
//Need to Change PDF File Name
Reply With Quote
  #8  
Old 03-14-2016, 08:06 AM
tmcdevitt tmcdevitt is offline
OBX.3 Kenobi
 
Join Date: Oct 2014
Posts: 125
tmcdevitt is on a distinguished road
Default

Yes I have two inputs XML and PDF, they both have the same file name just different extensions. The output needs to be two files HL7 and PDF. The HL7 is using the message builder base on values in the XML file. Then there is HL7 message formatting(fixing dates). The HL7 file name needs to be in the format 1_MSH5_Datetimestamp.hl7. For the PDF that will need to match with the HL7 message so its file name will be 1_MSH5_Datetimestamp.pdf
Reply With Quote
  #9  
Old 03-14-2016, 08:06 AM
jackwhaines jackwhaines is offline
 
Join Date: May 2011
Location: Kansas City, Missouri
Posts: 168
jackwhaines is on a distinguished road
Send a message via Skype™ to jackwhaines
Default

Tell me this, will the PDF always be there when the XML is processed? If so, what I might do is only process the .xml files using the channel (use the filename filter in the source) but then use the transformers to encode, move/delete the PDFs from the folder when the HL7 is processed. Basically, you don't want the channel processing the PDF file like you would the XML. I do this exact scenario in a production environment. Basically, the folder contains both, but the channel only grabs the XML.

If it's possible that the PDF will come in AFTER the XML (but it always will eventually) you could use a filter to not process the XML until both files were there.
__________________

-= Jack Haines : Healthcare Integrations, LLC
-= jack.haines@HealthcareIntegrations.com
-= Mirth Connect (Advanced)-certified
-= Gold member of HL7.org
-= Available for Mirth Connect channel development and consultation! Schedule a call with me at https://integrations.as.me

Last edited by jackwhaines; 03-14-2016 at 08:08 AM.
Reply With Quote
  #10  
Old 03-14-2016, 08:40 AM
tmcdevitt tmcdevitt is offline
OBX.3 Kenobi
 
Join Date: Oct 2014
Posts: 125
tmcdevitt is on a distinguished road
Default

Yes the PDF will always be there with the XML processed. But how would you sent the file name of the PDF file name?
Reply With Quote
Reply

Tags
filter, router

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 08:36 AM.


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