web stats
Build new XML message from Javascript reader source? - Page 3 - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #21  
Old 03-02-2016, 08:20 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

Sorry it took me so long... Here is a working channel (at least on my box).

P.S. - Step through the code... I may have changed some paths and not put them back...
Attached Files
File Type: xml Jack - FileInbound - eDischargePDF-Text.xml (17.0 KB, 9 views)
__________________

-= 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
  #22  
Old 03-02-2016, 08:22 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

Also, it looks like that example PDF is either missing the Post Code or something is wrong with your RegEx to grab it, but I didn't think that was in the scope of what you were trying to do.

Code:
<eDischarge>
    <msg_attendance_id>999999 </msg_attendance_id>
    <msg_nhs_id>0000000001 </msg_nhs_id>
    <msg_pcode_id/>
</eDischarge>
P.S. Now that I look at the output, looks like you might want to throw a trim() around those fields as well....
__________________

-= 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
  #23  
Old 03-02-2016, 08:24 AM
kirbykn2's Avatar
kirbykn2 kirbykn2 is offline
Mirth Guru
 
Join Date: Sep 2014
Location: Michigan
Posts: 567
kirbykn2 is on a distinguished road
Default

what was the solution?
__________________
Kirby

Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

Appliance Version 3.11.2
Mirth Connect Version 3.6.1
Java Version 1.6.0_45-b06
Java (64 bit) Version 1.6.0_45-b06
Java 7 (64 bit) Version 1.7.0_151-b15
Java 8 (64 bit) Version 1.8.0_121-b13
PostgreSQL Version 9.6.3
Reply With Quote
  #24  
Old 03-02-2016, 08:27 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

Well, first off, my installation had a hard time with the iText. I'm using 3.3.2, but it couldn't find that, but it did find com.lowagie.text.pdf. So, once I had that working, I basically added:

Code:
globalChannelMap.put("att",att);
globalChannelMap.put("nhs", nhs);
globalChannelMap.put("pcode", pcode);
to the bottom of the JavaScript reader, then changed the Source transformer to:

Code:
var att = globalChannelMap.get("att");
var nhs = globalChannelMap.get("nhs");
var pcode = globalChannelMap.get("pcode");

channelMap.put("filename",globalChannelMap.get("filename"));

tmp['msg_attendance_id'] = att;
tmp['msg_nhs_id'] = nhs;
tmp['msg_pcode_id'] = pcode;
There are a few other small changes, but that's the gist of it. Basically, you need to use a globalChannelMap in the JavaScript reader as ChannelMap doesn't work 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
  #25  
Old 03-02-2016, 09:03 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

Fixed the Post Code too... There are some hidden spaces and newlines to account for:

Change:

Code:
var pCode = contents.match(/(?:\n|\r)+(.{6,7})(?:\n|\r)+A&E Attendance/);
To:

Code:
var pCode = contents.match(/(?:\n|\r)+(.{6,7})(?:\s)(?:\n|\r)(?:\s)+A&E Attendance/);
__________________

-= 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
  #26  
Old 03-02-2016, 09:04 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

Sorry, also,

change:

Code:
var att = globalChannelMap.get("att");
var nhs = globalChannelMap.get("nhs");
var pcode = globalChannelMap.get("pcode");
to:

Code:
var att = globalChannelMap.get("att").trim();
var nhs = globalChannelMap.get("nhs").trim();
var pcode = globalChannelMap.get("pcode").trim();
__________________

-= 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
  #27  
Old 03-02-2016, 09:05 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

Final product!

Code:
<eDischarge>
    <msg_attendance_id>999999</msg_attendance_id>
    <msg_nhs_id>0000000001</msg_nhs_id>
    <msg_pcode_id>AA111AA</msg_pcode_id>
</eDischarge>
__________________

-= 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
  #28  
Old 03-02-2016, 11:38 PM
amble amble is offline
OBX.2 Kenobi
 
Join Date: Nov 2015
Posts: 91
amble is on a distinguished road
Default

Hero mate, will give this a test this morning I'd imagine it's spot on though.

Is the globalchannelmap thing by design, or was I right to assume a channelmap would work and this is just an edge case?
Reply With Quote
  #29  
Old 03-03-2016, 06:17 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

The different maps are just available (or not available) in certain spots due to the message flows. It just so happens that the ChannelMap is not available yet in the JavaScript Reader, but the GlobalChannelMap is.
__________________

-= 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
  #30  
Old 03-07-2016, 03:32 AM
sanderson sanderson is offline
OBX.1 Kenobi
 
Join Date: Dec 2015
Posts: 45
sanderson is on a distinguished road
Default

If you are having problems with finding patterns in the extracted text:

Items that look like they are on the same line in the PDF can be split across lines in the extracted text due to minescule PDF object placement changes/differences on the page. Similarly lines that you want to search for specific text tags can fail because the text object gets rendered with text right across the line of the page, eg looking in the left part of the page for a name, while there is other text on the right part of the page can affect your search.

I did something similar to you a while back and found that and PDF documents produced by people using word etc were prone to this. I had to code around it with look ahead and behind type searches to try to capture what I was looking for.

Machine produced PDFs were much more consistent though.

hope that helps with the PDF bit a bit!
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 11:33 AM.


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