17. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 6/18/2018 3:36:59 PM Eastern 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.

17.1 Files compared

# Location File Last Modified
1 CTT_DM2_v7.zip\CTT_ISAAC\hl7-messaging\src\main\java\gov\vha\isaac\ochre\deployment\publish HL7Sender.java Tue Jun 12 16:42:14 2018 UTC
2 CTT_DM2_v7.zip\CTT_ISAAC\hl7-messaging\src\main\java\gov\vha\isaac\ochre\deployment\publish HL7Sender.java Thu Jun 14 16:12:11 2018 UTC

17.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 606
Changed 1 2
Inserted 0 0
Removed 0 0

17.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

17.4 Active regular expressions

No regular expressions were active.

17.5 Comparison detail

  1   /**
  2    * Copyrig ht Notice
  3    *
  4    * This is  a work of  the U.S.  Government  and is no t subject  to copyrig ht
  5    * protect ion in the  United St ates. Fore ign copyri ghts may a pply.
  6    *
  7    * License d under th e Apache L icense, Ve rsion 2.0  (the "Lice nse");
  8    * you may  not use t his file e xcept in c ompliance  with the L icense.
  9    * You may  obtain a  copy of th e License  at
  10    *
  11    * http:// www.apache .org/licen ses/LICENS E-2.0
  12    *
  13    * Unless  required b y applicab le law or  agreed to  in writing , software
  14    * distrib uted under  the Licen se is dist ributed on  an "AS IS " BASIS,
  15    * WITHOUT  WARRANTIE S OR CONDI TIONS OF A NY KIND, e ither expr ess or imp lied.
  16    * See the  License f or the spe cific lang uage gover ning permi ssions and
  17    * limitat ions under  the Licen se.
  18    */
  19   package go v.vha.isaa c.ochre.de ployment.p ublish;
  20  
  21   import org .apache.lo gging.log4 j.LogManag er;
  22   import org .apache.lo gging.log4 j.Logger;
  23   import ca. uhn.hl7v2. model.Data TypeExcept ion;
  24   import ca. uhn.hl7v2. model.v24. message.MF N_M01;
  25   import ca. uhn.hl7v2. model.v24. message.MF Q_M01;
  26   import ca. uhn.hl7v2. model.v24. segment.MS H;
  27   import gov .vha.isaac .ochre.acc ess.maint. deployment .dto.Publi shMessage;
  28   import gov .vha.isaac .ochre.acc ess.maint. deployment .dto.Site;
  29   import gov .vha.isaac .ochre.acc ess.maint. messaging. hl7.Messag eDispatche r;
  30   import gov .vha.isaac .ochre.acc ess.maint. messaging. hl7.factor y.Business WareMessag eDispatche r;
  31   import gov .vha.isaac .ochre.api .LookupSer vice;
  32   import gov .vha.isaac .ochre.dep loyment.li stener.HL7 ResponseLi stener;
  33   import gov .vha.isaac .ochre.dep loyment.li stener.HL7 ResponseRe ceiveListe ner;
  34   import gov .vha.isaac .ochre.ser vices.dto. publish.Ap plicationP roperties;
  35   import gov .vha.isaac .ochre.ser vices.dto. publish.Me ssagePrope rties;
  36   import gov .vha.isaac .ochre.ser vices.exce ption.STSE xception;
  37  
  38   /**
  39    * The <co de>HL7Send er</code>  class mana ges the co nversion f rom the de ployment
  40    * server  database t o HL7 and  transmits  the HL7 me ssage.
  41    * <p>
  42    * The <co de>HL7Send er</code>  class is t he main in terface fo r the enti re process
  43    * of crea ting HL7 m essages to  be sent t o the Vitr ia Interfa ce Engine,  and then
  44    * on to t he Master  File Serve r (MFS) in  the VistA  environme nt.
  45    * <p>
  46    *
  47    * @author   PII
  48    */
  49  
  50   public cla ss HL7Send er
  51   {
  52           pr ivate stat ic Logger  LOG = LogM anager.get Logger(HL7 Sender.cla ss);
  53  
  54           pr ivate stat ic Message Dispatcher  dispatche r = new Bu sinessWare MessageDis patcher();
  55  
  56           pr ivate stat ic final S tring UPDA TE_MESSAGE _TYPE = "U PDATE";
  57           pr ivate stat ic final S tring QUER Y_MESSAGE_ TYPE = "QU ERY";
  58  
  59           pr ivate stat ic boolean  useInterf aceEngine;
  60  
  61           pr ivate Stri ng hl7Mess age_;
  62           pr ivate Publ ishMessage  publishMe ssage_;
  63           pr ivate Appl icationPro perties ap plicationP roperties_ ;
  64           pr ivate Mess agePropert ies messag ePropertie s_;
  65  
  66           /* *
  67            *  Send the  HL7 Messag e to the s ites in th e site lis t. This me thod detec ts
  68            *  the type  of message  and calls  the corre ct private  method to  actually  send
  69            *  the messa ge to the  sites.
  70            *  
  71            *  @param hl 7UpdateMes sage
  72            *  @param si teList
  73            *  @return L ist of mes sage IDs
  74            *  @throws S TSExceptio n
  75            * /
  76  
  77           pu blic HL7Se nder(Strin g hl7Messa ge, Publis hMessage p ublishMess age, Appli cationProp erties app licationPr operties,
  78                             Messag ePropertie s messageP roperties)  {
  79  
  80                    hl7M essage_ =  hl7Message ;
  81                    publ ishMessage _ = publis hMessage;
  82                    appl icationPro perties_ =  applicati onProperti es;
  83                    mess agePropert ies_ = mes sageProper ties;
  84           }
  85  
  86           /* *
  87            *  returns t rue, if a  message wa s sent tha t we expec t a respon se from.   False, if  we should  not expect  a respons e, 
  88            *  due to, f or example , the user InterfaceE ngine flag  being fal se, or som e error ha ppening du ring the s end that p revented t he send.
  89            * /
  90           pu blic boole an send(HL 7ResponseR eceiveList ener notif yOnRespons eReceived)  throws ST SException  {
  91                    useI nterfaceEn gine = get InterfaceE ngineUsage (Boolean.t oString(ap plicationP roperties_ .getUseInt erfaceEngi ne()));
  92                    
  93                    if ( useInterfa ceEngine)  {
  94                             String  messageTy pe = Messa geTypeIden tifier
  95                                               .getMessag eType(Mess ageTypeIde ntifier.ge tMessageHe ader(hl7Me ssage_));
  96                             if (Me ssageTypeI dentifier. MFN_TYPE.e quals(mess ageType))  {
  97                                      // MFN M 01: Master  file not  otherwise  specified
  98                                      MFN_M01  message =  HL7SubsetU pdateGener ator.getMe ssageMFN(h l7Message_ );
  99                                      sendHL7U pdateMessa ge(message , publishM essage_, a pplication Properties _, notifyO nResponseR eceived);
  100                             } else  if (Messa geTypeIden tifier.MFQ _TYPE.equa ls(message Type)) {
  101                                      // MFQ M 01: Query  for master  file reco rd
  102                                      MFQ_M01  message =  HL7Request Generator. getRequest Message(hl 7Message_) ;
  103                                      sendHL7R equestMess age(messag e, publish Message_,  applicatio nPropertie s_, messag ePropertie s_, notify OnResponse Received);
  104                             } else  {
  105                                      LOG.erro r("Unknown  message t ype.  Mess age header : {} ",
  106                                                       Me ssageTypeI dentifier. getMessage Header(hl7 Message_)) ;
  107                                      throw ne w STSExcep tion("Unko wn message  type. " +  MessageTy peIdentifi er.getMess ageHeader( hl7Message _));
  108                             } 
  109                             
  110                             //TODO , perhaps,  in the fu ture, we m ay have ca ses where  false is t he appropr iate value  to return  for certa in message s....
  111                             return  true;
  112                    } el se {
  113                             LOG.in fo("No Emu lator, ple ase set us eInterface Engine to  true.");
  114                             return  false;
  115                    }
  116           }
  117  
  118           /*
  119            *  Send the  HL7 Update  Message t o the spec ified topi cs. A new  message id  is
  120            *  generated  for each  message.
  121            *
  122            *  @param me ssage mess age object  of type M FN_M01 tha t needs to  be sent t o
  123            *  the sites
  124            *  
  125            *  @param si te list of  receiving  sites
  126            *
  127            *  @return m essage Id  of the mes sages that  have been  sent to t he sites.
  128            *
  129            *  @throws S TSExceptio n
  130            * /
  131           pr ivate sync hronized s tatic void  sendHL7Up dateMessag e(MFN_M01  message, P ublishMess age publis hMessage,
  132                             Applic ationPrope rties appl icationPro perties, H L7Response ReceiveLis tener noti fyOnRespon seReceived ) throws S TSExceptio n {
  133                    try  {
  134                             // ins ert the to pic and me ssage id
  135                             MSH ms h = messag e.getMSH() ;
  136                             Site s ite = publ ishMessage .getSite() ;
  137  
  138                             String  sendingFa cility = a pplication Properties .getSendin gFacilityN amespaceId ();
  139                             msh.ge tSendingFa cility().g etNamespac eID().setV alue(sendi ngFacility );
  140                             msh.ge tReceiving Facility() .getNamesp aceID().se tValue(sit e.getVaSit eId());
  141                             msh.ge tMessageCo ntrolID(). setValue(( (Long) pub lishMessag e.getMessa geId()).to String());
  142  
  143                             // ins ert the me ssage type  for the t opic
  144                             msh.ge tProcessin gID().getP rocessingI D().setVal ue(site.ge tMessageTy pe());
  145                             LOG.in fo("Use in terface en gine is se t to " + u seInterfac eEngine +  " and appl icationPro perties.ge tUseInterf aceEngine( ) is " + a pplication Properties .getUseInt erfaceEngi ne());
  146                             // Sen d the HL7  message
  147                             if (ap plicationP roperties. getUseInte rfaceEngin e()) {
  148                                      LookupSe rvice.get( ).getServi ce(HL7Resp onseListen er.class). registerLi stener(pub lishMessag e.getMessa geId(), no tifyOnResp onseReceiv ed);
  149                                      dispatch er.send(me ssage, app licationPr operties);
  150                             } else  {
  151                                      // TODO:  find code  to re-imp lement if  necessary.  Leaving
  152                                      // this  out for no w. and log ging error .
  153                                      /*
  154                                       * Strin g url =
  155                                       * Appli cationProp ertyReader .getApplic ationPrope rty(
  156                                       * "emul ator.url") ; if (url  != null) {
  157                                       * Emula torDelegat e.sendMess age(HL7Sub setUpdateG enerator.
  158                                       * getMe ssage(mess age), url) ; }
  159                                       */
  160                                      LOG.info ("No Emula tor, pleas e set useI nterfaceEn gine to tr ue.");
  161                             }
  162  
  163                             getDep loymentSta tusMessage (HL7Subset UpdateGene rator.getM essage(mes sage), use InterfaceE ngine, sit e,
  164                                               msh.getMes sageContro lID().toSt ring(), ms h.getProce ssingID(). getProcess ingID().ge tValue(),
  165                                               UPDATE_MES SAGE_TYPE) ;
  166  
  167                    } ca tch (DataT ypeExcepti on e) {
  168                             LOG.er ror("Excep tion when  setting to pic in mes sage.", e) ;
  169                             throw  new STSExc eption("Ex ception wh en setting  topic in  message.",  e);
  170                    } ca tch (Runti meExceptio n e) {
  171                             String  errorMess age = "Exc eption whe n attempti ng to send  the messa ge.  Inter face Engin e may not  be respond ing.";
  172                             LOG.er ror(errorM essage);
  173                             throw  new STSExc eption(err orMessage,  e);
  174                    } ca tch (Excep tion e) {
  175                             LOG.er ror("Excep tion in fi nding mess age type",  e);
  176                             throw  new STSExc eption("Ex ception in  finding m essage typ e", e);
  177                    }
  178           }
  179  
  180           /*
  181            *  Send the  HL7 Reques t Message  to the spe cified top ics. A new  message i d is
  182            *  generated  for each  message.
  183            *
  184            *  @param me ssage mess age object  of type M FQ_M01 tha t needs to  be sent t o
  185            *  the sites
  186            *  
  187            *  @param si te list of  receiving  sites
  188            *
  189            *  @return m essage Id  of the mes sages that  have been  sent to t he sites.
  190            *
  191            *  @throws V ETSPublish erExceptio n
  192            *  
  193            *  @throws H L7Exceptio n
  194            * /
  195           pr ivate sync hronized s tatic void  sendHL7Re questMessa ge(MFQ_M01  message,  PublishMes sage publi shMessage,
  196                             Applic ationPrope rties appl icationPro perties, M essageProp erties mes sageProper ties, HL7R esponseRec eiveListen er notifyO nResponseR eceived)
  197                             throws  STSExcept ion, STSEx ception {
  198                    try  {
  199  
  200                             // ins ert the to pic and me ssage id
  201                             MSH ms h = messag e.getMSH() ;
  202                             Site s ite = publ ishMessage .getSite() ;
  203                             String  sendingFa cility = a pplication Properties .getSendin gFacilityN amespaceId ();
  204                             LOG.in fo("sendin gFacility:  {}", send ingFacilit y);
  205  
  206                             msh.ge tSendingFa cility().g etNamespac eID().setV alue(sendi ngFacility );
  207                             LOG.in fo("getSen dingFacili ty().getNa mespaceID( ).setValue : {}", sen dingFacili ty);
  208  
  209                             msh.ge tReceiving Facility() .getNamesp aceID().se tValue(sit e.getVaSit eId());
  210                             LOG.in fo("getRec eivingFaci lity().get NamespaceI D().setVal ue: {}", s ite.getVaS iteId());
  211  
  212                             msh.ge tMessageCo ntrolID(). setValue(( (Long) pub lishMessag e.getMessa geId()).to String());
  213                             LOG.in fo("getMes sageContro lID().setV alue: {}",  publishMe ssage.getM essageId() );
  214  
  215                             // ins ert the me ssage type  for the t opic
  216                             msh.ge tProcessin gID().getP rocessingI D().setVal ue(site.ge tMessageTy pe());
  217                             LOG.in fo("getPro cessingID( ).getProce ssingID(). setValue:  {}", site. getMessage Type());
  218  
  219                             LOG.in fo("Messag e before c alling dis patcher");
  220                             LOG.in fo(message .toString( ));
  221  
  222                             // Sen d the HL7  message
  223                             if (us eInterface Engine) {
  224                                      LOG.info ("calling  dispatcher  to send m essage");
  225                                      LookupSe rvice.get( ).getServi ce(HL7Resp onseListen er.class). registerLi stener(pub lishMessag e.getMessa geId(), no tifyOnResp onseReceiv ed);
  226                                      dispatch er.send(me ssage, app licationPr operties);
  227                             } else  {
  228                                      // TODO:  find code  to re-imp lement if  necessary.  Leaving
  229                                      // this  out for no w and logg ing error.
  230                                      /*
  231                                       * Strin g url =
  232                                       * Appli cationProp ertyReader .getApplic ationPrope rty(
  233                                       * "emul ator.url") ; if (url  != null) {
  234                                       * Emula torDelegat e.sendMess age(HL7Sub setUpdateG enerator.
  235                                       * getMe ssage(mess age), url) ; }
  236                                       */
  237                                      LOG.erro r("No Emul ator, plea se set use InterfaceE ngine to t rue.");
  238                             }
  239  
  240                             getDep loymentSta tusMessage (HL7Reques tGenerator .getReques tMessage(m essage), u seInterfac eEngine, s ite,
  241                                               msh.getMes sageContro lID().toSt ring(), ms h.getProce ssingID(). getProcess ingID().ge tValue(),
  242                                               QUERY_MESS AGE_TYPE);
  243  
  244                    } ca tch (DataT ypeExcepti on e) {
  245                             LOG.er ror("Excep tion in se tting topi c in messa ge.", e);
  246                             throw  new STSExc eption("Ex ception ge nerating m essage.",  e);
  247                    } ca tch (Runti meExceptio n e) {
  248                             String  errorMess age = "Exc eption whe n attempti ng to send  the messa ge.  Inter face Engin e may not  be respond ing.";
  249                             LOG.er ror(errorM essage);
  250                             throw  new STSExc eption(err orMessage,  e);
  251                    } ca tch (Excep tion e) {
  252                             LOG.er ror("Excep tion in fi nding mess age type",  e);
  253                             throw  new STSExc eption("Ex ception in  finding m essage typ e", e);
  254                    }
  255           }
  256  
  257           pr ivate stat ic void ge tDeploymen tStatusMes sage(Strin g message,  boolean u seInterfac eEngine, S ite site,
  258                             String  messageId , String m essageProc essingType , String m essageType ) {
  259  
  260                    Stri ngBuilder  deployment Status = n ew StringB uilder();
  261                    depl oymentStat us.append( "Site: "). append(sit e.getName( )).append( "; Message  ID: ").ap pend(messa geId);
  262                    depl oymentStat us.append( "; Message  Type: "). append(mes sageProces singType);
  263                    depl oymentStat us.append( "; Paramet er useInte rfaceEngin e is set t o '");
  264                    depl oymentStat us.append( useInterfa ceEngine). append("'  so a messa ge ");
  265                    depl oymentStat us.append( useInterfa ceEngine = = true ? " was " : "W AS NOT ");
  266                    depl oymentStat us.append( "deployed  to ").appe nd(site.ge tName()).a ppend(".") ;
  267                    LOG. info(deplo ymentStatu s.toString ());
  268  
  269                    int  mshBeginIn dex = mess age.indexO f("MSH");
  270  
  271                    int  mshEndInde x = 0;
  272                    if ( messageTyp e.equals(U PDATE_MESS AGE_TYPE))  {
  273                             mshEnd Index = me ssage.inde xOf("MFI") ;
  274                    } el se {
  275                             mshEnd Index = me ssage.inde xOf("QRD") ;
  276                    }
  277  
  278                    Stri ng message Header = m essage.sub string(msh BeginIndex , mshEndIn dex);
  279  
  280                    LOG. info("Mess age header : {}", mes sageHeader );
  281  
  282                    LOG. info("Full  message:  \n{}", mes sage);
  283           }
  284  
  285           /*
  286            *  Determine  whether w e will be  using the  Interface  Engine whe n the mess age
  287            *  is sent.
  288            *  
  289            *  @return b oolean
  290            *  
  291            *  @throws S TSExceptio n
  292            * /
  293           pr ivate stat ic boolean  getInterf aceEngineU sage(Strin g useIE) t hrows STSE xception {
  294  
  295                    // d efault to  not use In terface En gine
  296                    bool ean ieUsag e = false;
  297                    if ( "true".equ alsIgnoreC ase(useIE)  || "false ".equalsIg noreCase(u seIE)) {
  298                             ieUsag e = Boolea n.valueOf( useIE).boo leanValue( );
  299                    } el se {
  300                             throw  new STSExc eption("us eInterface Engine par ameter mus t be 'true ' or 'fals e'.");
  301                    }
  302                    retu rn ieUsage ;
  303           }
  304   }