Announcement

Collapse
No announcement yet.

ZPD Segment PDF and Encoded Data

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ZPD Segment PDF and Encoded Data

    I have a ZPD 3.3 segment that contains uuencoded data (PDF via ZPD 3.2)... What is my best option on getting this data uudecoded and saved to the file system?

    am I going to have to drop to a shell in the transformer (ie. java.lang.Runtime().exec("uudecode ..... or is there a better way to go about this...?

    Any clues to keep me hacking would be appreciated...

    Thank you.

    encoded data is something like:

    begin 644 wav.dat

    %#DEF~~

    end


  • #2
    Re: ZPD Segment PDF and Encoded Data

    If you can find an open-source java class, you can invoke it for the decode. You could create your own java class too

    Comment


    • #3
      Re: ZPD Segment PDF and Encoded Data

      Yes, find any UUEncoder as a Jar (or create one) and drop it into the custom folder. (I.e. http://www.xmlserv.com/API/com/xmlserv/util/Coder.html). You can then access it from the transformer:

      Packages.classname

      -Chris
      Chris Lang

      Comment


      • #4
        Re: ZPD Segment PDF and Encoded Data

        ok, gotcha...

        I am hacking through this to understand it and port the concept... (i will tackle this through mirth after I get the mechanics down cold).

        My problem (agile story) is this:

        I have an application specific segment ZPD:

        ZPD-2: PDF (data type)
        ZPD-3-1: 89448 (size of encoded data)
        ZPD-3-2: 73272 (size of decoded data)
        ZPD-3-3: begin 644 WAV.DAT blehblehbleh end (encoded pdf)

        Now here is what I have come to understand:

        I dropped the encoded segment to a file, which the size matches 89448 bytes...
        I then have to strip the hl7 escape chars and encoding chars out of the segment because the hl7 standard does not allow un-printable characters.
        Then I have to uudecode the segment.

        My problem is escaping the non-printable and hl7 escape chars... In all attempts to strip these, I have come up either long or short with the resultant byte size for CRC (73272)... The uudecode works out, so the structure is intact (BEGIN mode file END), but the pdf is corrupt. The pdf through a hex editor resembles a pdf.

        My request is this: Does anybody have any perl/ruby/c#/java code to do this so I can take it appart to understand it (then port it to a JAVA class of my own)?

        Here is my class in java (give or take a few hundred attempts):

        Code:
        import java.io.BufferedReader ;
        import java.io.FileReader;
        import java.io.IOException;
        
        public class Replace {
        
            /**
             * @param args
             */
            public static void main(String args[]) {
               
                String record = null;
                int recCount = 0;
        
                try {
        
               FileReader fr = new FileReader("gar.dat"«»);
                   BufferedReader br = new BufferedReader(fr);
        
                   record = new String();
                   while ((record = br.readLine()) != null) {
                      recCount++;
                      //String gar = br.;
                      //String newrecord = record.replaceAll("\\\\\\\\X0D\\\\\\\\\\\\\\\\X0A\\\\\\\\M", "\\nM"«»);
                      String newrecord = record.replaceAll("\\\\\\\\X0D\\\\\\\\\\\\\\\\X0A\\\\\\\\", "\\n"«»);
                     
                      //newrecord = newrecord.replaceAll("\\\\\\\\X0A", ""«»);
                      //newrecord = newrecord.replaceAll("\\\\\\\\M", "\\nM" );
                      //newrecord = newrecord.replaceAll("\\\\^", "^"«»);
                      //newrecord = newrecord.replaceAll("\\\\\\\\~", "~"«»);
                      //newrecord = newrecord.replaceAll("\\\\\\\\&", "&"«»);
                      //newrecord = newrecord.replaceAll("end", "\\nend"«»);
                      newrecord = newrecord.replaceAll ("\\\\\\\\", ""«»);
                      newrecord = newrecord.replaceAll("  ", ""«»);
        
                      //System.out.println(recCount + ": " + record);
                      System.out.println (newrecord);
                   }
        
                } catch (IOException e) {
                   // catch possible io errors from readLine()
                   System.out.println("Uh oh, got an IOException error!"«»);
                   e.printStackTrace();
                }
        
            }
        
        
        }

        Comment


        • #5
          Re: ZPD Segment PDF and Encoded Data

          I got it, woot...



          Code:
          /* Rip binary stuff out of hl7 messages */
          /* Ron Sweeney 2007 */
          
          /* Thanks Marc Sturm @ STC-Users */
          
          import java.io.BufferedReader;
          import java.io.FileReader;
          import java.io.IOException;
          import java.io.*;
          
          public class Replace {
          
              /**
               * @param args
               */
              public static void main(String args[]) {
                 
                  String record = null;
                  int recCount = 0;
          	   int fromIndex;
          	    int len;
          	    boolean stop;
          	
          	    String[][] CODES = new String[][]
          	    {
          	        {"\\\\F\\\\","|"},
          	        {"\\\\S\\\\","^"},
          	        {"\\\\T\\\\","&"},
          	        {"\\\\R\\\\","~"},
          	        {"\\\\E\\\\","\\\\"},
          	        {"\\\\X0D\\\\","\\r"},
          	        {"\\\\X0A\\\\","\\n"}
          	    };
          	
          
                  try {
          
                 FileReader fr = new FileReader("gar.dat"«»);
                    // StringBuffer content = new StringBuffer(fr);
          		BufferedReader br = new BufferedReader(fr);
          
          		String gar = new String();
           while ((gar = br.readLine()) != null) {
          	
          	StringBuffer content = new StringBuffer(gar);
                     stop = true;
          		            char[] ca;
          		            for(int i=0;i<content.length();i++) {
          		                ca = new char[3];
          		                char c = content.charAt(i); 
          		                if(c=='\\\\') {
          		                    content.getChars(i,i+3,ca,0);
          		                    boolean skip = false;
          		                    for(int j=0;j<5;j++) {
          		                        if(new String(ca).equals(CODES[j][0])) {
          		                            content.replace(i,i+CODES[j][0].length(),CODES[j][1]);
          		                            skip = true;
          		                            break;
          		                        }
          		                    }
          		                    if(!skip) {
          		                        ca = new char[5];
          		                        content.getChars(i,i+5,ca,0);
          		                        for(int j=5;j<7;j++) {
          		                            if(new String(ca).equals(CODES[j][0])) {
          		                                content.replace(i,i+CODES[j][0].length(),CODES[j][1]);
          		                                break;
          		                            }
          		                        }
          		                    }
          		                }
          		 
                     }
          		System.out.println(content);
          
          }
          
                  } catch (IOException e) {
                     // catch possible io errors from readLine()
                     System.out.println("Uh oh, got an IOException error!"«»);
                     e.printStackTrace();
                  }
          
                  //BufferedReader br = new BufferedReader(fr);
          		
              }
          
          
          }

          Comment

          Working...
          X
          😀
          🥰
          🤢
          😎
          😡
          👍
          👎