120. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 3/25/2019 8:58:08 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.

120.1 Files compared

# Location File Last Modified
1 C:\AraxisMergeCompare\Pri_un\IMAG_Source\VISA\Java\VistaImagingDataSourceProvider\main\src\java\gov\va\med\imaging\vistaimagingdatasource VistaImagingQueryFactory.java Mon Mar 18 20:39:06 2019 UTC
2 C:\AraxisMergeCompare\Pri_re\IMAG_Source\VISA\Java\VistaImagingDataSourceProvider\main\src\java\gov\va\med\imaging\vistaimagingdatasource VistaImagingQueryFactory.java Tue Mar 19 15:16:04 2019 UTC

120.2 Comparison summary

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

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

120.4 Active regular expressions

No regular expressions were active.

120.5 Comparison detail

  1   package go v.va.med.i maging.vis taimagingd atasource;
  2  
  3   import gov .va.med.He althSummar yURN;
  4   import gov .va.med.im aging.Abst ractImagin gURN;
  5   import gov .va.med.im aging.Cprs Identifier ;
  6   import gov .va.med.im aging.Stor edStudyFil terURN;
  7   import gov .va.med.im aging.Stri ngUtil;
  8   import gov .va.med.im aging.Stud yURN;
  9   import gov .va.med.im aging.core .interface s.exceptio ns.MethodE xception;
  10   import gov .va.med.im aging.exch ange.Image AccessLogE vent;
  11   import gov .va.med.im aging.exch ange.Imagi ngLogEvent ;
  12   import gov .va.med.im aging.exch ange.busin ess.StudyF ilter;
  13   import gov .va.med.im aging.exch ange.busin ess.util.E xchangeUti l;
  14   import gov .va.med.im aging.exch ange.enums .ImageAcce ssReasonTy pe;
  15   import gov .va.med.im aging.exch ange.enums .StudyDele tedImageSt ate;
  16   import gov .va.med.im aging.exch ange.enums .StudyLoad Level;
  17   import gov .va.med.im aging.prot ocol.vista .VistaTran slatorUtil ity;
  18   import gov .va.med.im aging.tran sactioncon text.Trans actionCont ext;
  19   import gov .va.med.im aging.tran sactioncon text.Trans actionCont extFactory ;
  20   import gov .va.med.im aging.url. vista.Stri ngUtils;
  21   import gov .va.med.im aging.url. vista.Vist aQuery;
  22  
  23   import jav a.text.Dat eFormat;
  24   import jav a.text.Sim pleDateFor mat;
  25   import jav a.util.Dat e;
  26   import jav a.util.Has hMap;
  27   import jav a.util.Lis t;
  28   import jav a.util.Map ;
  29  
  30   import org .apache.lo gging.log4 j.LogManag er;
  31   import org .apache.lo gging.log4 j.Logger;
  32  
  33   /**
  34    * 
  35    * @author   DNS     beckec
  36    *
  37    */
  38   public cla ss VistaIm agingQuery Factory
  39   {
  40           pr ivate stat ic final S tring RPC_ XUS_GET_DI VISIONS =  "XUS DIVIS ION GET";
  41           pu blic final  static St ring MENU_ SUBSCRIPT  = "200.03" ;
  42           pu blic final  static St ring DELEG ATE_SUBSCR IPT = "200 .19";
  43  
  44           //  rpc calls  made to o ther packa ges
  45           pr ivate fina l static S tring RPC_ CONVERT_IC N_TO_DFN =  "VAFCTFU  CONVERT IC N TO DFN";
  46           pr ivate fina l static S tring RPC_ CONVERT_DF N_TO_ICN =  "VAFCTFU  CONVERT DF N TO ICN";
  47           pr ivate fina l static S tring RPC_ GET_VARIAB LE_VALUE =  "XWB GET  VARIABLE V ALUE";
  48           
  49           //  MAG rpc c alls         
  50           pr ivate fina l static S tring RPC_ MAG_GET_GR OUPS = "MA G4 PAT GET  IMAGES";
  51           pr ivate fina l static S tring RPC_ MAG_GET_ST UDY_IMAGES  = "MAGG G ROUP IMAGE S";
  52           pr ivate fina l static S tring RPC_ MAG_REPORT  = "MAGGRP T";
  53           pr ivate fina l static S tring RPC_ MAG_GET_NE TLOC = "MA G GET NETL OC";
  54           pr ivate fina l static S tring RPC_ MAG_MAGGUS ER2 = "MAG GUSER2";
  55           pr ivate fina l static S tring RPC_ MAG_DOD_GE T_STUDIES_ BY_IEN = " MAG DOD GE T STUDIES  IEN";
  56           pr ivate fina l static S tring RPC_ MAG_IMAGE_ CURRENT_IN FO = "MAG  IMAGE CURR ENT INFO";
  57           pr ivate fina l static S tring RPC_ MAG_NEW_SO P_INSTANCE _UID = "MA G NEW SOP  INSTANCE U ID";
  58           pr ivate fina l static S tring RPC_ MAG_ACTION _LOG = "MA GGACTION L OG";
  59           pr ivate fina l static S tring RPC_ MAG_WRKS_U PDATES = " MAGG WRKS  UPDATES";
  60           pr ivate fina l static S tring RPC_ MAG_OFFLIN E_IMAGE_AC CESSED = " MAGG OFFLI NE IMAGE A CCESSED";      
  61           pr ivate fina l static S tring RPC_ MAG_INSTAL L = "MAGG  INSTALL";
  62           pr ivate fina l static S tring RPC_ MAG_GET_IM AGE_INFO =  "MAG4 GET  IMAGE INF O";
  63           pr ivate fina l static S tring RPC_ MAG_SYS_GL OBAL_NODE  = "MAGG SY S GLOBAL N ODE";
  64           pr ivate fina l static S tring RPC_ MAG_DEV_FI ELD_VALUES  = "MAGG D EV FIELD V ALUES";
  65           pr ivate fina l static S tring RPC_ MAG_PAT_FI ND = "MAGG  PAT FIND" ;
  66           pr ivate fina l static S tring RPC_ MAG_PAT_IN FO = "MAGG  PAT INFO" ;
  67           pr ivate fina l static S tring RPC_ MAG_PAT_PH OTOS = "MA GG PAT PHO TOS";
  68           pr ivate fina l static S tring RPC_ MAG_CPRS_R AD_EXAM =  "MAGG CPRS  RAD EXAM" ;
  69           pr ivate fina l static S tring RPC_ MAG_CPRS_T IU_NOTE =  "MAG3 CPRS  TIU NOTE" ;
  70           pr ivate fina l static S tring RPC_ MAGN_CPRS_ IMAGE_LIST  = "MAGN C PRS IMAGE  LIST";
  71           pr ivate fina l static S tring RPC_ MAGN_PATIE NT_IMAGE_L IST = "MAG N PATIENT  IMAGE LIST ";    
  72           pr ivate fina l static S tring RPC_ MAG_BROKER _SECURITY  = "MAG BRO KER SECURI TY";
  73           
  74           pr ivate fina l static S tring RPC_ MAG_USER_K EYS = "MAG GUSERKEYS" ;
  75           
  76           pr ivate fina l static S tring RPC_ MAG_IMAGE_ ALLOW_ANNO TATE = "MA G ANNOT IM AGE ALLOW" ;
  77           pr ivate fina l static S tring RPC_ MAGJ_GET_T REATING_LI ST = "MAGJ  GET TREAT ING LIST";
  78           
  79           pr ivate fina l static S tring RPC_ MAGG_REASO N_LIST = " MAGG REASO N LIST";
  80           pr ivate fina l static S tring RPC_ MAGG_VERIF Y_ESIG = " MAGG VERIF Y ESIG";
  81           pr ivate fina l static S tring RPC_ MAGGHSLIST  = "MAGGHS LIST";
  82           pr ivate fina l static S tring RPC_ MAGGHS = " MAGGHS";
  83           
  84           pr ivate fina l static S tring RPC_ GET_TIMEOU T_PARAMETE RS = "MAGG  GET TIMEO UT";
  85           
  86           pr ivate fina l static S tring RPC_ MAG4_FILTE R_GET_LIST  = "MAG4 F ILTER GET  LIST";
  87           
  88           pr ivate fina l static S tring RPC_ MAG_IMAGE_ LIST = "MA G4 IMAGE L IST";
  89  
  90  
  91           //  we can le ave QA Che ck off bec ause this  will allow  "bad" ima ges to go  to the VA  but we sti ll
  92           //  will get  a QA error  message w hich will  prevent th ose images  from goin g to the D OD
  93           pr ivate fina l static S tring MAG_ QA_CHECK =  "1"; // 1  indicates  no QA che ck
  94           pr ivate fina l static i nt MAG_MAX _PATIENT_R ESULT_COUN T = 100;
  95           
  96           pr ivate fina l static S impleDateF ormat date Format = n ew SimpleD ateFormat( "yyyyMMddH HmmssSSS") ; // for D ICOM UID g eneration  only
  97           
  98           pr ivate stat ic Logger  getLogger( )
  99           {
  100                    retu rn LogMana ger.getLog ger(VistaI magingQuer yFactory.c lass);
  101           }                 
  102           
  103           /* *
  104            *  
  105            *  @param pa tientICN
  106            *  @return
  107            *  @throws M ethodExcep tion
  108            * /
  109           pu blic stati c VistaQue ry createG etPatientD FNVistaQue ry(String  patientICN
  110           {
  111                    Vist aQuery vm  = new Vist aQuery(RPC _CONVERT_I CN_TO_DFN) ;
  112                    vm.a ddParamete r(VistaQue ry.LITERAL , patientI CN);
  113                    logV istaQueryR equest(vm) ;
  114                    retu rn vm;
  115           }        
  116           
  117           pu blic stati c VistaQue ry createG etPatientI CNVistaQue ry(String  patientDFN
  118           {
  119                    Vist aQuery vm  = new Vist aQuery(RPC _CONVERT_D FN_TO_ICN) ;
  120                    vm.a ddParamete r(VistaQue ry.LITERAL , patientD FN);
  121                    logV istaQueryR equest(vm) ;
  122                    retu rn vm;
  123           }        
  124           
  125           /* *
  126            *  Create a  VistQuery  instance t hat can be  used to e xecute a
  127            *  RPC_MAG_G ET_STUDIES  RPC call  on Vista.
  128            *  The retur n from the  RPC call  is a list  of studies  matching  the
  129            *  class, da tes, packa ge, types,  specialty  and origi n filter f ields.
  130            *  The respo nse is a l ist of car et-delimit ed Strings , each of  which
  131            *  is a stud y descript ion includ ing the st udy IEN.
  132            *  ex:
  133            *  1^Class:  CLIN - 
  134            *  Item~S2^S ite^Note T itle~~W0^P roc DT~S1^ Procedure^ # Img~S2^S hort Desc^ Pkg^Class^ Type^Speci alty^Event ^Origin^Ca p Dt~S1~W0 ^Cap by~~W 0^Image ID ~S2~W0
  135            *  1^WAS^NUR SING NOTE^ 09/28/2001  00:01^NOT E^2^CONSUL T NURSE ME DICAL WOUN D SPEC INP T^NOTE^CLI N^CONSULT^ NURSING^WO UND ASSESS MENT^VA^09 /28/2001 0 1:35^IMAGP ROVIDERONE TWOSIX,ONE TWOSIX^175 2|1752^\\I SW-IMGGOLD BACK\image 1$\DM\00\1 7\DM001753 .JPG^\\ISW -IMGGOLDBA CK\image1$ \DM\00\17\ DM001753.A BS^CONSULT  NURSE MED ICAL WOUND  SPEC INPT ^3010928^1 1^NOTE^09/ 28/2001^36 ^M^A^^^2^1 ^WAS^^^711 ^IMAGPATIE NT1055,105 5^CLIN^^^
  136            *  2^WAS^OPH THALMOLOGY ^08/20/200 1 00:01^OP H^10^Ophth almology^N OTE^CLIN^I MAGE^EYE C ARE^^VA^08 /20/2001 2 2:32^IMAGP ROVIDERONE TWOSIX,ONE TWOSIX^178 3|1783^\\I SW-IMGGOLD BACK\image 1$\DM\00\1 7\DM001784 .DCM^\\ISW -IMGGOLDBA CK\image1$ \DM\00\17\ DM001784.A BS^Ophthal mology^301 0820^11^OP H^08/20/20 01^41^M^A^ ^^10^1^WAS ^^^711^IMA GPATIENT10 55,1055^CL IN^^^^
  137            *  
  138            *  @param pa tientDfn
  139            *  @param fi lter
  140            *  @return
  141            * /
  142           pu blic stati c VistaQue ry createG etGroupsVi staQuery(S tring pati entDfn, St udyFilter  filter)
  143       {
  144                String t oDate = "" ;
  145                    Stri ng fromDat e = "";
  146                    Stri ng studyPa ckage = "" ;
  147                    Stri ng studyCl ass = "";
  148                    Stri ng studyTy pes = "";
  149                    Stri ng studyEv ent = "";
  150                    Stri ng studySp ecialtiy =  "";
  151                    Stri ng studyOr igin = "";
  152                    if(f ilter != n ull) 
  153                    {
  154                             fromDa te = Vista Translator Utility.co nvertDateT oRpcFormat (filter.ge tFromDate( ));
  155                             toDate  = VistaTr anslatorUt ility.conv ertDateToR pcFormat(f ilter.getT oDate());
  156                             studyP ackage = f ilter.getS tudy_packa ge();
  157                             studyC lass = fil ter.getStu dy_class() ;
  158                             studyT ypes = fil ter.getStu dy_type();
  159                             studyE vent = fil ter.getStu dy_event() ;
  160                             studyS pecialtiy  = filter.g etStudy_sp ecialty();
  161                             studyO rigin = fi lter.getOr igin();
  162                    }
  163                    
  164                    Vist aQuery vm  = new Vist aQuery(RPC _MAG_GET_G ROUPS); //  really re turns grou ps
  165                    //                                                            Note: a  Study has  1.. Groups  and a Gro up can hav e 1.. Seri es!
  166                    vm.a ddParamete r(VistaQue ry.LITERAL , patientD fn);
  167                    vm.a ddParamete r(VistaQue ry.LITERAL , studyPac kage); //  PACKAGE
  168                    vm.a ddParamete r(VistaQue ry.LITERAL , studyCla ss); // CL ASS
  169                    vm.a ddParamete r(VistaQue ry.LITERAL , studyTyp es); // TY PES
  170                    vm.a ddParamete r(VistaQue ry.LITERAL , studyEve nt); // EV ENT - trie d WOUND AS SESSMENT
  171                    vm.a ddParamete r(VistaQue ry.LITERAL , studySpe cialtiy);  // SPEC -  tried RADI OLOGY
  172                    vm.a ddParamete r(VistaQue ry.LITERAL , fromDate ); // FROM  DATE
  173                    vm.a ddParamete r(VistaQue ry.LITERAL , toDate);  // TO DAT E
  174                    vm.a ddParamete r(VistaQue ry.LITERAL , studyOri gin); // O RIGIN
  175                    logV istaQueryR equest(vm) ;
  176                return v m;
  177       }
  178           
  179           /* *
  180            *  This vers ion should  be used a t sites wi thout P119  that do n ot have th e new para meter (FLA GS) for de leted imag es
  181            *  
  182            *  @param st udyMap
  183            *  @param pa tientDfn
  184            *  @return
  185            * /
  186           pu blic stati c VistaQue ry createG etStudiesB yIenVistaQ uery(Map<? ,?> studyM ap, String  patientDf n, StudyLo adLevel st udyLoadLev el)
  187           {
  188                    Vist aQuery que ry = new V istaQuery( RPC_MAG_DO D_GET_STUD IES_BY_IEN ); // IN:  Groups; Ou t: Studies
  189                    quer y.addParam eter(Vista Query.LIST , studyMap );
  190                    quer y.addParam eter(Vista Query.LITE RAL, patie ntDfn);
  191                    if(s tudyLoadLe vel.isIncl udeImages( ))
  192                    {
  193                             query. addParamet er(VistaQu ery.LITERA L, "0");
  194                    }
  195                    else
  196                    {
  197                             // onl y include  study deta ils
  198                             query. addParamet er(VistaQu ery.LITERA L, "1");
  199                    }
  200                    logV istaQueryR equest(que ry);
  201                    retu rn query;
  202           }
  203           
  204           /* *
  205            *  This vers ion should  be used a t sites wi thout P119  that do n ot have th e new para meter (FLA GS) for de leted imag es
  206            *  
  207            *  @param st udyMap
  208            *  @param pa tientDfn
  209            *  @return
  210            * /
  211           pu blic stati c VistaQue ry createG etSingleSt udyFromBot hDataStruc turesByCpr sIdentifie rVistaQuer y(Map<?,?>  studyMap,  String pa tientDfn,S tudyFilter  filter,   StudyLoadL evel study LoadLevel)
  212           {
  213                    Vist aQuery que ry = new V istaQuery( RPC_MAGN_C PRS_IMAGE_ LIST); //  IN: Groups ; Out: Stu dies
  214                    
  215                    Map< String,Str ing> study  = new Has hMap<Strin g,String>( );
  216                    Stud yURN study Urn = (Stu dyURN)filt er.getStud yId();
  217                    Stri ng studyIe n = studyU rn.getImag ingIdentif ier();
  218                    stud y.put("1",  studyIen) ;
  219                    quer y.addParam eter(Vista Query.LIST , study);
  220                    quer y.addParam eter(Vista Query.LITE RAL, "1");
  221                    //lo gVistaQuer yRequest(q uery);
  222                    retu rn query;
  223           }
  224  
  225           /* *
  226            *  This vers ion should  be used a t sites wi thout P119  that do n ot have th e new para meter (FLA GS) for de leted imag es
  227            *  
  228            *  @param st udyMap
  229            *  @param pa tientDfn
  230            *  @return
  231            * /
  232           pu blic stati c VistaQue ry createG etStudiesF romBothDat aStructure sByPatient VistaQuery (Map<?,?>  studyMap,  String pat ientDfn,St udyFilter  filter,  S tudyLoadLe vel studyL oadLevel)
  233           {
  234                    Vist aQuery que ry = new V istaQuery( RPC_MAGN_P ATIENT_IMA GE_LIST);  // IN: Gro ups; Out:  Studies
  235                    
  236                    quer y.addParam eter(Vista Query.LITE RAL, "DFN" );
  237                    quer y.addParam eter(Vista Query.LITE RAL, patie ntDfn);
  238                    quer y.addParam eter(Vista Query.LITE RAL, "1");
  239                    quer y.addParam eter(Vista Query.LITE RAL, "");
  240                    logV istaQueryR equest(que ry);
  241                    retu rn query;
  242           }
  243  
  244           /* *
  245            *  This vers ion makes  use of the  studyDele tedImageSt ate and sh ould be us ed by Patc h 119 (and  later)
  246            *  @param st udyMap
  247            *  @param pa tientDfn
  248            *  @param st udyLoadLev el
  249            *  @param st udyDeleted ImageState
  250            *  @return
  251            * /
  252           pu blic stati c VistaQue ry createG etStudiesB yIenVistaQ uery(Map<? ,?> studyM ap, String  patientDf n, 
  253                             StudyL oadLevel s tudyLoadLe vel, Study DeletedIma geState st udyDeleted ImageState )
  254           {
  255                    Vist aQuery que ry = new V istaQuery( RPC_MAG_DO D_GET_STUD IES_BY_IEN ); // IN:  Groups; Ou t: Studies
  256                    quer y.addParam eter(Vista Query.LIST , studyMap );
  257                    quer y.addParam eter(Vista Query.LITE RAL, patie ntDfn);
  258                    if(s tudyLoadLe vel.isIncl udeImages( ))
  259                    {
  260                             query. addParamet er(VistaQu ery.LITERA L, "0");
  261                    }
  262                    else
  263                    {
  264                             // onl y include  study deta ils
  265                             query. addParamet er(VistaQu ery.LITERA L, "1");
  266                    }
  267                    if(s tudyDelete dImageStat e == Study DeletedIma geState.in cludesDele tedImages)
  268                    {
  269                             query. addParamet er(VistaQu ery.LITERA L, "D");     
  270                    }
  271                    else
  272                    {
  273                             query. addParamet er(VistaQu ery.LITERA L, "");
  274                    }
  275                    logV istaQueryR equest(que ry);
  276                    retu rn query;
  277           }
  278           
  279           /* *
  280            *  Create a  VistaQuery  to get a  single Stu dy report  given the  IEN.
  281            *  
  282            *  @param ie n
  283            *  @return
  284            * /
  285           pu blic stati c VistaQue ry createG etReportVi staQuery(S tring ien)
  286           {
  287                    Vist aQuery vm  = new Vist aQuery(RPC _MAG_REPOR T);
  288                    vm.a ddParamete r(VistaQue ry.LITERAL , ien);
  289                    vm.a ddParamete r(VistaQue ry.LITERAL , MAG_QA_C HECK); //  QA Check
  290                    logV istaQueryR equest(vm) ;
  291                    retu rn vm;
  292           }
  293           
  294           pu blic stati c VistaQue ry createG etStudyIma gesVistaQu ery(String  studyIen)
  295           {
  296                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_GET_ STUDY_IMAG ES);
  297                    msg. addParamet er(VistaQu ery.LITERA L, studyIe n);
  298                    msg. addParamet er(VistaQu ery.LITERA L, MAG_QA_ CHECK); //  NO QA CHE CK
  299                    logV istaQueryR equest(msg );
  300                    retu rn msg;
  301           }
  302           
  303           pu blic stati c VistaQue ry createG etNetworkL ocationsVi staQuery()
  304           {
  305                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_GET_ NETLOC);
  306                    msg. addParamet er(VistaQu ery.LITERA L, "ALL");
  307                    logV istaQueryR equest(msg );
  308                    retu rn msg;
  309           }
  310           
  311           pu blic stati c VistaQue ry createG etImagingS iteParamet ersQuery(S tring work stationId)
  312           {
  313                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_MAGG USER2);
  314                    msg. addParamet er(VistaQu ery.LITERA L, worksta tionId);
  315                    logV istaQueryR equest(msg );
  316                    retu rn msg;
  317           }
  318           
  319           pu blic stati c VistaQue ry createN otifyArchi veOperator Query(Stri ng filenam e, String  imageIen)
  320           {
  321                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_OFFL INE_IMAGE_ ACCESSED);
  322                    msg. addParamet er(VistaQu ery.LITERA L, filenam e);
  323                    msg. addParamet er(VistaQu ery.LITERA L, imageIe n);
  324                    logV istaQueryR equest(msg );
  325                    retu rn msg;
  326           }
  327           
  328           pu blic stati c VistaQue ry createG etMagInsta lledVersio nsQuery()
  329           {
  330                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_INST ALL);                
  331                    logV istaQueryR equest(msg );
  332                    retu rn msg;
  333           }
  334           
  335           pu blic stati c VistaQue ry createS essionQuer y(String w orkstation Id)
  336           {
  337                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_WRKS _UPDATES);
  338                    msg. addParamet er(VistaQu ery.LITERA L, worksta tionId + " ^^^^^^^^^" );
  339                    logV istaQueryR equest(msg );
  340                    retu rn msg;
  341           }
  342           
  343           pu blic stati c VistaQue ry createL ogImageAcc essQuery(b oolean isD odImage, S tring user Duz, 
  344                             String  imageIen,  String pa tientDFN,  String use rSiteNumbe r)
  345           {
  346                    Tran sactionCon text trans actionCont ext = Tran sactionCon textFactor y.get();
  347                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_ACTI ON_LOG);
  348                    Stri ngBuilder  logParamBu ilder = ne w StringBu ilder();
  349                    if(i sDodImage)
  350                    {
  351                             getLog ger().info ("Creating  query to  log VA acc ess to DOD  image");
  352                             // if  the image  is from th e DOD, the n the pers on looking  at it is  always fro m the VA,  no reason
  353                             // to  look at th e user sit e number f ield
  354                             
  355                             // nee d to put t he DOD Ima ge id into  the prope r place
  356                             // als o need to  put in RDO DVA to ind icate user  is from t he VA acce ssing a DO D image
  357                             // we  don't put  the image  Id into th e IEN fiel d but the  additional  field sin ce this is  a DOD ide ntifier
  358                             logPar amBuilder. append("RV DODVA^" +  userDuz +  "^");
  359                             logPar amBuilder. append("^W rks^" + pa tientDFN +  "^1^");
  360                             logPar amBuilder. append(ima geIen);
  361                             logPar amBuilder. append("|" );
  362                             logPar amBuilder. append(tra nsactionCo ntext.getT ransaction Id());
  363                             logPar amBuilder. append("|" );
  364                             logPar amBuilder. append(tra nsactionCo ntext.getS iteNumber( ));
  365                             logPar amBuilder. append("|" );
  366                    }
  367                    else
  368                    {
  369                             if(Exc hangeUtil. isSiteDOD( userSiteNu mber))
  370                             {
  371                                      // image  is from t he VA but  the user i s from the  DOD, so n o workstat ion to use
  372                                      getLogge r().info(" Creating q uery to lo g DOD acce ss to VA i mage");
  373                                      logParam Builder.ap pend("RVVA DOD^" + us erDuz + "^ ");
  374                                      logParam Builder.ap pend(image Ien + "^DO D^");
  375                                      logParam Builder.ap pend(patie ntDFN + "^ 1^");                                
  376                                      logParam Builder.ap pend("");  // no imag e identifi er since V A image
  377                                      logParam Builder.ap pend("|");
  378                                      logParam Builder.ap pend(trans actionCont ext.getTra nsactionId ());
  379                                      logParam Builder.ap pend("|");
  380                                      logParam Builder.ap pend(trans actionCont ext.getLog gerSiteNum ber());
  381                                      logParam Builder.ap pend("|");
  382                                      logParam Builder.ap pend(trans actionCont ext.getLog gerFullNam e());                           
  383                             }
  384                             else
  385                             {
  386                                      // image  is from t he VA and  the user i s from the  VA (V2V)
  387                                      getLogge r().info(" Creating q uery to lo g VA acces s to VA im age");
  388                                      logParam Builder.ap pend("RVVA VA^" + use rDuz + "^" );
  389                                      logParam Builder.ap pend(image Ien + "^Wr ks^");
  390                                      logParam Builder.ap pend(patie ntDFN + "^ 1^");
  391                                      logParam Builder.ap pend("");  // no imag e identifi er since V A image
  392                                      logParam Builder.ap pend("|");
  393                                      logParam Builder.ap pend(trans actionCont ext.getTra nsactionId ());
  394                                      logParam Builder.ap pend("|");
  395                                      logParam Builder.ap pend(trans actionCont ext.getSit eNumber()) ;
  396                                      logParam Builder.ap pend("|");
  397                                      logParam Builder.ap pend("");  // don't n eed user f ull name s ince using  real pers on DUZ
  398                             }                         
  399                    }
  400                    getL ogger().de bug("Image  Access Lo gging Para meter '" +  logParamB uilder.toS tring() +  "'");
  401                    msg. addParamet er(VistaQu ery.LITERA L, logPara mBuilder.t oString()) ;
  402                    
  403                    logV istaQueryR equest(msg );
  404                    retu rn msg;
  405           }
  406           
  407           pu blic stati c VistaQue ry createL ogPatientI dMismatchQ uery(Strin g imageIen , String p atientDFN)
  408           {
  409                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_ACTI ON_LOG);
  410                    Stri ngBuilder  copyParamB uilder = n ew StringB uilder();
  411                    copy ParamBuild er.append( "IMGMM");
  412                    copy ParamBuild er.append( "^^");
  413                    copy ParamBuild er.append( imageIen);
  414                    copy ParamBuild er.append( "^ICN/SSN  mismatch^" );
  415                    copy ParamBuild er.append( patientDFN );
  416                    copy ParamBuild er.append( "^1");
  417                    msg. addParamet er(VistaQu ery.LITERA L, copyPar amBuilder. toString() );
  418                    logV istaQueryR equest(msg );
  419                    retu rn msg;
  420           }
  421           
  422           pu blic stati c VistaQue ry createL ogImageCop yQuery(
  423                             ImageA ccessLogEv ent event)
  424           {
  425                    Tran sactionCon text trans actionCont ext = Tran sactionCon textFactor y.get();
  426                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_ACTI ON_LOG);
  427                    Stri ngBuilder  copyParamB uilder = n ew StringB uilder();
  428                    copy ParamBuild er.append( event.getR easonCode( ));
  429                    copy ParamBuild er.append( "^^");
  430                    copy ParamBuild er.append( event.getD ecodedImag eIen());
  431                    copy ParamBuild er.append( "^Copy Ima ge^");
  432                    copy ParamBuild er.append( event.getP atientDfn( ));
  433                    copy ParamBuild er.append( "^1");
  434                    copy ParamBuild er.append( "^");
  435                    if(( event.getR easonDescr iption() ! = null) &&  (event.ge tReasonDes cription() .length()  > 0))
  436                    {                         
  437                             copyPa ramBuilder .append(ev ent.getRea sonDescrip tion());           
  438                    }
  439                    copy ParamBuild er.append( "|");
  440                    copy ParamBuild er.append( transactio nContext.g etTransact ionId());
  441                    msg. addParamet er(VistaQu ery.LITERA L, copyPar amBuilder. toString() );
  442                    logV istaQueryR equest(msg );
  443                    retu rn msg;
  444           }
  445           
  446           pu blic stati c VistaQue ry createL ogImagePri ntQuery(Im ageAccessL ogEvent ev ent)
  447           {
  448                    Tran sactionCon text trans actionCont ext = Tran sactionCon textFactor y.get();
  449                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_ACTI ON_LOG);
  450                    Stri ngBuilder  copyParamB uilder = n ew StringB uilder();
  451                    copy ParamBuild er.append( event.getR easonCode( ));
  452                    copy ParamBuild er.append( "^^");
  453                    copy ParamBuild er.append( event.getD ecodedImag eIen());
  454                    copy ParamBuild er.append( "^Print Im age^");
  455                    copy ParamBuild er.append( event.getP atientDfn( ));
  456                    copy ParamBuild er.append( "^1");
  457                    copy ParamBuild er.append( "^");
  458                    if(( event.getR easonDescr iption() ! = null) &&  (event.ge tReasonDes cription() .length()  > 0))
  459                    {                         
  460                             copyPa ramBuilder .append(ev ent.getRea sonDescrip tion());
  461                    }
  462                    copy ParamBuild er.append( "|");
  463                    copy ParamBuild er.append( transactio nContext.g etTransact ionId());
  464                    msg. addParamet er(VistaQu ery.LITERA L, copyPar amBuilder. toString() );
  465                    logV istaQueryR equest(msg );
  466                    retu rn msg;
  467           }
  468           
  469           /* *
  470            *  Create qu ery to log off from V istA (clos e Imaging  sessions o n server)
  471            *  @return
  472            * /
  473           /*
  474           pu blic stati c VistaQue ry createM agLogoffQu ery()
  475           {
  476                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_LOGO FF);
  477                    retu rn msg;
  478           }* /
  479           
  480           /* *
  481            *  Create Qu ery to get  the HIS u pdate for  an image
  482            *  @param im ageIen
  483            *  @return
  484            * /
  485           pu blic stati c VistaQue ry createG etHisUpdat eQuery(Str ing imageI en)
  486           {
  487                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_IMAG E_CURRENT_ INFO);
  488                    msg. addParamet er(VistaQu ery.LITERA L, imageIe n);
  489                    logV istaQueryR equest(msg );
  490                    retu rn msg;
  491           }
  492           
  493           pu blic stati c VistaQue ry createN ewSOPInsta nceUidQuer y(String s iteNumber,  String im ageIen)
  494           {
  495                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_NEW_ SOP_INSTAN CE_UID);
  496                    msg. addParamet er(VistaQu ery.LIST,  "");
  497                    // T ODO if the re is a co ncept of p roduct ID  at VI, it  should pre ceed the s ite#
  498                    msg. addParamet er(VistaQu ery.LITERA L, "1.2.84 0.113754."  + siteNum ber + "."  + dateForm at.format( new Date() ) + ".1");
  499                    msg. addParamet er(VistaQu ery.LITERA L, imageIe n);
  500                    logV istaQueryR equest(msg );
  501                    retu rn msg;
  502           }
  503           
  504           pu blic stati c VistaQue ry createG etImageInf ormationQu ery(String  imageId)
  505           {
  506                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_GET_ IMAGE_INFO );
  507                    msg. addParamet er(VistaQu ery.LITERA L, imageId );
  508                    logV istaQueryR equest(msg );
  509                    retu rn msg;
  510           }
  511           
  512           pu blic stati c VistaQue ry createG etImageInf ormationQu ery(String  imageId,  boolean in cludeDelet edImages)
  513           {
  514                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_GET_ IMAGE_INFO );
  515                    msg. addParamet er(VistaQu ery.LITERA L, imageId );
  516                    if(i ncludeDele tedImages)
  517                    {
  518                             msg.ad dParameter (VistaQuer y.LITERAL,  "D");       
  519                    }
  520                    else
  521                    {
  522                             msg.ad dParameter (VistaQuer y.LITERAL,  "");
  523                    }
  524                    logV istaQueryR equest(msg );
  525                    retu rn msg;
  526           }
  527           
  528           pu blic stati c VistaQue ry createG etSysGloba lNodesQuer y(String i mageId)
  529           {
  530                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_SYS_ GLOBAL_NOD E);
  531                    msg. addParamet er(VistaQu ery.LITERA L, imageId );
  532                    logV istaQueryR equest(msg );
  533                    retu rn msg;
  534           }
  535           
  536           pu blic stati c VistaQue ry createG etDevField Values(Str ing imageI d, String  flags)
  537           {                 
  538                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_DEV_ FIELD_VALU ES);
  539                    msg. addParamet er(VistaQu ery.LITERA L, imageId );
  540                    if(f lags == nu ll)
  541                             flags  = "";
  542                    msg. addParamet er(VistaQu ery.LITERA L, flags.t oUpperCase ());
  543                    logV istaQueryR equest(msg );
  544                    retu rn msg;
  545           }
  546           
  547           /* *
  548            *  Create qu ery to sea rch for pa tients by  name
  549            *  @param se archName
  550            *  @return
  551            * /
  552           pu blic stati c VistaQue ry createF indPatient Query(Stri ng searchN ame)
  553           {
  554                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_PAT_ FIND);
  555                    msg. addParamet er(VistaQu ery.LITERA L, MAG_MAX _PATIENT_R ESULT_COUN T + "^" +  searchName .toUpperCa se());
  556                    logV istaQueryR equest(msg );
  557                    retu rn msg;
  558           }
  559           
  560           /* *
  561            *  Create qu ery to loo k for pati ent info d etails
  562            *  @param pa tientDfn
  563            *  @return
  564            * /
  565           pu blic stati c VistaQue ry createG etPatientI nfoQuery(S tring pati entDfn)
  566           {
  567                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_PAT_ INFO);
  568                    msg. addParamet er(VistaQu ery.LITERA L, patient Dfn + "^^0 ^^1");
  569                    logV istaQueryR equest(msg );
  570                    retu rn msg;
  571           }
  572           
  573           /* *
  574            *  Creates a  patient p hoto Id qu ery
  575            *  @param pa tientDfn
  576            *  @return
  577            * /
  578           pu blic stati c VistaQue ry createG etPatientP hotosQuery (String pa tientDfn)
  579           {
  580                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_PAT_ PHOTOS);
  581                    msg. addParamet er(VistaQu ery.LITERA L, patient Dfn);
  582                    logV istaQueryR equest(msg );
  583                    retu rn msg;
  584           }
  585           
  586           pu blic stati c VistaQue ry createG etImagesFo rCprsRadEx am(CprsIde ntifier cp rsIdentifi er)
  587           {
  588                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_CPRS _RAD_EXAM) ;
  589                    msg. addParamet er(VistaQu ery.LITERA L, cprsIde ntifier.ge tCprsIdent ifier());
  590                    logV istaQueryR equest(msg );
  591                    retu rn msg;
  592           }
  593  
  594           pu blic stati c VistaQue ry createG etImagesFo rCprsRadEx am(CprsIde ntifier cp rsIdentifi er, StudyF ilter filt er)
  595           {
  596                    //WF P-Need to  still add  code here.
  597                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_CPRS _RAD_EXAM) ;
  598                    msg. addParamet er(VistaQu ery.LITERA L, cprsIde ntifier.ge tCprsIdent ifier());
  599                    logV istaQueryR equest(msg );
  600                    retu rn msg;
  601           }
  602  
  603           pu blic stati c VistaQue ry createG etImagesFo rCprsTiuNo te(CprsIde ntifier cp rsIdentifi er)
  604           {
  605                    Stri ng tiuId =  StringUti ls.MagPiec e(cprsIden tifier.get CprsIdenti fier(), St ringUtils. CARET, 5);
  606                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_CPRS _TIU_NOTE) ;
  607                    msg. addParamet er(VistaQu ery.LITERA L, tiuId);
  608                    logV istaQueryR equest(msg );
  609                    retu rn msg;
  610           }
  611  
  612           pu blic stati c VistaQue ry createG etImagesFo rCprsTiuNo te(CprsIde ntifier cp rsIdentifi er, StudyF ilter filt er)
  613           {
  614                    //WF P-Need to  still add  code here.
  615                    Stri ng tiuId =  StringUti ls.MagPiec e(cprsIden tifier.get CprsIdenti fier(), St ringUtils. CARET, 5);
  616                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_CPRS _TIU_NOTE) ;
  617                    msg. addParamet er(VistaQu ery.LITERA L, tiuId);
  618                    logV istaQueryR equest(msg );
  619                    retu rn msg;
  620           }
  621  
  622           pu blic stati c VistaQue ry createG etImagesFo rCprsIdent ifiers(Lis t<CprsIden tifier> cp rsIdentifi ers)
  623           {
  624                    Vist aQuery msg  = new Vis taQuery(RP C_MAGN_CPR S_IMAGE_LI ST);
  625                    Map< String, St ring> cprs Identifier sParameter s = new Ha shMap<Stri ng, String >();
  626                    
  627                    for( CprsIdenti fier item:  cprsIdent ifiers) {
  628                             //getL ogger().de bug("creat eGetImages ForCprsIde ntifiers ( " + cprsId entifiersP arameters. size() + " ) = " + it em.getCprs Identifier ());
  629                             String  cprsIdent ifier = it em.getCprs Identifier ();
  630                             cprsId entifiersP arameters. put(cprsId entifiersP arameters. size() + 1  + "",  cp rsIdentifi er);
  631                    }
  632                    msg. addParamet er(VistaQu ery.LIST,  cprsIdenti fiersParam eters);
  633                    logV istaQueryR equest(msg );
  634                    retu rn msg;
  635           }
  636  
  637           pu blic stati c VistaQue ry createG etImagesFo rCprsIdent ifiers(Lis t<CprsIden tifier> cp rsIdentifi ers, Study Filter fil ter)
  638           {
  639  
  640                    Vist aQuery msg  = new Vis taQuery(RP C_MAGN_CPR S_IMAGE_LI ST);
  641                    Map< String, St ring> cprs Identifier sParameter s = new Ha shMap<Stri ng, String >();
  642                    
  643                    Bool ean isTIU  = false;
  644                    
  645                    for( CprsIdenti fier item:  cprsIdent ifiers) {
  646                             //getL ogger().de bug("creat eGetImages ForCprsIde ntifiers ( " + cprsId entifiersP arameters. size() + " ) = " + it em.getCprs Identifier ());
  647                             String  cprsIdent ifier = it em.getCprs Identifier ();
  648  
  649                             //P185
  650                             if (fi lter.isInc ludeAllObj ects())
  651                             {
  652                                      cprsIden tifier = c prsIdentif ier + "~2" ;
  653                             }
  654  
  655                    if ( StringUtil .Piece(cpr sIdentifie r, StringU til.CARET,  4).equals ("TIU"))
  656                    {
  657                             isTIU  = true;
  658                    }
  659                             
  660                             cprsId entifiersP arameters. put(cprsId entifiersP arameters. size() + 1  + "", cpr sIdentifie r);
  661                    }
  662  
  663                    Stri ng imageLe ss = "1";
  664                    if ( filter.isI ncludeImag es() || is TIU)
  665                    {
  666                             imageL ess = "0";
  667                    }
  668  
  669                    getL ogger().de bug("Image Less: " +  imageLess) ;
  670                    
  671                    msg. addParamet er(VistaQu ery.LIST,  cprsIdenti fiersParam eters);
  672                    msg. addParamet er(VistaQu ery.LITERA L, imageLe ss);
  673                    logV istaQueryR equest(msg );
  674                    retu rn msg;
  675           }
  676  
  677           pu blic stati c VistaQue ry createG etImageGro upIENVista Query(Stri ng imageIe n) 
  678           {
  679                    //ge tLogger(). info("getC ontextIEN  Transactio nContext ( " + Transa ctionConte xtFactory. get().getD isplayIden tity() + " ).");
  680                    
  681                    Vist aQuery msg  = new Vis taQuery(RP C_GET_VARI ABLE_VALUE );
  682                    Stri ng arg = " ^MAG(2005, " + imageI en + ",0)" ;
  683                    msg. addParamet er(VistaQu ery.REFERE NCE, arg);
  684                    logV istaQueryR equest(msg );
  685                    retu rn msg;
  686           }
  687           
  688           pu blic stati c VistaQue ry createM agBrokerSe curityQuer y()
  689           {
  690                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_BROK ER_SECURIT Y);
  691                    
  692                    logV istaQueryR equest(msg );
  693                    retu rn msg;
  694           }        
  695  
  696           /* *
  697            *  
  698            *  @param pa tientDfn
  699            *  @param st udyFilter
  700            *  @param al lowDeleted Images
  701            *  @return
  702            * /
  703           pu blic stati c VistaQue ry createM agImageLis tQuery(Str ing patien tDfn, Stud yFilter st udyFilter,  
  704                             boolea n allowDel etedImages )
  705           {
  706                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_IMAG E_LIST);
  707                    Stri ng control Parameter  = "E"; //  existing i mages
  708                    Stri ng fromDat e = "";
  709                    Stri ng toDate  = "";
  710                    
  711                    Stri ng studyPa ckage = "" ;
  712                    Stri ng studyCl ass = "";
  713                    Stri ng studyTy pes = "";
  714                    Stri ng studyEv ent = "";
  715                    Stri ng studySp ecialty =  "";
  716                    Stri ng studyOr igin = "";
  717                    int  maximumRes ults = Int eger.MAX_V ALUE;
  718                    if(s tudyFilter  != null) 
  719                    {
  720                             fromDa te = Vista Translator Utility.co nvertDateT oRpcFormat (studyFilt er.getFrom Date());
  721                             toDate  = VistaTr anslatorUt ility.conv ertDateToR pcFormat(s tudyFilter .getToDate ());
  722                             studyP ackage = s tudyFilter .getStudy_ package();
  723                             studyC lass = stu dyFilter.g etStudy_cl ass();
  724                             studyT ypes = stu dyFilter.g etStudy_ty pe();
  725                             studyE vent = stu dyFilter.g etStudy_ev ent();
  726                             studyS pecialty =  studyFilt er.getStud y_specialt y();
  727                             studyO rigin = st udyFilter. getOrigin( );
  728                             maximu mResults =  studyFilt er.getMaxi mumResults ();
  729                    }
  730                    
  731                    
  732                    if(( allowDelet edImages)  && (studyF ilter != n ull) && (s tudyFilter .isInclude Deleted()) )            
  733                             contro lParameter  += "D"; / / deleted  images
  734                    msg. addParamet er(VistaQu ery.LITERA L, control Parameter) ;
  735                    msg. addParamet er(VistaQu ery.LITERA L, fromDat e);
  736                    msg. addParamet er(VistaQu ery.LITERA L, toDate) ;
  737                    if(m aximumResu lts < Inte ger.MAX_VA LUE)
  738                    {
  739                             msg.ad dParameter (VistaQuer y.LITERAL,  maximumRe sults + "" );
  740                    }
  741                    else
  742                    {
  743                             msg.ad dParameter (VistaQuer y.LITERAL,  "");
  744                    }
  745                    Map< String, St ring> filt erParamete rs = new H ashMap<Str ing, Strin g>();
  746                    
  747                    filt erParamete rs.put(fil terParamet ers.size()  + "", "ID FN^^" + pa tientDfn);
  748                    if(! "".equals( studyClass ))
  749                    {
  750                             studyC lass = stu dyClass.re place(',',  '^'); //  need to co nvert , to  ^
  751                             filter Parameters .put(filte rParameter s.size() +  "", "IXCL ASS^^" + s tudyClass) ;
  752                    }
  753                    if(! "".equals( studyPacka ge))
  754                    {
  755                             studyP ackage = s tudyPackag e.replace( ',', '^');  // need t o convert  , to ^                          
  756                             filter Parameters .put(filte rParameter s.size() +  "", "IXPK G^^" + stu dyPackage) ;
  757                    }
  758                    if(! "".equals( studyTypes ))
  759                    {
  760                             studyT ypes = stu dyTypes.re place(',',  '^'); //  need to co nvert , to  ^
  761                             filter Parameters .put(filte rParameter s.size() +  "", "IXTY PE^^" + st udyTypes);
  762                    }
  763                    //TO DO: make s ure Event  == Procedu re - i thi nk so?
  764                    if(! "".equals( studyEvent ))
  765                    {
  766                             studyE vent = stu dyEvent.re place(',',  '^'); //  need to co nvert , to  ^
  767                             filter Parameters .put(filte rParameter s.size() +  "", "IXPR OC^^" + st udyEvent);
  768                    }
  769                    if(! "".equals( studySpeci alty))
  770                    {
  771                             studyS pecialty =  studySpec ialty.repl ace(',', ' ^'); // ne ed to conv ert , to ^     
  772                             filter Parameters .put(filte rParameter s.size() +  "", "IXSP EC^^" + st udySpecial ty);
  773                    }
  774                    if(! "".equals( studyOrigi n))
  775                    {
  776                             studyO rigin = st udyOrigin. replace(', ', '^'); / / need to  convert ,  to ^
  777                             filter Parameters .put(filte rParameter s.size() +  "", "IXOR IGIN^^" +  studyOrigi n);
  778                    }
  779                    msg. addParamet er(VistaQu ery.LIST,  filterPara meters);                      
  780                    retu rn msg;
  781           }
  782           
  783           pu blic stati c VistaQue ry createG etUserKeys Query()
  784           {
  785                    Vist aQuery que ry = new V istaQuery( RPC_MAG_US ER_KEYS);
  786                    logV istaQueryR equest(que ry);
  787                    retu rn query;
  788           }
  789  
  790           pu blic stati c VistaQue ry createG etDivision sQuery(Str ing access Code) 
  791           {
  792                    Vist aQuery que ry = new V istaQuery( RPC_XUS_GE T_DIVISION S);
  793                    quer y.addParam eter(Vista Query.LITE RAL, acces sCode);
  794                    logV istaQueryR equest(que ry);
  795                    retu rn query;
  796           }
  797           
  798           pu blic stati c VistaQue ry createA llowAnnota teQuery()
  799           {
  800                    Vist aQuery que ry = new V istaQuery( RPC_MAG_IM AGE_ALLOW_ ANNOTATE);
  801                    logV istaQueryR equest(que ry);
  802                    retu rn query;
  803           }
  804           
  805           /* *
  806            *  This is a  MAGJ rpc  that gets  the treati ng sites f or a patie nt and for mats the r esult as a  list rath er than a  string. Th is RPC is  available  to 
  807            *  MAG WINDO WS as part  of Patch  122
  808            *  @param pa tientDfn
  809            *  @return
  810            * /
  811           pu blic stati c VistaQue ry createM agJGetTrea tingSitesQ uery(Strin g patientD fn)
  812           {
  813                    getL ogger().in fo("MagJGe tTreatingS ites(" + p atientDfn  + ") Trans actionCont ext (" + T ransaction ContextFac tory.get() .getDispla yIdentity( ) + ").");
  814                    
  815                    Vist aQuery vm  = new Vist aQuery(RPC _MAGJ_GET_ TREATING_L IST);
  816                    vm.a ddParamete r(VistaQue ry.LITERAL , patientD fn);
  817                    
  818                    logV istaQueryR equest(vm) ;
  819                    retu rn vm;
  820           }
  821           
  822           pu blic stati c VistaQue ry createL ogImagingQ uery(Imagi ngLogEvent  logEvent,  String pa tientDfn)
  823           {
  824                    Tran sactionCon text trans actionCont ext = Tran sactionCon textFactor y.get();
  825                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_ACTI ON_LOG);
  826                    Stri ngBuilder  sb = new S tringBuild er();
  827                    sb.a ppend(logE vent.getAc cessType() );
  828                    sb.a ppend("^") ;
  829                    sb.a ppend(tran sactionCon text.getDu z());
  830                    sb.a ppend("^") ;
  831                    
  832                    Abst ractImagin gURN imagi ngUrn = lo gEvent.get ImagingUrn ();
  833                    if(i magingUrn  != null)
  834                    {
  835                             boolea n isDodIma ge = Excha ngeUtil.is SiteDOD(im agingUrn.g etOriginat ingSiteId( ));
  836                             // if  this is a  VA image t hen put th e IEN in p lace here
  837                             if(!is DodImage)
  838                                      sb.appen d(imagingU rn.getImag ingIdentif ier());
  839                    }
  840                    sb.a ppend("^") ;
  841                    sb.a ppend(logE vent.getUs erInterfac e());
  842                    sb.a ppend("^") ;
  843                    sb.a ppend(pati entDfn);
  844                    sb.a ppend("^") ;
  845                    if(l ogEvent.ge tImageCoun t() >= 0)
  846                             sb.app end(logEve nt.getImag eCount());
  847                    sb.a ppend("^") ;
  848                    sb.a ppend(logE vent.getAd ditionalDa ta());
  849                    getL ogger().de bug("Imagi ng log eve nt Paramet er '" + sb .toString( ) + "'");
  850                    msg. addParamet er(VistaQu ery.LITERA L, sb.toSt ring());
  851                    logV istaQueryR equest(msg );
  852                    retu rn msg;
  853           }
  854           
  855           pu blic stati c VistaQue ry createG etReasonsL istQuery(L ist<ImageA ccessReaso nType> rea sonTypes)
  856           {
  857                    Vist aQuery que ry = new V istaQuery( RPC_MAGG_R EASON_LIST );
  858                    Stri ngBuilder  reasons =  new String Builder();
  859                    if(r easonTypes  != null)
  860                    {
  861                             for(Im ageAccessR easonType  reasonType  : reasonT ypes)
  862                             {
  863                                      reasons. append(rea sonType.ge tCode());
  864                             }
  865                    }
  866                    else
  867                    {
  868                             // put  all optio ns in
  869                             for(Im ageAccessR easonType  reasonType  : ImageAc cessReason Type.value s())
  870                             {
  871                                      reasons. append(rea sonType);
  872                             }
  873                    }
  874                    quer y.addParam eter(Vista Query.LITE RAL, reaso ns.toStrin g());
  875                    
  876                    logV istaQueryR equest(que ry);
  877                    retu rn query;
  878           }
  879           
  880           pu blic stati c VistaQue ry createV erifyElect ronicSigna tureQuery( String ele ctronicSig nature)
  881           {                 
  882                    Vist aQuery vm  = new Vist aQuery(RPC _MAGG_VERI FY_ESIG);
  883                    vm.a ddEncrypte dParameter (VistaQuer y.LITERAL,  electroni cSignature );
  884                    logV istaQueryR equest(vm) ;
  885                    retu rn vm;
  886           }
  887           
  888           pu blic stati c VistaQue ry createG etHealthSu mmariesQue ry()
  889           {
  890                    Vist aQuery vm  = new Vist aQuery(RPC _MAGGHSLIS T);
  891                    vm.a ddParamete r(VistaQue ry.LITERAL , ""); //  parameter  does nothi ng
  892                    logV istaQueryR equest(vm) ;
  893                    retu rn vm;
  894           }
  895           
  896           pu blic stati c VistaQue ry createG etHealthSu mmary(Heal thSummaryU RN healthS ummaryUrn,  String pa tientDfn)
  897           {
  898                    Vist aQuery vm  = new Vist aQuery(RPC _MAGGHS);
  899                    vm.a ddParamete r(VistaQue ry.LITERAL , patientD fn + Strin gUtils.CAR ET + healt hSummaryUr n.getSumma ryId());
  900                    logV istaQueryR equest(vm) ;
  901                    retu rn vm;
  902           }
  903           
  904           pu blic stati c VistaQue ry createG etApplicat ionTimeout Parameters (String si teId, Stri ng applica tionName) 
  905           {
  906                    Vist aQuery vm  = new Vist aQuery(RPC _GET_TIMEO UT_PARAMET ERS);
  907                    vm.a ddParamete r(VistaQue ry.LITERAL , applicat ionName);
  908                    logV istaQueryR equest(vm) ;
  909                    retu rn vm;
  910           }
  911           
  912           pu blic stati c void log VistaQuery Request(Vi staQuery v m){
  913                    getL ogger().in fo("RPC Re quest: "+S tringUtils .displayEn codedChars (vm.toStri ng()));
  914           }
  915  
  916           pu blic stati c VistaQue ry createG etFilterLi st(String  userDuz)
  917           {
  918                    Vist aQuery vm  = new Vist aQuery(RPC _MAG4_FILT ER_GET_LIS T);
  919                    vm.a ddParamete r(VistaQue ry.LITERAL , userDuz) ;
  920                    vm.a ddParamete r(VistaQue ry.LITERAL ,  "1");
  921                    logV istaQueryR equest(vm) ;
  922                    retu rn vm;
  923           }
  924           /* *
  925            *  @param st udyFilter
  926            *  @return
  927            * /
  928           pu blic stati c VistaQue ry createM agImageLis tQuery(Stu dyFilter s tudyFilter )
  929           {
  930                    Vist aQuery msg  = new Vis taQuery(RP C_MAG_IMAG E_LIST);
  931                    Stri ng control Parameter  = "EC"; //  existing  images, ca ptured dat e
  932   //               if(s tudyFilter .isInclude Deleted())                
  933   //                        contro lParameter  += "D"; / / deleted  images
  934  
  935                    if ( (studyFilt er.getMaxi mumResultT ype() != n ull) && (s tudyFilter .getMaximu mResultTyp e().equals ("%")))
  936                             contro lParameter  += "S";
  937                    
  938                    cont rolParamet er += "G";
  939                    
  940                    Date Format dat eFormat =  new Simple DateFormat ("yyyyMMdd ");       
  941                    Stri ng fromDat e = "";
  942                    if ( studyFilte r.getFromD ate() != n ull)
  943                    {
  944                    from Date = dat eFormat.fo rmat(study Filter.get FromDate() );
  945                             int fr om = Integ er.parseIn t(fromDate ) - 170000 00;
  946                             fromDa te = Integ er.toStrin g(from);
  947                    }                 
  948                    
  949                    Stri ng toDate  = "";
  950                    if ( studyFilte r.getToDat e() != nul l)
  951                    {
  952                             toDate  = dateFor mat.format (studyFilt er.getToDa te());
  953                             int to  = Integer .parseInt( toDate) -  17000000;
  954                             toDate  = Integer .toString( to);
  955                    }                 
  956                    
  957                    Stri ng studyPa ckage = st udyFilter. getStudy_p ackage();
  958                    Stri ng studyCl ass = stud yFilter.ge tStudy_cla ss();
  959                    Stri ng studyTy pes = stud yFilter.ge tStudy_typ e();
  960                    Stri ng studyEv ent = stud yFilter.ge tStudy_eve nt();
  961                    Stri ng studySp ecialty =  studyFilte r.getStudy _specialty ();
  962                    Stri ng studyOr igin = stu dyFilter.g etOrigin() ;
  963                    Stri ng capture App = stud yFilter.ge tCaptureAp p();
  964                    Stri ng capture SavedBy =  studyFilte r.getCaptu reSavedBy( );
  965                    Stri ng qaStatu s = studyF ilter.getQ AStatus();
  966                    
  967                    int  maximumRes ults = stu dyFilter.g etMaximumR esults();
  968                    
  969                    msg. addParamet er(VistaQu ery.LITERA L, control Parameter) ;
  970                    msg. addParamet er(VistaQu ery.LITERA L, fromDat e);
  971                    msg. addParamet er(VistaQu ery.LITERA L, toDate) ;
  972                    
  973                    if(m aximumResu lts < Inte ger.MAX_VA LUE)
  974                    {
  975                             msg.ad dParameter (VistaQuer y.LITERAL,  maximumRe sults + "" );
  976                    }
  977                    else
  978                    {
  979                             msg.ad dParameter (VistaQuer y.LITERAL,  "");
  980                    }
  981  
  982                    Map< String, St ring> filt erParamete rs = new H ashMap<Str ing, Strin g>();
  983                    
  984                    if ( (studyClas s != null)  && !"".eq uals(study Class))
  985                    {
  986                             studyC lass = stu dyClass.re place(',',  '^'); //  need to co nvert , to  ^
  987                             filter Parameters .put(filte rParameter s.size() +  "", "IXCL ASS^^" + s tudyClass) ;
  988                    }
  989                    
  990                    if ( (studyPack age != nul l) && !"". equals(stu dyPackage) )
  991                    {
  992                             studyP ackage = s tudyPackag e.replace( ',', '^');  // need t o convert  , to ^                          
  993                             filter Parameters .put(filte rParameter s.size() +  "", "IXPK G^^" + stu dyPackage) ;
  994                    }
  995                    
  996                    if ( (studyType s != null)  && !"".eq uals(study Types))
  997                    {
  998                             studyT ypes = stu dyTypes.re place(',',  '^'); //  need to co nvert , to  ^
  999                             filter Parameters .put(filte rParameter s.size() +  "", "IXTY PE^^" + st udyTypes);
  1000                    }
  1001                    
  1002                    if ( (studyEven t != null)  && !"".eq uals(study Event))
  1003                    {
  1004                             studyE vent = stu dyEvent.re place(',',  '^'); //  need to co nvert , to  ^
  1005                             filter Parameters .put(filte rParameter s.size() +  "", "IXPR OC^^" + st udyEvent);
  1006                    }
  1007                    
  1008                    if ( (studySpec ialty != n ull) && !" ".equals(s tudySpecia lty))
  1009                    {
  1010                             studyS pecialty =  studySpec ialty.repl ace(',', ' ^'); // ne ed to conv ert , to ^     
  1011                             filter Parameters .put(filte rParameter s.size() +  "", "IXSP EC^^" + st udySpecial ty);
  1012                    }
  1013                    
  1014                    if ( (studyOrig in != null ) && !"".e quals(stud yOrigin))
  1015                    {
  1016                             studyO rigin = st udyOrigin. replace(', ', '^'); / / need to  convert ,  to ^
  1017                             filter Parameters .put(filte rParameter s.size() +  "", "IXOR IGIN^^" +  studyOrigi n);
  1018                    }
  1019                    
  1020                    if ( (captureAp p != null)  && !"".eq uals(captu reApp))
  1021                    {
  1022                             captur eApp = cap tureApp.re place(',',  '^'); //  need to co nvert , to  ^                      
  1023                             filter Parameters .put(filte rParameter s.size() +  "", "CAPT APP^^" + c aptureApp) ;
  1024                    }
  1025  
  1026                    if ( (captureSa vedBy != n ull) && !" ".equals(c aptureSave dBy))
  1027                    {
  1028                             captur eSavedBy =  captureSa vedBy.repl ace(',', ' ^'); // ne ed to conv ert , to ^                      
  1029                             filter Parameters .put(filte rParameter s.size() +  "", "SAVE DBY^^" + c aptureSave dBy);
  1030                    }
  1031  
  1032                    if ( (qaStatus  != null) & & !"".equa ls(qaStatu s))
  1033                    {
  1034                             qaStat us = qaSta tus.replac e(',', '^' ); // need  to conver t , to ^                           
  1035                             filter Parameters .put(filte rParameter s.size() +  "", "ISTA T^^" + qaS tatus);
  1036                    }
  1037  
  1038                    if ( filterPara meters.siz e() > 0)
  1039                             msg.ad dParameter (VistaQuer y.LIST, fi lterParame ters);                      
  1040                    
  1041                    logV istaQueryR equest(msg );
  1042                    retu rn msg;
  1043           }
  1044  
  1045   }