PDF to Embedded PDF

Homepage Clovertech Forums Cloverleaf PDF to Embedded PDF

  • Creator
    Topic
  • #113978
    Timothy O’Donnell
    Participant

    I’m looking to take a PDF file dropped to a file path and embed that PDF in an outbound HL7 message going from Cloverleaf to Athena. Is this workflow feasible? What would be the best way to set this up? Any help is appreciated.

Viewing 3 reply threads
  • Author
    Replies
    • #113979
      Peter Heggie
      Participant

      This is fairly straight-forward. Use a result message (ex ORU) as the base HL7 and populate it as required. The OBR segment should be coded as usual. The PDF will be inserted into an OBX segment, in OBX.5. The PDF must be encoded in base64 before inserting into OBX.5.

      package require base64

      set code [catch {base64::encode -maxlen 0 “$msg”} encoded_data]
      if {$debug > 1} {echo “$module – base64 encode code: $code”}
      if {$code} {
      echo “$module error code $code for base64 encoding PDF document”
      lappend dispList “ERROR $mh”
      msgmetaset $mh USERDATA “base64 decoding error – MUSE EKG PDF mrn: $ekgmrn date: $ekgdate”
      return $dispList
      }

      if {$debug > 2} {echo “$module – encoded_data: $encoded_data”}

      Determine if your vendor needs more metadata on the PDF. For instance, Cerner Soarian Clinicals wants to see ‘ED’ in OBX.2, ‘AP’ in OBX.5[1], ‘PDF’ in OBX.5[2], ‘Base64’ in OBX.5[3] and the base64-encoded data in OBX.5[4].

      It is helpful to have a temporary second destination thread that has an outbound tcl proc which reads the message, extracts the encoded PDF, decodes the PDF back into binary, and then writes the binary output to a windows file with a PDF extension. You should be able to open up the PDF successfully, to verify that you encoded it correctly. Don’t forget to set your inbound thread protocol encoding to binary and use a fileset read option of ‘single’ or ‘EOF’ (same for your temporary outbound thread).

      Peter Heggie

      • #113980
        Timothy O’Donnell
        Participant

        Peter:

        Thank you! I’m still newer to Cloverleaf so how would you build the threads for this in NetConfig. Should the tcl be attached to a upoc? Sorry for the novice questions.

    • #114000
      Jim Kosloskey
      Participant

      Tim,

      There are a few things I will mention:

      1.  Is there one PDF per file, or multiple PDFs per file?
        1. If multiple PDFs per file then the PDFs should already be encoded (hopefully base64) so the engine can break the file apart into multiple messages.
      2. Are the PDF file(s) you want the only files in the directory?
        1. If not, you will need to either have a Directory Parse UPoC Tcl proc to select the files (or in 6.2 or 19.1 – I don’t recall which – I think a method was introduced to select files).
        2. The other option is to use some pre-processing to place only the PDF files in a directory that you can point to (getting the originating system to do that is best).
      3. The IB Protocol will be Fileset:
        1. Fileset Local if the file location is directly addressable from the engine
        2. Fileset FTP if the file(s) exist on a foreign (foreign to the engine) file system.
          1. If FTPS or SFTP needs to be used, you may need the Cloverleaf add-on to support Secured connections.
        3. You will need to provide (in the configuration) the directory where the file is located so Cloverleaf can search for the files.
        4. You will also need to set the timing of the directory Search as well as the number of record to retrieve with each read and the read timing.
        5. Be aware PDF files can be quite large and proper control over their arrival can assist on not overloading the engine. Even then, in a busy site/process the large messages could cause issues.
        6. Assuming only one PDF per file it is likely the PDFs are not encoded (if they are you do not need to do this) so you will need to provide a Tcl Proc at the IB Data TPS UPoC to encode each message Cloverleaf reads as Peter indicated.
      4. Routing will probably be Raw with either an Xlate or Tcl code 9I would favor an Xlate) wherein the encoded PDF is imbedded in a message (the Message/Event Type probably determined by the receiving system).
        1. Personally I would always use the appropriate components/sub-components needed as defined in the HL/7 Specification for the ED Data Type.
        2. Including the value ‘ED’ in the proper OBX field (I think that is OBX-2) if using the OBX segment.
      5. I am assuming the OB protocol will be something like TCP/IP. No need for anything special here normally.
        1. Peter makes a good point though about saving the content off in a decoded storage (like files) for trouble shooting purposes.
        2. I would recommend generating a unique MSH-10 in the OB message and using that value in the file name you use for troubleshooting so you can tie the specific PDF back to the message sent.

      Just keep in mind always that PDFs can be large (really large) and ever time a new copy exists, the engine is impacted.

      It would be good if you can get some information regarding what the average PDF size might be and also what the largest might be so you can pro-actively evaluate the best architecture to use in Cloverleaf.

      I may not have covered everything and given your current novice situation (that will change quickly) you may have questions regarding what I have presented or other questions.

      Please feel free to post your questions here. We all were novices once – no one is born knowing Integration or Cloverleaf.

      This forum is here to help you.

      If you want to you can email me directly and I will try to assist you.

      • This reply was modified 4 years, 9 months ago by Jim Kosloskey.

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

      • #114002
        Jim Kosloskey
        Participant

        Oh and you will probably need to specify a VRL for the IB message if using an Xlate.

        The VRL defined with one field of unlimited length.

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

    • #114077
      Jeff Dinsmore
      Participant

      There’s also the issue of populating the rest of the message.

      Where will you get the patient’s name/DOB/gender/MRN/encounter/etc ?  Does the message need to contain order codes/descriptions, order numbers, document IDs ?

      The system that’s producing the PDF files either has to encode all required info into the file names, generate an auxiliary file with that info, or better, a trigger message that carries all of that stuff.

      Jeff Dinsmore
      Chesapeake Regional Healthcare

    • #116003
      Scott Caldwell
      Participant

      This thread is a few months old, but hoping people are still active.  I am working on this exact issue, but not needing to actually imbed the PDF as it’s already been done.  My issue is I use a 3rd party tool to FTP down the file into a folder, Cloverleaf grabs the file but its not processing.  The file just disappears.  Nothing in the error log, and nothing other than notes that a file was found, opened & found EOF regarding the actual file being processed.

      Attached are the log & the file in question.

      I have run it through the Testing Tool and attached that as well.

      This is just a pass-through interface at this point, no TCL processing going on.  Its just picking up the file, and sending it through to its destination.

      Any help would be appreciated.  Thanks.

      Attachments:
      You must be logged in to view attached files.
      • #116005
        Scott Caldwell
        Participant

        Here are the other two files – hoping they’ll attach this time.

        Attachments:
        You must be logged in to view attached files.
Viewing 3 reply threads
  • You must be logged in to reply to this topic.

Forum Statistics

Registered Users
5,117
Forums
28
Topics
9,292
Replies
34,435
Topic Tags
286
Empty Topic Tags
10