72. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 7/10/2017 1:01:44 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.

72.1 Files compared

# Location File Last Modified
1 C:\AraxisMergeCompare\Pri_un\IV-ehmp_cif\ImagingDicomDCFUtilities\src\java\gov\va\med\imaging\dicom\dcftoolkit\utilities\reconstitution LegacyTextFileParser.java Thu Jun 29 17:22:24 2017 UTC
2 C:\AraxisMergeCompare\Pri_re\IV-ehmp_cif\ImagingDicomDCFUtilities\src\java\gov\va\med\imaging\dicom\dcftoolkit\utilities\reconstitution LegacyTextFileParser.java Thu Jul 6 15:03:16 2017 UTC

72.2 Comparison summary

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

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

72.4 Active regular expressions

No regular expressions were active.

72.5 Comparison detail

  1   /**
  2    * 
  3     Package:  MAG - Vis tA Imaging
  4     WARNING:  Per VHA D irective 2 004-038, t his routin e should n ot be modi fied.
  5     Date Cre ated: Sept ember 26,  2006
  6     Site Nam e:  Washin gton OI Fi eld Office , Silver S pring, MD
  7       Developer:          
PETERB
  8     Descript ion: 
  9  
  10           ;;  +-------- ---------- ---------- ---------- ---------- ---------- ---------- +
  11           ;;  Property  of the US  Government .
  12           ;;  No permis sion to co py or redi stribute t his softwa re is give n.
  13           ;;  Use of un released v ersions of  this soft ware requi res the us er
  14           ;;   to execu te a writt en test ag reement wi th the Vis tA Imaging
  15           ;;   Developm ent Office  of the De partment o f Veterans  Affairs,
  16           ;;   telephon e (301) 73 4-0100.
  17           ;;
  18           ;;  The Food  and Drug A dministrat ion classi fies this  software a s
  19           ;;  a Class I I medical  device.  A s such, it  may not b e changed
  20           ;;  in any wa y.  Modifi cations to  this soft ware may r esult in a n
  21           ;;  adulterat ed medical  device un der 21CFR8 20, the us e of which
  22           ;;  is consid ered to be  a violati on of US F ederal Sta tutes.
  23           ;;  +-------- ---------- ---------- ---------- ---------- ---------- ---------- +
  24    */
  25   package go v.va.med.i maging.dic om.dcftool kit.utilit ies.recons titution;
  26  
  27   import gov .va.med.im aging.Size dInputStre am;
  28   import gov .va.med.im aging.dico m.common.i nterfaces. IDicomData Set;
  29   import gov .va.med.im aging.dico m.dcftoolk it.common. impl.Dicom DataSetImp l;
  30   import gov .va.med.im aging.exce ptions.Tex tFileExcep tion;
  31   import gov .va.med.im aging.exce ptions.Tex tFileExtra ctionExcep tion;
  32   import gov .va.med.im aging.exce ptions.Tex tFileNotFo undExcepti on;
  33  
  34   import jav a.io.Buffe redReader;
  35   import jav a.io.FileN otFoundExc eption;
  36   import jav a.io.FileR eader;
  37   import jav a.io.IOExc eption;
  38   import jav a.io.Input StreamRead er;
  39   import jav a.nio.Byte Buffer;
  40   import jav a.nio.Shor tBuffer;
  41   import jav a.util.Arr ayList;
  42   import jav a.util.Has hMap;
  43   import jav a.util.Ite rator;
  44   import jav a.util.reg ex.Pattern ;
  45  
  46   import org .apache.lo g4j.Logger ;
  47  
  48   import com .lbs.DCS.A ttributeTa g;
  49   import com .lbs.DCS.D CM;
  50   import com .lbs.DCS.D CSExceptio n;
  51   import com .lbs.DCS.D icomCSElem ent;
  52   import com .lbs.DCS.D icomDataDi ctionary;
  53   import com .lbs.DCS.D icomDataSe t;
  54   import com .lbs.DCS.D icomElemen t;
  55   import com .lbs.DCS.D icomElemen tFactory;
  56   import com .lbs.DCS.D icomFDElem ent;
  57   import com .lbs.DCS.D icomFLElem ent;
  58   import com .lbs.DCS.D icomOBElem ent;
  59   import com .lbs.DCS.D icomOWElem ent;
  60   import com .lbs.DCS.D icomSLElem ent;
  61   import com .lbs.DCS.D icomSQElem ent;
  62   import com .lbs.DCS.D icomSSElem ent;
  63   import com .lbs.DCS.D icomULElem ent;
  64   import com .lbs.DCS.D icomUSElem ent;
  65  
  66   /**
  67    *
  68    * Text Fi le Parser  class. Thi s parser i s specific  to the Vi sta Imagin g Legacy
  69    * environ ment.  The  class wil l parse th e Text fil e passed f rom Archiv ing 
  70    * and bui ld a new D icomDataSe t from the  Text file  informati on.  Then  the class  shall
  71    * wrap th e DicomDat aSet objec t into a g eneric Dic omDataSet  object.  T he wrappin g allows
  72    * the Dic omDataSet  object to  be passed  to the Dic om Generic  Layer.
  73    *
  74    * @author  William P eterson
  75    * extende d by Csaba  Titton
  76    *                        for Vi X streamin
  77    */
  78  
  79   //NOTE 000 8,1032/000 8,0103 and
  80   //               0040 ,0260/0008 ,0103 and
  81   //               0040 ,0275/0040 ,0008/0008 ,0103 has  no value i n output14 .dcm. Inve stigated t he issue.
  82   //      Th is is acce ptable acc ording to  the DICOM  Standard.
  83  
  84   public cla ss LegacyT extFilePar ser {
  85       /*
  86        * Cre ate a Dico mDataSet o bject.  Th is object  is DCF Too lkit speci fic.
  87        */
  88       privat e DicomDat aSet dicom DataSet =  null;
  89       
  90       privat e IDicomDa taSet tool kitDDS = n ull;
  91       
  92       privat e Original PixelDataI nfo origin alPixelDat a = null;
  93       
  94       privat e static L ogger logg er = Logge r.getLogge r (LegacyT extFilePar ser.class) ;
  95       privat e static L ogger test Logger = L ogger.getL ogger("JUN IT_TEST");
  96  
  97           
  98       /**
  99        * Con structor
  100        */
  101       public  LegacyTex tFileParse r() {
  102           su per();
  103       }
  104       
  105       /**
  106        * Inv oke method  to create  a DicomDa taSet base d on a Tex t file.
  107        * 
  108        * @pa ram textFi lename rep resents th e name (an d path) of  the Text  file.
  109        * @re turn repre sents the  encapsulat ed DicomDa taSet that  is safe f or DicomGe neric Laye r.
  110        * @th rows TextF ileNotFoun dException
  111        * @th rows TextF ileExcepti on
  112        * @th rows TextF ileExtract ionExcepti on
  113        */
  114       public  IDicomDat aSet creat eDicomData Set(String  textFilen ame, Origi nalPixelDa taInfo pix elData)
  115                throws T extFileNot FoundExcep tion, Text FileExcept ion, 
  116                TextFile Extraction Exception{
  117           
  118           lo gger.info( this.getCl ass().getN ame()+": D icom Toolk it Layer:  " +
  119                    "... parsing Te xt file in to DicomDa taSet.");
  120           lo gger.debug ("Text Fil e: "+ text Filename);
  121           th is.origina lPixelData  = pixelDa ta;
  122           Bu fferedRead er buffer  = null;
  123           tr y{
  124                //Get Te xt file.
  125                //JUNIT  Create tes t to verif y how this  fails if  not correc t permissi ons.
  126                buffer =  new Buffe redReader( new FileRe ader(textF ilename));
  127                //Invoke  parser.
  128                this.par seTextFile (buffer, t rue);
  129                //REMIND ER Find ou t why I ha ve the fol lowing lin e.  It doe s not make  sense, bu t
  130                //  I do n't want t o change i t now.  Un sure of ef fects if o mitted.
  131                pixelDat a = this.o riginalPix elData;
  132                //encaps ulate Dico mDataSet o bject.
  133                return ( this.encap sulateDico mDataSet() );
  134           }
  135           ca tch(FileNo tFoundExce ption noFi le){
  136                logger.e rror(noFil e.getMessa ge());
  137                logger.e rror(this. getClass() .getName() +": Dicom  Toolkit la yer: " +
  138                         "Exception  thrown wh ile attemp ting to op en "+textF ilename+". ");
  139                throw ne w TextFile NotFoundEx ception("C ould not f ind or ope n "+textFi lename+"." , noFile);
  140           }
  141           fi nally{
  142                    if(b uffer != n ull){
  143                             try{
  144                                      buffer.c lose();
  145                             }
  146                             catch( Throwable  T){
  147                                      logger.e rror(this. getClass() .getName() +": Dicom  Toolkit la yer: "+
  148                                                       "E xception t hrown whil e closing  Text File  "+textFile name+".");
  149                             }
  150                             System .gc();
  151                    }
  152           }      
  153                    
  154       }
  155       /**
  156        * Inv oke method  to create  a DicomDa taSet base d on a Tex t data str eam.
  157        * 
  158        * @pa ram textSt ream repre sents the  stream of  VistA Imag ing TXT da ta.
  159        * @re turn repre sents the  encapsulat ed DicomDa taSet that  is safe f or DicomGe neric Laye r.
  160        * @th rows TextF ileNotFoun dException
  161        * @th rows TextF ileExcepti on
  162        * @th rows TextF ileExtract ionExcepti on
  163        */
  164       public  IDicomDat aSet creat eDicomData Set(Buffer edReader b uffer, Ori ginalPixel DataInfo p ixelData)
  165                throws   TextFileEx ception, T extFileExt ractionExc eption {
  166           
  167           lo gger.info( "... Dicom  Toolkit L ayer: pars ing Text d ata into D icomDataSe t ...");
  168           lo gger.debug ("... Star t Text Dat a Stream p arsing...  ");
  169           th is.origina lPixelData  = pixelDa ta;
  170  
  171           // Invoke par ser.
  172           th is.parseTe xtFile(buf fer, false );
  173           
  174           pi xelData =  this.origi nalPixelDa ta;
  175           // encapsulat e DicomDat aSet objec t.
  176           re turn (this .encapsula teDicomDat aSet());
  177       }
  178       
  179       /**
  180        * Enc apsulates  the DCF To olkit spec ific Dicom DataSet ob ject.
  181        * 
  182        * @re turn repre sents the  Generic Di comDataSet  object.
  183        */
  184       privat e IDicomDa taSet enca psulateDic omDataSet( ){
  185           
  186           te stLogger.i nfo("... e ncapsulati ng DDS ... ");
  187           tr y{
  188                //toolki tDDS = (ID icomDataSe t)SpringCo ntext.getC ontext().g etBean("Di comDataSet ");
  189                    //to olkitDDS.s etDicomDat aSet(dicom DataSet);
  190                toolkitD DS = new D icomDataSe tImpl(dico mDataSet);
  191           }
  192           ca tch(Except ion e){
  193                logger.e rror("Erro r: " + e.g etMessage( ));
  194                logger.e rror(this. getClass() .getName() +": Dicom  Toolkit la yer: " +
  195                         "Exception  thrown wh ile encaps ulating Di com Datase t.");
  196                e.printS tackTrace( );
  197           }
  198           re turn toolk itDDS;
  199       }
  200       
  201       /**
  202        * Inv oke method  to extrac t HIS upda tes from a n open Tex t data str eam.
  203        * 
  204        * @pa ram buffer  represent s the stre am of Vist A Imaging  TXT data.
  205        * @re turn HashM ap of DICO m tag-valu e pairs to  be update d in DICOM  DataSet.
  206        * @th rows TextF ileExtract ionExcepti on
  207        */
  208       public  HashMap<S tring, Str ing> getHi sUpdates(B ufferedRea der buffer )
  209                throws   TextFileEx ception, T extFileExt ractionExc eption {
  210           
  211           lo gger.info( "... Parsi ng text da ta HIS upd ate sectio n ...");
  212           lo gger.debug ("... Cont inue Text  Data parsi ng for Vis tA updates ... ");
  213  
  214           Ha shMap<Stri ng, String > hisChang es=null;
  215           hi sChanges =  this.pars eHisUpdate s(buffer);
  216           tr y {
  217                    buff er.close() ;
  218           }
  219           ca tch(IOExce ption io){
  220                logger.e rror("Cann ot close T ext Stream  Buffer.") ;
  221                throw ne w TextFile Extraction Exception( );
  222           }
  223           re turn (hisC hanges);
  224       }
  225       
  226       /**
  227        * Inv oke method  to extrac t HIS upda tes from a n open Tex t data str eam.
  228        * 
  229        * @pa ram buffer  represent s the stre am of Vist A Imaging  TXT data.
  230        * @re turn HashM ap of DICO m tag-valu e pairs to  be update d in DICOM  DataSet.
  231        * @th rows TextF ileExtract ionExcepti on
  232        */
  233       public  HashMap<S tring, Str ing> extra ctHisUpdat esfromText Stream(Siz edInputStr eam sizedT extStream)
  234                throws   TextFileEx ception, T extFileExt ractionExc eption {
  235           
  236           lo gger.info( "... Parsi ng text da ta HIS upd ate sectio n ...");
  237           lo gger.debug ("... Star t parsing  VistA upda tes... ");
  238  
  239           Ha shMap<Stri ng, String > hisChang es=null;
  240           Bu fferedRead er buffer  = new Buff eredReader (new Input StreamRead er(sizedTe xtStream.g etInStream ()));
  241  
  242           hi sChanges =  this.pars eHisUpdate s(buffer);
  243           tr y {
  244                    buff er.close() ;
  245           }
  246           ca tch(IOExce ption io){
  247                logger.e rror("Cann ot close T ext Stream  Buffer.") ;
  248                throw ne w TextFile Extraction Exception( );
  249           }
  250           re turn (hisC hanges);
  251       }
  252       
  253       /**
  254        * Par se the Tex t file.  T he Text fi le is made  up of two  sections,  "Data1" a nd 
  255        * "DI COM Data".   Both sec tions are  read and d ecoded.
  256        * 
  257        * @pa ram buffer  represent s the Text  file now  in the for m of a Buf ferReader  object.
  258        * @th rows TextF ileExcepti on
  259        * @th rows TextF ileExtract ionExcepti on
  260        */
  261       privat e void par seTextFile (BufferedR eader buff er, boolea n doClose)  throws Te xtFileExce ption,
  262                TextFile Extraction Exception{
  263           
  264           St ring textL ine = "";
  265           te stLogger.i nfo("... P arsing tex t data top  section . ..");
  266           tr y{
  267                //Loop t hru the li nes until  $$BEGIN DA TA1.
  268                //Ignore  each line  until $$B EGIN DATA1
  269                do{
  270                    text Line = thi s.getNextT extLine(bu ffer);
  271                } while( !(textLine .equals("$ $BEGIN DAT A1")));
  272                
  273                do{
  274                    text Line = thi s.getNextT extLine(bu ffer);
  275                    //Ex tract only  the PATIE NTS_XXX fi elds
  276                    //Re place comm as with ca rats in Pa tient's Na me field
  277                    //10 0507-WFP-R emoving al l IF state ments exce pt DCM_TO_ TGA_PARAME TERS.
  278                    //   Reason is  the applic ation does  not use t his inform ation.  It  serves
  279                    //   no purpose .  But I'm  leaving t he code in  case I'm  wrong.
  280                    /*
  281                    if(t extLine.st artsWith(" PATIENTS_N AME")){
  282                         String pat ientsName  = textLine .substring (textLine. indexOf("= ")+1);
  283                    }
  284                    if(t extLine.st artsWith(" PATIENTS_I D")){
  285                         String pat ientsID =  textLine.s ubstring(t extLine.in dexOf("=") +1);
  286                    }
  287                    if(t extLine.st artsWith(" PATIENTS_B IRTH_DATE" )){
  288                         String pat ientsBirth  = textLin e.substrin g(textLine .indexOf(" =")+1);
  289                    }
  290                    if(t extLine.st artsWith(" PATIENTS_A GE")){
  291                         String pat ientsAge =  textLine. substring( textLine.i ndexOf("=" )+1);
  292                    }
  293                    if(t extLine.st artsWith(" PATIENTS_S EX")){
  294                         String pat ientsSex =  textLine. substring( textLine.i ndexOf("=" )+1);
  295                    }
  296                    if(t extLine.st artsWith(" ACCESSION_ NUMBER")){
  297                         String acc essionNumb er = textL ine.substr ing(textLi ne.indexOf ("=")+1);
  298                    }
  299                    */
  300                    if(t extLine.st artsWith(" DCM_TO_TGA _PARAMETER S")){
  301                         String dcm totgaParam eters = te xtLine.sub string(tex tLine.inde xOf("=")+1 );
  302                         this.origi nalPixelDa ta.setDcmt otgaParame ters(dcmto tgaParamet ers);
  303                    }
  304                    //Pl ace these  PATIENTS_X XX fields  into a tem p DicomDat aSet objec t.
  305                }while(! (textLine. equals("$$ END DATA1" )));
  306                
  307                //Invoke  parseDico mDataSecti on to pars e rest of  file.
  308                this.par seDicomDat aSection(b uffer);
  309                if (doCl ose) 
  310                    buff er.close() ;
  311           }
  312           ca tch(IOExce ption io){
  313                logger.e rror("Cann ot extract  from Text  File.");
  314                logger.e rror("Work ing on Lin e: " + tex tLine);
  315                throw ne w TextFile Extraction Exception( );
  316           }
  317       }
  318       
  319       /**
  320        * Par se the "DI COM Data"  section of  the Text  file.  Thi s is the g runt of th e work
  321        * tha t needs to  be done.
  322        * 
  323        * @pa ram buffer  represent s the Text  file now  in the for m of a Buf feredReade r object.
  324        * @th rows TextF ileExtract ionExcepti on
  325        */
  326       privat e void par seDicomDat aSection(B ufferedRea der buffer )
  327                throws T extFileExt ractionExc eption{
  328           
  329           th is.dicomDa taSet = ne w DicomDat aSet();
  330           St ring textD icomLine =  "";
  331           bo olean sequ enceFlag =  false;
  332           Di comSQEleme nt sequenc eElement =  null;
  333           te stLogger.i nfo("... P arsing tex t data Dic om DataSet  section . ..");
  334           tr y{
  335                //Mark B uffer.
  336                buffer.m ark(255);
  337                //Declar e lineArra y object.
  338                ArrayLis t<String>  lineArray  = new Arra yList<Stri ng>();
  339                //Loop t hru the li nes until  $BEGIN DIC OM DATA.
  340                //Ignore  each line  until $$B EGIN DICOM  DATA. 
  341                do{
  342                    text DicomLine  = this.get NextTextLi ne(buffer) ;
  343                } while( !(textDico mLine.equa ls("$$BEGI N DICOM DA TA")));
  344                
  345                textDico mLine = th is.getNext TextLine(b uffer);
  346   //           testLogg er.debug(" Current Li ne: " + te xtDicomLin e);
  347                //Loop t hru each l ine until  $$END DICO M DATA.
  348                while(!( textDicomL ine.equals ("$$END DI COM DATA") )){
  349                    //Ch eck for Od d Group.
  350                    Stri ng checkGr oup = text DicomLine. substring( 0,4);
  351                    //St ring check Element =  textDicomL ine.substr ing(5,9);
  352                    int  i = Intege r.parseInt (checkGrou p, 16);
  353                    if(t his.isGrou pToBeAdded (i)){
  354                    //If  no Odd gr oup or Gro up 88,
  355                         //Check if  9th chara cter in li ne is a "| ".
  356                         if(!(textD icomLine.s ubstring(9 ,10).equal s("|"))){
  357                         //If no,
  358                             //Add  string to  lineArray  object.
  359                             lineAr ray.add(te xtDicomLin e);
  360                             //Set  Sequence f lag.
  361                             sequen ceFlag = t rue;
  362                         }
  363                         else{
  364                         //If yes, 
  365                             //Chec k if Seque nce flag i s set.
  366                             if(seq uenceFlag) {
  367                             //If y es,
  368                                 // Reset Mark  Buffer.   This allow s to pick  up the ele ment after  the
  369                                 //   sequence  again.
  370                                 bu ffer.reset ();
  371                                 // Invoke ext ractSequen ceData met hod and pa ss lineArr ay.
  372                                 se quenceElem ent = this .extractSe quenceData (lineArray );
  373                                 // Add DicomS QElement o bject to d ds.
  374                                 th is.dicomDa taSet.inse rt(sequenc eElement);
  375                                 // Clean line Array obje ct.
  376                                 li neArray.cl ear();
  377                                 // Unset the  Sequence f lag.
  378                                 se quenceFlag  = false;
  379                             }
  380                             else{
  381                             //If n o,
  382                                 // Invoke ext ractDicomE lement met hod and pa ss the lin e.
  383                                 th is.extract DicomEleme nt(textDic omLine, th is.dicomDa taSet);
  384                             }
  385                         //End If f or "|" del imiter.
  386                         }
  387                    //En d If for O dd Group.
  388                    }
  389                    //Ma rk Buffer.
  390                    buff er.mark(25 5);
  391                    text DicomLine  = this.get NextTextLi ne(buffer) ;
  392   //                 te stLogger.d ebug("Curr ent Line:  " + textDi comLine);
  393  
  394                //End Lo op due to  $$END DICO M DATA or  EOF.
  395                }
  396           }
  397           ca tch(IOExce ption io){
  398                logger.e rror(io.ge tMessage() );
  399                logger.e rror(this. getClass() .getName() +": " +
  400                         "Exception  thrown wh ile readin g Text fil e's Dicom  Data Secti on.");
  401                throw ne w TextFile Extraction Exception( "Failure t o read Dic omData Sec tion.", io );
  402           }
  403           ca tch(Number FormatExce ption numb er){
  404                logger.e rror(numbe r.getMessa ge());
  405                logger.e rror(this. getClass() .getName() +": Workin g on Dicom  Line: " +  textDicom Line);
  406                throw ne w TextFile Extraction Exception( "Failure o n Number F ormat.", n umber);
  407           }
  408           
  409           th is.customT GAElementC leanup();
  410       }
  411       
  412       /**
  413        * Rec ursive met hod to han dle the Se quences an d nested S equences i nside of t he "DICOM
  414        * Dat a" section .
  415        * 
  416        * @pa ram lines  represents  the Array  of Sequen ce lines i n the Text  file.
  417        * @re turn repre sents the  Sequence l ines conve rted into  a single D icom Seque nce Elemen t.
  418        * @th rows TextF ileExtract ionExcepti on
  419        */
  420       privat e DicomSQE lement ext ractSequen ceData(Arr ayList<Str ing> lines )
  421                throws T extFileExt ractionExc eption{
  422           
  423           Di comDataSet  seqDDS =  new DicomD ataSet();
  424           Ar rayList<Di comDataSet > ddsArray List = new  ArrayList <DicomData Set>();
  425           // Create Dic omSQElemen t object.
  426           Di comSQEleme nt sequenc e = null;
  427           
  428           St ring eleme nt = new S tring("");
  429           // Initialize  seqDDS in dex to 0.
  430           in t ddsIndex  = 0;
  431           // Create pre viouseSeqI tem.
  432           St ring previ ousSeqItem  = "";
  433           // Set Sequen ce flag to  false.
  434           bo olean sequ enceFlag =  false;
  435           // Declare se qArray obj ect.
  436           Ar rayList<St ring> seqA rray = new  ArrayList <String>() ;
  437           tr y{
  438           // Loop thru  each line  of lines a rray until  null.  Gr ab line in  Loop.
  439           fo r(int x=0;  x<lines.s ize(); x++ ){
  440                
  441                //Split  line into  two substr ings using  first per iod.
  442                String s eqLine = ( String)lin es.get(x);
  443                String s ubLines[]  = seqLine. split("\\. ",2);
  444                //Assign  first sub string to  Tag.
  445                element  = subLines [0];
  446                //Split  second sub string int o two sub- strings us ing first  carat.
  447                String s ubSubLines [] = subLi nes[1].spl it("\\^",2 );
  448                //Assign  first sub -substring  to seqIte m.
  449                String s eqItem = s ubSubLines [0];
  450                //Assign  second su b-substrin g to seqAr ray object .
  451                String e lementData  = subSubL ines[1];
  452                if(previ ousSeqItem .equals("" )){
  453                //If yes
  454                    //In itialize p reviousSeq Item with  seqItem.
  455                    prev iousSeqIte m = seqIte m;
  456                }
  457                //Check  if first s ub-substri ng matches  seqItem.
  458                if(!(pre viousSeqIt em.equals( seqItem))) {
  459                //If no,
  460                    ddsA rrayList.a dd(seqDDS) ;
  461                    seqD DS = new D icomDataSe t();
  462                    prev iousSeqIte m = seqIte m;
  463                //End If
  464                }
  465                String c heckGroup  = elementD ata.substr ing(0,4);
  466                int g =  Integer.pa rseInt(che ckGroup, 1 6);
  467                if(this. isGroupToB eAdded(g)) {
  468                    //Ch eck if 9th  character  is a "|".   This mea ns another  Sequence.
  469                    //Th is if/else  determine s if the l ine is ano ther seque nce.
  470                    if(! (elementDa ta.substri ng(9,10).e quals("|") )){
  471                         //If no,
  472                         //Add stri ng to seqA rray objec t.
  473                         seqArray.a dd(element Data);
  474                         //Set Sequ ence flag.
  475                         sequenceFl ag = true;
  476                         //If yes,
  477                    }
  478                    else {
  479                         //Check if  Sequence  flag is se t.
  480                         if(sequenc eFlag){
  481                             //If y es,
  482                             //Decr ement line s array in dex.
  483                             x--;
  484                             //Re-i nvoke extr actSequenc eData meth od and pas s lineArra y.
  485                             DicomS QElement s ubSequence  = this.ex tractSeque nceData(se qArray);
  486                             //add  DicomSQEle ment objec t to dds.
  487                             seqDDS .insert(su bSequence) ;
  488                             //Unse t the Sequ ence flag.
  489  
  490                             sequen ceFlag = f alse;
  491                         }
  492                         else{
  493                             //If n o,
  494                             //Invo ke extract DicomEleme nt method  and pass t he second  substring  and
  495                             //  an d temp Dic omDataSet  object.
  496                             this.e xtractDico mElement(e lementData , seqDDS);
  497                             //End  If for Seq uence flag .
  498                         }
  499                         //End If f or "|" del imiter.
  500                    }
  501                    //En d If for G roup Check
  502                }
  503                //Increm ent lines  array inde x.
  504           // Loop thru  lines arra y is compl ete.
  505           }
  506           // Check if S equence fl ag is set.
  507           if (sequenceF lag){
  508           // If yes,
  509                //Re-inv oke extrac tSequenceD ata method  and pass  lineArray.
  510                DicomSQE lement sub Sequence =  this.extr actSequenc eData(seqA rray);
  511                //add Di comSQEleme nt object  to dds.
  512                seqDDS.i nsert(subS equence);
  513                //Unset  the Sequen ce flag.
  514                sequence Flag = fal se;
  515           }
  516           dd sArrayList .add(seqDD S);
  517           dd sIndex = d dsArrayLis t.size();
  518           Di comDataSet  ddsSeqIte ms[] = new  DicomData Set[ddsInd ex];
  519           fo r(int y=0;  y<ddsInde x; y++){
  520               ddsSeqIte ms[y] = dd sArrayList .get(y); 
  521           }
  522           At tributeTag  tag = new  Attribute Tag(elemen t);
  523           se quence = n ew DicomSQ Element(ta g, ddsSeqI tems);
  524           }
  525           ca tch(DCSExc eption dcs ){
  526                logger.e rror(dcs.g etMessage( ));
  527                logger.e rror(this. getClass() .getName() +": " +
  528                         "Exception  thrown wh ile extrac ting Seque nce Data." );
  529                throw ne w TextFile Extraction Exception( "Failure t o extract  Sequence." , dcs);
  530           }
  531           re turn seque nce;
  532       }
  533       
  534       /**
  535        * Ext racts a si ngle parse d line, in dependent  of any seq uences, an d converts  it to a D ICOM 
  536        * Ele ment and s tores the  DICOM Elme nt into th e desired  DCF Toolki t specific  
  537        * Dic omDataSet.
  538        * 
  539        * @pa ram line r epresents  the parsed  line from  the Text  file. 
  540        * @pa ram dds re presents t he DCF Too lkit speci fic DicomD ataSet obj ect.
  541        * @th rows TextF ileExtract ionExcepti on
  542        */
  543       privat e void ext ractDicomE lement(Str ing line,  DicomDataS et dds)
  544                throws T extFileExt ractionExc eption{
  545           // Setup the  ^ parser.
  546           St ring split CaratPatte rn = "\\^" ;
  547           Pa ttern pInf o = Patter n.compile( splitCarat Pattern);
  548           // Setup the  | parser.
  549           St ring split PipePatter n = "\\|";
  550           Pa ttern pFie lds = Patt ern.compil e(splitPip ePattern);
  551           // Setup the  , parser.
  552           St ring split CommaPatte rn = ",";
  553           Pa ttern pTag  = Pattern .compile(s plitCommaP attern);
  554  
  555           St ring field s[] = new  String[4];
  556           fi elds = pFi elds.split (line);
  557           // Parse the  basic data .
  558           // Set the Ta g variable .
  559           St ring tag =  fields[0] ;
  560           
  561           St ring eleme ntInfo = f ields[1];
  562           sh ort elemen tVR = ' ';
  563  
  564           tr y{
  565                Attribut eTag aTag  = new Attr ibuteTag(t ag);
  566                
  567                //Get th e VR.
  568                if(eleme ntInfo.cha rAt(elemen tInfo.leng th()-3) ==  '^'){
  569                    Stri ng subElem entInfo[]  = new Stri ng[2];
  570                    subE lementInfo  = pInfo.s plit(line) ;
  571                    elem entVR = Di comDataDic tionary.ge tVR(subEle mentInfo[1 ]);
  572                    orig inalPixelD ata.setVal ueRepresen tationInTe xtFile(tru e);
  573                }
  574                else{
  575                    elem entVR = Di comDataDic tionary.ge tElementVR (aTag);
  576                    orig inalPixelD ata.setVal ueRepresen tationInTe xtFile(fal se);
  577                }
  578  
  579                String m ultiplicit y;
  580                //This I F makes su re the VM, ML values  exist.
  581                if(field s.length >  2){
  582                    mult iplicity =  fields[2] ;
  583                    //Th is IF make s sure the re is a co mma delimi ter.
  584                    if(m ultiplicit y.indexOf( ",") >= 0) {
  585                         String val ue;
  586                         if(fields. length < 4 ){
  587                             value  = "";
  588                         }
  589                         else{
  590                             value  = fields[3 ];
  591                             if(val ue.equals( "<unknown> ")){
  592                                 va lue = "";
  593                             }
  594                         }
  595                         String mul tiple[] =  multiplici ty.split(" ,");
  596                         //Assign t he VM to a  temp fiel d. |VM,ML|
  597                         int vm = I nteger.par seInt(mult iple[0]);
  598                         //Assign t he ML to a  temp fiel d. |VM,ML|
  599                         int ml = I nteger.par seInt(mult iple[1]);
  600                         //100407-W FP-Discove red DCF do es not han dle VR=OF.   Adding I
  601                         //  statem ent to ign ore any te xt lines w ith this V R value.
  602                         if(element VR == Dico mDataDicti onary.getV R("OF")){
  603                             return ;
  604                         }
  605                         //If VM is  greater t han 1.
  606                         if(vm > 1) {
  607  
  608                             if(ele mentVR ==  DicomDataD ictionary. getVR("OB" )){
  609                                 Di comOBEleme nt element ;
  610                                 by te[] dataA rray = nul l;
  611                                 // If element  already e xist, then  pull the  data and a dd new val ue.
  612                                 if (dds.conta insElement (aTag)){
  613                                      //Extrac t element  from dds.
  614                                      element  = (DicomOB Element)dd s.findElem ent(aTag);
  615                                      //Extrac t the exis ting data  from the e lement
  616                                      ByteBuff er dataBuf fer = elem ent.getBuf fer();
  617                                      dataBuff er.get(dat aArray);
  618                                 }
  619                                 // Assign val ue to nuVa lue.  It u ses Long p rimitive t o make sur e there is  no
  620                                 //   truncati on of data .
  621                                 Lo ng nuValue  = new Lon g(value);
  622                                 // Add nuValu e to exist ing data.
  623                                 by te[] nuArr ay = this. addElement ToByteArra y(dataArra y, nuValue );
  624                                 // You cannot  just add  the nuArra y to the e xisting el ement in t he dds.
  625                                 //   Must cre ate a new  element an d insert i t into the  dds.  Thi s automati cally
  626                                 //   overwrit es the ori ginal elem ent.
  627                                 Di comOBEleme nt updated Element =  new DicomO BElement(a Tag, nuArr ay);
  628                                 dd s.insert(u pdatedElem ent);
  629                             }
  630                             else i f(elementV R == Dicom DataDictio nary.getVR ("US")){
  631                                 Di comUSEleme nt element ;
  632                                 in t[] dataAr ray = null ;
  633                                 // If element  already e xist, then  pull the  data and a dd new val ue.
  634                                 if (dds.conta insElement (aTag)){
  635                                      //Extrac t element  from dds.
  636                                      element  = (DicomUS Element)dd s.findElem ent(aTag);
  637                                      //Extrac t the exis ting data  from the e lement
  638                                      dataArra y = elemen t.getUSDat a();   
  639                                 }
  640                                 // Assign val ue to nuVa lue.  It u ses Long p rimitive t o make sur e there is  no
  641                                 //   truncati on of data .
  642                                 Lo ng nuValue  = new Lon g(value);
  643                                 // Add nuValu e to exist ing data.
  644                                 in t[] nuArra y = this.a ddElementT oIntArray( dataArray,  nuValue);
  645                                 // You cannot  just add  the nuArra y to the e xisting el ement in t he dds.
  646                                 //   Must cre ate a new  element an d insert i t into the  dds.  Thi s automati cally
  647                                 //   overwrit es the ori ginal elem ent.
  648                                 Di comUSEleme nt updated Element =  new DicomU SElement(a Tag, nuArr ay);
  649                                 dd s.insert(u pdatedElem ent);
  650                             }
  651                             else i f(elementV R == Dicom DataDictio nary.getVR ("SL")){
  652                                 Di comSLEleme nt element ;
  653                                 in t[] dataAr ray = null ;
  654                                 // If element  already e xist, then  pull the  data and a dd new val ue.
  655                                 if (dds.conta insElement (aTag)){
  656                                      //Extrac t element  from dds.
  657                                      element  = (DicomSL Element)dd s.findElem ent(aTag);
  658                                      //Extrac t the exis ting data  from the e lement
  659                                      dataArra y = elemen t.getSLDat a();   
  660                                 }
  661                                 // Assign val ue to nuVa lue.  It u ses Long p rimitive t o make sur e there is  no
  662                                 //   truncati on of data .
  663                                 Lo ng nuValue  = new Lon g(value);
  664                                 // Add nuValu e to exist ing data.
  665                                 in t[] nuArra y = this.a ddElementT oIntArray( dataArray,  nuValue);
  666                                 // You cannot  just add  the nuArra y to the e xisting el ement in t he dds.
  667                                 //   Must cre ate a new  element an d insert i t into the  dds.  Thi s automati cally
  668                                 //   overwrit es the ori ginal elem ent.
  669                                 Di comSLEleme nt updated Element =  new DicomS LElement(a Tag, nuArr ay);
  670                                 dd s.insert(u pdatedElem ent);
  671                             }
  672                             else i f(elementV R == Dicom DataDictio nary.getVR ("OW")){
  673                                 Di comOWEleme nt element ;
  674                                 sh ort[] data Array = nu ll;
  675                                 // If element  already e xist, then  pull the  data and a dd new val ue.
  676                                 if (dds.conta insElement (aTag)){
  677                                      //Extrac t element  from dds.
  678                                      element  = (DicomOW Element)dd s.findElem ent(aTag);
  679                                      //Extrac t the exis ting data  from the e lement
  680                                      ShortBuf fer dataBu ffer = (Sh ortBuffer) element.ge tValue();  // 3.2.2c  getShortBu ffer();
  681                                      dataBuff er.get(dat aArray);
  682                                 }
  683                                 // Assign val ue to nuVa lue.  It u ses Long p rimitive t o make sur e there is  no
  684                                 //   truncati on of data .
  685                                 Lo ng nuValue  = new Lon g(value);
  686                                 // Add nuValu e to exist ing data.
  687                                 sh ort[] nuAr ray = this .addElemen tToShortAr ray(dataAr ray, nuVal ue);
  688                                 // You cannot  just add  the nuArra y to the e xisting el ement in t he dds.
  689                                 //   Must cre ate a new  element an d insert i t into the  dds.  Thi s automati cally
  690                                 //   overwrit es the ori ginal elem ent.
  691                                 Di comOWEleme nt updated Element =  new DicomO WElement(a Tag, nuArr ay);
  692                                 dd s.insert(u pdatedElem ent);
  693                             }
  694                             else i f(elementV R == Dicom DataDictio nary.getVR ("SS")){
  695                                 Di comSSEleme nt element ;
  696                                 sh ort[] data Array = nu ll;
  697                                 // If element  already e xist, then  pull the  data and a dd new val ue.
  698                                 if (dds.conta insElement (aTag)){
  699                                      //Extrac t element  from dds.
  700                                      element  = (DicomSS Element)dd s.findElem ent(aTag);
  701                                      //Extrac t the exis ting data  from the e lement
  702                                      dataArra y = elemen t.getSSDat a();   
  703                                 }
  704                                 // Assign val ue to nuVa lue.  It u ses Long p rimitive t o make sur e there is  no
  705                                 //   truncati on of data .
  706                                 Lo ng nuValue  = new Lon g(value);
  707                                 // Add nuValu e to exist ing data.
  708                                 sh ort[] nuAr ray = this .addElemen tToShortAr ray(dataAr ray, nuVal ue);
  709                                 // You cannot  just add  the nuArra y to the e xisting el ement in t he dds.
  710                                 //   Must cre ate a new  element an d insert i t into the  dds.  Thi s automati cally
  711                                 //   overwrit es the ori ginal elem ent.
  712                                 Di comSSEleme nt updated Element =  new DicomS SElement(a Tag, nuArr ay);
  713                                 dd s.insert(u pdatedElem ent);
  714                             }
  715                             else i f(elementV R == Dicom DataDictio nary.getVR ("UL")){
  716                                 Di comULEleme nt element ;
  717                                 in t[] dataAr ray = null ;
  718                                 // If element  already e xist, then  pull the  data and a dd new val ue.
  719                                 if (dds.conta insElement (aTag)){
  720                                      //Extrac t element  from dds.
  721                                      element  = (DicomUL Element)dd s.findElem ent(aTag);
  722                                      //Extrac t the exis ting data  from the e lement
  723                                      dataArra y = elemen t.getULDat a();   
  724                                 }
  725                                 // Assign val ue to nuVa lue.  It u ses Long p rimitive t o make sur e there is  no
  726                                 //   truncati on of data .
  727                                 Lo ng nuValue  = new Lon g(value);
  728                                 // Add nuValu e to exist ing data.
  729                                 in t[] nuArra y = this.a ddElementT oIntArray( dataArray,  nuValue);
  730                                 // You cannot  just add  the nuArra y to the e xisting el ement in t he dds.
  731                                 //   Must cre ate a new  element an d insert i t into the  dds.  Thi s automati cally
  732                                 //   overwrit es the ori ginal elem ent.
  733                                 Di comULEleme nt updated Element =  new DicomU LElement(a Tag, nuArr ay);
  734                                 dd s.insert(u pdatedElem ent);
  735                             }
  736                             else i f(elementV R == Dicom DataDictio nary.getVR ("FL")){
  737                                      DicomFLE lement ele ment;
  738                                 fl oat[] data Array = nu ll;
  739                                 // If element  already e xist, then  pull the  data and a dd new val ue.
  740                                 if (dds.conta insElement (aTag)){
  741                                      //Extrac t element  from dds.
  742                                      element  = (DicomFL Element)dd s.findElem ent(aTag);
  743                                      //Extrac t the exis ting data  from the e lement
  744                                      dataArra y = elemen t.getFLDat a();   
  745                                 }
  746                                 // Assign val ue to nuVa lue.  It u ses Long p rimitive t o make sur e there is  no
  747                                 //   truncati on of data .
  748                                 fl oat nuValu e = new Fl oat(value) ;
  749                                 // Add nuValu e to exist ing data.
  750                                 fl oat[] nuAr ray = this .addElemen tToFloatAr ray(dataAr ray, nuVal ue);
  751                                 // You cannot  just add  the nuArra y to the e xisting el ement in t he dds.
  752                                 //   Must cre ate a new  element an d insert i t into the  dds.  Thi s automati cally
  753                                 //   overwrit es the ori ginal elem ent.
  754                                 Di comFLEleme nt updated Element =  new DicomF LElement(a Tag, nuArr ay);
  755                                 dd s.insert(u pdatedElem ent);
  756                             }
  757                             else i f(elementV R == Dicom DataDictio nary.getVR ("FD")){
  758                                      DicomFDE lement ele ment;
  759                                 do uble[] dat aArray = n ull;
  760                                 // If element  already e xist, then  pull the  data and a dd new val ue.
  761                                 if (dds.conta insElement (aTag)){
  762                                      //Extrac t element  from dds.
  763                                      element  = (DicomFD Element)dd s.findElem ent(aTag);
  764                                      //Extrac t the exis ting data  from the e lement
  765                                      dataArra y = elemen t.getFDDat a();   
  766                                 }
  767                                 // Assign val ue to nuVa lue.  It u ses Long p rimitive t o make sur e there is  no
  768                                 //   truncati on of data .
  769                                 do uble nuVal ue = new D ouble(valu e);
  770                                 // Add nuValu e to exist ing data.
  771                                 do uble[] nuA rray = thi s.addEleme ntToDouble Array(data Array, nuV alue);
  772                                 // You cannot  just add  the nuArra y to the e xisting el ement in t he dds.
  773                                 //   Must cre ate a new  element an d insert i t into the  dds.  Thi s automati cally
  774                                 //   overwrit es the ori ginal elem ent.
  775                                 Di comFDEleme nt updated Element =  new DicomF DElement(a Tag, nuArr ay);
  776                                 dd s.insert(u pdatedElem ent);
  777                             }
  778                             else{ 
  779                                      // at th is point i t is assum ed value V R is of ch ar string,  not binar y!
  780                                 St ring curre ntValue =  "";
  781                                 if (dds.conta insElement (aTag)){
  782                                      // Extra ct element  from dds  -- Must re trieve eac h individu al value t his way
  783                                      // as th e VM is gr eater than  1. -- The n concaten ate togeth er again.
  784                                      DicomEle ment eleme nt = dds.f indElement (aTag);
  785                                      for(int  i=0; i<ele ment.vm();  i++){
  786                                          curr entValue =  currentVa lue.concat (element.g etStringVa lue(i));
  787                                          if(i  < element .vm()-1){
  788                                               currentVal ue = curre ntValue.co ncat("\\") ;
  789                                          }
  790                                      }
  791                                 }
  792                                 el se{
  793                                      currentV alue = nul l;
  794                                 }
  795  
  796                                 // then Appen d a "\\" a nd the Val ue variabl e to this  Tag.
  797                                 Di comElement  updatedEl ement = Di comElement Factory.in stance().c reateEleme nt(aTag,
  798                                          (cur rentValue+ "\\"+value ));
  799                                 dd s.insert(u pdatedElem ent);
  800                             }
  801                         }
  802                         //If ML is  greater t han 1.
  803                         else if(ml  > 1){
  804                             //then  extract t his Tag fr om the dds .
  805                             String  currentVa lue;
  806                             if(dds .containsE lement(aTa g)){
  807                                 cu rrentValue  = dds.get ElementStr ingValue(a Tag);
  808                             }
  809                             else{
  810                                 cu rrentValue  = null;
  811                             }
  812                             //then  Append th e Value va riable to  this Tag.
  813                             if(aTa g.group()  != 0x7FE0) {
  814                                 Di comElement  updatedEl ement = Di comElement Factory.in stance().c reateEleme nt(aTag,
  815                                          (cur rentValue+ value));
  816                                 dd s.insert(u pdatedElem ent);
  817                             }
  818                             if(aTa g.group()  == 0x7FE0) {
  819                                 if (ml == 2){
  820                                      String p arsedValue s[] = valu e.split("= ");
  821                                      String l engthValue  = parsedV alues[1];
  822                                      String p arsedLengt h[] = leng thValue.sp lit(" ");
  823                                      String p ixelDataLe ngth = par sedLength[ 0].trim();
  824                                      Long len gthLong =  new Long(p ixelDataLe ngth);
  825                                      this.ori ginalPixel Data.setOr iginalLeng th(lengthL ong.longVa lue());
  826                                 }
  827                                 if (ml == 3){
  828                                      String p arsedValue s[] = valu e.split("= ");
  829                                      String l engthValue  = parsedV alues[1];
  830                                      String p arsedOffse t[] = leng thValue.sp lit(" ");
  831                                      String p ixelDataOf fset = par sedOffset[ 0].trim();
  832                                      Integer  offsetInt  = new Inte ger(pixelD ataOffset) ;
  833                                      this.ori ginalPixel Data.setOr iginalOffs et(offsetI nt.intValu e());
  834                                 }
  835                             }
  836                         }
  837                         else{
  838                             //FUTU RE The if  sequence w orks.  But  I like to  find a mo re efficie nt way.
  839                             //Attr ibuteTag a Tag = new  AttributeT ag(tag);
  840                             if((aT ag.element () == 0) | | (aTag.el ement() ==  1)){
  841                                 if (aTag.grou p() <= 2){
  842                                      DicomEle ment nuEle ment = Dic omElementF actory.ins tance().cr eateElemen t(aTag,
  843                                               value);
  844                                      dds.inse rt(nuEleme nt);
  845                                 }
  846                             }
  847                             else{
  848                                 if (aTag.grou p() != 0x7 FE0){
  849                                      DicomEle ment nuEle ment = Dic omElementF actory.ins tance().cr eateElemen t(aTag,
  850                                               value);
  851                                      dds.inse rt(nuEleme nt);
  852                                 }
  853                                 if ((aTag.gro up() == 0x 7FE0) && ( aTag.eleme nt() == 0x 0010)) {
  854                                      char isC arat = fie lds[1].cha rAt((field s[1].lengt h())-3);
  855                                      if(isCar at == '^') {
  856                                          Stri ng desc_vr Field = fi elds[1];
  857                                          Stri ng desc_vr [] = desc_ vrField.sp lit("\\^") ;
  858                                          Stri ng textfil eVR = desc _vr[1];
  859                                          orig inalPixelD ata.setOri ginalVR(Di comDataDic tionary.ge tVR(textfi leVR));
  860                                      }
  861                                      else{
  862                                          shor t bitsAllo cated = (s hort)dds.g etElementI ntValue(DC M.E_BITS_A LLOCATED);
  863                                          this .originalP ixelData.s etBitsAllo cated(bits Allocated) ;
  864                                      }
  865                                 }
  866                             }
  867                         }
  868                         //End If f or VM/VL.
  869                    }
  870                }
  871                else if  (fields.le ngth == 2) {
  872                    shor t vr = Dic omDataDict ionary.get ElementVR( aTag);
  873                    if(D icomDataDi ctionary.g etVRString (vr).equal s("SQ")){
  874                         DicomSQEle ment nuEle ment = new  DicomSQEl ement( aTa g, (DicomD ataSet[])n ull );                      
  875                         dds.insert (nuElement );    
  876                    }
  877                }
  878           }
  879           ca tch(DCSExc eption dcs ){
  880                logger.e rror(dcs.g etMessage( ));
  881                logger.e rror(this. getClass() .getName() +": " +
  882                         "Exception  thrown wh ile extrac ting Dicom  Element." );
  883                throw ne w TextFile Extraction Exception( "Failure t o extract  Dicom Elem ent.", dcs );
  884           }
  885       }
  886  
  887       /**
  888        * Par se the Tex t file HIS  Update se ction.  Th e Text fil e is made  up of thre e sections ,
  889        * "Da ta1", "DIC OM Data" a nd  option ally "HIS  UPDATE".   Here only  the HIS UP DATE secti on
  890        * is  read and d ecoded.
  891        * 
  892        * @pa ram buffer  represent s the Text  file now  in the for m of a Buf ferReader  object.
  893        * @th rows TextF ileExtract ionExcepti on
  894        */
  895       //WFP- This does  not appear  to be cor rect.  The re is no s uch sectio n in the . txt file.
  896       //  Wi ll address  later whe n I have t ime.
  897       privat e HashMap< String, St ring> pars eHisUpdate s(Buffered Reader buf fer) 
  898           th rows TextF ileExtract ionExcepti on {
  899           
  900           St ring textL ine = "";
  901           Ha shMap<Stri ng, String > hisUpdat es=null;
  902   //      te stLogger.i nfo("... P arsing tex t data upd ate sectio n ...");
  903           tr y { // par se line fo r initial  "gggg,eeee " or "gggg ,eeee gggg ,eeee" tag s
  904                    do {
  905                       t extLine =  this.getNe xtTextLine (buffer);
  906                    } wh ile(!(text Line.start sWith("$$B EGIN HIS U PDATE")));
  907           }
  908                catch(Te xtFileExtr actionExce ption tfee ) { // cat ch all
  909                    logg er.info("W arning: NO  HIS Updat e section  in text da ta !!!");
  910                    logg er.debug(" Warning: o bsolete TX T format N O VistA up dates !!!  ");
  911                    retu rn hisUpda tes;
  912                }
  913           te xtLine = t his.getNex tTextLine( buffer); / / skip to  first HIS  update lin e
  914           hi sUpdates=n ew HashMap <String, S tring>();
  915               
  916           wh ile(!(text Line.start sWith("$$E ND HIS UPD ATE"))) {
  917               try { //  parse line  for initi al "gggg,e eee" or "g ggg,eeee g ggg,eeee"  tags
  918                       / / and endi ng text va lue 
  919                       S tring spli tPipePatte rn = "\\|" ;
  920                       P attern pFi elds = Pat tern.compi le(splitPi pePattern) ;
  921                       S tring fiel ds[] = new  String[4] ;
  922                       f ields = pF ields.spli t(textLine );
  923                       i f ( ((fiel ds[0].leng th()==9) | | (fields[ 0].length( )==18)) &&
  924                                         (fiel ds[3].leng th()>0)) {
  925                                //  place tag( s)-value p airs to Ha shMap
  926                                his Updates.pu t(fields[0 ], fields[ 3]);
  927                       }
  928               }
  929               catch(Thr owable t)  { // catch  all
  930               }
  931               textLine  = this.get NextTextLi ne(buffer) ;
  932           }  // end wil e
  933           lo gger.debug ("Number o f HIS Upda tes: "+his Updates.si ze());
  934           if  (hisUpdat es.isEmpty ()) 
  935                    retu rn null;
  936           el se 
  937                    retu rn hisUpda tes; 
  938       }
  939  
  940       /**
  941        * Rea ds next li ne from th e Text fil e, which i s now in t he form of  BufferedR eader 
  942        * obj ect.  This  method ch ecks for E OF, nulls,  and blank  lines.  T his is pri marily in
  943        * cas e the Text  file was  not proper ly formatt ed or corr upted.  If  the line  is valid, 
  944        * the  line is r eturned.
  945        * 
  946        * @pa ram in rep resents th e Buffered Reader obj ect.
  947        * @re turn repre sents the  next line  read from  the Buffer edReader o bject.
  948        * @th rows TextF ileExtract ionExcepti on
  949        */
  950       privat e String g etNextText Line(Buffe redReader  in) throws  TextFileE xtractionE xception{
  951           St ring line  = null;
  952           tr y{
  953                do{
  954                    if(( line = in. readLine() ) == null) {
  955                         throw new  TextFileEx tractionEx ception();
  956                    }
  957                }while(l ine.equals (""));
  958           }
  959           ca tch(IOExce ption io){
  960                logger.e rror(io.ge tMessage() );
  961                logger.e rror(this. getClass() .getName() +": " +
  962                         "Exception  thrown wh ile gettin g next lin e from Tex t Line.");
  963                throw ne w TextFile Extraction Exception( "Failure t o get next  line.", i o);
  964           }
  965           re turn line;
  966       }
  967       
  968       privat e boolean  isGroupToB eAdded(int  Group){
  969           bo olean addG roup = tru e;
  970           
  971           // Do not all ow Odd Gro ups
  972           if ((Group %  2) != 0){
  973                addGroup  = false;
  974           }
  975           
  976           // Do not all ow Icon Im age Sequen ces
  977           if (Group ==  0x0088){
  978                addGroup  = false;
  979           }
  980           
  981           // Need to re move Group  0002 elem ents.  Fou nd bug of  sending Gr oup 0002 e lements
  982           //   to CSTor e SCP devi ce.  This  is not val id.  I str ongly beli eve to add  it here.   I do
  983           //   not thin k any code  between h ere and th e sending  uses this  group.  Bu t I could  be 
  984           //   wrong.
  985           if (Group ==  0x0002){
  986                addGroup  = false;
  987           }
  988           
  989           re turn addGr oup;
  990       }
  991       
  992       privat e void cus tomTGAElem entCleanup (){
  993           tr y{
  994                    if(t his.dicomD ataSet.con tainsEleme nt(new Att ributeTag( "0008,0008 "))){
  995                             DicomC SElement o bjectType  = (DicomCS Element)th is.dicomDa taSet.find Element(ne w Attribut eTag("0008 ,0008"));
  996                             String [] values  = objectTy pe.getStri ngData();
  997                             ArrayL ist<String > nuValueA rray = new  ArrayList <String>(v alues.leng th);
  998                             for(in t i=0; i<v alues.leng th; i++){
  999                                               nuValueArr ay.add(val ues[i]);
  1000                             }
  1001                             while( nuValueArr ay.contain s("")){
  1002                                      nuValueA rray.remov e("");
  1003                             }
  1004                             nuValu eArray.tri mToSize();
  1005                             
  1006                             String [] nuValue s = new St ring[nuVal ueArray.si ze()];
  1007                             Iterat or<String>  iter = nu ValueArray .iterator( );
  1008                             int j  = 0;
  1009                             while( iter.hasNe xt()){
  1010                                      nuValues [j] = iter .next();
  1011                                      j++;
  1012                             }
  1013                             DicomC SElement n uObjectTyp e = new Di comCSEleme nt(new Att ributeTag( "0008,0008 "),
  1014                                                                                                   nu Values);
  1015                             this.d icomDataSe t.insert(n uObjectTyp e);
  1016                    }
  1017           }
  1018           ca tch(DCSExc eption dcs X){
  1019                    //do  nothing
  1020           }
  1021           
  1022       }
  1023       
  1024       privat e byte[] a ddElementT oByteArray (byte[] ol dArray, Lo ng nuValue ){
  1025       
  1026           if (oldArray  == null){
  1027                oldArray  = new byt e[0];
  1028           }
  1029           in t length =  oldArray. length;
  1030           in t index =  length+1;
  1031           by te nuArray [] = new b yte[index] ;
  1032           Sy stem.array copy(oldAr ray, 0, nu Array, 0,  length);
  1033           nu Array[inde x-1] = nuV alue.byteV alue();
  1034           re turn nuArr ay;
  1035       }
  1036       
  1037       privat e short[]  addElement ToShortArr ay(short[]  oldArray,  Long nuVa lue){
  1038           
  1039                int leng th = oldAr ray.length ;
  1040                int inde x = length +1;
  1041                short nu Array[] =  new short[ index];
  1042                System.a rraycopy(o ldArray, 0 , nuArray,  0, length );
  1043                nuArray[ index-1] =  nuValue.s hortValue( );
  1044                return n uArray;
  1045           }
  1046  
  1047       privat e int[] ad dElementTo IntArray(i nt[] oldAr ray, Long  nuValue){
  1048           
  1049                int leng th = oldAr ray.length ;
  1050                int inde x = length +1;
  1051                int nuAr ray[] = ne w int[inde x];
  1052                System.a rraycopy(o ldArray, 0 , nuArray,  0, length );
  1053                nuArray[ index-1] =  nuValue.i ntValue();
  1054                return n uArray;
  1055           }
  1056  
  1057       privat e float[]  addElement ToFloatArr ay(float[]  oldArray,  Float nuV alue){
  1058           
  1059                int leng th = oldAr ray.length ;
  1060                int inde x = length +1;
  1061                float nu Array[] =  new float[ index];
  1062                System.a rraycopy(o ldArray, 0 , nuArray,  0, length );
  1063                nuArray[ index-1] =  nuValue.f loatValue( );
  1064                return n uArray;
  1065           }
  1066  
  1067       privat e double[]  addElemen tToDoubleA rray(doubl e[] oldArr ay, Double  nuValue){
  1068           
  1069                int leng th = oldAr ray.length ;
  1070                int inde x = length +1;
  1071                double n uArray[] =  new doubl e[index];
  1072                System.a rraycopy(o ldArray, 0 , nuArray,  0, length );
  1073                nuArray[ index-1] =  nuValue.d oubleValue ();
  1074                return n uArray;
  1075           }     
  1076   }