390. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 12/5/2017 12:06:50 PM Central Standard 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.

390.1 Files compared

# Location File Last Modified
1 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\VistaImagingDataSourceProvider\main\src\java\gov\va\med\imaging\protocol\vista VistaImagingParser.java Mon Dec 4 21:35:16 2017 UTC
2 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\VistaImagingDataSourceProvider\main\src\java\gov\va\med\imaging\protocol\vista VistaImagingParser.java Mon Dec 4 22:06:39 2017 UTC

390.2 Comparison summary

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

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

390.4 Active regular expressions

No regular expressions were active.

390.5 Comparison detail

  1   /**
  2    * 
  3    */
  4   package go v.va.med.i maging.pro tocol.vist a;
  5  
  6   import jav a.util.Arr ayList;
  7   import jav a.util.Ite rator;
  8   import jav a.util.Lis t;
  9   import org .apache.lo gging.log4 j.LogManag er;
  10   import org .apache.lo gging.log4 j.Logger;
  11  
  12   /**
  13    * Parse t he lines r ead from a  Vista int o a hierar chy as def ined by th e tag
  14    * delimit er keys. T he first l ine is ski pped. Exam ple: lines  = 8 NEXT_ STUDY||712
  15    * STUDY_I EN|712 STU DY_PAT|101 1|92171036 63V710366| IMAGPATIEN T1011,1011
  16    * NEXT_SE RIES SERIE S_IEN|712  NEXT_IMAGE  IMAGE_IEN |713
  17    * IMAGE_I NFO|B2^713 ^\\isw-wer felj-lt\im age1$\DM\0 0\07\DM000 713.TGA^\\ isw-werfel j-lt\image 1$\DM\00\0 7\DM000713 .ABS^04060 0-28
  18    * CHEST S INGLE
  19    * VIEW^30 00406.1349 ^3^CR^04/0 6/2000^^M^ A^^^1^1^SL C^^^1011^I MAGPATIENT 1011,1011^ CLIN^^^^
  20    * and ont ologyDelim iterKeys =  NEXT_STUD Y, NEXT_SE RIES, NEXT _IMAGE
  21    * 
  22    * would r eturn a li st: Parsed VistaLine  with key=" NEXT_STUDY " and valu es="",
  23    * "712" a nd propert ies: Parse dVistaLine  with key= "STUDY_IEN " and valu es="712"
  24    * ParsedV istaLine w ith key="S TUDY_PAT"  and values ="1011", " 9217103663 V710366",
  25    * IMAGPAT IENT1011,1 011 and ch ildren: Pa rsedVistaL ine with k ey="NEXT_S ERIES" and
  26    * values=  and prope rties: Par sedVistaLi ne with ke y="SERIES_ IEN" and
  27    * values= "712" and  children:  ParsedVist aLine with  key="NEXT _IMAGE" an d values=
  28    * and pro perties: P arsedVista Line with  key="IMAGE _IEN" and  values="71 3"
  29    * ParsedV istaLine w ith key="I MAGE_INFO"  and
  30    * values= "B2^713^\\ isw-werfel j-lt\image 1$\DM\00\0 7\DM000713 .TGA^\\isw -werfelj-l t\image1$\ DM\00\07\D M000713.AB S^040600-2 8
  31    * CHEST S INGLE
  32    * VIEW^30 00406.1349 ^3^CR^04/0 6/2000^^M^ A^^^1^1^SL C^^^1011^I MAGPATIENT 1011,1011^ CLIN^^^^"
  33    * 
  34    * 
  35    * 
  36    * @param  lines
  37    * @param  delimiterK eys -
  38    *             A list  of key va lues that  define the  start of  each seria lized
  39    *             object . The orde r of the d elimiter k eys IS SIG NIFICANT.  Later,
  40    *             numeri cally high er index,  delimiter  keys are c onsidered  children
  41    *             of ear lier keys.  The retur ned List w ill consis t entirely  of
  42    *             Parsed VistaLine  where the  key is the  first del imiterKeys  member.
  43    *             Each o f those Pa rsedVistaL ine will h ave childr en with a  key value
  44    *             of the  second de limiterKey s member,  etc ...
  45    * 
  46    * @return
  47    * @author  vhaiswbec kec
  48    * 
  49    */
  50   public cla ss VistaIm agingParse r
  51   {
  52           pr ivate Onto logyDelimi terKey[] o ntologyDel imiterKeys ;
  53           pr ivate Logg er logger  = LogManag er.getLogg er(this.ge tClass());
  54           
  55           Vi staImaging Parser(Ont ologyDelim iterKey[]  ontologyDe limiterKey s)
  56           {
  57                    this .ontologyD elimiterKe ys = new O ntologyDel imiterKey[ ontologyDe limiterKey s.length];
  58                    Syst em.arrayco py(ontolog yDelimiter Keys, 0, t his.ontolo gyDelimite rKeys, 0,  ontologyDe limiterKey s.length);
  59           }
  60  
  61           /* *
  62            *  
  63            *  @param li nes
  64            *  @param di scardUnkno wnRootLine s
  65            *  @return
  66            * /
  67           pu blic List< ParsedVist aLine> par se(String[ ] lines, b oolean dis cardUnknow nRootLines )
  68           {
  69  
  70                    // p arameter c hecking, t he ontolog y delimite r keys mus t be provi ded
  71                    if ( ontologyDe limiterKey s == null  || ontolog yDelimiter Keys.lengt h <= 0)
  72                             throw  new Illega lArgumentE xception(" The delimi ter keys m ust not be  null or a n empty ar ray.");
  73  
  74                    for  (OntologyD elimiterKe y ontology DelimiterK ey : ontol ogyDelimit erKeys)
  75                             if (on tologyDeli miterKey = = null ||  ontologyDe limiterKey .getKey()  == null
  76                                      || ontol ogyDelimit erKey.getK ey().lengt h() <= 0)
  77                                      throw ne w IllegalA rgumentExc eption(
  78                                               "All keys  in the del imiter key s must not  be null o r an empty  String.") ;
  79  
  80                    List <ParsedVis taLine> pa rsedLines  = new Arra yList<Pars edVistaLin e>();
  81                    // i f no lines  given the n return a n empty li st
  82                    if ( lines == n ull || lin es.length  <= 1)
  83                             return  parsedLin es;
  84  
  85                    logg er.info("P arsing " +  lines.len gth + " li nes using  " + ontolo gyDelimite rKeys.leng th + " key s.");
  86  
  87                    // A n array of  ParsedVis taLine ins tances tha t define t he current  path
  88                    // i n the resu lting hier archy. New  instances  of Parsed VistaLine,  as they
  89                    // a re parsed,  are added  to the cu rrent path , unless t hey are de limiter
  90                    // k eys, in wh ich case t hey change  the curre nt path.
  91                    Pars edVistaLin e[] curren tHierarchy Path = new  ParsedVis taLine[ont ologyDelim iterKeys.l ength];
  92                    for  (int index  = 0; inde x < curren tHierarchy Path.lengt h; ++index )
  93                             curren tHierarchy Path[index ] = null;
  94                    // t he depth i nto the hi erarchy th at we are  currently  adding to
  95                    // t his is als o the inde x into cur rentHierar chyPath of  the "acti ve"
  96                    // e lement
  97                    int  currentHie rarchyDept h = 0;
  98  
  99                    for  (String li ne : lines )
  100                    {
  101                             if (li ne == null ) // shoul d never ha ppen, but  ...
  102                                      continue ;
  103                             line =  line.trim (); // rem ove traili ng whitesp ace
  104  
  105                             //logg er.debug(" Parsing li ne '" + li ne + "'.") ;
  106  
  107                             // giv en a line  like "NEXT _STUDY||71 2" get the  parts "NE XT_STUDY",
  108                             // "",  "712"
  109                             String  parts[] =  line.spli t("\\|", - 1); // Str ingUtils.S plit(line,
  110                                                                                                                     // Str ingUtils.S TICK);
  111                             String  key = par ts[0].trim ();
  112                             String [] values  = parts.le ngth > 1 ?  new Strin g[parts.le ngth - 1]  : null;
  113                             if (va lues != nu ll)
  114                                      System.a rraycopy(p arts, 1, v alues, 0,  parts.leng th - 1);
  115                             // at  this point  the examp le line sh ould end u p like:
  116                             // key  = "NEXT_S TUDY"
  117                             // val ues = "",  "712"
  118  
  119                             // sim ply see if  the key i s an ontol ogy delimi ter, its h e index va lue we'll  be looking  at later
  120                             int on tologyKeyI ndex;
  121                             for (o ntologyKey Index = 0;  ontologyK eyIndex <  ontologyDe limiterKey s.length;  ++ontology KeyIndex)
  122                                      if (onto logyDelimi terKeys[on tologyKeyI ndex].getK ey().equal s(key))
  123                                               break;
  124                             
  125                             int pa rentKeyInd ex = -1;
  126                             if (on tologyKeyI ndex >= on tologyDeli miterKeys. length)
  127                             {
  128                                      ontology KeyIndex =  -1;
  129                                      // if th e current  key is not  a ontolog y key, che ck to see  if the
  130                                      // curre nt key
  131                                      // is a  exceptiona l key for  an ontolog y. if so w e will add  this
  132                                      // prope rty to tha t key
  133                                      for (par entKeyInde x = ontolo gyDelimite rKeys.leng th - 1; pa rentKeyInd ex >= 0; - -parentKey Index)
  134                                      {
  135                                               if (ontolo gyDelimite rKeys[pare ntKeyIndex ].contains Exceptiona lKey(key))
  136                                               {
  137                                                       br eak;
  138                                               }
  139                                      }
  140                             }
  141  
  142                             // if  the new li ne is a ro ot line
  143                             if (on tologyKeyI ndex == 0)
  144                             {
  145                                      logger.d ebug("Root  line dete cted '" +  line + "'. ");
  146  
  147                                      ParsedVi staLine ro ot = new P arsedVista Line(key,  values);
  148                                      parsedLi nes.add(ro ot);
  149                                      currentH ierarchyDe pth = 0;
  150                                      currentH ierarchyPa th[current HierarchyD epth] = ro ot;
  151                             }
  152  
  153                             // if  the new li ne is just  a propert y
  154                             else i f (ontolog yKeyIndex  == -1)
  155                             {
  156                                      logger.d ebug("Prop erty line  detected ' " + line +  "'.");
  157                                      ParsedVi staLine pa rent = nul l;
  158                                      // if th e parent k ey index i s not -1,  then there  is a pare nt key
  159                                      // index  to use, n ot the cur rent one
  160                                      if (pare ntKeyIndex  >= 0)
  161                                      {
  162                                               parent = c urrentHier archyPath[ parentKeyI ndex];
  163                                      }
  164                                      else
  165                                      {
  166                                               parent = c urrentHier archyPath[ currentHie rarchyDept h];
  167                                      }
  168                                      if (pare nt != null )
  169                                               parent.add Property(k ey, values );
  170                                      else
  171                                      {
  172                                               if (discar dUnknownRo otLines)
  173                                                       lo gger.warn( "There is  no current  line to a dd unknown  line '" +  line + "'  to, disca rding.");
  174                                               else
  175                                                       pa rsedLines. add(new Pa rsedVistaL ine(key, v alues));
  176                                      }
  177                             }
  178  
  179                             // if  the key is  a delimit er at the  current hi erarchy le vel
  180                             // and  it is not  the root  level (whi ch we addr essed in t he
  181                             // pre ceeding 'i f' block)
  182                             // cre ate a new  ParsedVist aLine as a  sibling o f the curr ent
  183                             // and  make the  new elemen t the curr ently acti ve element
  184                             else i f (ontolog yKeyIndex  == current HierarchyD epth)
  185                             {
  186                                      logger.d ebug("Sibl ing delimi ter line d etected '"  + line +  "'.");
  187  
  188                                      ParsedVi staLine pa rent = cur rentHierar chyPath[on tologyKeyI ndex - 1];
  189                                      currentH ierarchyPa th[ontolog yKeyIndex]  = parent. addChild(k ey, values );
  190                             }
  191  
  192                             // if  the key is  a delimit er at the  child hier erchy leve l
  193                             // cre ate a new  ParsedVist aLine as a  child of  the curren t
  194                             // mak e the new  element th e currentl y active e lement
  195                             // set  the curre nt depth t o the new  deeper lev el
  196                             else i f (ontolog yKeyIndex  > currentH ierarchyDe pth)
  197                             {
  198                                      logger.d ebug("Desc endent del imiter lin e detected  '" + line  + "'.");
  199  
  200                                      ParsedVi staLine pa rent = cur rentHierar chyPath[cu rrentHiera rchyDepth] ;
  201                                      currentH ierarchyPa th[ontolog yKeyIndex]  = parent. addChild(k ey, values );
  202                                      currentH ierarchyDe pth = onto logyKeyInd ex;
  203                             }
  204  
  205                             // if  the key is  a delimit er at an a ncestor hi ererchy le vel
  206                             // cre ate a new  ParsedVist aLine
  207                             // mak e the new  element th e currentl y active e lement
  208                             // set  the curre nt depth t o the new  shallower  level
  209                             else i f (ontolog yKeyIndex  < currentH ierarchyDe pth)
  210                             {
  211                                      logger.d ebug("Ance stor delim iter line  detected ' " + line +  "'.");
  212  
  213                                      ParsedVi staLine pa rent = cur rentHierar chyPath[on tologyKeyI ndex - 1];
  214                                      currentH ierarchyPa th[ontolog yKeyIndex]  = parent. addChild(k ey, values );
  215                                      currentH ierarchyDe pth = onto logyKeyInd ex;
  216                             }
  217                    }
  218  
  219                    retu rn parsedL ines;
  220           }
  221  
  222           /* *
  223            *  A class t hat contai ns parsed  lines from  Vista wit h no seman tics appli ed,
  224            *  other tha n recogniz ing "NEXT_ XXX" as a  start deli miter.
  225            *  
  226              * @author        
BECKEC
  227            *  
  228            * /
  229           pu blic stati c class Pa rsedVistaL ine
  230           {
  231                    priv ate Logger  logger =  LogManager .getLogger (this.getC lass());
  232                    
  233                    priv ate final  String key ;
  234                    priv ate final  List<Strin g> values;
  235                    priv ate final  List<Parse dVistaLine > properti es;
  236                    priv ate final  List<Parse dVistaLine > children ;
  237  
  238                    Pars edVistaLin e(String k ey, String [] values)
  239                    {
  240                             this.k ey = key;
  241                             this.v alues = ne w ArrayLis t<String>( );
  242                             if (va lues != nu ll)
  243                                      for (Str ing value  : values)
  244                                               this.value s.add(valu e);
  245                             this.p roperties  = new Arra yList<Pars edVistaLin e>();
  246                             this.c hildren =  new ArrayL ist<Parsed VistaLine> ();
  247                    }
  248  
  249                    /**
  250                     * A  Child is  a line who se type in dicates an  inferior  position i n the
  251                     * d efined hie rarchy.
  252                     * 
  253                     * @ param key
  254                     * @ param valu es
  255                     * @ return
  256                     */
  257                    Pars edVistaLin e addChild (String ke y, String[ ] values)
  258                    {
  259                             Parsed VistaLine  child = ne w ParsedVi staLine(ke y, values) ;
  260                             childr en.add(chi ld);
  261  
  262                             return  child;
  263                    }
  264  
  265                    /**
  266                     * A  Property  is a line  whose type  indicates  an equiva lent posit ion in
  267                     * t he defined  hierarchy .
  268                     * 
  269                     * @ param key
  270                     * @ param valu es
  271                     * @ return
  272                     */
  273                    Pars edVistaLin e addPrope rty(String  key, Stri ng[] value s)
  274                    {
  275                             Parsed VistaLine  property =  new Parse dVistaLine (key, valu es);
  276                             proper ties.add(p roperty);
  277  
  278                             return  property;
  279                    }
  280  
  281                    Stri ng getKey( )
  282                    {
  283                             return  key;
  284                    }
  285  
  286                    Iter ator<Strin g> valuesI terator()
  287                    {
  288                             return  values.it erator();
  289                    }
  290  
  291                    Iter ator<Parse dVistaLine > property Iterator()
  292                    {
  293                             return  propertie s.iterator ();
  294                    }
  295  
  296                    Iter ator<Parse dVistaLine > childIte rator()
  297                    {
  298                             return  children. iterator() ;
  299                    }
  300  
  301                    Stri ng getValu eAtIndex(i nt index)
  302                    {
  303                             return  values.ge t(index);
  304                    }
  305  
  306                    bool ean isValu eAtIndexEx ists(int i ndex)
  307                    {
  308                             if (in dex < 0)
  309                                      return f alse;
  310                             if (in dex >= val ues.size() )
  311                                      return f alse;
  312                             return  true;
  313                    }
  314  
  315                    Pars edVistaLin e getPrope rtyAtIndex (int index )
  316                    {
  317                             return  propertie s.get(inde x);
  318                    }
  319  
  320                    Pars edVistaLin e getChild AtIndex(in t index)
  321                    {
  322                             return  children. get(index) ;
  323                    }
  324  
  325                    Pars edVistaLin e getPrope rty(String  key)
  326                    {
  327                             for (I terator<Pa rsedVistaL ine> iter  = property Iterator() ; iter.has Next();)
  328                             {
  329                                      ParsedVi staLine pr operty = i ter.next() ;
  330                                      if (key. equals(pro perty.getK ey()))
  331                                               return pro perty;
  332                             }
  333  
  334                             return  null;
  335                    }
  336  
  337                    /**
  338                     * T he keys mu st match a nd the pro perties an d children  must also  be
  339                     * e quals and  in the sam e order.
  340                     * 
  341                     * @ see java.l ang.Object #equals(ja va.lang.Ob ject)
  342                     */
  343                    @Ove rride
  344                    publ ic boolean  equals(Ob ject obj)
  345                    {
  346                             if (ob j instance of ParsedV istaLine)
  347                             {
  348                                      ParsedVi staLine th at = (Pars edVistaLin e) obj;
  349  
  350                                      if (this .getKey()  == null &&  that.getK ey() != nu ll || this .getKey()  != null &&  that.getK ey() == nu ll
  351                                               || !this.g etKey().eq uals(that. getKey()))
  352                                      {
  353                                               logger.inf o("this.ke y '" + thi s.getKey()  + "' is n ot equal t o that.key  '" + that .getKey()  + "'.");
  354                                               return fal se;
  355                                      }
  356  
  357                                      if (this .values.si ze() != th at.values. size())
  358                                      {
  359                                               logger.inf o("this.va lues.size  '" + this. values.siz e() + "' i s not equa l to that. values.siz e '"
  360                                                       +  that.value s.size() +  "'.");
  361                                               return fal se;
  362                                      }
  363  
  364                                      Iterator <String> t hisValueIt erator = t his.values Iterator() ;
  365                                      Iterator <String> t hatValueIt erator = t hat.values Iterator() ;
  366                                      for (; t hisValueIt erator.has Next() &&  thatValueI terator.ha sNext();)
  367                                      {
  368                                               String thi sValue = t hisValueIt erator.nex t();
  369                                               String tha tValue = t hatValueIt erator.nex t();
  370                                               if (!thisV alue.equal s(thatValu e))
  371                                               {
  372                                                       lo gger.info( "this(" +  this.getKe y() + ").v alue '" +  thisValue  + "' is no t equal to  that("
  373                                                                + th at.getKey( ) + ").val ue '" + th atValue +  "'.");
  374                                                       re turn false ;
  375                                               }
  376                                      }
  377  
  378                                      if (this .propertie s.size() ! = that.pro perties.si ze())
  379                                      {
  380                                               logger.inf o("this.pr operties.s ize '" + t his.proper ties.size( )
  381                                                       +  "' is not  equal to t hat.proper ties.size  '" + that. properties .size() +  "'.");
  382                                               return fal se;
  383                                      }
  384  
  385                                      Iterator <ParsedVis taLine> th isProperty Iterator =  this.prop ertyIterat or();
  386                                      Iterator <ParsedVis taLine> th atProperty Iterator =  that.prop ertyIterat or();
  387                                      for (; t hisPropert yIterator. hasNext()  && thatPro pertyItera tor.hasNex t();)
  388                                      {
  389                                               ParsedVist aLine this Property =  thisPrope rtyIterato r.next();
  390                                               ParsedVist aLine that Property =  thatPrope rtyIterato r.next();
  391                                               if (!thisP roperty.eq uals(thatP roperty))
  392                                                       re turn false ;
  393                                      }
  394  
  395                                      if (this .children. size() !=  that.child ren.size() )
  396                                      {
  397                                               logger.inf o("this.ch ildren.siz e '" + thi s.children .size()
  398                                                       +  "' is not  equal to t hat.childr en.size '"  + that.ch ildren.siz e() + "'." );
  399                                               return fal se;
  400                                      }
  401  
  402                                      Iterator <ParsedVis taLine> th isChildIte rator = th is.childIt erator();
  403                                      Iterator <ParsedVis taLine> th atChildIte rator = th at.childIt erator();
  404                                      for (; t hisChildIt erator.has Next() &&  thatChildI terator.ha sNext();)
  405                                      {
  406                                               ParsedVist aLine this Child = th isChildIte rator.next ();
  407                                               ParsedVist aLine that Child = th atChildIte rator.next ();
  408                                               if (!thisC hild.equal s(thatChil d))
  409                                                       re turn false ;
  410                                      }
  411  
  412                                      return t rue;
  413                             }
  414  
  415                             return  false;
  416                    }
  417  
  418                    @Ove rride
  419                    publ ic String  toString()
  420                    {
  421                             String Builder sb  = new Str ingBuilder ();
  422  
  423                             sb.app end("Parse dVistaLine  \r");
  424  
  425                             sb.app end("\tKey  :'");
  426                             sb.app end(key);
  427                             sb.app end("'\r") ;
  428  
  429                             sb.app end("\tVal ues :'");
  430                             for (S tring valu e : values )
  431                                      sb.appen d(value +  " ");
  432                             sb.app end("'\r") ;
  433  
  434                             return  sb.toStri ng();
  435                    }
  436           }
  437  
  438           /* *
  439            *  Represent s an ontol ogy key in  the study , series,  instance h ierearchy
  440            *  
  441            *  @author v haiswwerfe j
  442            *  
  443            * /
  444           st atic class  OntologyD elimiterKe y
  445           {
  446                    priv ate final  String key ;
  447                    priv ate final  String[] e xceptional Keys;
  448  
  449                    /**
  450                     * C reate an o ntology de limiter ke y with no  exceptiona l keys
  451                     * 
  452                     * @ param key
  453                     */
  454                    Onto logyDelimi terKey(Str ing key)
  455                    {
  456                             this.k ey = key;
  457                             except ionalKeys  = null;
  458                    }
  459  
  460                    /**
  461                     * C reate an o ntology de limiter ke y with exc eptional k eys
  462                     * 
  463                     * @ param key
  464                     * @ param exce ptionalKey s
  465                     */
  466                    Onto logyDelimi terKey(Str ing key, S tring[] ex ceptionalK eys)
  467                    {
  468                             this.k ey = key;
  469                             this.e xceptional Keys = exc eptionalKe ys;
  470                    }
  471  
  472                    /**
  473                     * @ return the  key
  474                     */
  475                    publ ic String  getKey()
  476                    {
  477                             return  key;
  478                    }
  479  
  480                    /**
  481                     * @ return the  exception alKeys
  482                     */
  483                    publ ic String[ ] getExcep tionalKeys ()
  484                    {
  485                             return  exception alKeys;
  486                    }
  487  
  488                    publ ic boolean  containsE xceptional Key(String  searchExc eptionalKe y)
  489                    {
  490                             if (ex ceptionalK eys == nul l)
  491                                      return f alse;
  492                             if (se archExcept ionalKey = = null)
  493                                      return f alse;
  494                             for (S tring exce ptionalKey  : excepti onalKeys)
  495                             {
  496                                      if (exce ptionalKey .equals(se archExcept ionalKey))
  497                                               return tru e;
  498                             }
  499                             return  false;
  500                    }
  501           }
  502   }