158. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 7/10/2017 1:01:47 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

158.1 Files compared

# Location File Last Modified
1 C:\AraxisMergeCompare\Pri_un\IV-ehmp_cif\VistaImagingDataSourceProvider\main\src\java\gov\va\med\imaging\vistaimagingdatasource VistaImagingStudyGraphDataSourceService.java Thu Jun 29 17:22:03 2017 UTC
2 C:\AraxisMergeCompare\Pri_re\IV-ehmp_cif\VistaImagingDataSourceProvider\main\src\java\gov\va\med\imaging\vistaimagingdatasource VistaImagingStudyGraphDataSourceService.java Thu Jul 6 15:06:05 2017 UTC

158.2 Comparison summary

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

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

158.4 Active regular expressions

No regular expressions were active.

158.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: Jan  7, 2008
  6     Site Nam e:  Washin gton OI Fi eld Office , Silver S pring, MD
  7     Develope r:  
  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.vis taimagingd atasource;
  27  
  28   import gov .va.med.Gl obalArtifa ctIdentifi er;
  29   import gov .va.med.Pa tientIdent ifier;
  30   import gov .va.med.Ro utingToken ;
  31   import gov .va.med.UR NFactory;
  32   import gov .va.med.im aging.Stud yURN;
  33   import gov .va.med.im aging.arti factsource .ResolvedA rtifactSou rce;
  34   import gov .va.med.im aging.core .interface s.exceptio ns.Connect ionExcepti on;
  35   import gov .va.med.im aging.core .interface s.exceptio ns.MethodE xception;
  36   import gov .va.med.im aging.exce ptions.URN FormatExce ption;
  37   import gov .va.med.im aging.exch ange.busin ess.Site;
  38   import gov .va.med.im aging.exch ange.busin ess.Study;
  39   import gov .va.med.im aging.exch ange.busin ess.StudyF ilter;
  40   import gov .va.med.im aging.exch ange.busin ess.StudyS etResult;
  41   import gov .va.med.im aging.exch ange.enums .StudyDele tedImageSt ate;
  42   import gov .va.med.im aging.exch ange.enums .StudyLoad Level;
  43   import gov .va.med.im aging.prot ocol.vista .VistaImag ingTransla tor;
  44   import gov .va.med.im aging.core .interface s.exceptio ns.Patient NotFoundEx ception;
  45   import gov .va.med.im aging.tran sactioncon text.Trans actionCont extFactory ;
  46   import gov .va.med.im aging.url. vista.Stri ngUtils;
  47   import gov .va.med.im aging.url. vista.Vist aQuery;
  48   import gov .va.med.im aging.url. vista.exce ptions.Inv alidVistaC redentials Exception;
  49   import gov .va.med.im aging.url. vista.exce ptions.Vis taMethodEx ception;
  50   import gov .va.med.im aging.vist adatasourc e.common.V istaCommon Utilities;
  51   import gov .va.med.im aging.vist adatasourc e.session. VistaSessi on;
  52   import gov .va.med.im aging.vist aimagingda tasource.c ommon.Vist aImagingCo mmonUtilit ies;
  53   import gov .va.med.im aging.vist aobjects.V istaGroup;
  54  
  55   import jav a.io.IOExc eption;
  56   import jav a.util.Has hMap;
  57   import jav a.util.Map ;
  58   import jav a.util.Sor tedSet;
  59   import jav a.util.Tre eSet;
  60  
  61   import org .apache.lo g4j.Logger ;
  62  
  63   /**
  64    * An impl ementation  of a Stud yGraphData SourceSpi  that talks  to VistA.
  65    * 
  66    * NOTE:
  67    * 1.) pub lic method s that do  Vista acce ss (partic ularly any thing defi ned
  68    * in the  StudyGraph DataSource Spi interf ace) must  acquire a  VistaSessi on instanc e using
  69    * getVist aSession() .
  70    * 2.) pri vate metho ds which a re only ca lled from  public met hods that  do Vista a ccess
  71    * must in clude a Vi staSession  parameter , they sho uld not ac quire thei r own Vist aSession
  72    * 3.) Whe re a metho d is both  public and  called fr om within  this class , there sh ould be a
  73    * public  version fo llowing ru le 1, call ing a priv ate versio n followin g rule 2.
  74    * 
  75    * @author         
BECKEC
  76    *
  77    */
  78   public cla ss VistaIm agingStudy GraphDataS ourceServi ce 
  79   extends Ab stractBase VistaImagi ngStudyGra phService
  80   {       
  81           pu blic final  static St ring SUPPO RTED_PROTO COL = "vis taimaging" ;
  82           
  83           /*  ========= ========== ========== ========== ========== ========== ==========
  84            *  Instance  fields and  methods
  85            *  ========= ========== ========== ========== ========== ========== ==========  */
  86           pr ivate Logg er logger  = Logger.g etLogger(t his.getCla ss());
  87           // private in t maximumP atientSens itivityLev el = DEFAU LT_PATIENT _SENSITIVI TY_LEVEL;
  88           
  89           //  The requi red versio n of VistA  Imaging n eeded to e xecute the  RPC calls  for this  operation
  90           pu blic final  static St ring MAG_R EQUIRED_VE RSION = "3 .0P83";
  91           
  92       /**
  93            *  @param re solvedArti factSource
  94            *  @param pr otocol
  95            * /
  96           pu blic Vista ImagingStu dyGraphDat aSourceSer vice(Resol vedArtifac tSource re solvedArti factSource , String p rotocol)
  97           {
  98                    supe r(resolved ArtifactSo urce, prot ocol);
  99           }
  100  
  101           /*  (non-Java doc)
  102            *  @see gov. va.med.ima ging.vista datasource .AbstractB aseVistaSt udyGraphSe rvice#getR equiredVis taImagingV ersion()
  103            * /
  104           @O verride
  105           pr otected St ring getRe quiredVist aImagingVe rsion() 
  106           {
  107                    retu rn VistaIm agingCommo nUtilities .getVistaD ataSourceI magingVers ion(
  108                             VistaI magingData SourceProv ider.getVi staConfigu ration(), 
  109                             this.g etClass(),  
  110                             MAG_RE QUIRED_VER SION);
  111           }
  112  
  113           /* *
  114            *  Return th e maximum  permissibl e patient  sensitivit y level
  115            *  that will  be includ ed in resu lts.  Sens itivity le vels
  116            *  range fro m:
  117            *  0 - least  sensitive
  118            *      - to  -
  119            *  3 - most  sensitive
  120            *  
  121            *  @return
  122            * /
  123           pu blic int g etMaximumP atientSens itivityLev el(StudyFi lter filte r)
  124           {
  125                    retu rn filter. getMaximum AllowedLev el().getCo de();
  126           }
  127       
  128       /**
  129        * Get ting Studi es from Vi sta is a t wo step-pr ocess beca use:
  130        * a.)  the Vista  data stru cture is n ot organiz ed around  a study-se ries-insta nce hierar chy but
  131        * aro und a stud y-group-in stance, wh ere group  and study  are not sy nonymous.   A Study h as 
  132        * 1.. n Groups a nd a Group  can have  1..n Serie s.
  133        * b.)  the filte ring provi ded by Vis ta does no t implemen t all of t he filteri ng that ou r
  134        * Fil ter object  requires
  135        * 
  136        * @pa ram patien tIcn
  137        * @pa ram filter
  138        * @re turn
  139        * @th rows  
  140        * @se e gov.va.m ed.imaging .datasourc e.StudyGra phDataSour ceSpi#getS tudies(Str ing, Filte r)
  141        */
  142       @Overr ide
  143       public  StudySetR esult getP atientStud ies(Routin gToken glo balRouting Token, Pat ientIdenti fier patie ntIdentifi er, 
  144                    Stud yFilter fi lter, Stud yLoadLevel  studyLoad Level)
  145       throws  Unsupport edOperatio nException , MethodEx ception, C onnectionE xception
  146           {
  147           Vi staCommonU tilities.s etDataSour ceMethodAn dVersion(" getPatient Studies",  getDataSou rceVersion ());
  148           lo gger.info( "getPatien tStudies("  + patient Identifier  + 
  149                                      ", " + ( filter ==  null ? "<n ull>" : fi lter.toStr ing()) + 
  150                                      ", Study  load leve l " + stud yLoadLevel .toString( ) + 
  151                                      ") Trans actionCont ext (" + T ransaction ContextFac tory.get() .getDispla yIdentity( ) + ").");
  152                    
  153                    Vist aSession l ocalVistaS ession = n ull;
  154  
  155                    try
  156                    {
  157                             localV istaSessio n = getVis taSession( );
  158                             
  159                             String  patientDf n = null;
  160                             try
  161                             {
  162                                      patientD fn = getPa tientDfn(l ocalVistaS ession, pa tientIdent ifier);
  163                             }
  164                             catch( PatientNot FoundExcep tion pnfX)
  165                             {
  166                                      // JMW 3 /12/08 The  patient w as not fou nd in the  database,  return an  empty set  of studies  instead o f
  167                             logger .warn("Pat ient [" +  patientIde ntifier +  "] was not  found in  the VistA  database,  returning  empty stud y set", pn fX);
  168                             return  StudySetR esult.crea teFullResu lt(new Tre eSet<Study >());
  169                             }
  170                             
  171                             // if  we are get ting a sin gle study
  172                             if((fi lter != nu ll) && (fi lter.isStu dyIenSpeci fied()))
  173                             {
  174                                      // we ar e getting  a single s tudy                                   
  175                                      logger.i nfo("Getti ng study ' " + filter .getStudyI d() + "' f or patient  '" + pati entIdentif ier + "'") ;
  176                                      Study si ngleStudy  = getSingl eStudyMatc hingFilter (localVist aSession,  patientIde ntifier, 
  177                                                       pa tientDfn,  filter, st udyLoadLev el);
  178                                      SortedSe t<Study> s tudies = n ew TreeSet <Study>();
  179                                      studies. add(single Study);
  180                                      return S tudySetRes ult.create FullResult (studies);
  181                             }
  182                             // we  are gettin g multiple  studies
  183                             else
  184                             {
  185                                      // we ar e getting  all the st udies for  a patient  (that matc h the filt er)                           
  186                                      logger.i nfo("Getti ng all stu dies that  match filt er for pat ient '" +  patientIde ntifier +  "'");
  187                                      
  188                             // che ck the pat ient sensi tivity fir st, if it  fails an e xception w ill be thr own
  189                             checkP atientSens itive(loca lVistaSess ion, patie ntDfn, pat ientIdenti fier, filt er);
  190                             
  191                                      return S tudySetRes ult.create FullResult (getAllStu diesMatchi ngFilter(l ocalVistaS ession, pa tientIdent ifier, pat ientDfn, f ilter, stu dyLoadLeve l));
  192                             }                                                            
  193                    } 
  194                    catc h (IOExcep tion e)
  195           {
  196                             throw  new Connec tionExcept ion(e);
  197           }
  198                    fina lly
  199                    {
  200                             try{lo calVistaSe ssion.clos e();}
  201                             catch( Throwable  t){}
  202                    }
  203           }        
  204       
  205       /**
  206        * Thi s method i s implemen ted here f or complet eness.
  207        * As  of this da te it is n ot used in  productio n deployme nt. 
  208        */
  209       @Overr ide
  210           pu blic Study  getStudy( PatientIde ntifier pa tientIdent ifier, Glo balArtifac tIdentifie r studyId)  
  211       throws  MethodExc eption, Co nnectionEx ception
  212           {
  213           Vi staCommonU tilities.s etDataSour ceMethodAn dVersion(" getStudy",  getDataSo urceVersio n());
  214           if ( !(studyI d instance of StudyUR N) )
  215                    thro w new Conn ectionExce ption(this .getClass( ).getSimpl eName() +  " does not  recognize  GAI of ty pe " + stu dyId.getCl ass().getN ame() + ". ");
  216           
  217           St udyFilter  filter = n ew StudyFi lter(study Id); 
  218                    Stud yLoadLevel  studyLoad Level = St udyLoadLev el.FULL;
  219                    Stud ySetResult  result =  getPatient Studies(st udyId, pat ientIdenti fier, filt er, studyL oadLevel);
  220                    if(r esult == n ull)
  221                    {
  222                             logger .error("Go t null Stu dySetResul t - this s hould NEVE R happen!" );
  223                             return  null;
  224                    }
  225                    Sort edSet<Stud y> studies  = result. getArtifac ts();
  226                    if(s tudies !=  null && st udies.size () > 0)
  227                             return  studies.f irst();
  228                    
  229                    retu rn null;
  230           }
  231  
  232       /**
  233        * Thi s method i s implemen ted here f or complet eness.
  234        * As  of this da te it is n ot used in  productio n deployme nt. 
  235        */
  236           @O verride
  237           pu blic Strin g getStudy Report(Pat ientIdenti fier patie ntIdentifi er, Global ArtifactId entifier s tudyId) 
  238           th rows Metho dException , Connecti onExceptio n
  239           {
  240                    Vist aCommonUti lities.set DataSource MethodAndV ersion("ge tStudyRepo rt", getDa taSourceVe rsion());
  241                    Stud y study =  getStudy(p atientIden tifier, st udyId);
  242                    retu rn study.g etRadiolog yReport();
  243           }
  244  
  245           /* *
  246        * 
  247        * @pa ram localV istaSessio n
  248        * @pa ram patien tIcn
  249        * @pa ram patien tDfn
  250        * @pa ram filter
  251        * @pa ram studyL oadLevel
  252        * @re turn
  253        * @th rows Conne ctionExcep tion
  254        * @th rows Metho dException
  255        * @th rows IOExc eption
  256        */
  257       privat e SortedSe t<Study> g etAllStudi esMatching Filter(
  258           Vi staSession  localVist aSession, 
  259           Pa tientIdent ifier pati entIdentif ier, 
  260           St ring patie ntDfn, 
  261           St udyFilter  filter, 
  262           St udyLoadLev el studyLo adLevel)
  263           th rows Conne ctionExcep tion, Meth odExceptio n, IOExcep tion
  264       {
  265                    // N ote: a Stu dy has 1..  Groups an d a Group  can have 1 .. Series!
  266                    Sort edSet<Vist aGroup> gr oups = nul l;
  267                    logg er.info("G etting gro ups for pa tient '" +  patientId entifier +  "'.");
  268                    grou ps = getPa tientGroup s(localVis taSession,  getSite() , patientD fn, patien tIdentifie r, filter) ;          // 23Nov C TB = group s study ie n is null
  269                    logg er.info("F ound '" +  groups.siz e() + "' g roups for  patient '"  + patient Identifier  + "'");
  270                    // n o groups i s not an e xception s cenario bu t it does  mean we do n't need t o bother g etting mor
  271                    // i nformation  about eac h study
  272                    if(g roups.size () == 0)
  273                             return  new TreeS et<Study>( );             // ret urn a zero -length se t              
  274                    
  275                    // W arning: if  this filt er (and st udyIen) is  not null,  reducedGr oup might  truncate m ultiple gr oup studie s!!!
  276                    Map< String, St ring> stud yMap = new  HashMap<S tring, Str ing>();
  277                             
  278                    // J MW 12/17/2 008, call  the filter  to remove  studies f rom the gr oups, this  way
  279                    // t he datasou rce doesn' t need to  have knowl edge of th e filter d etails
  280                    if(f ilter != n ull)
  281                             filter .preFilter (groups);
  282                    
  283                    // i f we filte red everyt hing out r eturn now,  and don't  bother ma king the c all
  284                    // t o populate  the entir e Studies  tree
  285                    if(g roups.size () == 0)
  286                             return  new TreeS et<Study>( );             // ret urn a zero -length se t              
  287                    
  288                    logg er.info("L oading stu dy graph d ata for fi ltered gro ups");
  289  
  290                    // B uild a lis t of Study  IEN
  291                    // T he use of  a Map is a n artifact  of VistA,  which nee ds an inde x of the l ist elemen ts.
  292                    // T he Map end s up as so mething li ke {"0", " 662576753" },{"1", "7 61576512"}  ...
  293                    Stri ngBuilder  groupMessa ge = new S tringBuild er();
  294                    grou pMessage.a ppend('{') ;
  295                    for( VistaGroup  group : g roups)
  296                    {
  297                             // CTB  29Nov2009
  298                             //stud yMap.put(" " + studyM ap.size(),  Base32Con versionUti lity.base3 2Decode(gr oup.getIen ()));
  299                             studyM ap.put( In teger.toSt ring(study Map.size() ), group.g etIen() );
  300                             if(gro upMessage. length() >  1)
  301                                      groupMes sage.appen d(',');
  302                             groupM essage.app end(group. getIen());
  303                    }
  304                    grou pMessage.a ppend('}') ;
  305                    
  306                    //
  307                    bool ean includ esDeletedI mages = (f ilter == n ull ? fals e : filter .isInclude Deleted()) ;
  308                    bool ean canInc ludeDelete dImages =  canRetriev eDeletedIm ages(); //  if this d ata source  cannot su pport gett ing delete d images,  then it is  not an op tion
  309                    Stud yDeletedIm ageState s tudyDelete dImageStat e = StudyD eletedImag eState.can notInclude DeletedIma ges;
  310                    if(c anIncludeD eletedImag es) // if  the DS sup ports gett ing delete d images,  set approp riately ba sed on use r request
  311                             studyD eletedImag eState = ( includesDe letedImage s ? StudyD eletedImag eState.inc ludesDelet edImages :  StudyDele tedImageSt ate.doesNo tIncludeDe letedImage s);
  312                    Sort edSet<Stud y> studies  = getPati entStudyGr aph(localV istaSessio n, studyMa p, patient Dfn, 
  313                                      studyLoa dLevel, st udyDeleted ImageState );
  314                    logg er.info("g etPatientS tudyGraph  for studie s " + grou pMessage.t oString()  + " return ed " + stu dies.size( ) + " stud ies.");
  315                    Sort edSet<Stud y> result 
  316                             VistaI magingComm onUtilitie s.mergeStu dyLists(lo calVistaSe ssion, stu dies, grou ps, studyL oadLevel);
  317                    logg er.info("M erging stu dies and g roups resu lts in " +  result.si ze() + " s tudies.");
  318                    
  319                    // J MW 12/17/2 008, call  the filter  to remove  studies f rom the gr oups, this  way
  320                    // t he datasou rce doesn' t need to  have knowl edge of th e filter d etails
  321                    if(f ilter != n ull)
  322                    {
  323                             filter .postFilte r(result);
  324                    }
  325                    logg er.info("C ompleted g etPatientS tudies(),  returning  '" + resul t.size() +  "' studie s.");
  326                    retu rn result;
  327       }
  328  
  329           /* *
  330        * 
  331        * @pa ram localV istaSessio n
  332        * @pa ram patien tIcn
  333        * @pa ram patien tDfn
  334        * @pa ram filter
  335        * @pa ram studyL oadLevel
  336        * @re turn
  337        * @th rows Conne ctionExcep tion
  338        * @th rows Metho dException
  339        * @th rows IOExc eption
  340        */
  341       privat e Study ge tSingleStu dyMatching Filter(Vis taSession  localVista Session, 
  342                    Pati entIdentif ier patien tIdentifie r, String  patientDfn , StudyFil ter filter , StudyLoa dLevel stu dyLoadLeve l)
  343           th rows Conne ctionExcep tion, Meth odExceptio n, IOExcep tion
  344       {
  345           St udyURN stu dyUrn = nu ll;
  346           if (filter.ge tStudyId()  instanceo f StudyURN )
  347           {
  348                    try
  349                    {
  350                             studyU rn = URNFa ctory.crea te(filter. getStudyId ().toStrin g());
  351                    }
  352                    catc h(URNForma tException  urnfX)
  353                    {
  354                             throw  new Method Exception( "Error con verting fi lter study  Id to Stu dyURN", ur nfX);
  355                    }
  356           }
  357           el se
  358           {
  359                    thro w new Meth odExceptio n("Cannot  cast filte r study Id  '" + filt er.getStud yId() + "'  to StudyU RN, must b e study UR N to get s tudy type. ");
  360           }        
  361           
  362           St ring study Ien = stud yUrn.getSt udyId();
  363           Ma p<String,  String> st udyMap = n ew HashMap <String, S tring>();
  364                    // C TB 29Nov20 09
  365           // studyMap.p ut("" + st udyMap.siz e(), Base3 2Conversio nUtility.b ase32Decod e(studyIen ));
  366           st udyMap.put ("" + stud yMap.size( ), studyIe n);
  367           
  368           bo olean incl udesDelete dImages =  (filter ==  null ? fa lse : filt er.isInclu deDeleted( ));
  369           bo olean canI ncludeDele tedImages  = canRetri eveDeleted Images();  // if this  data sour ce cannot  support ge tting dele ted images , then it  is not an  option
  370                    Stud yDeletedIm ageState s tudyDelete dImageStat e = StudyD eletedImag eState.can notInclude DeletedIma ges;
  371                    if(c anIncludeD eletedImag es) // if  the DS sup ports gett ing delete d images,  set approp riately ba sed on use r request
  372                             studyD eletedImag eState = ( includesDe letedImage s ? StudyD eletedImag eState.inc ludesDelet edImages :  StudyDele tedImageSt ate.doesNo tIncludeDe letedImage s);
  373           
  374           So rtedSet<St udy> studi es = getPa tientStudy Graph(loca lVistaSess ion, study Map, patie ntDfn, 
  375                             studyL oadLevel,  studyDelet edImageSta te);
  376           if ((studies  == null) | | (studies .size() <=  0))
  377           {
  378                    thro w new Meth odExceptio n("Study [ " + studyI en + "] no t found");
  379           }                 
  380           if (studies.s ize() > 1)
  381           {
  382                    thro w new Meth odExceptio n("Found ' " + studie s.size() +  "' matchi ng studies , this sho uld never  happen!");
  383           }
  384           St udy study  = studies. first();
  385                    logg er.info("G etting gro ups for pa tient '" +  patientId entifier +  "'.");
  386                    Sort edSet<Vist aGroup> gr oups = get PatientGro ups(localV istaSessio n, getSite (), patien tDfn, pati entIdentif ier, filte r);
  387                    if(( groups ==  null) || ( groups.siz e() <= 0))
  388           {
  389                    thro w new Meth odExceptio n("Study [ " + studyI en + "] no t found");
  390           }    
  391                    logg er.info("F ound '" +  groups.siz e() + "' g roups for  patient '"  + patient Identifier  + "'");
  392                    Stud y result =  VistaImag ingCommonU tilities.m ergeStudyW ithMatchin gGroup(loc alVistaSes sion, stud y, groups,  studyLoad Level);
  393                    if(r esult == n ull)
  394                    {
  395                             throw  new Method Exception( "Cannot fi nd study ' " + studyI en + "', c ould not m atch group  to study. ");
  396                    }
  397                    retu rn result;
  398       }
  399       
  400       /**
  401        * 
  402        * @pa ram localV istaSessio n
  403        * @pa ram studyM ap
  404        * @pa ram patien tDfn
  405        * @pa ram studyL oadLevel
  406        * @re turn
  407        * @th rows Metho dException
  408        * @th rows Conne ctionExcep tion
  409        */
  410       privat e SortedSe t<Study> g etPatientS tudyGraph(
  411           Vi staSession  localVist aSession, 
  412           Ma p<String,  String> st udyMap, 
  413           St ring patie ntDfn, 
  414           St udyLoadLev el studyLo adLevel,
  415           St udyDeleted ImageState  studyDele tedImageSt ate)
  416           th rows Metho dException , Connecti onExceptio n
  417       {            
  418           tr y
  419           {
  420                    Vist aQuery que ry = getPa tientStudy GraphVista Query(stud yMap, pati entDfn, st udyLoadLev el, 
  421                                      studyDel etedImageS tate);
  422                             logger .info("Ret rieving st udy graph  for patien t containi ng '" + st udyMap.siz e() + "' g roups");
  423                             String  vistaResp onse = loc alVistaSes sion.call( query);
  424                             logger .info(quer y.getRpcNa me()+" RPC  Results:" +StringUti ls.display EncodedCha rs(vistaRe sponse));                   
  425                             logger .info("Com pleted stu dy graph R PC call, p arsing res ponse...") ;                               
  426                             
  427                             Sorted Set<Study>  studies =  VistaImag ingTransla tor.create StudiesFro mGraph(get Site(), 
  428                                               vistaRespo nse, study LoadLevel,  studyDele tedImageSt ate);
  429                             logger .info("Con verted res ponse into  '" + ((st udies == n ull) ? 0 :  studies.s ize()) + " ' studies" );
  430                             return  studies;
  431           }
  432                    catc h (Excepti on ex)
  433                    {
  434                             logger .error(ex) ;
  435                             ex.pri ntStackTra ce();
  436                             throw  new Method Exception( ex);
  437                    }
  438       }
  439       
  440       protec ted VistaQ uery getPa tientGroup sVistaQuer y(String p atientDfn,  StudyFilt er studyFi lter)
  441       {
  442           re turn Vista ImagingQue ryFactory. createGetG roupsVista Query(pati entDfn, st udyFilter) ;
  443       }
  444       
  445       /**
  446        * Met hod to get  the Vista Query to c all to get  the study  graph
  447        * @pa ram studyM ap
  448        * @pa ram patien tDfn
  449        * @pa ram studyL oadLevel
  450        * @pa ram studyD eletedImag eState
  451        * @re turn
  452        */
  453       protec ted VistaQ uery getPa tientStudy GraphVista Query(Map< String, St ring> stud yMap, 
  454                    Stri ng patient Dfn, 
  455                    Stud yLoadLevel  studyLoad Level,
  456                    Stud yDeletedIm ageState s tudyDelete dImageStat e)
  457       {
  458           //  this vers ion does n ot use the  studyDele tedImageSt ate
  459           re turn Vista ImagingQue ryFactory. createGetS tudiesByIe nVistaQuer y(studyMap
  460                             patien tDfn, stud yLoadLevel );
  461       }
  462  
  463           /* *
  464            *  @throws I OException  
  465            *  @throws M ethodExcep tion 
  466            *  @throws C onnectionE xception 
  467            *  @throws I nvalidVist aCredentia lsExceptio
  468            *  
  469            * /
  470           pr ivate Sort edSet<Vist aGroup> ge tPatientGr oups(
  471                    Vist aSession s ession, 
  472                    Site  site, 
  473                    Stri ng patient Dfn, 
  474                    Pati entIdentif ier patien tIdentifie r, 
  475                    Stud yFilter fi lter)
  476           th rows Metho dException , IOExcept ion, Conne ctionExcep tion
  477           {                 
  478                    logg er.info("g etPatientG roups(" +  patientIde ntifier +  ") Transac tionContex t (" + Tra nsactionCo ntextFacto ry.get().g etDisplayI dentity()  + ").");
  479  
  480                    // c reates cal l to RPC M AG4_PAT_GE T_IMAGES
  481                    Vist aQuery vm  = getPatie ntGroupsVi staQuery(p atientDfn,  filter);
  482                    logg er.info("g etPatientG roups with  RPC '" +  vm.getRpcN ame() + "' .");
  483                    
  484                    Stri ng rtn = n ull;
  485                    try
  486                    {
  487                             logger .info("Mak ing call t o get grou ps for pat ient '" +  patientIde ntifier +  "'");
  488                             rtn =  session.ca ll(vm);
  489                             logger .info(vm.g etRpcName( )+" RPC Re sults:"+St ringUtils. displayEnc odedChars( rtn));                        
  490  
  491                             // che ck to be s ure first  character  is a 1 (me ans result  is ok)
  492                             
  493                             // if  no images  for patien t, respons e is [0^No  images fo r filter:  All Images ]
  494                             
  495                             if(rtn .charAt(0)  == '1') 
  496                             {                         
  497                                      boolean  includesDe letedImage s = (filte r == null  ? false :  filter.isI ncludeDele ted());
  498                                      boolean  canInclude DeletedIma ges = canR etrieveDel etedImages (); // if  this data  source can not suppor t getting  deleted im ages, then  it is not  an option
  499                                      StudyDel etedImageS tate study DeletedIma geState =  StudyDelet edImageSta te.cannotI ncludeDele tedImages;
  500                                      if(canIn cludeDelet edImages)  // if the  DS support s getting  deleted im ages, set  appropriat ely based  on user re quest
  501                                               studyDelet edImageSta te = (incl udesDelete dImages ?  StudyDelet edImageSta te.include sDeletedIm ages : Stu dyDeletedI mageState. doesNotInc ludeDelete dImages);
  502                                      return V istaImagin gTranslato r.createGr oupsFromGr oupLines(s ite, rtn,  patientIde ntifier, 
  503                                                       st udyDeleted ImageState );
  504                             }
  505                             else i f(rtn.star tsWith("0^ No images  for filter ")) 
  506                             {
  507                                      logger.i nfo("0 res ponse from  getPatien tGroupsVis taQuery()  rpc, no im ages found , [" + rtn  + "]");
  508                                      return n ew TreeSet <VistaGrou p>();
  509                             }
  510                             else i f(rtn.star tsWith("0^ No Such Pa tient:")) 
  511                             {
  512                                      logger.i nfo("0 res ponse from  getPatien tGroupsVis taQuery()  rpc, [" +  rtn + "]") ;
  513                                      throw ne w VistaMet hodExcepti on("No pat ient [ "+  patientIde ntifier +  "] found i n database ");
  514                             }
  515                             else 
  516                             {
  517                                      logger.i nfo("0 res ponse from  getPatien tGroupsVis taQuery()  rpc, [" +  rtn + "]") ;
  518                                      throw ne w VistaMet hodExcepti on(rtn);
  519                             }
  520                    }
  521                    catc h (Excepti on ex)
  522                    {
  523                             logger .error(ex) ;
  524                             throw  new Method Exception( ex);
  525                    }
  526           }        
  527           
  528           /* *
  529            *  
  530            *  @param pr ocedure
  531            *  @param fi lter
  532            *  @return
  533            * /
  534           /*
  535           pr ivate bool ean proced ureUsed(St ring proce dure, Stud yFilter fi lter) 
  536           {
  537                    if(p rocedure = = null)
  538                             return  false;
  539                    
  540                    if(  filter.get AllowableS tudyTypes( ) == null  || filter. getAllowab leStudyTyp es().size( ) == 0 )
  541                             return  true;
  542                    
  543                    for(  int i = 0 ; i < filt er.getAllo wableStudy Types().si ze(); i++  )
  544                             if( pr ocedure.eq ualsIgnore Case(filte r.getAllow ableStudyT ypes().get (i)) )
  545                                      return t rue;
  546                    
  547                    retu rn false;
  548           }
  549           */
  550       
  551       /**
  552        * 
  553        * @re turn
  554        * @th rows IOExc eption 
  555        * @th rows Vista Exception 
  556        */
  557           pu blic boole an disconn ect() 
  558           th rows IOExc eption 
  559           {
  560                    // d on;t do an ything, le t the conn ection tim eout
  561                    retu rn true;
  562           }
  563           
  564           /* *
  565            *  Determine s if this  data sourc e can hand le retriev ing delete d images i f the user  requests  them
  566            *  @return
  567            * /
  568           pr otected bo olean canR etrieveDel etedImages ()
  569           {
  570                    retu rn false;
  571           }
  572           
  573           @O verride
  574           pr otected St ring getDa taSourceVe rsion()
  575           {
  576                    retu rn "1";
  577           }
  578   }