21. EPMO Open Source Coordination Office Redaction File Detail Report

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

21.1 Files compared

# Location File Last Modified
1 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\AWIVWebApp\main\src\java\gov\va\med\imaging\awiv\translator AWIVTranslatorV2.java Mon Dec 4 21:34:56 2017 UTC
2 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\AWIVWebApp\main\src\java\gov\va\med\imaging\awiv\translator AWIVTranslatorV2.java Mon Dec 4 21:56:42 2017 UTC

21.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 3 2172
Changed 2 4
Inserted 0 0
Removed 0 0

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

21.4 Active regular expressions

No regular expressions were active.

21.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: Dec  15, 2011
  6     Site Nam e:  Washin gton OI Fi eld Office , Silver S pring, MD
  7       Developer:          
WERFEJ
  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    */
  26   package go v.va.med.i maging.awi v.translat or;
  27  
  28   import gov .va.med.Pa tientArtif actIdentif ierImpl;
  29   import gov .va.med.Ro utingToken ;
  30   import gov .va.med.SE RIALIZATIO N_FORMAT;
  31   import gov .va.med.UR N;
  32   import gov .va.med.UR NFactory;
  33   import gov .va.med.We llKnownOID ;
  34   import gov .va.med.ex ceptions.R outingToke nFormatExc eption;
  35   import gov .va.med.im aging.Abst ractImagin gURN;
  36   import gov .va.med.im aging.Stud yURN;
  37   import gov .va.med.im aging.awiv .configura tion.AWIVW ebAppConfi guration;
  38   import gov .va.med.im aging.awiv .webservic es.soap.v2 .Electroni cSignature ResultType ;
  39   import gov .va.med.im aging.exce ptions.URN FormatExce ption;
  40   import gov .va.med.im aging.exch ange.Image AccessLogE vent;
  41   import gov .va.med.im aging.exch ange.Image AccessLogE vent.Image AccessLogE ventType;
  42   import gov .va.med.im aging.exch ange.Imagi ngLogEvent ;
  43   import gov .va.med.im aging.exch ange.Routi ngTokenHel per;
  44   import gov .va.med.im aging.exch ange.busin ess.Electr onicSignat ureResult;
  45   import gov .va.med.im aging.exch ange.busin ess.Image;
  46   import gov .va.med.im aging.exch ange.busin ess.ImageA ccessReaso n;
  47   import gov .va.med.im aging.exch ange.busin ess.Series ;
  48   import gov .va.med.im aging.exch ange.busin ess.Study;
  49   import gov .va.med.im aging.exch ange.busin ess.annota tions.Imag eAnnotatio n;
  50   import gov .va.med.im aging.exch ange.busin ess.annota tions.Imag eAnnotatio nDetails;
  51   import gov .va.med.im aging.exch ange.busin ess.annota tions.Imag eAnnotatio nSource;
  52   import gov .va.med.im aging.exch ange.busin ess.annota tions.Imag eAnnotatio nUser;
  53   import gov .va.med.im aging.exch ange.busin ess.docume nts.Docume nt;
  54   import gov .va.med.im aging.exch ange.busin ess.docume nts.Docume ntSet;
  55   import gov .va.med.im aging.exch ange.busin ess.docume nts.Docume ntSetResul t;
  56   import gov .va.med.im aging.exch ange.busin ess.util.E xchangeUti l;
  57   import gov .va.med.im aging.exch ange.enums .ImageAcce ssReasonTy pe;
  58   import gov .va.med.im aging.exch ange.enums .ImageQual ity;
  59   import gov .va.med.im aging.exch ange.enums .ObjectSta tus;
  60   import gov .va.med.im aging.exch ange.enums .SiteConne ctivitySta tus;
  61   import gov .va.med.im aging.exch ange.enums .VistaImag eType;
  62   import gov .va.med.im aging.tran slator.Abs tractClini calTransla tor;
  63   import gov .va.med.im aging.webs ervices.cl inical.Cli nicalConte ntTypeConf ig;
  64  
  65   import jav a.math.Big Integer;
  66   import jav a.text.Dat eFormat;
  67   import jav a.text.Sim pleDateFor mat;
  68   import jav a.util.Arr ayList;
  69   import jav a.util.Col lections;
  70   import jav a.util.Com parator;
  71   import jav a.util.Dat e;
  72   import jav a.util.Has hMap;
  73   import jav a.util.Lis t;
  74   import jav a.util.Map ;
  75   import jav a.util.Map .Entry;
  76  
  77   import org .apache.lo gging.log4 j.LogManag er;
  78   import org .apache.lo gging.log4 j.Logger;
  79   /**
  80    * @author         
WERFEJ
  81    *
  82    */
  83   public cla ss AWIVTra nslatorV2
  84   extends Ab stractClin icalTransl ator
  85   {
  86           pr ivate fina l static L ogger logg er = LogMa nager.getL ogger(AWIV Translator V2.class);
  87           
  88           pr ivate fina l static S tring awiv Webservice ShortDateF ormat = "M M/dd/yyyy" ;
  89           pr ivate fina l static S tring awiv Webservice LongDateFo rmat = "MM /dd/yyyy H H:mm";
  90           
  91           pr ivate stat ic Map<Ima geAnnotati onSource,  gov.va.med .imaging.a wiv.webser vices.soap .v2.Annota tionTypeSo urce> anno tationSour ceMap;
  92           pr ivate stat ic Map<Ima geAccessRe asonType,  gov.va.med .imaging.a wiv.webser vices.soap .v2.ImageA ccessReaso nTypeType>  imageAcce ssReasonsM ap;
  93           
  94           st atic
  95           {                 
  96                    anno tationSour ceMap = 
  97                             new Ha shMap<Imag eAnnotatio nSource, g ov.va.med. imaging.aw iv.webserv ices.soap. v2.Annotat ionTypeSou rce>();
  98                    anno tationSour ceMap.put( ImageAnnot ationSourc e.clinical Display, 
  99                                      gov.va.m ed.imaging .awiv.webs ervices.so ap.v2.Anno tationType Source.Cli nicalDispl ay);
  100                    anno tationSour ceMap.put( ImageAnnot ationSourc e.vistaRad
  101                                      gov.va.m ed.imaging .awiv.webs ervices.so ap.v2.Anno tationType Source.Vis tARad);
  102                    anno tationSour ceMap.put( ImageAnnot ationSourc e.clinical Capture, 
  103                                      gov.va.m ed.imaging .awiv.webs ervices.so ap.v2.Anno tationType Source.Cli nicalCaptu re);
  104                    
  105                    imag eAccessRea sonsMap = 
  106                             new Ha shMap<Imag eAccessRea sonType, g ov.va.med. imaging.aw iv.webserv ices.soap. v2.ImageAc cessReason TypeType>( );
  107                    imag eAccessRea sonsMap.pu t(ImageAcc essReasonT ype.changi ngImageSta tus, 
  108                                      gov.va.m ed.imaging .awiv.webs ervices.so ap.v2.Imag eAccessRea sonTypeTyp e.CHANGE_I MAGE_STATU S);
  109                    imag eAccessRea sonsMap.pu t(ImageAcc essReasonT ype.copyIm age, 
  110                                      gov.va.m ed.imaging .awiv.webs ervices.so ap.v2.Imag eAccessRea sonTypeTyp e.COPY_IMA GE);
  111                    imag eAccessRea sonsMap.pu t(ImageAcc essReasonT ype.delete Image, 
  112                                      gov.va.m ed.imaging .awiv.webs ervices.so ap.v2.Imag eAccessRea sonTypeTyp e.DELETE_I MAGE);
  113                    imag eAccessRea sonsMap.pu t(ImageAcc essReasonT ype.printI mage, 
  114                                      gov.va.m ed.imaging .awiv.webs ervices.so ap.v2.Imag eAccessRea sonTypeTyp e.PRINT_IM AGE);
  115                    
  116           }        
  117           
  118           pr ivate stat ic DateFor mat getAWI VWebservic eShortDate Format()
  119           {
  120                    retu rn new Sim pleDateFor mat(awivWe bserviceSh ortDateFor mat);
  121           }
  122           
  123           pr ivate stat ic DateFor mat getAWI VWebservic eLongDateF ormat()
  124           {
  125                    retu rn new Sim pleDateFor mat(awivWe bserviceLo ngDateForm at);
  126           }
  127           
  128           pu blic stati c gov.va.m ed.imaging .awiv.webs ervices.so ap.v2.Grou pType tran slate(List <Study> st udies)
  129           th rows URNFo rmatExcept ion
  130           {
  131                    if(s tudies ==  null)
  132                             return  new gov.v a.med.imag ing.awiv.w ebservices .soap.v2.G roupType() ;
  133                    Stud y study =  studies.ge t(0);
  134                    gov. va.med.ima ging.awiv. webservice s.soap.v2. GroupType  result = t ranslate(s tudy, fals e);// crea teGroupFro mStudy(stu dy);
  135                    List <gov.va.me d.imaging. awiv.webse rvices.soa p.v2.Image Type> imag es = 
  136                             new Ar rayList<go v.va.med.i maging.awi v.webservi ces.soap.v 2.ImageTyp e>();
  137                    imag es.addAll( translateI mages(stud y));
  138                    for( int i = 1;  i < studi es.size();  i++)
  139                    {
  140                             study  = studies. get(i);
  141                             images .addAll(tr anslateIma ges(study) );
  142                    }
  143                    resu lt.setImag es(new gov .va.med.im aging.awiv .webservic es.soap.v2 .ImagesTyp e(images.t oArray(new  gov.va.me d.imaging. awiv.webse rvices.soa p.v2.Image Type[image s.size()]) ));
  144                    resu lt.setImag eCount(Big Integer.va lueOf(imag es.size()) );
  145                    retu rn result;
  146           }
  147           
  148           /*
  149           @S uppressWar nings("dep recation")
  150           pr ivate stat ic gov.va. med.imagin g.awiv.web services.s oap.v2.Gro upType cre ateGroupFr omStudy(St udy study)
  151           th rows URNFo rmatExcept ion
  152           {
  153                    gov. va.med.ima ging.awiv. webservice s.soap.v2. GroupType  result = 
  154                             new go v.va.med.i maging.awi v.webservi ces.soap.v 2.GroupTyp e();
  155                    
  156                    resu lt.setDesc ription(ex tractIlleg alCharacte rs(study.g etDescript ion()));
  157                    resu lt.setEven t(extractI llegalChar acters(stu dy.getEven t()));
  158                    //re sult.setIm ageCount(B igInteger. valueOf(st udy.getIma geCount()) );
  159                    resu lt.setImag ePackage(e xtractIlle galCharact ers(study. getImagePa ckage()));
  160                    resu lt.setImag eType(stud y.getImage Type());
  161                    resu lt.setNote Title(extr actIllegal Characters (study.get NoteTitle( )));
  162                    resu lt.setOrig in(extract IllegalCha racters(st udy.getOri gin()));
  163                    resu lt.setPati entIcn(stu dy.getPati entIcn());
  164                    resu lt.setPati entName(st udy.getPat ientName() );
  165                    resu lt.setProc edure(extr actIllegal Characters (study.get Procedure( )));
  166                    resu lt.setSite Number(stu dy.getSite Number());
  167                    resu lt.setSpec ialty(extr actIllegal Characters (study.get Specialty( )));
  168                    
  169                    // 2 /19/08 - n ow include  the site  name so th e Display  client sho ws what sp ecific DOD  facility  the study  is from
  170                    if(E xchangeUti l.isSiteDO D(study.ge tSiteNumbe r()))
  171                    {
  172                             result .setSiteAb breviation (study.get SiteAbbr() + (study.g etSiteName () != null  ? "-" + s tudy.getSi teName() :  ""));                          
  173                    }
  174                    else
  175                    {
  176                             result .setSiteAb breviation (study.get SiteAbbr() );
  177                    }                                  
  178                    resu lt.setStud yPackage(e xtractIlle galCharact ers(study. getImagePa ckage()));
  179                    resu lt.setStud yClass(ext ractIllega lCharacter s(study.ge tStudyClas s() == nul l ? "" : s tudy.getSt udyClass() )); // get  this from  study
  180                    resu lt.setStud yType(extr actIllegal Characters (study.get ImageType( )));
  181                    resu lt.setCapt ureDate(st udy.getCap tureDate() );
  182                    resu lt.setCapt uredBy(stu dy.getCapt ureBy());               
  183                    if(s tudy.getPr ocedureDat e() == nul l)
  184                    {
  185                             logger .warn("Set ting null  procedure  date for s tudy");
  186                             result .setProced ureDate("" );
  187                    }
  188                    else
  189                    {
  190                             if((st udy.getPro cedureDate String() = = null) ||  (study.ge tProcedure DateString ().length( ) <= 0))
  191                             {
  192                                      // if th e hour and  minute ar e not 0, t hen likely  they cont ain real v alues for  hour and m inute (not  00:00)
  193                                      // this  leaves ope n the poss ibility of  invalid d ata, if th e real dat e was at 0 0:00 then  this would  not show  that time.
  194                                      // we wo uld then o mit data,  not show i nvalid dat a
  195                                      if((stud y.getProce dureDate() .getHours( ) <= 0) &&  (study.ge tProcedure Date().get Minutes()  <= 0))
  196                                      {
  197                                               result.set ProcedureD ate(getAWI VWebservic eShortDate Format().f ormat(stud y.getProce dureDate() ));
  198                                      }
  199                                      else
  200                                      {
  201                                               result.set ProcedureD ate(getAWI VWebservic eLongDateF ormat().fo rmat(study .getProced ureDate()) );
  202                                      }
  203                                      
  204                             }
  205                             else i f(study.ge tProcedure DateString ().length( ) > 10)
  206                             {
  207                                      result.s etProcedur eDate(getA WIVWebserv iceLongDat eFormat(). format(stu dy.getProc edureDate( )));
  208                             }
  209                             else {
  210                                      result.s etProcedur eDate(getA WIVWebserv iceShortDa teFormat() .format(st udy.getPro cedureDate ()));
  211                             }
  212                    }                 
  213                    // n eed to add  site numb er field
  214                    
  215                    Stud yURN study Urn = stud y.getStudy Urn();// S tudyURN.cr eate(study .getSiteNu mber(), st udy.getStu dyIen(), s tudy.getPa tientIcn() );
  216                    resu lt.setStud yUrn(study Urn.toStri ngCDTP());              
  217                    retu rn result;
  218           }* /
  219           
  220           pr ivate stat ic List<go v.va.med.i maging.awi v.webservi ces.soap.v 2.ImageTyp e> transla teImages(S tudy study )
  221           th rows URNFo rmatExcept ion
  222           {
  223                    List <gov.va.me d.imaging. awiv.webse rvices.soa p.v2.Image Type> imag es = 
  224                             new Ar rayList<go v.va.med.i maging.awi v.webservi ces.soap.v 2.ImageTyp e>();
  225                    for( Series ser ies : stud y.getSerie s())
  226                    {
  227                             for(Im age image  : series)
  228                             {
  229                                      gov.va.m ed.imaging .awiv.webs ervices.so ap.v2.Imag eType it =  transform ImageToFat Image(imag e, series) ;
  230                                      if(it !=  null)
  231                                               images.add (it);
  232                             }                                   
  233                    }
  234                    retu rn images;
  235           }
  236           
  237           pu blic stati c gov.va.m ed.imaging .awiv.webs ervices.so ap.v2.Grou pType tran slate(Docu mentSetRes ult docume ntSetResul t)
  238           {
  239                    gov. va.med.ima ging.awiv. webservice s.soap.v2. GroupType  result =
  240                             new go v.va.med.i maging.awi v.webservi ces.soap.v 2.GroupTyp e();
  241                    
  242                    int  imageCount  = 0;
  243                    resu lt.setCapt ureDate("" );
  244                    resu lt.setCapt uredBy("") ;
  245                    resu lt.setDesc ription("" );
  246                    resu lt.setDocu mentDate(" ");
  247                    resu lt.setEven t("");
  248                    resu lt.setImag ePackage(" ");
  249                    resu lt.setImag eType("");
  250                    resu lt.setNote Title("");
  251                    resu lt.setOrig in("");
  252                    resu lt.setPati entIcn("") ;
  253                    resu lt.setPati entName("" );
  254                    resu lt.setProc edure("");
  255                    resu lt.setProc edureDate( "");
  256                    resu lt.setSens itive(fals e);
  257                    resu lt.setSite Abbreviati on("DoD");
  258                    resu lt.setSite Number(Exc hangeUtil. getDodSite Number());
  259                    resu lt.setSpec ialty("");
  260                    resu lt.setStat us(ObjectS tatus.NO_S TATUS.getV alue() + " ");                
  261                    resu lt.setSens itive(fals e);
  262                    resu lt.setStud yClass("") ;
  263                    resu lt.setStud yImagesHav eAnnotatio ns(false);
  264                    resu lt.setStud yPackage(" ");
  265                    resu lt.setStud yType("");
  266                    resu lt.setStud yUrn("");
  267                    resu lt.setView Status(Obj ectStatus. NO_STATUS. getValue()  + "");
  268                    
  269                    if(d ocumentSet Result !=  null && do cumentSetR esult.getA rtifacts()  != null)
  270                    {
  271                             List<g ov.va.med. imaging.aw iv.webserv ices.soap. v2.ImageTy pe> images  = 
  272                                      new Arra yList<gov. va.med.ima ging.awiv. webservice s.soap.v2. ImageType> ();                  
  273                             List<D ocumentSet Document>  allDocumen ts = new A rrayList<D ocumentSet Document>( );
  274                             for(Do cumentSet  documentSe t : docume ntSetResul t.getArtif acts())
  275                             {
  276                                      for(Docu ment docum ent : docu mentSet)
  277                                      {
  278                                               allDocumen ts.add(new  DocumentS etDocument (documentS et, docume nt));
  279                                      }
  280                             }
  281                             Collec tions.sort (allDocume nts, new D ocumentSet DocumentCo mparator(f alse));
  282                             for(Do cumentSetD ocument do cumentSetD ocument :  allDocumen ts)
  283                             {
  284                                      gov.va.m ed.imaging .awiv.webs ervices.so ap.v2.Imag eType imag eType = 
  285                                               translate( documentSe tDocument. getDocumen tSet(), do cumentSetD ocument.ge tDocument( ));
  286                                      if(image Type != nu ll)
  287                                      {
  288                                               images.add (imageType );
  289                                               imageCount ++;
  290                                      }
  291                             }
  292                             
  293                             result .setImages (
  294                                               new gov.va .med.imagi ng.awiv.we bservices. soap.v2.Im agesType(i mages.toAr ray(
  295                                                                new  gov.va.med .imaging.a wiv.webser vices.soap .v2.ImageT ype[images .size()])) );
  296                    }
  297                    resu lt.setImag eCount(Big Integer.va lueOf(imag eCount));
  298                    
  299                    retu rn result;
  300           }
  301           
  302           pr ivate stat ic gov.va. med.imagin g.awiv.web services.s oap.v2.Ima geType tra nslate(Doc umentSet d ocumentSet ,
  303                             Docume nt documen t) 
  304           {
  305                    if(d ocument ==  null)
  306                             return  null;
  307                    gov. va.med.ima ging.awiv. webservice s.soap.v2. ImageType  result = 
  308                             new go v.va.med.i maging.awi v.webservi ces.soap.v 2.ImageTyp e();
  309                    
  310                    Vist aImageType  vistaImag eType = ge tImageType (AWIVWebAp pConfigura tion.getCo nfiguratio n(), docum ent);
  311                    if(v istaImageT ype == nul l)
  312                    {
  313                             vistaI mageType =  VistaImag eType.UNKN OWN_IMAGIN G_TYPE;
  314                             logger .debug("Do cument wit h media ty pe '" + do cument.get MediaType( ) + "', re turning Vi staImageTy pe of '" +  vistaImag eType + "'  for Clini cal Displa y.");                                             
  315                    }                 
  316                    Stri ng id = do cument.get GlobalArti factIdenti fier().toS tring(SERI ALIZATION_ FORMAT.CDT P);
  317                    resu lt.setImag eUrn(id);
  318                    resu lt.setPati entIcn(doc ument.getP atientId() );
  319                    resu lt.setPati entName(do cumentSet. getPatient Name());
  320                    Date  procedure Date = nul l;
  321                    if(d ocumentSet .getProced ureDate()  != null)
  322                    {
  323                             proced ureDate =  documentSe t.getProce dureDate() ;
  324                    }
  325                    else
  326                    {
  327                             if(doc ument.getC reationDat e() != nul l)
  328                             {
  329                                      procedur eDate = do cument.get CreationDa te();
  330                                      logger.d ebug("Docu mentSet Pr ocedureDat e is null,  using Doc ument Crea tionDate") ;
  331                             }
  332                             else
  333                             {
  334                                      logger.d ebug("Docu mentSet Pr ocedureDat e and Docu ment Creat ionDate ar e both nul l.");
  335                             }                                           
  336                    }
  337                    if(p rocedureDa te == null )
  338                    {
  339                             result .setProced ureDate("" );
  340                    }
  341                    else
  342                    {
  343                             result .setProced ureDate(ge tAWIVWebse rviceLongD ateFormat( ).format(p rocedureDa te));
  344                    }
  345                    
  346                    Stri ng procedu re = docum ent.getNam e();
  347                    if(v istaImageT ype == Vis taImageTyp e.NCAT)
  348                    {
  349                             // NCA T reports  don't have  a name va lue
  350                             proced ure = "NCA T Report";
  351                    }
  352                    
  353                    //re sult.setPr ocedure(pr ocedure);
  354                    resu lt.setProc edure("");
  355                    resu lt.setDesc ription(pr ocedure);
  356                    resu lt.setImag eType(BigI nteger.val ueOf(vista ImageType. getImageTy pe()));
  357                    resu lt.setStat us(ObjectS tatus.NO_S TATUS.getV alue() + " ");
  358                    resu lt.setView Status(Obj ectStatus. NO_STATUS. getValue()  + "");
  359                    resu lt.setSens itive(fals e);
  360                    resu lt.setSite Abbr("DoD" );
  361                    
  362                    if(( WellKnownO ID.HAIMS_D OCUMENT.is Applicable (document. getGlobalA rtifactIde ntifier(). getHomeCom munityId() ) || 
  363                                      (ncatRep ositoryId. equals(doc ument.getR epositoryI d()))))
  364                    {
  365                             result .setSiteNu mber("200" );
  366                    }                                  
  367                    else
  368                    {
  369                             // thi s should b e a VA doc ument, set  the site  number to  the reposi tory (ther e should n ot actuall
  370                             // be  VA documen ts here bu t just in  case)
  371                             result .setSiteNu mber(docum ent.getRep ositoryId( ));
  372                    }
  373                    
  374                    if(W ellKnownOI D.HAIMS_DO CUMENT.isA pplicable( document.g etGlobalAr tifactIden tifier().g etHomeComm unityId()) )
  375                    {
  376                             // if  there is n o defined  abstract i mage and t he image i s from the  DoD, use  the follow ing canned  image
  377                             result .setAbsIma geURI(cann edDoDAbstr act);
  378                    }
  379                    else
  380                    {
  381                             result .setAbsIma geURI("");
  382                    }
  383                    resu lt.setFull ImageURI(" imageURN="  + result. getImageUr n() + "&im ageQuality =" + Image Quality.DI AGNOSTICUN COMPRESSED .getCanoni cal() + "& contentTyp e=" + docu ment.getMe diaType(). toString() .toLowerCa se());
  384                    
  385                    // P atch 122 f ields
  386                    resu lt.setAsso ciatedNote Resulted(" ");
  387                    resu lt.setImag ePackage(" ");
  388                    resu lt.setImag eAnnotatio nStatus(Bi gInteger.v alueOf(0)) ;
  389                    resu lt.setImag eAnnotatio nStatusDes cription(" ");
  390                    resu lt.setImag eHasAnnota tions(fals e);
  391                    resu lt.setImag eExtension (vistaImag eType.getD efaultFile Extension( ));
  392                    
  393                    retu rn result;
  394           }
  395           
  396           @S uppressWar nings("dep recation")
  397           pu blic stati c gov.va.m ed.imaging .awiv.webs ervices.so ap.v2.Grou pType tran slate(Stud y study, 
  398                             boolea n includeI mages)
  399           th rows URNFo rmatExcept ion
  400           {
  401                    
  402                    gov. va.med.ima ging.awiv. webservice s.soap.v2. GroupType  result = 
  403                             new go v.va.med.i maging.awi v.webservi ces.soap.v 2.GroupTyp e();
  404                    
  405                    resu lt.setDesc ription(ex tractIlleg alCharacte rs(study.g etDescript ion()));
  406                    resu lt.setEven t(extractI llegalChar acters(stu dy.getEven t()));
  407                    resu lt.setImag eCount(Big Integer.va lueOf(stud y.getImage Count()));
  408                    resu lt.setImag ePackage(e xtractIlle galCharact ers(study. getImagePa ckage()));
  409                    resu lt.setImag eType(stud y.getImage Type());
  410                    resu lt.setNote Title(extr actIllegal Characters (study.get NoteTitle( )));
  411                    resu lt.setOrig in(extract IllegalCha racters(st udy.getOri gin()));
  412                    resu lt.setPati entIcn(stu dy.getPati entId());
  413                    resu lt.setPati entName(st udy.getPat ientName() );
  414                    resu lt.setProc edure(extr actIllegal Characters (study.get Procedure( )));
  415                    resu lt.setSite Number(stu dy.getSite Number());
  416                    resu lt.setSpec ialty(extr actIllegal Characters (study.get Specialty( )));
  417                    
  418                    // 2 /19/08 - n ow include  the site  name so th e Display  client sho ws what sp ecific DOD  facility  the study  is from
  419                    if(E xchangeUti l.isSiteDO D(study.ge tSiteNumbe r()))
  420                    {
  421                             result .setSiteAb breviation (study.get SiteAbbr() + (study.g etSiteName () != null  ? "-" + s tudy.getSi teName() :  ""));                          
  422                    }
  423                    else
  424                    {
  425                             result .setSiteAb breviation (study.get SiteAbbr() );
  426                    }                                  
  427                    resu lt.setStud yPackage(e xtractIlle galCharact ers(study. getImagePa ckage()));
  428                    resu lt.setStud yClass(ext ractIllega lCharacter s(study.ge tStudyClas s() == nul l ? "" : s tudy.getSt udyClass() )); // get  this from  study
  429                    resu lt.setStud yType(extr actIllegal Characters (study.get ImageType( )));
  430                    resu lt.setCapt ureDate(st udy.getCap tureDate() );
  431                    resu lt.setCapt uredBy(stu dy.getCapt ureBy());               
  432                    if(s tudy.getPr ocedureDat e() == nul l)
  433                    {
  434                             logger .warn("Set ting null  procedure  date for s tudy");
  435                             result .setProced ureDate("" );
  436                    }
  437                    else
  438                    {
  439                             if((st udy.getPro cedureDate String() = = null) ||  (study.ge tProcedure DateString ().length( ) <= 0))
  440                             {
  441                                      // if th e hour and  minute ar e not 0, t hen likely  they cont ain real v alues for  hour and m inute (not  00:00)
  442                                      // this  leaves ope n the poss ibility of  invalid d ata, if th e real dat e was at 0 0:00 then  this would  not show  that time.
  443                                      // we wo uld then o mit data,  not show i nvalid dat a
  444                                      if((stud y.getProce dureDate() .getHours( ) <= 0) &&  (study.ge tProcedure Date().get Minutes()  <= 0))
  445                                      {
  446                                               result.set ProcedureD ate(getAWI VWebservic eShortDate Format().f ormat(stud y.getProce dureDate() ));
  447                                      }
  448                                      else
  449                                      {
  450                                               result.set ProcedureD ate(getAWI VWebservic eLongDateF ormat().fo rmat(study .getProced ureDate()) );
  451                                      }
  452                                      
  453                             }
  454                             else i f(study.ge tProcedure DateString ().length( ) > 10)
  455                             {
  456                                      result.s etProcedur eDate(getA WIVWebserv iceLongDat eFormat(). format(stu dy.getProc edureDate( )));
  457                             }
  458                             else {
  459                                      result.s etProcedur eDate(getA WIVWebserv iceShortDa teFormat() .format(st udy.getPro cedureDate ()));
  460                             }
  461                    }                 
  462                    if(i ncludeImag es)
  463                    {
  464                             List<g ov.va.med. imaging.aw iv.webserv ices.soap. v2.ImageTy pe>  image s = 
  465                                      new Arra yList<gov. va.med.ima ging.awiv. webservice s.soap.v2. ImageType> ();
  466                             for(Se ries serie s : study. getSeries( ))
  467                             {
  468                                      for(Imag e image :  series)
  469                                      {
  470                                               gov.va.med .imaging.a wiv.webser vices.soap .v2.ImageT ype it = t ransformIm ageToFatIm age(image,  series);
  471                                               if(it != n ull)
  472                                                       im ages.add(i t);
  473                                      }
  474                                                
  475                             }
  476                             result .setImages (
  477                                               new gov.va .med.imagi ng.awiv.we bservices. soap.v2.Im agesType(
  478                                                                imag es.toArray (
  479                                                                                  new gov. va.med.ima ging.awiv. webservice s.soap.v2. ImageType[ images.siz e()])));
  480                    }
  481                    // n eed to add  site numb er field
  482                    
  483                    Stud yURN study Urn = stud y.getStudy Urn();// S tudyURN.cr eate(study .getSiteNu mber(), st udy.getStu dyIen(), s tudy.getPa tientIcn() );
  484                    resu lt.setStud yUrn(study Urn.toStri ngCDTP());
  485                    
  486                    
  487                    if(s tudy.getDo cumentDate () != null )
  488                    {
  489                             result .setDocume ntDate(get AWIVWebser viceLongDa teFormat() .format(st udy.getDoc umentDate( )));
  490                    }
  491                    else
  492                    {
  493                             result .setDocume ntDate("") ;
  494                    }
  495                    resu lt.setStat us(study.g etStudySta tus().getV alue() + " ");
  496                    resu lt.setSens itive(stud y.isSensit ive());
  497                    resu lt.setView Status(stu dy.getStud yViewStatu s().getVal ue() + "") ;
  498                    resu lt.setStud yImagesHav eAnnotatio ns(study.i sStudyImag esHaveAnno tations()) ;
  499                    
  500                    retu rn result;
  501           }
  502           
  503           @S uppressWar nings("dep recation")
  504           pr ivate stat ic gov.va. med.imagin g.awiv.web services.s oap.v2.Ima geType tra nsformImag eToFatImag e(Image im age, Serie s series) 
  505           th rows URNFo rmatExcept ion 
  506           {
  507                    if(i mage == nu ll)
  508                             return  null;
  509                    
  510                    if(i mage.isDel eted())
  511                    {
  512                             logger .debug("Im age '" + i mage.getIm ageUrn().t oString(SE RIALIZATIO N_FORMAT.C DTP) + "'  is deleted , excludin g from res ult.");
  513                             return  null;
  514                    }
  515                    
  516                    gov. va.med.ima ging.awiv. webservice s.soap.v2. ImageType  result = 
  517                             new go v.va.med.i maging.awi v.webservi ces.soap.v 2.ImageTyp e();
  518                    
  519                    resu lt.setDesc ription(ex tractIlleg alCharacte rs(image.g etDescript ion()));
  520                    resu lt.setPati entIcn(ima ge.getPati entId());
  521                    resu lt.setPati entName(im age.getPat ientName() );
  522                    resu lt.setDico mImageNumb er((image. getImageNu mber() !=  null) && ( image.getI mageNumber ().length( ) > 0) ? i mage.getIm ageNumber( ) : image. getDicomIm ageNumberF orDisplay( ));
  523                    //re sult.setDi comSequenc eNumber(im age.getDic omSequence NumberForD isplay());
  524                    resu lt.setDico mSequenceN umber((ser ies != nul l) && (ser ies.getSer iesNumber( ) != null)  && (serie s.getSerie sNumber(). length() >  0) ? seri es.getSeri esNumber()  : image.g etDicomSeq uenceNumbe rForDispla y());
  525                    resu lt.setProc edure(extr actIllegal Characters (image.get Procedure( )));
  526                    if(i mage.getPr ocedureDat e() == nul l)
  527                    {
  528                             logger .warn("Set ting null  procedure  date for i mage");
  529                             result .setProced ureDate("" );
  530                    }
  531                    else  
  532                    {
  533                             // if  the hour a nd minute  are not 0,  then like ly they co ntain real  values fo r hour and  minute (n ot 00:00)
  534                             // thi s leaves o pen the po ssibility  of invalid  data, if  the real d ate was at  00:00 the n this wou ld not sho w that tim e.
  535                             // we  would then  omit data , not show  invalid d ata
  536                             if((im age.getPro cedureDate ().getHour s() <= 0)  && (image. getProcedu reDate().g etMinutes( ) <= 0))
  537                             {
  538                                      result.s etProcedur eDate(getA WIVWebserv iceShortDa teFormat() .format(im age.getPro cedureDate ()));
  539                             }
  540                             else
  541                             {
  542                                      result.s etProcedur eDate(getA WIVWebserv iceLongDat eFormat(). format(ima ge.getProc edureDate( )));
  543                             }
  544                    }
  545                    resu lt.setSite Number(ima ge.getSite Number());
  546                    resu lt.setSite Abbr(image .getSiteAb br());
  547                    resu lt.setImag eClass(ext ractIllega lCharacter s(image.ge tImageClas s()));
  548                    resu lt.setAbsL ocation(im age.getAbs Location() );
  549                    resu lt.setFull Location(i mage.getFu llLocation ());
  550                    resu lt.setImag eExtension (getFileEx tension(im age.getFul lFilename( )));
  551                    
  552                    resu lt.setImag eType(BigI nteger.val ueOf(image .getImgTyp e()));
  553  
  554                    //Im ageURN ima geUrn = Im ageURNFact ory.create (image.get SiteNumber (), image. getIen(),  parentIen( image), im age.getPat ientICN(),  image.get ImageModal ity(), Ima geURN.clas s);
  555                    // u se the VA  internal f orm of the  URN for c har set sa fety and i nclusion o f extra id entifiers
  556                    //re sult.setIm ageUrn( im age.getIma geUrn().to StringCDTP () );
  557                    resu lt.setImag eUrn(image .getImageU rn().toStr ing(SERIAL IZATION_FO RMAT.CDTP) );
  558                    
  559                    bool ean isRadI mage = isR adImage(im age);
  560                    if(( image.getF ullFilenam e() != nul l) && (ima ge.getFull Filename() .startsWit h("-1")))
  561                    {
  562                             result .setFullIm ageURI(ima ge.getFull Filename() ); // put  in error s tate
  563                    }
  564                    else
  565                    {
  566                             // if  the image  is not rad iology, th en this is  a ref ima ge request , if not r ad image
  567                             // the n ref loca tion is fo r the diag nostic ima ge.
  568                             int im ageQuality  = (isRadI mage ? Ima geQuality. REFERENCE. getCanonic al() : Ima geQuality. DIAGNOSTIC UNCOMPRESS ED.getCano nical());                     
  569                             result .setFullIm ageURI("im ageURN=" +  result.ge tImageUrn( ) + "&imag eQuality="  + imageQu ality + "& contentTyp e=" + getC ontentType (image, Im ageQuality .REFERENCE ));
  570                    }
  571                    if(( image.getA bsFilename () != null ) && (imag e.getAbsFi lename().s tartsWith( "-1")))
  572                    {
  573                             result .setAbsIma geURI(imag e.getAbsFi lename());
  574                    }
  575                    else
  576                    {
  577                             result .setAbsIma geURI("ima geURN=" +  result.get ImageUrn()  + "&image Quality=20 &contentTy pe=" + get ContentTyp e(image, I mageQualit y.THUMBNAI L));
  578                    }
  579                    if(i sRadImage)
  580                    {
  581                             if((im age.getBig Filename()  != null)  && (image. getBigFile name().sta rtsWith("- 1")))
  582                             {
  583                                      result.s etDiagImag eURI(image .getBigFil ename());
  584                             }
  585                             else
  586                             {
  587                                      
  588                                      result.s etDiagImag eURI("imag eURN=" + r esult.getI mageUrn()  + "&imageQ uality=90& contentTyp e=" + getC ontentType (image, Im ageQuality .DIAGNOSTI C));
  589                             }
  590                    }
  591                    else
  592                    {
  593                             result .setDiagIm ageURI("") ;
  594                    }
  595                    
  596                    
  597                    if(i mage.getCa ptureDate( ) != null)
  598                    {
  599                             result .setCaptur eDate(getA WIVWebserv iceLongDat eFormat(). format(ima ge.getCapt ureDate()) );        
  600                    }
  601                    else
  602                    {
  603                             result .setCaptur eDate("");
  604                    }
  605                    if(i mage.getDo cumentDate () != null )
  606                    {
  607                             result .setDocume ntDate(get AWIVWebser viceLongDa teFormat() .format(im age.getDoc umentDate( )));
  608                    }
  609                    else
  610                    {
  611                             result .setDocume ntDate("") ;
  612                    }
  613                    resu lt.setStat us(image.g etImageSta tus().getV alue() + " ");
  614                    resu lt.setSens itive(imag e.isSensit ive());
  615                    resu lt.setView Status(ima ge.getImag eViewStatu s().getVal ue() + "") ;
  616                    
  617                    resu lt.setAsso ciatedNote Resulted(i mage.getAs sociatedNo teResulted () == null  ? "" : im age.getAss ociatedNot eResulted( ));
  618                    resu lt.setImag ePackage(i mage.getIm agePackage () == null  ? "" : im age.getIma gePackage( ));
  619                    resu lt.setImag eAnnotatio nStatus(Bi gInteger.v alueOf(ima ge.getImag eAnnotatio nStatus()) );
  620                    resu lt.setImag eAnnotatio nStatusDes cription(i mage.getIm ageAnnotat ionStatusD escription () == null  ? "" : im age.getIma geAnnotati onStatusDe scription( ));
  621                    resu lt.setImag eHasAnnota tions(imag e.isImageH asAnnotati ons());
  622                    
  623                    retu rn result;
  624           }
  625           
  626           pr ivate stat ic Clinica lContentTy peConfig g etContentT ypeConfig( int imageT ype, Image Quality im ageQuality )
  627           {
  628                    Vist aImageType  vistaImag eType = ge tVistaImag eType(imag eType);
  629                    if(v istaImageT ype == nul l)
  630                    {
  631                             return  null;                      
  632                    }
  633                    retu rn getAWIV Configurat ion().getC ontentType Configurat ion(vistaI mageType, 
  634                                      imageQua lity);
  635           }
  636           
  637           
  638           pr ivate stat ic AWIVWeb AppConfigu ration get AWIVConfig uration()
  639           {
  640                    retu rn AWIVWeb AppConfigu ration.get Configurat ion();
  641           }
  642           
  643           pr ivate stat ic VistaIm ageType ge tVistaImag eType(int  imageType)
  644           {
  645                    retu rn VistaIm ageType.va lueOfImage Type(image Type);
  646           }
  647           
  648           pr ivate stat ic String  getContent Type(Image  image, Im ageQuality  imageQual ity)
  649           {
  650                    Stri ng content Type = "";
  651                    
  652                    Clin icalConten tTypeConfi g config =  getConten tTypeConfi g(image.ge tImgType() , imageQua lity);
  653                    if(c onfig != n ull)
  654                             conten tType = co nfig.getCo ntentType( );
  655                    
  656                    if(c ontentType .length()  > 0)
  657                    {
  658                             conten tType += " ,*/*";
  659                    }
  660                    else
  661                    {
  662                             conten tType = "* /*";
  663                    }
  664                    retu rn content Type;
  665           }
  666           
  667           /* *
  668            *  Returns t he file ex tension wi thout the  '.'
  669            *  @param fi lename
  670            *  @return
  671            * /
  672           pr ivate stat ic String  getFileExt ension(Str ing filena me)
  673           {
  674                    if(f ilename ==  null)
  675                             return  "";
  676                    int  loc = file name.lastI ndexOf("." );
  677                    if(l oc >= 0)
  678                    {
  679                             return  filename. substring( loc + 1);
  680                    }
  681                    retu rn "";
  682           }
  683           
  684           pu blic stati c gov.va.m ed.imaging .awiv.webs ervices.so ap.v2.Ping ServerType PingRespon se transla te(SiteCon nectivityS tatus site Status)
  685           {
  686                    gov. va.med.ima ging.awiv. webservice s.soap.v2. PingServer TypePingRe sponse res ponse = nu ll;
  687                    if(s iteStatus  == SiteCon nectivityS tatus.VIX_ READY)
  688                    {
  689                             respon se = gov.v a.med.imag ing.awiv.w ebservices .soap.v2.P ingServerT ypePingRes ponse.SERV ER_READY;
  690                    }
  691                    else  if(siteSt atus == Si teConnecti vityStatus .DATASOURC E_UNAVAILA BLE)
  692                    {
  693                             respon se = gov.v a.med.imag ing.awiv.w ebservices .soap.v2.P ingServerT ypePingRes ponse.VIST A_UNAVAILA BLE;
  694                    }
  695                    else  
  696                    {
  697                             respon se = gov.v a.med.imag ing.awiv.w ebservices .soap.v2.P ingServerT ypePingRes ponse.SERV ER_UNAVAIL ABLE;
  698                    }
  699                    
  700                    retu rn respons e;
  701           }
  702           
  703           pu blic stati c ImageAcc essLogEven t translat e(gov.va.m ed.imaging .awiv.webs ervices.so ap.v2.Imag eAccessLog EventType  logEventTy pe) 
  704           th rows URNFo rmatExcept ion 
  705           {
  706                    if(l ogEventTyp e == null)
  707                             return  null;
  708                    
  709                    
  710                    URN  urn = URNF actory.cre ate(logEve ntType.get Id(), SERI ALIZATION_ FORMAT.CDT P);
  711                    if(u rn instanc eof Abstra ctImagingU RN)
  712                    {
  713                             Abstra ctImagingU RN abstrac tImagingUr n = (Abstr actImaging URN)urn;
  714                             boolea n isDodIma ge = Excha ngeUtil.is SiteDOD(ab stractImag ingUrn.get Originatin gSiteId())
  715                             
  716                             // JMW  9/7/2012  this code  below is n ew but cop ied from t he section  below
  717                             // the  logSiteNu mber is th e user sit e number a nd is used  if the im age is DoD  because a ccess
  718                             // to  a DoD imag e cannot b e logged t o the DoD.   If the u ser authen ticated to  site 100  (CLAIMS) t hen
  719                             // we  want to lo g to the s ite where  the patien t lookup w as done be cause site  100 does  not have I maging.
  720                             // the  logic bel ow will se t the logS iteNumber  to the pat ientLookup Site which  will eith er be the 
  721                             // sam e as the a uthenticat ing site ( if not a C LAIMS user ) or it wi ll be the  site where  the patie nt 
  722                             // was  selected  from                      
  723                             String  logSiteNu mber = log EventType. getCredent ials().get SiteNumber (); // the  site numb er to log  the access  to
  724                             String  patientLo okupSiteNu mber = log EventType. getCredent ials().get PatientLoo kupSite();
  725                             if(pat ientLookup SiteNumber  != null & & patientL ookupSiteN umber.leng th() > 0)
  726                                      logSiteN umber = pa tientLooku pSiteNumbe r;
  727                             
  728                             ImageA ccessLogEv entType im ageAccessL ogEventTyp e = transl ate(logEve ntType.get EventType( ));
  729                             ImageA ccessLogEv ent result  =                      
  730                                      new Imag eAccessLog Event(abst ractImagin gUrn.getIm agingIdent ifier(), " ", logEven tType.getP atientIcn( ), 
  731                                                       ab stractImag ingUrn.get Originatin gSiteId(),  System.cu rrentTimeM illis(), 
  732                                               logEventTy pe.getReas on() + "",  "", 
  733                                               imageAcces sLogEventT ype, isDod Image, log SiteNumber );             
  734                             return  result;
  735                    }
  736                    else  if(urn in stanceof P atientArti factIdenti fierImpl)
  737                    {
  738                             Patien tArtifactI dentifierI mpl pai =  (PatientAr tifactIden tifierImpl )urn;
  739                             // JMW  9/7/2012  the code b elow is ol d but I'm  adding thi s comment  to describ e it
  740                             // the  logSiteNu mber is th e user sit e number a nd is used  if the im age is DoD  because a ccess
  741                             // to  a DoD imag e cannot b e logged t o the DoD.   If the u ser authen ticated to  site 100  (CLAIMS) t hen
  742                             // we  want to lo g to the s ite where  the patien t lookup w as done be cause site  100 does  not have I maging.
  743                             // the  logic bel ow will se t the logS iteNumber  to the pat ientLookup Site which  will eith er be the 
  744                             // sam e as the a uthenticat ing site ( if not a C LAIMS user ) or it wi ll be the  site where  the patie nt 
  745                             // was  selected  from
  746                             String  logSiteNu mber = log EventType. getCredent ials().get SiteNumber (); // the  site numb er to log  the access  to
  747                             String  patientLo okupSiteNu mber = log EventType. getCredent ials().get PatientLoo kupSite();
  748                             if(pat ientLookup SiteNumber  != null & & patientL ookupSiteN umber.leng th() > 0)
  749                                      logSiteN umber = pa tientLooku pSiteNumbe r;
  750                             
  751                             ImageA ccessLogEv entType im ageAccessL ogEventTyp e = transl ate(logEve ntType.get EventType( ));
  752                             ImageA ccessLogEv ent result  =                      
  753                                      new Imag eAccessLog Event(pai. toString() , "", logE ventType.g etPatientI cn(), 
  754                                                       "2 00", Syste m.currentT imeMillis( ), 
  755                                                       lo gEventType .getReason () + "", " ", 
  756                                                       im ageAccessL ogEventTyp e, true, l ogSiteNumb er);           
  757                             return  result;
  758                    }
  759                    else
  760                    {
  761                             logger .warn("Ima ge Id '" +  logEventT ype.getId( ) + "' is  not an Abs tractImagi ngURN or P atientArti factIdenti fier and c annot be l ogged at t his time." );
  762                             return  null;
  763                    }
  764                    
  765                    
  766           }        
  767  
  768           pu blic stati c ImageAcc essLogEven tType tran slate(gov. va.med.ima ging.awiv. webservice s.soap.v2. ImageAcces sLogEventT ypeEventTy pe eventTy pe) {
  769                    Imag eAccessLog EventType  result;//  = new gov. va.med.ima ging.excha nge.enums. ImageAcces sLogEventT ype();
  770                    if(e ventType = = gov.va.m ed.imaging .awiv.webs ervices.so ap.v2.Imag eAccessLog EventTypeE ventType.I MAGE_COPY)  {
  771                             result  = ImageAc cessLogEve ntType.IMA GE_COPY;
  772                    }
  773                    else  if(eventT ype == gov .va.med.im aging.awiv .webservic es.soap.v2 .ImageAcce ssLogEvent TypeEventT ype.PATIEN T_ID_MISMA TCH)
  774                    {
  775                             result  = ImageAc cessLogEve ntType.PAT IENT_ID_MI SMATCH;
  776                    }
  777                    else  if(eventT ype == gov .va.med.im aging.awiv .webservic es.soap.v2 .ImageAcce ssLogEvent TypeEventT ype.IMAGE_ ACCESS)
  778                    {
  779                             result  = ImageAc cessLogEve ntType.IMA GE_ACCESS;
  780                    }
  781                    else  {
  782                             result  = ImageAc cessLogEve ntType.IMA GE_PRINT;
  783                    }
  784                    retu rn result;
  785           }
  786           
  787           /* *
  788            *  Certain c haracters  cannot be  given to t he Clinica l Display  client bec ause they  will cause  exception s
  789            *  in the pa rsing, the y must be  removed to  ensure pr oper displ ay of meta data. This  function  removes th ose
  790            *  character s and repl aces them  with a spa ce
  791            *  @param in put Input  string to  check
  792            *  @return
  793            * /
  794           pr ivate stat ic String  extractIll egalCharac ters(Strin g input)
  795           {
  796                    if(i nput == nu ll)
  797                             return  "";
  798                    retu rn input.r eplaceAll( "\\^", " " );    
  799           }
  800           
  801           pr otected st atic boole an isRadIm age(Image  image)
  802           {
  803                    if(i mage == nu ll)
  804                             return  false;
  805                    int  imgType =  image.getI mgType();
  806                    if(( imgType ==  VistaImag eType.DICO M.getImage Type()) ||  
  807                                      (imgType  == VistaI mageType.X RAY.getIma geType()))
  808                    {
  809                             return  true;
  810                    }
  811                    retu rn false;
  812           }
  813           
  814           pu blic stati c gov.va.m ed.imaging .awiv.webs ervices.so ap.v2.Anno tationType [] transla teImageAnn otations(L ist<ImageA nnotation>  imageAnno tations)
  815           {
  816                    if(i mageAnnota tions == n ull)
  817                    {
  818                             return  new gov.v a.med.imag ing.awiv.w ebservices .soap.v2.A nnotationT ype[0];
  819                    }
  820                    gov. va.med.ima ging.awiv. webservice s.soap.v2. Annotation Type[] res ult = 
  821                             new go v.va.med.i maging.awi v.webservi ces.soap.v 2.Annotati onType[ima geAnnotati ons.size() ];
  822                    
  823                    for( int i = 0;  i < image Annotation s.size();  i++)
  824                    {
  825                             result [i] = tran slate(imag eAnnotatio ns.get(i)) ;
  826                    }
  827                    
  828                    retu rn result;
  829           }
  830           
  831           pr ivate stat ic SimpleD ateFormat  getAnnotat ionDateFor mat()
  832           {
  833                    retu rn new Sim pleDateFor mat(annota tionDateFo rmat);
  834           }        
  835           
  836           pu blic stati c gov.va.m ed.imaging .awiv.webs ervices.so ap.v2.Anno tationType  translate (ImageAnno tation ima geAnnotati on)
  837           {
  838                    gov. va.med.ima ging.awiv. webservice s.soap.v2. Annotation Type resul t = 
  839                             new go v.va.med.i maging.awi v.webservi ces.soap.v 2.Annotati onType();
  840                    
  841                    resu lt.setAnno tationId(i mageAnnota tion.getAn notationUr n().toStri ng(SERIALI ZATION_FOR MAT.CDTP)) ;
  842                    resu lt.setImag eId(imageA nnotation. getImaging Urn().toSt ring(SERIA LIZATION_F ORMAT.CDTP ));
  843                    resu lt.setAnno tationVers ion(imageA nnotation. getAnnotat ionVersion ());
  844                    resu lt.setSave dAfterResu lt(imageAn notation.i sSavedAfte rResult()) ;
  845                    resu lt.setSave dDate(imag eAnnotatio n.getAnnot ationSaved Date() ==  null ? ""  : getAnnot ationDateF ormat().fo rmat(image Annotation .getAnnota tionSavedD ate()));
  846                    resu lt.setSour ce(transla te(imageAn notation.g etAnnotati onSource() ));
  847                    resu lt.setUser (translate (imageAnno tation.get Annotation SavedByUse r()));
  848                    resu lt.setAnno tationDele ted(imageA nnotation. isAnnotati onDeleted( ));
  849                    
  850                    retu rn result;
  851           }
  852           
  853           pr ivate stat ic gov.va. med.imagin g.awiv.web services.s oap.v2.Ann otationTyp eSource tr anslate (
  854                             ImageA nnotationS ource anno tationSour ce)
  855           {
  856                    for( Entry<Imag eAnnotatio nSource, g ov.va.med. imaging.aw iv.webserv ices.soap. v2.Annotat ionTypeSou rce> entry  : AWIVTra nslatorV2. annotation SourceMap. entrySet() )
  857                    {
  858                             if(ent ry.getKey( ) == annot ationSourc e)
  859                                      return e ntry.getVa lue();                          
  860                    }
  861                    retu rn null;
  862           }
  863           
  864           pr ivate stat ic gov.va. med.imagin g.awiv.web services.s oap.v2.Ann otationUse rType tran slate(
  865                             ImageA nnotationU ser user)
  866           {
  867                    if(u ser == nul l)
  868                             return  new gov.v a.med.imag ing.awiv.w ebservices .soap.v2.A nnotationU serType();
  869                    gov. va.med.ima ging.awiv. webservice s.soap.v2. Annotation UserType r esult = 
  870                             new go v.va.med.i maging.awi v.webservi ces.soap.v 2.Annotati onUserType ();
  871                    
  872                    resu lt.setDuz( user.getUs erId());
  873                    resu lt.setName (user.getN ame());
  874                    resu lt.setServ ice(user.g etService( ));
  875                    
  876                    retu rn result;
  877           }
  878           
  879           pu blic stati c gov.va.m ed.imaging .awiv.webs ervices.so ap.v2.Anno tationDeta ilsType tr anslate(
  880                             ImageA nnotationD etails ima geAnnotati onDetails)
  881           {
  882                    if(i mageAnnota tionDetail s == null)
  883                    {
  884                             return  new gov.v a.med.imag ing.awiv.w ebservices .soap.v2.A nnotationD etailsType ();
  885                    }
  886                    gov. va.med.ima ging.awiv. webservice s.soap.v2. Annotation DetailsTyp e result =
  887                             new go v.va.med.i maging.awi v.webservi ces.soap.v 2.Annotati onDetailsT ype();
  888                    
  889                    resu lt.setAnno tation(tra nslate(ima geAnnotati onDetails. getImageAn notation() ));
  890                    resu lt.setDeta ils(imageA nnotationD etails.get Annotation Xml());
  891                    
  892                    retu rn result;
  893           }
  894           
  895           pu blic stati c ImagingL ogEvent tr anslate(go v.va.med.i maging.awi v.webservi ces.soap.v 2.ThinClie ntAccessLo gEventType  thinClien tDetails,
  896                             String  transacti onId)
  897           th rows URNFo rmatExcept ion, Routi ngTokenFor matExcepti on
  898           {
  899                    if(t hinClientD etails ==  null)
  900                             return  null;
  901                    Stri ng delimit er = "|";
  902                    Stri ngBuilder  additional Data = new  StringBui lder();
  903                    addi tionalData .append(tr ansactionI d);
  904                    addi tionalData .append(de limiter);
  905                    addi tionalData .append(th inClientDe tails.getS creenResol ution());
  906                    
  907                    Stri ng logSite Number = t hinClientD etails.get Credential s().getSit eNumber();  // the si te number  to log the  access to
  908                    Stri ng patient LookupSite Number = t hinClientD etails.get Credential s().getPat ientLookup Site();
  909                    if(p atientLook upSiteNumb er != null  && patien tLookupSit eNumber.le ngth() > 0 )
  910                             logSit eNumber =  patientLoo kupSiteNum ber;
  911                    
  912                    Rout ingToken r outingToke nToLogTo =  RoutingTo kenHelper. createSite Appropriat eRoutingTo ken(logSit eNumber);
  913                    
  914                    Abst ractImagin gURN abstr actImaging Urn = null ;            
  915                    if(t hinClientD etails.isI sGroup() & & thinClie ntDetails. getId() !=  null && t hinClientD etails.get Id().lengt h() > 0)
  916                    {
  917                             URN ur n = URNFac tory.creat e(thinClie ntDetails. getId(), S ERIALIZATI ON_FORMAT. CDTP);
  918                             if(urn  instanceo f Abstract ImagingURN )
  919                             {
  920                                      abstract ImagingUrn  = (Abstra ctImagingU RN)urn;
  921                                      if(Excha ngeUtil.is SiteDOD(ab stractImag ingUrn.get Originatin gSiteId()) )
  922                                      {
  923                                               // this is  a DoD ima ge so put  the value  here
  924                                               additional Data.appen d("|");
  925                                               additional Data.appen d(thinClie ntDetails. getId());
  926                                      }
  927                             }
  928                    }
  929                    else  if(!thinC lientDetai ls.isIsGro up())
  930                    {
  931                             additi onalData.a ppend("|") ;
  932                             additi onalData.a ppend("DOD _Artifacts ");
  933                    }
  934                    
  935                    retu rn new Ima gingLogEve nt(routing TokenToLog To, abstra ctImagingU rn, thinCl ientDetail s.getPatie ntIcn(), 
  936                                      "AWIVTC" , "AWIV",  -1, additi onalData.t oString()) ;
  937           }
  938           
  939           pu blic stati c gov.va.m ed.imaging .awiv.webs ervices.so ap.v2.Imag eAccessRea sonType[]  translateI mageAccess Reasons(Li st<ImageAc cessReason > reasons)
  940           {
  941                    if(r easons ==  null)
  942                             return  new gov.v a.med.imag ing.awiv.w ebservices .soap.v2.I mageAccess ReasonType [0];
  943                    
  944                    gov. va.med.ima ging.awiv. webservice s.soap.v2. ImageAcces sReasonTyp e[] result  = 
  945                             new go v.va.med.i maging.awi v.webservi ces.soap.v 2.ImageAcc essReasonT ype[reason s.size()];
  946                    for( int i = 0;  i < reaso ns.size();  i++)
  947                    {
  948                             result [i] = tran slate(reas ons.get(i) );
  949                    }
  950                    
  951                    retu rn result;
  952           }
  953           
  954           pr ivate stat ic gov.va. med.imagin g.awiv.web services.s oap.v2.Ima geAccessRe asonType t ranslate(I mageAccess Reason rea son)
  955           {
  956                    gov. va.med.ima ging.awiv. webservice s.soap.v2. ImageAcces sReasonTyp e result =  
  957                             new go v.va.med.i maging.awi v.webservi ces.soap.v 2.ImageAcc essReasonT ype();
  958                    
  959                    resu lt.setDesc ription(re ason.getDe scription( ));
  960                    resu lt.setGlob alReasonCo de(reason. getGlobalR easonCode( ) + "");
  961                    resu lt.setReas onCode(rea son.getRea sonCode()  + "");
  962                    resu lt.setReas onType(tra nslateReas onTypes(re ason.getRe asonTypes( )));             
  963                    
  964                    retu rn result;
  965           }
  966           
  967           pr ivate stat ic gov.va. med.imagin g.awiv.web services.s oap.v2.Ima geAccessRe asonTypeTy pe[] trans lateReason Types(List <ImageAcce ssReasonTy pe> reason Types)
  968           {
  969                    if(r easonTypes  == null)
  970                             return  new gov.v a.med.imag ing.awiv.w ebservices .soap.v2.I mageAccess ReasonType Type[0];
  971                    
  972                    gov. va.med.ima ging.awiv. webservice s.soap.v2. ImageAcces sReasonTyp eType[] re sult = 
  973                             new go v.va.med.i maging.awi v.webservi ces.soap.v 2.ImageAcc essReasonT ypeType[re asonTypes. size()];
  974                    for( int i = 0;  i < reaso nTypes.siz e(); i++)
  975                    {
  976                             result [i] = tran slate(reas onTypes.ge t(i));
  977                    }
  978                    
  979                    retu rn result;
  980           }
  981           
  982           pu blic stati c List<Ima geAccessRe asonType>  translate( gov.va.med .imaging.a wiv.webser vices.soap .v2.ImageA ccessReaso nTypeType[ ] reasons)
  983           {
  984                    if(r easons ==  null)
  985                             return  new Array List<Image AccessReas onType>();
  986                    
  987                    List <ImageAcce ssReasonTy pe> result  = new Arr ayList<Ima geAccessRe asonType>( );
  988                    
  989                    for( int i = 0;  i < reaso ns.length;  i++)
  990                    {
  991                             result .add(trans late(reaso ns[i]));
  992                    }
  993                    
  994                    retu rn result;
  995           }
  996           
  997           pr ivate stat ic gov.va. med.imagin g.awiv.web services.s oap.v2.Ima geAccessRe asonTypeTy pe transla te (
  998                             ImageA ccessReaso nType reas on)
  999           {
  1000                    for( Entry<Imag eAccessRea sonType, g ov.va.med. imaging.aw iv.webserv ices.soap. v2.ImageAc cessReason TypeType>  entry : AW IVTranslat orV2.image AccessReas onsMap.ent rySet())
  1001                    {
  1002                             if(ent ry.getKey( ) == reaso n)
  1003                                      return e ntry.getVa lue();                          
  1004                    }
  1005                    retu rn null;
  1006           }
  1007           
  1008           pr ivate stat ic ImageAc cessReason Type trans late (
  1009                             gov.va .med.imagi ng.awiv.we bservices. soap.v2.Im ageAccessR easonTypeT ype reason )
  1010           {
  1011                    for( Entry<Imag eAccessRea sonType, g ov.va.med. imaging.aw iv.webserv ices.soap. v2.ImageAc cessReason TypeType>  entry : AW IVTranslat orV2.image AccessReas onsMap.ent rySet())
  1012                    {
  1013                             if(ent ry.getValu e() == rea son)
  1014                                      return e ntry.getKe y();                    
  1015                    }
  1016                    retu rn null;
  1017           }
  1018           
  1019           pu blic stati c gov.va.m ed.imaging .awiv.webs ervices.so ap.v2.Elec tronicSign atureResul tType tran slate(Elec tronicSign atureResul t electron icSignatur e)
  1020           {
  1021                    retu rn new Ele ctronicSig natureResu ltType(ele ctronicSig nature.isS uccess(), 
  1022                                      electron icSignatur e.getMessa ge());
  1023           }
  1024           
  1025           st atic class  DocumentS etDocument
  1026           {
  1027                    priv ate final  DocumentSe t document Set;
  1028                    priv ate final  Document d ocument;                  
  1029                    
  1030                    /**
  1031                     * @ param docu mentSet
  1032                     * @ param docu ment
  1033                     */
  1034                    publ ic Documen tSetDocume nt(Documen tSet docum entSet, Do cument doc ument)
  1035                    {
  1036                             super( );
  1037                             this.d ocumentSet  = documen tSet;
  1038                             this.d ocument =  document;
  1039                    }
  1040  
  1041                    /**
  1042                     * @ return the  documentS et
  1043                     */
  1044                    publ ic Documen tSet getDo cumentSet( )
  1045                    {
  1046                             return  documentS et;
  1047                    }
  1048  
  1049                    /**
  1050                     * @ return the  document
  1051                     */
  1052                    publ ic Documen t getDocum ent()
  1053                    {
  1054                             return  document;
  1055                    }
  1056           }
  1057           
  1058           st atic class  DocumentS etDocument Comparator  
  1059           im plements C omparator< DocumentSe tDocument>
  1060           {
  1061                    priv ate final  boolean as cending;
  1062                    
  1063                    publ ic Documen tSetDocume ntComparat or(boolean  ascending )
  1064                    {
  1065                             this.a scending =  ascending ;
  1066                    }
  1067                    
  1068  
  1069                    /* ( non-Javado c)
  1070                     * @ see java.u til.Compar ator#compa re(java.la ng.Object,  java.lang .Object)
  1071                     */
  1072                    @Ove rride
  1073                    publ ic int com pare(Docum entSetDocu ment dsd1,  DocumentS etDocument  dsd2)
  1074                    {
  1075                             if(dsd 1.document .getCreati onDate() = = null)
  1076                                      return - 1;
  1077                             if(dsd 2.document .getCreati onDate() = = null)
  1078                                      return 1 ;
  1079                             
  1080                             int va lue = dsd1 .document. getCreatio nDate().co mpareTo(ds d2.getDocu ment().get CreationDa te());
  1081                             if(!as cending)
  1082                                      value =  value * -1 ;
  1083                             
  1084                             return  value;
  1085                    }
  1086                    
  1087           }
  1088   }