150. EPMO Open Source Coordination Office Redaction File Detail Report

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

150.1 Files compared

# Location File Last Modified
1 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\DicomServiceProvider\main\src\java\gov\va\med\imaging\dicom\parser\impl DicomDateFormat.java Mon Dec 4 21:35:22 2017 UTC
2 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\DicomServiceProvider\main\src\java\gov\va\med\imaging\dicom\parser\impl DicomDateFormat.java Tue Dec 5 12:44:09 2017 UTC

150.2 Comparison summary

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

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

150.4 Active regular expressions

No regular expressions were active.

150.5 Comparison detail

  1   /**
  2    * 
  3    */
  4   package go v.va.med.i maging.dic om.parser. impl;
  5  
  6   import jav a.text.Dat eFormat;
  7   import jav a.text.Dec imalFormat ;
  8   import jav a.text.Num berFormat;
  9   import jav a.text.Par seExceptio n;
  10   import jav a.text.Sim pleDateFor mat;
  11   import jav a.util.Cal endar;
  12   import jav a.util.Dat e;
  13   import jav a.util.Gre gorianCale ndar;
  14   import jav a.util.Loc ale;
  15   import jav a.util.Tim eZone;
  16   import org .apache.lo gging.log4 j.LogManag er;
  17   import org .apache.lo gging.log4 j.Logger;
  18   import jav a.util.reg ex.Matcher ;
  19   import jav a.util.reg ex.Pattern ;
  20  
  21   /**
  22    * A date  formatter  for DICOM  date-time  data eleme nts (DT).
  23    * 
  24    * ======= ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ====
  25    * From th e DICOM Sp ec (06.05  pg.26):
  26    * "The Da te Time co mmon data  type. Indi cates a co ncatenated  date-time  ASCII str ing in the  format: Y YYYMMDDHHM MSS.FFFFFF &ZZZZ
  27    * The com ponents of  this stri ng, from l eft to rig ht, are 
  28    * YYYY =  Year, 
  29    * MM = Mo nth, 
  30    * DD = Da y, 
  31    * HH = Ho ur, 
  32    * MM = Mi nute, 
  33    * SS = Se cond, 
  34    * FFFFFF  = Fraction al Second,  
  35    * & = “+”  or “-”, a nd 
  36    * ZZZZ =  Hours and  Minutes of  offset. 
  37    * &ZZZZ i s an optio nal suffix  for plus/ minus offs et from Co ordinated  Universal  Time. A co mponent th at is omit ted from t he string  is
  38    * termed  a null com ponent. Tr ailing nul l componen ts of Date  Time are  ignored. N ontrailing  null comp onents are  prohibite d, given
  39    * that th e optional  suffix is  not consi dered as a  component .
  40    * Note: F or reasons  of backwa rd compati bility wit h versions  of this s tandard pr ior to V3. 0, many ex isting DIC OM Data
  41    * Element s use the  separate D A and TM V Rs. Standa rd and Pri vate Data  Elements d efined in  the future  should us e DT, when  
  42    * appropr iate, to b e more com pliant wit h ANSI HIS PP MSDS."
  43    * ======= ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ====
  44    * 
  45    * NOTES
  46    * 1.) Thi s class DO ES NOT sup port the b ackward co mpatibilit y mentione d above fo r versions  before 3. 0.
  47    * 2.) The  DICOM spe cification  does not  specify th e calendar  used for  date inter pretation.   This cla ss
  48    * always  uses a Gre gorian cal endar.
  49    * 3.) The  timezone  is default ed to the  default ti mezone for  the VM if  it is not  specified .
  50    * 4.) DIC OM uses 1- indexing f or months.  
  51    * ======= ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ====
  52    * 
  53    * @author         
BECKEC
  54    */
  55   public cla ss DicomDa teFormat
  56   extends Si mpleDateFo rmat
  57   {
  58           pr ivate stat ic final l ong serial VersionUID  = -138146 1230116366 880L;
  59  
  60           //  YYYYMMDDH HMMSS.FFFF FF+ZZZZ
  61           //  The compo nents of t his string , from lef t to right , are 
  62           //  YYYY = Ye ar, 
  63           //  MM = Mont h, 
  64           //  DD = Day,  
  65           //  HH = Hour
  66           //  MM = Minu te, 
  67           //  SS = Seco nd,
  68           //  FFFFFF =  millisecon ds
  69           //  ZZZZZ - t imezone of fset (firs t digit is  + or -
  70           pr ivate fina l static S tring dico mDateForma t = "yyyyM MddHHmmss. SSSSSSZZZZ Z";
  71           
  72           //  The regul are expres sion patte rn should  read as:
  73           //       requ ired   4 d igits (the  year)
  74           //       opti onally 2 d igit (the  month of t he year)
  75           //       opti onally 2 d igit (the  day of the  month)
  76           //       opti onally 2 d igits (for  each of t he hour, m inute and  seconds)
  77           //       opti onally 1 d ecimal poi nt followe d by 4 or  6 digits ( for the mi lliseconds )
  78           //       opti onally 1 ' +' or '-'  followed b y 4 digits , 2 for ho urs and 2  for minute s (for the  offset fr om UCT)
  79           pr ivate fina l static S tring dico mDateRegex  = "(\\d{4 })(\\d{2}) ?(\\d{2})? (\\d{2})?( \\d{2})?(\ \d{2})?(\\ .(\\d{4}|\ \d{6}))?(( [+|-]\\d{4 }))?";
  80           
  81           pr ivate stat ic final i nt yearGro upIndex =  1;
  82           pr ivate stat ic final i nt monthGr oupIndex =  2;
  83           pr ivate stat ic final i nt dayGrou pIndex = 3 ;
  84           pr ivate stat ic final i nt hourGro upIndex =  4;
  85           pr ivate stat ic final i nt minuteG roupIndex  = 5;
  86           pr ivate stat ic final i nt secondG roupIndex  = 6;
  87           pr ivate stat ic final i nt millise condGroupI ndex = 8;
  88           pr ivate stat ic final i nt timezon eGroupInde x = 9;
  89           
  90           //  during pr ocessing i t may be n ecessary t o calculat e a date t o use for  timezone
  91           //  determina tion, this  is NOT th e DateForm at used to  do our fo rmatting o r parsing
  92           pr ivate Date Format uti lityDateFo rmat = new  SimpleDat eFormat("y yyyMMddhhm mss.SSSSSS ");
  93  
  94           //  a NumberF ormat used  to build  timezone f ormatted s trings
  95           pr ivate Numb erFormat t imezoneNum berFormat  = new Deci malFormat( "+0000;-00 00");
  96           
  97           /* *
  98            *  Construct  a DicomDa teFormat i nstance us ing the de fault loca le.
  99            *
  100            * /
  101           pu blic Dicom DateFormat ()
  102           {
  103                    supe r(dicomDat eFormat);
  104                    supe r.setCalen dar(new Gr egorianCal endar());
  105           }
  106  
  107           /* *
  108            *  Construct  a DicomDa teFormat i nstance sp ecifying a  locale.
  109            *  
  110            *  @param lo cale
  111            * /
  112           pu blic Dicom DateFormat (Locale lo cale)
  113           {
  114                    supe r(dicomDat eFormat, l ocale);
  115                    supe r.setCalen dar(new Gr egorianCal endar());
  116           }
  117  
  118           /* *
  119            *  Method do es nothing , the date  format pa ttern is d efined by  the class.
  120            *  
  121            *  @see java .text.Simp leDateForm at#applyLo calizedPat tern(java. lang.Strin g)
  122            * /
  123           @O verride
  124           pu blic void  applyLocal izedPatter n(String p attern) {}
  125  
  126           /* *
  127            *  Method do es nothing , the date  format pa ttern is d efined by  the class.
  128            *  
  129            *  @see java .text.Simp leDateForm at#applyPa ttern(java .lang.Stri ng)
  130            * /
  131           @O verride
  132           pu blic void  applyPatte rn(String  pattern){}
  133  
  134           /* *
  135            *  Method do es nothing , the Cale ndar is de fined by t he class a s a Gregor ian calend ar instanc e.
  136            *  
  137            *  @see java .text.Date Format#set Calendar(j ava.util.C alendar)
  138            * /
  139           @O verride
  140           pu blic void  setCalenda r(Calendar  newCalend ar){}
  141  
  142           /* *
  143            *  @throws P arseExcept ion 
  144            *  
  145            * /
  146           @O verride
  147           pu blic Date  parse(Stri ng dicomFo rmattedDat e) 
  148           th rows Parse Exception
  149           {
  150                    Stri ng year =  null;
  151                    Stri ng month =  null;
  152                    Stri ng day = n ull;
  153                    Stri ng hour =  null;
  154                    Stri ng minute  = null;
  155                    Stri ng second  = null;
  156                    Stri ng millise cond = nul l;
  157                    Stri ng timezon eOffset =  null;
  158                    
  159                    Patt ern dicomP attern = P attern.com pile(dicom DateRegex) ;
  160                    
  161                    Matc her matche r = dicomP attern.mat cher(dicom FormattedD ate);
  162                    if(  ! matcher. matches()  )
  163                             throw  new ParseE xception(" '" + dicom FormattedD ate + "' i s not a va lid DICOM  date.", 0) ;
  164  
  165                    year  = matcher .group(yea rGroupInde x);
  166                    
  167                    mont h  = match er.group(m onthGroupI ndex);
  168                    mont h = (month  == null ?  "01" : mo nth);
  169                    int  monthInt =  Integer.p arseInt(mo nth);
  170                    if(m onthInt <  1 || month Int > 12)
  171                             throw  new ParseE xception(" Month must  be betwee n 01 and 1 1", 3);
  172                    
  173                    day   = matcher .group(day GroupIndex );
  174                    day  = (day ==  null ? "01 " : day);
  175                    
  176                    hour   = matche r.group(ho urGroupInd ex);
  177                    hour  = (hour = = null ? " 00" : hour );
  178                    
  179                    minu te = match er.group(m inuteGroup Index);
  180                    minu te = (minu te == null  ? "00" :  minute);
  181                    
  182                    seco nd  = matc her.group( secondGrou pIndex);
  183                    seco nd = (seco nd == null  ? "00" :  second);
  184                    
  185                    mill isecond  =  matcher.g roup(milli secondGrou pIndex);
  186                    mill isecond =  (milliseco nd == null  ? "000000 " : millis econd);
  187                    
  188                    time zoneOffset   = matche r.group(ti mezoneGrou pIndex);
  189                    if(t imezoneOff set == nul l)
  190                    {
  191                             Date d ate = util ityDateFor mat.parse( year + mon th + day +  hour + mi nute + sec ond + "."  + millisec ond);
  192                             
  193                             // get Offset() r eturns the  amount of  time in m illisecond s to add t o UTC to g et local t ime.
  194                             int of fset = Tim eZone.getD efault().g etOffset(d ate.getTim e());
  195                             
  196                             int of fsetMinute s = offset  / (1000 *  60);
  197                             int of fsetHours  = offsetMi nutes / 60 ;
  198                             offset Minutes %=  60;
  199                             
  200                             timezo neOffset =  timezoneN umberForma t.format(o ffsetHours  * 100 + o ffsetMinut es);
  201                    }
  202                    
  203                    //fo r(int grou pIndex=0;  groupIndex  < matcher .groupCoun t(); ++gro upIndex)
  204                    //{
  205                    //       String  group = m atcher.gro up(groupIn dex);
  206                    //       System .out.print ln("\tGrou p [" + gro upIndex +  "] = '" +  group + "' ");
  207                    //}
  208                    Stri ng concate natedTime  = year + m onth + day  + hour +  minute + s econd + ". " + millis econd + ti mezoneOffs et;
  209                    
  210                    LogM anager.get Logger(thi s.getClass ().getName ()).info(" Parsing co ncatenated  time '" +  concatena tedTime +  "'.");
  211                    retu rn super.p arse(conca tenatedTim e);
  212           }
  213  
  214           /* *
  215            *  @see java .text.Simp leDateForm at#equals( java.lang. Object)
  216            * /
  217           @O verride
  218           pu blic boole an equals( Object obj )
  219           {
  220                    retu rn obj ins tanceof Di comDateFor mat && sup er.equals( obj);
  221           }
  222  
  223           /* *
  224            *  This is s imply a te st driver  for develo pment.
  225            *  
  226            *  @param ar gv
  227            * /
  228           pu blic stati c void mai n(String [ ] argv)
  229           {
  230                    Date Format out putDf = ne w SimpleDa teFormat(" dd-MMM-yyy y @ hh:mm: ss.SSSS ZZ ZZZ");
  231                    try
  232                    {
  233                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 7")) ); //  year
  234                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 712")) );  // year, m onth
  235                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 71230")) ) ; // year,  month, da y
  236                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 7123012"))  ); // yea r, month,  day, hour
  237                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 712301234" )) ); // y ear, month , day, hou r, minute
  238                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 7123012345 6")) ); //  year, mon th, day, h our, minut e, second
  239                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 7123012345 6.9999"))  ); // year , month, d ay, hour,  minute, se cond, mill isecond
  240                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 7123012345 6.999999") ) ); // ye ar, month,  day, hour , minute,  second, mi llisecond
  241                             
  242                             // rep eat all of  the above  with posi tive timez one
  243                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 7+0500"))  ); // year
  244                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 712+0500") ) ); // ye ar, month
  245                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 71230+0500 ")) ); //  year, mont h, day
  246                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 7123012+05 00")) ); / / year, mo nth, day,  hour
  247                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 712301234+ 0500")) );  // year,  month, day , hour, mi nute
  248                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 7123012345 6+0500"))  ); // year , month, d ay, hour,  minute, se cond
  249                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 7123012345 6.9999+050 0")) ); //  year, mon th, day, h our, minut e, second,  milliseco nd
  250                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 7123012345 6.999999+0 500")) );  // year, m onth, day,  hour, min ute, secon d, millise cond
  251                             
  252                             // rep eat all of  the above  with nega tive timez one
  253                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 7-0500"))  ); // year
  254                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 712-0500") ) ); // ye ar, month
  255                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 71230-0500 ")) ); //  year, mont h, day
  256                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 7123012-05 00")) ); / / year, mo nth, day,  hour
  257                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 712301234- 0500")) );  // year,  month, day , hour, mi nute
  258                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 7123012345 6-0500"))  ); // year , month, d ay, hour,  minute, se cond
  259                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 7123012345 6.9999-050 0")) ); //  year, mon th, day, h our, minut e, second,  milliseco nd
  260                             System .out.print ln( "Resul t is '" +  outputDf.f ormat(pars eDate("200 7123012345 6.999999-0 500")) );  // year, m onth, day,  hour, min ute, secon d, millise cond
  261                    } 
  262                    catc h(Exceptio n x)
  263                    {
  264                             x.prin tStackTrac e();
  265                    }
  266           }
  267           pr ivate stat ic Date pa rseDate(St ring dateS tring) 
  268           th rows Parse Exception
  269           {
  270                    Dico mDateForma t df = new  DicomDate Format();
  271                    
  272                    Syst em.out.pri ntln("Pars ing '" + d ateString  + "'.");
  273                    retu rn df.pars e(dateStri ng);
  274           }
  275   }