Can PDF file be embedded in HL7 and extracted by Cloverleaf

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Can PDF file be embedded in HL7 and extracted by Cloverleaf

  • Creator
    Topic
  • #54966
    Tom Brown
    Participant

      Can a PDF file be embedded into an HL7 message and have Cloverleaf extract the embedded PDF file from the HL7 message and deposit the PDF file on a file folder?  If so does anyone have coding examples to share or point me in the right direction. Thanks for your help.

    Viewing 3 reply threads
    • Author
      Replies
      • #83621
        Jim Kosloskey
        Participant

          Assuming the source system followed the HL/7 standard and encoded thee PDF (probablly base-64).

          Also assuming the receiving system can decode.

          I would try defining a VRL of only 1 field.

          Then I would use an Xlate and copy the PDF base64 encoded component to the VRL field.

          Then I would route to a Fileset/Local (or FTP if that is what is needed) protocol.

          Should be rather quick to set up to see if it works.

          email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

        • #83622
          Charlie Bursell
          Participant

            As Jim said, make sure the embedded PDF is Base-64 encoded.   If you extract the PDF you have to decode it and write it to a file.  Be sure and use the binary mode to write it.  Use the base64 package to decode.

            Something like this: (Assumes Tcl 8.5)

            Assume you know how to extract HL7 field to a variable

            Assume you extracted PDF into a variable named pdf

            # Load base64 package

            package require base64

            # Open for write in binary mode

            set fd [open myfile.pdf wb]

            puts -nonewline $fd [base64::decode $pdf]

            close $fd

          • #83623
            Jim Kosloskey
            Participant

              OK again assuming source has encoded the HL/7 component correctly.

              I set up a single field VRL

                 Type String

                 Max Width -1

                 NO ‘SF Sep’ or ‘Escape Pair’

               Global Properties:

                 Field Seperator – ,

                 Default SubField Separator – x20

                 Termination – (empty)

              I set up a Fileset/local inbound thread and outbound thread. I used some procs we have to make sure I only got the  file I wanted but other than that the Protocol properties are unremarkable.

              I built a one line Xlate with HL/7 in and my VRL out. I COPY’d the OBX-5.5 component (that is where my base64 encoded PDF is) to my single VRL field.

              I used _hci_static routee invoking my Xlate.

              File gets created.

              Now the file which gets created is still base64 encoded. So any system wanting to use the file needs to decode it.

              In order to create a decoded file, Tcl will be needed as Charlie has shown.

              If I get time I might see if I can just add decode Tcl somewhere inside so file handling will still be done by the engine rather than Tcl.

              email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

            • #83624
              Michael Hertel
              Participant

                You can view this post to see how I did it with tcl.

                https://usspvlclovertch2.infor.com/viewtopic.php?t=7582

            Viewing 3 reply threads
            • The forum ‘Cloverleaf’ is closed to new topics and replies.