63. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 4/5/2017 4:21:46 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

63.1 Files compared

# Location File Last Modified
1 C:\working_scrub\Unredacted\eHX Code Base\eHX_Bld2_Source Code_CIF_2017-02-14\NHIN_adapter\AdapterLIB\src\archive\java\gov\va\med\nhin\adapter\utils\datasharing\messaging\transceiver HL7DCLLPTransceiver.java Fri Feb 10 15:41:44 2017 UTC
2 eHX-CIF.zip\eHX-CIF\eHX Code Base\eHX_Bld2_Source Code_CIF_2017-02-14\NHIN_adapter\AdapterLIB\src\archive\java\gov\va\med\nhin\adapter\utils\datasharing\messaging\transceiver HL7DCLLPTransceiver.java Mon Apr 3 14:24:58 2017 UTC

63.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 3 514
Changed 2 10
Inserted 0 0
Removed 0 0

63.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

63.4 Active regular expressions

No regular expressions were active.

63.5 Comparison detail

  1   /* ------- ---------- ---------- ---------- ---------- ---------- -------
  2    * File Na me    : HL 7DCLLPTran sceiver.ja va
  3    * Authore d By  : sp awaradmin
  4    * Created  on   : Fe b 02, 2009
  5    * 
  6    * This is  copyright ed softwar e of the U nited Stat es Federal  Governmen t.   
  7    * Any use  must be a uthorized  by the
  8    * 
  9    *            Departm ent of Vet erans Affa irs
  10    *            Nationa l Health I nformation  Network -  (NHIN)
  11    *            
  12    *
  13    * Any un- authorized  use is st rictly pro hibited an d subject  to 
  14    * legal a ction.
  15    * 
  16    * Purpose       :
  17    * 
  18    * 
  19    * ------- ---------- ---------- ---------- ---------- ---------- ---------- -
  20    *                  M  o d i f i  c a t i o  n   H i s  t o r y
  21    * 
  22    * Date          :
  23    * Author        :
  24    * Purpose       : 
  25    * 
  26    * 
  27    * ------- ---------- ---------- ---------- ---------- ---------- ----------
  28    */
  29  
  30   package go v.va.med.n hin.adapte r.utils.da tasharing. messaging. transceive r;
  31  
  32   import jav a.io.FileI nputStream ;
  33   import jav a.io.IOExc eption;
  34   import jav a.io.Input Stream;
  35   import jav a.io.Outpu tStream;
  36   import jav a.util.Pro perties;
  37  
  38   public cla ss HL7DCLL PTransceiv er extends  SocketTra nsceiver
  39   {
  40           pr ivate stat ic final S tring STR_ CRLF = "\r \n";
  41           pr ivate stat ic final S tring STR_ CR = "\r";
  42           pr ivate stat ic final c har CR = ' \r';
  43           pr ivate stat ic final i nt PREFIX_ LENGTH = 3 ;
  44           pr ivate stat ic final S tring DATA _TERMINATO R = "\u001 B\u001B\u0 01B";
  45           pr ivate stat ic final S tring DATA _BEGIN_MAR KER = "DAT A PARAM=MP I\r\n";
  46           pr ivate int  msgCount;
  47  
  48           pu blic HL7DC LLPTransce iver()
  49           {
  50                    init (new Prope rties());
  51           }
  52  
  53           pu blic HL7DC LLPTransce iver(Prope rties p)
  54           {
  55                    init (p);
  56           }
  57  
  58           pr ivate void  init(Prop erties p)
  59           {
  60                    if(p  != null & & p instan ceof Prope rties)
  61                             servic ePropertie s = p;
  62                    else
  63                             servic ePropertie s = new Pr operties() ;
  64           }
  65  
  66           pu blic Strin g formatIn comingMess age(String  msg) thro ws Message LLPExcepti on
  67           {
  68                    int  count = 0;
  69                    int  marker = 0 ;
  70                    Stri ngBuffer r esult = ne w StringBu ffer();
  71                    if(( marker = m sg.indexOf (DATA_BEGI N_MARKER))  == -1)
  72                    {
  73                             // log ger.debug( "Bad msg:  " + msg);
  74                             throw  new Messag eMarkerExc eption("MP I Data Beg in marker  is not fou nd");
  75                    }
  76                    else
  77                             marker  += DATA_B EGIN_MARKE R.length() ;
  78                    whil e(marker <  msg.lengt h())
  79                    {
  80                             count  = Integer. parseInt(m sg.substri ng(marker,  marker +  PREFIX_LEN GTH));
  81                             if(cou nt > 0)
  82                             {
  83                                      String s s = msg.su bstring(ma rker + PRE FIX_LENGTH , marker +  PREFIX_LE NGTH + cou nt);
  84                                      if(!ss.e quals(DATA _TERMINATO R))
  85                                      {
  86                                               result.app end(ss);
  87                                      }
  88                             }
  89                             else
  90                             {
  91                                      if(resul t.charAt(r esult.leng th() - 1)  != CR)
  92                                      {
  93                                               result.app end(CR);
  94                                      }
  95                             }
  96                             marker  = marker  + PREFIX_L ENGTH + co unt;
  97                    }
  98                    retu rn result. toString() ;
  99           }
  100  
  101           pr ivate Stri ng formatO utgoingMes sage(Strin g msg) thr ows Messag eLLPExcept ion
  102           {
  103                    Stri ng[] resul ts = new S tring[4];
  104                    Stri ng[] parts  = msg.spl it(STR_CR) ;
  105                    if(p arts.lengt h != 3)
  106                             throw  new Messag eLLPExcept ion("Query  has to ha ve exactly  3 segment s.");
  107  
  108                    for( int i = 0;  i < parts .length; i ++)
  109                             result s[i] = par ts[i];
  110                    resu lts[3] = D ATA_TERMIN ATOR;
  111                    Stri ngBuffer m essage = n ew StringB uffer();
  112                    for( int i = 0;  i < resul ts.length;  i++)
  113                    {
  114                             String  prefix =  String.val ueOf(resul ts[i].leng th());
  115                             while( prefix.len gth() < PR EFIX_LENGT H)
  116                             {
  117                                      prefix =  "0" + pre fix;
  118                             }
  119                             messag e.append(p refix).app end(result s[i]);
  120                    }
  121                    retu rn message .toString( );
  122           }
  123  
  124           pr otected vo id sendCom mand(Strin g command,  OutputStr eam outStr eam) throw s MessageL LPExceptio n
  125           {
  126                    send (command,  outStream) ;
  127           }
  128  
  129           pr otected vo id sendDat a(String d ata, Outpu tStream ou tStream) t hrows Mess ageLLPExce ption
  130           {
  131                    Stri ng message  = formatO utgoingMes sage(data) ;
  132                    send (message,  outStream) ;
  133           }
  134  
  135           pr otected St ring recei veCommandR esponse(In putStream  inStream)  throws Mes sageLLPExc eption
  136           {
  137                    retu rn receive (inStream,  STR_CRLF,  0);
  138           }
  139  
  140           pr otected St ring recei veData(Inp utStream i nStream) t hrows Mess ageLLPExce ption
  141           {
  142                    Stri ng message  = this.re ceive(inSt ream, DATA _TERMINATO R, 0);
  143                    retu rn(formatI ncomingMes sage(messa ge));
  144           }
  145  
  146           pr otected St ring sendM essage(Str ing msg, I nputStream  ins, Outp utStream o uts) throw s MessageL LPExceptio n
  147           {
  148                    Stri ng ss = nu ll;
  149                    Stri ng data =  null;
  150                    send Command("H ELO" + STR _CRLF, out s);
  151  
  152                    ss =  receiveCo mmandRespo nse(ins);
  153  
  154                    if(s s.startsWi th("2"))
  155                    {
  156                             sendCo mmand("DAT A PARAM=MP I" + STR_C RLF, outs) ;
  157                             sendDa ta(msg, ou ts);
  158                             ss = r eceiveComm andRespons e(ins);
  159                             sendCo mmand("TUR N" + STR_C RLF, outs) ;
  160                             // ss  = receiveC ommandResp onse(ins);
  161                             data =  receiveDa ta(ins);
  162                             sendCo mmand("200  OK" + STR _CRLF, out s);
  163                             sendCo mmand("QUI T" + STR_C RLF, outs) ;
  164                    }
  165                    else
  166                    {
  167                             sendCo mmand("QUI T" + STR_C RLF, outs) ;
  168                             throw  new Messag eLLPExcept ion("Error  code " +  ss + " rec eived from  MPI.");
  169                    }
  170                    retu rn data;
  171           }
  172  
  173           pu blic Objec t transcei ve(Object  payload) t hrows Mess ageLLPExce ption, IOE xception {
  174                    msgC ount++;
  175                    Stri ng result  = "";
  176                    int  tries = 4;
  177                    int  tried = 0;
  178                    Inpu tStream is  = null;
  179                    Outp utStream o s = null;
  180  
  181                    whil e(true)
  182                    {
  183                             connec t();
  184                             try
  185                             {
  186                                      tried++;
  187                                      is = get InputStrea m();
  188                                      os = get OutputStre am();
  189                                      result =  sendMessa ge((String ) payload,  is, os);
  190                                      return r esult;
  191                             }
  192                             catch( MessageMar kerExcepti on e)
  193                             {
  194                                      if(tried  >= tries)
  195                                      {
  196                                               // e.print StackTrace ();
  197                                               throw new  MessageLLP Exception( "MPI Data  Begin Mark er is not  found, tri ed " + tri ed + " tim es ... ",  e);
  198                                      }
  199                             }
  200                             finall y
  201                             {
  202                                      if(is !=  null)
  203                                      {
  204                                               safeClose( is);
  205                                      }
  206                                      if(os !=  null)
  207                                      {
  208                                               safeClose( os);
  209                                      }
  210                                      disconne ct();
  211                             }
  212                    }
  213           }
  214  
  215           pu blic stati c void saf eClose(Inp utStream f is) {
  216                    if ( fis != nul l) {
  217                             try {
  218                                      fis.clos e();
  219                             } catc h (IOExcep tion e) {
  220                                      e.printS tackTrace( );
  221                             }
  222                    }
  223           }
  224  
  225           pu blic stati c void saf eClose(Out putStream  fos) {
  226                    if ( fos != nul l) {
  227                             try {
  228                                      fos.clos e();
  229                             } catc h (IOExcep tion e) {
  230                                      e.printS tackTrace( );
  231                             }
  232                    }
  233           }
  234  
  235           pu blic stati c void mai n(String[]  args) thr ows Except ion
  236           {
  237                    Stri ng mpiQuer y = "MSH|^ ~\\&|MPI_L OAD|200M|M PI-ICN||20 0502021050 53-0500||V QQ^Q02|" +  System.cu rrentTimeM illis() +  "|T|2.4||| AL|NE|\r"  + "VTQ|" +  System.cu rrentTimeM illis() +  "|T|VTQ_PI D_ICN_NO_L OAD|ICN|@0 0108.1^EQ^ CHDRKCCAAD ^AND~@0010 8.2^EQ^MAN ADC^AND~@0 0111^EQ^M^ AND~@00122 ^EQ^666010 004^AND~@0 0110^EQ^19 550114\r"  + "RDF|8|@ 00108.2^ST ^30~@00108 .3^ST^16~@ 00108.1^ST ^30~@00122 ^ST^9~@001 10^ST^8~@0 0105^ST^19 ~@00756^ST ^5~@00169^ ST^999\r";
  238                    Stri ng strTest Output = " ";
  239  
  240                    Prop erties ser viceProper ties = new  Propertie s();
  241                     /*  IP             test  IP                 prod */
  242                     servicePro perties.se tProperty( SocketTran sceiver.PR OP_HOST, " IP           ");
  243                    /* 1 5500 test  5500 prod  */
  244                    serv icePropert ies.setPro perty(Sock etTranscei ver.PROP_P ORT, Integ er.toStrin g(15500));
  245                    serv icePropert ies.setPro perty(Sock etTranscei ver.PROP_T OUT, Long. toString(3 00000L));
  246                     servicePro perties.se tProperty( SocketTran sceiver.PR OP_SFAC, " 200HD. D N
S           URL          ");
  247                     /* prod=MP I-AUSTIN URL          , test=TLM PI. D N
S           URL            */
  248                     servicePro perties.se tProperty( SocketTran sceiver.PR OP_RFAC, " TLMPI. D N
S           URL          ");
  249                    serv icePropert ies.setPro perty(Sock etTranscei ver.PROP_L ATT, "NT") ;
  250                    HL7D CLLPTransc eiver tr =  new HL7DC LLPTransce iver(servi ceProperti es);
  251                    long  st;
  252                    Stri ng queryRe sults;
  253                    Syst em.out.pri ntln(mpiQu ery);
  254                    st =  System.cu rrentTimeM illis();
  255   //               quer yResults =  (String)  tr.transce ive(mpiQue ry);
  256   //               tr.g etOutputSt ream();
  257   //               strT estOutput  = tr.getOu tputStream ().toStrin g();
  258   //
  259   //               Syst em.out.pri ntln("\n"  + queryRes ults);
  260   //               Syst em.out.pri ntln("Outp ut String:  " + strTe stOutput);
  261           }
  262   }