100. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 7/3/2018 11:43:41 AM 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.

100.1 Files compared

# Location File Last Modified
1 eHealth_v8.2.0_build_8.2.0.1.zip\NHIN_adapter\AdapterLIB\src\main\java\gov\va\med\nhin\adapter\datamanager\translators FileManDateUnfilteredDataTranslator.java Tue Jun 26 18:27:13 2018 UTC
2 eHealth_v8.2.0_build_8.2.0.1.zip\NHIN_adapter\AdapterLIB\src\main\java\gov\va\med\nhin\adapter\datamanager\translators FileManDateUnfilteredDataTranslator.java Fri Jun 29 20:39:55 2018 UTC

100.2 Comparison summary

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

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

100.4 Active regular expressions

No regular expressions were active.

100.5 Comparison detail

  1   package go v.va.med.n hin.adapte r.datamana ger.transl ators;
  2  
  3   import jav a.math.Big Decimal;
  4   import jav a.text.Dec imalFormat ;
  5   import jav a.text.Sim pleDateFor mat;
  6   import jav a.util.Dat e;
  7  
  8   import gov .va.med.nh in.adapter .datamanag er.DataDat e;
  9   import gov .va.med.nh in.adapter .datamanag er.DataMan agerExcept ion;
  10   import gov .va.med.nh in.adapter .datamanag er.DataQue ry;
  11   import gov .va.med.nh in.adapter .datamanag er.DataTra nslator;
  12   import gov .va.med.nh in.adapter .datamanag er.Referen ce;
  13   import gov .va.med.nh in.adapter .utils.Nul lChecker;
  14   import jav a.text.Par seExceptio n;
  15  
  16   /**
  17    * Convert s dates re turned fro m VistA in to the pas sed in for mat. This  is a
  18    * modifie d version  of FileMan DateDataTr anslater.  This new c lass will  not reject
  19    * date fo rmats and  will not l imit the s cope of th e date pat tern.
  20    * 
  21    * Time fo rmats must  be simple  formats l imited to:  Begining  with hour  (H, h, K,
  22    * k) endi ng in eith er: minute s (m), Sec onds (s),  MilliSecon ds (S), or  AM/PM
  23    * designa tor (a). A ll in betw een charac ters will  be removed .
  24    * 
  25    * Date fo rmats shou ld also be  simple, a s no in be tween char acters wil l be
  26    * removed . If the n eed arises  those sho uld be add ed. There  are specia l handlers
  27    * for usi ng the "pr etty" form at.
  28    * 
  29    * @author   PII
  30    *
  31    */
  32   public cla ss FileMan DateUnfilt eredDataTr anslator i mplements  DataTransl ator<DataD ate>
  33   {
  34           st atic priva te final S tring DATE _FORMAT =  "yyyyMMddH Hmmss";
  35           st atic priva te final S tring PRET TY_FORMAT  = "MMM dd,  yyyy, hh: mm a";
  36           st atic priva te final i nt YEAR_LE NGTH = 4;
  37           st atic priva te final i nt MONTH_L ENGTH = 6;
  38           st atic priva te final i nt DAY_LEN GTH = 8;
  39  
  40           @O verride
  41           pu blic DataD ate transl ate(Object  input, Ob ject resul t, Referen ce transla tion, Data Query data Query)
  42           {
  43                    Data Date ret =  null;
  44  
  45                    if(i nput != nu ll && !inp ut.toStrin g().equals ("0"))
  46                    {
  47                             if(!(i nput insta nceof java .math.BigD ecimal))
  48                             {
  49                                      try
  50                                      {
  51                                               input = ja va.math.Bi gDecimal.v alueOf(Dou ble.parseD ouble((Str ing) input ));
  52                                      }
  53                                      catch(Nu mberFormat Exception  e)
  54                                      {
  55                                               throw new  DataManage rException ("input mu st be of t ype java.m ath.BigDec imal");
  56                                      }
  57                             }
  58  
  59                             String  targetDat eFormat =  translatio n.getPrope rty("targe tDateForma t");
  60  
  61                             if(Nul lChecker.i sNullOrEmp ty(targetD ateFormat) )
  62                             {
  63                                      targetDa teFormat =  PRETTY_FO RMAT;
  64                             }
  65  
  66                             String  s = fixFi leManDate( (BigDecima l) input);
  67  
  68                             String  datePatte rn = DATE_ FORMAT.sub string(0,  s.length() );
  69  
  70                             Simple DateFormat  formatter  = new Sim pleDateFor mat(datePa ttern);
  71                             try
  72                             {
  73                                      Date d =  formatter .parse(s);
  74                                      ret = ne w DataDate (d.getTime (), filter Format(s.l ength(), t argetDateF ormat));
  75                             }
  76                             catch( ParseExcep tion t)
  77                             {
  78                                      throw ne w DataMana gerExcepti on("There  was an err or parsing  the date. ", t);
  79                             }
  80                    }
  81  
  82                    retu rn ret;
  83           }
  84  
  85           pr ivate Stri ng fixFile ManDate(Bi gDecimal f ileManDate )
  86           {
  87                    Stri ng ret;
  88                    doub le d = fil eManDate.d oubleValue () + 17000 000;
  89                    Deci malFormat  formatter  = (Decimal Format) De cimalForma t.getNumbe rInstance( );
  90                    form atter.appl yPattern(" 00000000.# #####");
  91                    ret  = formatte r.format(d );
  92  
  93                    int  dotIndex =  ret.index Of(".");
  94                    if(d otIndex ==  -1)
  95                    {
  96                             while( ret.endsWi th("00"))
  97                             {
  98                                      ret = re t.substrin g(0, ret.l ength() -  2);
  99                             }
  100                    }
  101                    else
  102                    {
  103                             if((re t.length()  - 9) % 2  != 0)
  104                             {
  105                                      ret += " 0";
  106                             }
  107  
  108                             ret =  ret.substr ing(0, dot Index) + r et.substri ng(dotInde x + 1);
  109                    }
  110  
  111                    retu rn ret;
  112           }
  113  
  114           /* *
  115            *  This meth od will re move unuse d portions  of the da te format.  For examp le
  116            *  if there  is no time  do not ap ply time.  If there i s no day . ..
  117            *  
  118            *  @param le ngth
  119            *  @param fo rmat
  120            *  @return
  121            * /
  122           pr ivate Stri ng filterF ormat(fina l int leng th, final  String for mat)
  123           {
  124                    Stri ng ret;
  125                    swit ch(length)
  126                    {
  127                    case  YEAR_LENG TH:
  128                             ret =  removeMont h(format);
  129                             break;
  130                    case  MONTH_LEN GTH:
  131                             ret =  removeDay( format);
  132                             break;
  133                    case  DAY_LENGT H:
  134                             ret =  removeTime (format);
  135                             break;
  136                    defa ult:
  137                             ret =  format;
  138                    }
  139  
  140                    retu rn ret.tri m();
  141           }
  142  
  143           pr ivate Stri ng removeM onth(final  String fo rmat)
  144           {
  145                    Stri ng ret = r emoveDay(f ormat);
  146                    retu rn ret.rep lace("M",  "");
  147           }
  148  
  149           pr ivate Stri ng removeD ay(final S tring form at)
  150           {
  151                    Stri ng ret = r emoveTime( format);
  152                    // R emove "pre tty" forma tted day.
  153                    ret  = ret.repl ace("dd, " , "");
  154  
  155                    ret  = ret.repl ace("d", " ");
  156                    ret  = ret.repl ace("D", " ");
  157                    ret  = ret.repl ace("F", " ");
  158                    ret  = ret.repl ace("E", " ");
  159                    ret  = ret.repl ace("w", " ");
  160                    retu rn ret;
  161           }
  162  
  163           pr ivate Stri ng removeT ime(final  String for mat)
  164           {
  165                    Stri ng ret = f ormat;
  166  
  167                    // R emove "pre tty" forma tted time.
  168                    ret  = ret.repl aceAll(",  h.+a", "") ;
  169  
  170                    // R emove Time s starting  with Hour  0-23
  171                    ret  = ret.repl aceAll("H. +a", "");
  172                    ret  = ret.repl aceAll("H. +S", "");
  173                    ret  = ret.repl aceAll("H. +s", "");
  174                    ret  = ret.repl aceAll("H. +m", "");
  175  
  176                    // R emove Time s starting  with hour  1-24
  177                    ret  = ret.repl aceAll("k. +a", "");
  178                    ret  = ret.repl aceAll("k. +S", "");
  179                    ret  = ret.repl aceAll("k. +s", "");
  180                    ret  = ret.repl aceAll("k. +m", "");
  181  
  182                    // R emove time s starting  with hour  0-11
  183                    ret  = ret.repl aceAll("K. +a", "");
  184                    ret  = ret.repl aceAll("K. +S", "");
  185                    ret  = ret.repl aceAll("K. +s", "");
  186                    ret  = ret.repl aceAll("K. +m", "");
  187  
  188                    // R emove time s starting  with hour  1-12
  189                    ret  = ret.repl aceAll("h. +a", "");
  190                    ret  = ret.repl aceAll("h. +S", "");
  191                    ret  = ret.repl aceAll("h. +s", "");
  192                    ret  = ret.repl aceAll("h. +m", "");
  193  
  194                    retu rn ret;
  195           }
  196  
  197   }