[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Camel route help] HL7 listener, to parse body, to base64 decode, pdf to file on filesystem

I’d have to work out all the XML syntax for this, but you should be able to use the HAPI Terser ( <terser> element in the XML) to extract the field you want.

I’d probably do this in a bean - it’s easy to do the HL7 Decode at that point.

Something like

String myMethod(@Body ca.uhn.hl7v2.model.Message hapiMessage) {
  ca.uhn.hl7v2.util.Terser terser = new Terser(hapiMessage);

  String obx5 = terser.get(“/OBX-5-5”);

  String decoded = Base64.getDecoder().decode(obx5);

I know that the above probably won’t run (just made it up for the email) - but hopefully it give’s you an idea.

> On Jun 19, 2018, at 8:06 AM, John F. Berry <bohnjerry@xxxxxxxxx.INVALID> wrote:
> I appologize.. Newbie here to the open source/project world.  Long time programmer in other realms.
> I have a base64 encoded pdf that will be sent to me via HL7 in the OBX-5-5 field of this message body that I need to decode and create an actual pdf file on a filesystem.  I have tried various themes of attempting to access the unmarshalled structure, but that's where the trail gets cold.
> I haven't attached any "code" since it is more representative of thrashing to get some sort of result rather than intelligent design.  I created two maven archetypes (Camel java DSL and Camel spring) and attempted to re-engineer the sample file read-decision-log-write route and take this one step at a time.  Currently I can receive HL7, ACK, unmarshal, log the message body, marshal, and write to entire HL7 message to a file. I wish to receive the HL7, ACK, unmarshal, isolate OBX-5-5, decode it's contents back to binary, and write this to a new file on the file system with a filename and .pdf extension, and dispose of the HL7 message (end the route here).
> I've owned :"Camel in Action" for years now, but have not been able yet to apply it's wisdom to my situations.  Perhaps a little hand-holding will help me see the landscape of this technology.  I am missing something, as to what exactly, I've been struggling to figure out. 
> So I've been parallel developing two maven projects, one Java DSL and one Spring.  Here's the latest skeleton I have for the Spring version:
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Configures the Camel Context-->
> <beans xmlns="";
>        xmlns:xsi="";
>        xsi:schemaLocation="
> <bean id="hl7decoder" class="org.apache.camel.component.hl7.HL7MLLPNettyDecoderFactory"/>
> <bean id="hl7encoder" class="org.apache.camel.component.hl7.HL7MLLPNettyEncoderFactory"/>
> <!--<bean id="hl7codec" class="org.apache.camel.component.hl7.HL7MLLPCodec"/> -->
>   <camelContext xmlns="";>
>    <endpoint id="hl7listener" uri="mllp://" />
>     <route>
>       <from uri="hl7listener"/>
>       <convertBodyTo type="java.lang.String" />
>       <unmarshal>
>         <hl7 validate = "false" />
>       </unmarshal>
>       <log message="${body}" />
>       <marshal><hl7 /> </marshal>
>           <log message="Other message"/>
> <!--          <convertBodyTo type="java.lang.String"/> -->
>           <to uri="file:target/messages/others"/>
>     </route>
>   </camelContext>
> </beans>
> Ideas?  Thanks!

( ! ) Warning: include(msgfooter.php): failed to open stream: No such file or directory in /var/www/git/apache-camel-users/msg03429.html on line 129
Call Stack
10.0006368728{main}( ).../msg03429.html:0

( ! ) Warning: include(): Failed opening 'msgfooter.php' for inclusion (include_path='.:/var/www/git') in /var/www/git/apache-camel-users/msg03429.html on line 129
Call Stack
10.0006368728{main}( ).../msg03429.html:0