52. EPMO Open Source Coordination Office Redaction File Detail Report

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

52.1 Files compared

# Location File Last Modified
1 C:\AraxisMergeCompare\Pri_un\IMAG_Source\VISA\Java\StudyWebApp\main\src\java\gov\va\med\imaging\study\rest\translator RestStudyTranslator.java Mon Mar 18 20:39:15 2019 UTC
2 C:\AraxisMergeCompare\Pri_re\IMAG_Source\VISA\Java\StudyWebApp\main\src\java\gov\va\med\imaging\study\rest\translator RestStudyTranslator.java Tue Mar 19 12:04:04 2019 UTC

52.2 Comparison summary

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

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

52.4 Active regular expressions

No regular expressions were active.

52.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: Mar  16, 2012
  6     Site Nam e:  Washin gton OI Fi eld Office , Silver S pring, MD
  7       Developer:     DN S      WERFEJ
  8     Descript ion: 
  9  
  10           ;;  +-------- ---------- ---------- ---------- ---------- ---------- ---------- +
  11           ;;  Property  of the US  Government .
  12           ;;  No permis sion to co py or redi stribute t his softwa re is give n.
  13           ;;  Use of un released v ersions of  this soft ware requi res the us er
  14           ;;   to execu te a writt en test ag reement wi th the Vis tA Imaging
  15           ;;   Developm ent Office  of the De partment o f Veterans  Affairs,
  16           ;;   telephon e (301) 73 4-0100.
  17           ;;
  18           ;;  The Food  and Drug A dministrat ion classi fies this  software a s
  19           ;;  a Class I I medical  device.  A s such, it  may not b e changed
  20           ;;  in any wa y.  Modifi cations to  this soft ware may r esult in a n
  21           ;;  adulterat ed medical  device un der 21CFR8 20, the us e of which
  22           ;;  is consid ered to be  a violati on of US F ederal Sta tutes.
  23           ;;  +-------- ---------- ---------- ---------- ---------- ---------- ---------- +
  24  
  25    */
  26   package go v.va.med.i maging.stu dy.rest.tr anslator;
  27  
  28   import jav a.util.Arr ayList;
  29   import jav a.util.Dat e;
  30   import jav a.util.Has hMap;
  31   import jav a.util.Lis t;
  32   import jav a.util.Map ;
  33   import jav a.util.Map .Entry;
  34  
  35   import org .apache.lo gging.log4 j.LogManag er;
  36   import org .apache.lo gging.log4 j.Logger;
  37  
  38   import gov .va.med.SE RIALIZATIO N_FORMAT;
  39   import gov .va.med.UR NFactory;
  40   import gov .va.med.We llKnownOID ;
  41   import gov .va.med.im aging.Stor edStudyFil terURN;
  42   import gov .va.med.im aging.Stud yURN;
  43   import gov .va.med.im aging.awiv .AwivEncry ption;
  44   import gov .va.med.im aging.encr yption.exc eptions.Ae sEncryptio nException ;
  45   import gov .va.med.im aging.exce ptions.URN FormatExce ption;
  46   import gov .va.med.im aging.exch ange.busin ess.Artifa ctResultEr ror;
  47   import gov .va.med.im aging.exch ange.busin ess.Artifa ctResults;
  48   import gov .va.med.im aging.exch ange.busin ess.Image;
  49   import gov .va.med.im aging.exch ange.busin ess.Series ;
  50   import gov .va.med.im aging.exch ange.busin ess.Stored StudyFilte r;
  51   import gov .va.med.im aging.exch ange.busin ess.Study;
  52   import gov .va.med.im aging.exch ange.busin ess.StudyS etResult;
  53   import gov .va.med.im aging.exch ange.busin ess.docume nts.Docume nt;
  54   import gov .va.med.im aging.exch ange.busin ess.docume nts.Docume ntSet;
  55   import gov .va.med.im aging.exch ange.busin ess.docume nts.Docume ntSetResul t;
  56   import gov .va.med.im aging.exch ange.enums .ImageQual ity;
  57   import gov .va.med.im aging.exch ange.enums .ObjectSta tus;
  58   import gov .va.med.im aging.exch ange.enums .PatientSe nsitivityL evel;
  59   import gov .va.med.im aging.exch ange.enums .VistaImag eType;
  60   import gov .va.med.im aging.exch ange.trans lation.exc eptions.Tr anslationE xception;
  61   import gov .va.med.im aging.stud y.StudyFac adeFilter;
  62   import gov .va.med.im aging.stud y.configur ation.Stud yFacadeCon figuration ;
  63   import gov .va.med.im aging.stud y.rest.typ es.LoadedS tudyType;
  64   import gov .va.med.im aging.stud y.rest.typ es.StoredF ilterType;
  65   import gov .va.med.im aging.stud y.rest.typ es.StoredF iltersType ;
  66   import gov .va.med.im aging.stud y.rest.typ es.Studies ResultType ;
  67   import gov .va.med.im aging.stud y.rest.typ es.Studies Type;
  68   import gov .va.med.im aging.stud y.rest.typ es.StudyIm agesType;
  69   import gov .va.med.im aging.stud y.rest.typ es.StudySe riesType;
  70   import gov .va.med.im aging.stud y.rest.typ es.StudyFi lterType;
  71   import gov .va.med.im aging.stud y.rest.typ es.StudyIm ageType;
  72   import gov .va.med.im aging.stud y.rest.typ es.StudyOb jectStatus Type;
  73   import gov .va.med.im aging.stud y.rest.typ es.StudySe riesesType ;
  74   import gov .va.med.im aging.stud y.rest.typ es.StudySo urceErrorT ype;
  75   import gov .va.med.im aging.stud y.rest.typ es.StudySo urceErrors Type;
  76   import gov .va.med.im aging.stud y.rest.typ es.StudyTy pe;
  77   import gov .va.med.im aging.tran slator.Abs tractClini calTransla tor;
  78  
  79   /**
  80    * @author   DN S      WERFEJ
  81    *
  82    */
  83   public cla ss RestStu dyTranslat or
  84   extends Ab stractClin icalTransl ator
  85   {
  86           pr ivate fina l static L ogger logg er = LogMa nager.getL ogger(Rest StudyTrans lator.clas s);
  87           pr ivate stat ic Map<Obj ectStatus,  StudyObje ctStatusTy pe> object StatusMap;
  88           
  89           st atic
  90           {
  91                    obje ctStatusMa p = new Ha shMap<Obje ctStatus,  StudyObjec tStatusTyp e>();
  92                    obje ctStatusMa p.put(Obje ctStatus.C ONTROLLED,  StudyObje ctStatusTy pe.CONTROL LED);
  93                    obje ctStatusMa p.put(Obje ctStatus.D ELETED, St udyObjectS tatusType. DELETED);
  94                    obje ctStatusMa p.put(Obje ctStatus.I MAGE_GROUP , StudyObj ectStatusT ype.IMAGE_ GROUP);
  95                    obje ctStatusMa p.put(Obje ctStatus.I N_PROGRESS , StudyObj ectStatusT ype.IN_PRO GRESS);
  96                    obje ctStatusMa p.put(Obje ctStatus.N EEDS_REFRE SH, StudyO bjectStatu sType.NEED S_REFRESH) ;
  97                    obje ctStatusMa p.put(Obje ctStatus.N EEDS_REVIE W, StudyOb jectStatus Type.NEEDS _REVIEW);
  98                    obje ctStatusMa p.put(Obje ctStatus.N O_STATUS,  StudyObjec tStatusTyp e.NO_STATU S);
  99                    obje ctStatusMa p.put(Obje ctStatus.Q A_REVIEWED , StudyObj ectStatusT ype.QA_REV IEWED);
  100                    obje ctStatusMa p.put(Obje ctStatus.Q UESTIONABL E_INTEGRIT Y, StudyOb jectStatus Type.QUEST IONABLE_IN TEGRITY);
  101                    obje ctStatusMa p.put(Obje ctStatus.R AD_EXAM_ST ATUS_BLOCK , StudyObj ectStatusT ype.RAD_EX AM_STATUS_ BLOCK);
  102                    obje ctStatusMa p.put(Obje ctStatus.T IU_AUTHORI ZATION_BLO CK, StudyO bjectStatu sType.TIU_ AUTHORIZAT ION_BLOCK) ;
  103                    obje ctStatusMa p.put(Obje ctStatus.U NKNOWN, St udyObjectS tatusType. UNKNOWN);
  104                    obje ctStatusMa p.put(Obje ctStatus.V IEWABLE, S tudyObject StatusType .VIEWABLE) ;
  105           }
  106           
  107           pr otected st atic Logge r getLogge r()
  108           {
  109                    retu rn logger;
  110           }
  111           
  112           pu blic stati c StudyFac adeFilter  tranlsate( StudyFilte rType stud yFilter)
  113           {
  114                    Stud yFacadeFil ter filter  = null;
  115                    if(s tudyFilter  == null)
  116                    {
  117                             filter  = StudyFa cadeFilter .createAll Filter();
  118                    }
  119                    else
  120                    {
  121                             switch (studyFilt er.getResu ltType())
  122                             {
  123                                      case art ifacts:
  124                                               filter = S tudyFacade Filter.cre ateArtifac tsFilter() ;
  125                                               break;
  126                                      case rad iology:
  127                                               filter = S tudyFacade Filter.cre ateRadiolo gyFilter() ;
  128                                               break;
  129                                      default:
  130                                               filter = S tudyFacade Filter.cre ateAllFilt er();
  131                                               break;
  132                             }
  133                             filter .setFromDa te(studyFi lter.getFr omDate());
  134                             filter .setToDate (studyFilt er.getToDa te());
  135                             filter .setModali tyCodes(st udyFilter. getModalit yCodes());
  136                             filter .setCptCod es(studyFi lter.getCp tCodes());
  137                             if(stu dyFilter.g etStoredFi lterId() ! = null) 
  138                             {
  139                                      try
  140                                      {
  141                                               StoredStud yFilterURN  storedStu dyFilterUr n = URNFac tory.creat e(studyFil ter.getSto redFilterI d(), SERIA LIZATION_F ORMAT.CDTP , StoredSt udyFilterU RN.class);                    
  142                                               filter.set StoredStud yFilterUrn (storedStu dyFilterUr n);
  143                                      }
  144                                      catch(UR NFormatExc eption urn fX)
  145                                      {
  146                                               logger.err or(urnfX);
  147                                      }
  148                             }
  149                    }
  150                    filt er.setMaxi mumAllowed Level(Pati entSensiti vityLevel. DISPLAY_WA RNING_REQU IRE_OK);
  151                                      
  152                    retu rn filter;
  153           }
  154           
  155           pu blic stati c StudiesR esultType  translate( ArtifactRe sults arti factResult s)
  156           th rows Trans lationExce ption
  157           {
  158                    if(a rtifactRes ults == nu ll)
  159                             return  null;
  160                    
  161                    Stud iesResultT ype result  = new Stu diesResult Type(trans lateArtifa ctResults( artifactRe sults), 
  162                                      translat eErrors(ar tifactResu lts), arti factResult s.isPartia lResult()) ;            
  163                    retu rn result;
  164           }
  165           
  166           pr ivate stat ic StudySo urceErrors Type trans lateErrors (ArtifactR esults art ifactResul ts)
  167           {
  168                    
  169                    List <StudySour ceErrorTyp e> errors  = new Arra yList<Stud ySourceErr orType>();
  170                    
  171                    if(a rtifactRes ults.getSt udySetResu lt().getAr tifactResu ltErrors()  != null)
  172                    {
  173                             errors .addAll(tr anslateErr ors(artifa ctResults. getStudySe tResult(). getArtifac tResultErr ors()));
  174                    }
  175                    if(( artifactRe sults.getD ocumentSet Result() ! = null) &&  (artifact Results.ge tDocumentS etResult() .getArtifa ctResultEr rors() !=  null))
  176                    {
  177                             errors .addAll(tr anslateErr ors(artifa ctResults. getDocumen tSetResult ().getArti factResult Errors())) ;
  178                    }
  179                    
  180                    retu rn new Stu dySourceEr rorsType(e rrors.toAr ray(new St udySourceE rrorType[e rrors.size ()]));
  181           }
  182           
  183           pr ivate stat ic List<St udySourceE rrorType>  translateE rrors(List <ArtifactR esultError > errors)
  184           {
  185                    List <StudySour ceErrorTyp e> result  = new Arra yList<Stud ySourceErr orType>();
  186                    
  187                    for( ArtifactRe sultError  error : er rors)
  188                    {
  189                             result .add(trans late(error ));
  190                    }
  191                    
  192                    retu rn result;
  193           }
  194           
  195           pr ivate stat ic StudySo urceErrorT ype transl ate(Artifa ctResultEr ror error)
  196           {
  197                    retu rn new Stu dySourceEr rorType(er ror.getCod eContext()
  198                                      error.ge tSeverity( ).name(),  error.getL ocation(),  error.get ErrorCode( ).name());
  199           }
  200           
  201           pr ivate stat ic Studies Type trans lateArtifa ctResults( ArtifactRe sults arti factResult s)
  202           th rows Trans lationExce ption
  203           {
  204                    if(a rtifactRes ults == nu ll)
  205                             return  null;
  206                    
  207                    List <StudyType > result =  new Array List<Study Type>();
  208                    resu lt.addAll( translate( artifactRe sults.getD ocumentSet Result())) ;
  209                    resu lt.addAll( translate( artifactRe sults.getS tudySetRes ult()));
  210                    
  211                    retu rn new Stu diesType(r esult.toAr ray(new St udyType[re sult.size( )]));            
  212           }
  213           
  214           pr ivate stat ic List<St udyType> t ranslate(S tudySetRes ult studyS etResult)
  215           th rows Trans lationExce ption
  216           {
  217                    List <StudyType > result =  new Array List<Study Type>(); 
  218                    if(s tudySetRes ult != nul l && study SetResult. getArtifac ts() != nu ll)
  219                    {
  220                             for(St udy study  : studySet Result.get Artifacts( ))
  221                             {
  222                                      StudyTyp e studyTyp e = transl ate(study,  false);
  223                                      if(study Type != nu ll)
  224                                               result.add (studyType );
  225                             }
  226                    }
  227                    retu rn result;
  228           }
  229           
  230           pr ivate stat ic StudyTy pe transla te(Study s tudy, bool ean includ eImages)
  231           th rows Trans lationExce ption
  232           {
  233                    Stud yType resu lt = null;
  234                    if(i ncludeImag es)
  235                             result  = new Loa dedStudyTy pe();
  236                    else              
  237                             result  = new Stu dyType(); 
  238                    if(s tudy == nu ll)
  239                             return  result;
  240                    
  241                    resu lt.setDesc ription(st udy.getDes cription() );
  242                    
  243                    resu lt.setEven t(study.ge tEvent());
  244                    resu lt.setImag eCount(stu dy.getImag eCount());
  245                    resu lt.setImag ePackage(s tudy.getIm agePackage ());
  246                    resu lt.setImag eType(stud y.getImage Type());
  247                    resu lt.setNote Title(stud y.getNoteT itle());
  248                    resu lt.setOrig in(study.g etOrigin() );
  249                    resu lt.setPati entId(stud y.getPatie ntIdentifi er().toStr ing());
  250                    resu lt.setPati entName(st udy.getPat ientName() );
  251                    resu lt.setProc edureDescr iption(stu dy.getProc edure());
  252                    resu lt.setSite Number(stu dy.getSite Number());
  253                    resu lt.setSite Name(study .getSiteNa me());
  254                    resu lt.setSite Abbreviati on(study.g etSiteAbbr ());
  255                    resu lt.setSpec ialtyDescr iption(stu dy.getSpec ialty());
  256                    resu lt.setProc edureDate( study.getP rocedureDa te());
  257                    
  258                    resu lt.setStud yPackage(s tudy.getIm agePackage ());
  259                    resu lt.setStud yClass(stu dy.getStud yClass() = = null ? " " : study. getStudyCl ass());
  260                    resu lt.setStud yType(stud y.getImage Type());
  261                    resu lt.setCapt ureDate(st udy.getCap tureDate() );
  262                    resu lt.setCapt uredBy(stu dy.getCapt ureBy());      
  263                    
  264                    resu lt.setDocu mentDate(s tudy.getDo cumentDate ());
  265                    resu lt.setSens itive(stud y.isSensit ive());
  266                    resu lt.setStud yStatus(tr anslate(st udy.getStu dyStatus() ));
  267                    resu lt.setStud yViewStatu s(translat e(study.ge tStudyView Status())) ;
  268                    resu lt.setCptC ode(study. getCptCode ());
  269                    // r eturn null  for the U ID instead  of the em pty string  to be con sistent wi th the WSD L - DKB
  270                    if ( study.getS tudyUid()  != null &&  study.get StudyUid() .trim().le ngth() > 0 )
  271                             result .setDicomU id(study.g etStudyUid ());
  272                    else
  273                             result .setDicomU id(null);
  274                    
  275                    //re sult.setSt udyId(stud y.getStudy Urn().toSt ring(SERIA LIZATION_F ORMAT.CDTP ));
  276                    // J MW 1/3/13  - using VF TP format  so any add itional pa rameters a re URL enc oded prope rly
  277                    resu lt.setStud yId(study. getStudyUr n().toStri ng(SERIALI ZATION_FOR MAT.VFTP)) ;
  278                    
  279                    if(s tudy.getSe ries() !=  null && in cludeImage s)
  280                    {
  281                             StudyS eriesType  [] seriesT ype = new  StudySerie sType[stud y.getSerie sCount()];
  282                             int i  = 0;
  283                             for(Se ries ser :  study)
  284                             {
  285                                      seriesTy pe[i] = tr anslate(se r);
  286                                      i++;
  287                             }                         
  288                             ((Load edStudyTyp e)result). setSeries( new StudyS eriesesTyp e(seriesTy pe));
  289                    }
  290                    
  291                    if(s tudy.getFi rstImage()  == null)
  292                             throw  new Transl ationExcep tion("Stud y.firstIma ge is null , translat ion of stu dy '" + st udy.getStu dyUrn() +  "' cannot  continue." );
  293                    
  294                    Stud yImageType  firstImag e = transl ate(study. getFirstIm age());
  295                    resu lt.setFirs tImage(fir stImage);
  296                    resu lt.setFirs tImageId(f irstImage. getImageId ());
  297                    
  298                    if(s tudy.getMo dalities()  != null)
  299                             result .setStudyM odalities( study.getM odalities( ).toArray( new String  [study.ge tModalitie s().size() ]));
  300                    resu lt.setStud yImagesHav eAnnotatio ns(study.i sStudyImag esHaveAnno tations()) ;
  301                    resu lt.setAwiv Parameters (translate AwivParame ters(study ));
  302                    resu lt.setStud yCanHaveRe port(true) ;
  303                    resu lt.setStud yHasImageG roup(true) ;
  304                    resu lt.setNumb erOfDicomI mages(stud y.getNumbe rOfDicomIm ages());
  305                    int  numberOfNo nDicomImag es = study .getImageC ount() - s tudy.getNu mberOfDico mImages();
  306                    resu lt.setNumb erOfNonDic omImages(n umberOfNon DicomImage s);
  307                    
  308                    retu rn result;
  309           }
  310           
  311           pr ivate stat ic StudySe riesType t ranslate(S eries seri es)
  312           {
  313                    Stud ySeriesTyp e result =  new Study SeriesType ();
  314                    resu lt.setModa lity(serie s.getModal ity());
  315                    //re sult.setSe riesIen(se ries.getSe riesIen()) ;
  316                    resu lt.setSeri esNumber(s eries.getS eriesNumbe r());
  317                    resu lt.setSeri esUid(seri es.getSeri esUid());
  318                    
  319                    Stud yImageType  [] images  = new Stu dyImageTyp e[series.g etImageCou nt()];
  320                    int  i = 0;
  321                    for( Image imag e : series )
  322                    {
  323                             images [i] = tran slate(imag e);
  324                             i++;
  325                    }
  326                    
  327                    resu lt.setImag es(new Stu dyImagesTy pe(images) );
  328                    retu rn result;
  329           }
  330           
  331           
  332           pr ivate stat ic String  translateA wivParamet ers(Study  study)
  333           {
  334                    try
  335                    {
  336                             //TODO : need way  to get pa tient SSN
  337                             return  AwivEncry ption.encr yptParamet ers(study. getPatient Name(), "" , study.ge tPatientId (),
  338                                               study.getS tudyUrn(). toStringCD TP(), stud y.getSiteN umber(),
  339                                               getStudyFa cadeConfig uration(). getSiteSer viceUrl(),  
  340                                               getStudyFa cadeConfig uration(). getCvixSit eNumber(),  AwivEncry ption.view TypeVistaI maging,
  341                                               AwivEncryp tion.ncatD oesNotHasK ey, study. getSiteNum ber());
  342                    }
  343                    catc h(AesEncry ptionExcep tion aeX)
  344                    {
  345                             getLog ger().erro r("Error c reating AW IV encrypt ed paramet ers for st udy '" + s tudy.getSt udyUrn().t oStringCDT P() + "',  " + aeX.ge tMessage() );
  346                             return  null;
  347                    }
  348           }
  349           
  350           pr ivate stat ic List<St udyType> t ranslate(D ocumentSet Result doc umentSetRe sult)
  351           th rows Trans lationExce ption
  352           {
  353                    List <StudyType > result =  new Array List<Study Type>(); 
  354                    
  355                    if(d ocumentSet Result !=  null && do cumentSetR esult.getA rtifacts()  != null)
  356                    {
  357                             for(Do cumentSet  documentSe t : docume ntSetResul t.getArtif acts())
  358                             {
  359                                      List<Stu dyType> st udiesType  = translat e(document Set);
  360                                      if(studi esType !=  null)
  361                                               result.add All(studie sType);
  362                             }
  363                    }
  364                    
  365                    retu rn result;
  366           }
  367           
  368           pr ivate stat ic List<St udyType> t ranslate(D ocumentSet  documentS et)
  369           {
  370                    List <StudyType > result =  new Array List<Study Type>();
  371                    if(d ocumentSet  == null)
  372                             return  result;
  373                             
  374                             for(Do cument doc ument : do cumentSet)
  375                             {
  376                                      StudyTyp e studyTyp e = new St udyType();
  377                                      
  378                                      VistaIma geType vis taImageTyp e = getIma geType(get StudyFacad eConfigura tion(), do cument);
  379                                      if(vista ImageType  == null)
  380                                      {
  381                                               vistaImage Type = Vis taImageTyp e.UNKNOWN_ IMAGING_TY PE;
  382                                               getLogger( ).debug("D ocument wi th media t ype '" + d ocument.ge tMediaType () + "', r eturning V istaImageT ype of '"  + vistaIma geType + " ' for Clin ical Displ ay.");                                                
  383                                      }                
  384                                      String i d = docume nt.getGlob alArtifact Identifier ().toStrin g(SERIALIZ ATION_FORM AT.CDTP);
  385                                      
  386                                      studyTyp e.setStudy Id(id);
  387                                      studyTyp e.setPatie ntId(docum entSet.get PatientIcn ());
  388                                      studyTyp e.setPatie ntName(doc umentSet.g etPatientN ame());
  389                                      studyTyp e.setSiteA bbreviatio n(document Set.getSit eAbbr());
  390                                      Date pro cedureDate  = null;
  391                                      if(docum entSet.get ProcedureD ate() != n ull)
  392                                      {
  393                                               procedureD ate = docu mentSet.ge tProcedure Date();
  394                                      }
  395                                      else
  396                                      {
  397                                               if(documen t.getCreat ionDate()  != null)
  398                                               {
  399                                                       pr ocedureDat e = docume nt.getCrea tionDate() ;
  400                                                       ge tLogger(). debug("Doc umentSet P rocedureDa te is null , using Do cument Cre ationDate" );
  401                                               }
  402                                               else
  403                                               {
  404                                                       ge tLogger(). debug("Doc umentSet P rocedureDa te and Doc ument Crea tionDate a re both nu ll.");
  405                                               }                                          
  406                                      }
  407                                      studyTyp e.setProce dureDate(p rocedureDa te);
  408                                      studyTyp e.setProce dureDescri ption(docu ment.getNa me());
  409                                      studyTyp e.setImage Type(vista ImageType. getImageTy pe() + "") ;
  410                                      studyTyp e.setImage Count(1);
  411                                      studyTyp e.setFirst Image(tran slate(docu mentSet, d ocument, v istaImageT ype));
  412                                      studyTyp e.setStudy Status(Stu dyObjectSt atusType.N O_STATUS);
  413                                      studyTyp e.setStudy ViewStatus (StudyObje ctStatusTy pe.NO_STAT US);
  414                                      studyTyp e.setSensi tive(false );
  415                                      studyTyp e.setOrigi n("DOD");
  416                                      studyTyp e.setSiteA bbreviatio n("DoD");
  417                                      
  418                                      if((Well KnownOID.H AIMS_DOCUM ENT.isAppl icable(doc ument.getG lobalArtif actIdentif ier().getH omeCommuni tyId()) ||  
  419                                                       (n catReposit oryId.equa ls(documen t.getRepos itoryId()) )))
  420                                      {
  421                                               studyType. setSiteNum ber("200") ;
  422                                      }                                  
  423                                      else
  424                                      {
  425                                               // this sh ould be a  VA documen t, set the  site numb er to the  repository  (there sh ould not a ctually 
  426                                               // be VA d ocuments h ere but ju st in case )
  427                                               studyType. setSiteNum ber(docume nt.getRepo sitoryId() );
  428                                      }
  429                                      studyTyp e.setStudy CanHaveRep ort(false) ;
  430                                      studyTyp e.setStudy HasImageGr oup(false) ;
  431                                      result.a dd(studyTy pe);                    
  432                             }
  433                    
  434                    retu rn result;
  435           }
  436           
  437           pr ivate stat ic StudyIm ageType tr anslate(Do cumentSet  documentSe t, 
  438                             Docume nt documen t, VistaIm ageType vi staImageTy pe)
  439           {
  440                    Stud yImageType  image = 
  441                             new St udyImageTy pe();
  442                    imag e.setImage Id(documen t.getGloba lArtifactI dentifier( ).toString (SERIALIZA TION_FORMA T.CDTP));
  443                    imag e.setImage Type(vista ImageType. name());
  444                    imag e.setSensi tive(false );
  445                    imag e.setImage Status(Stu dyObjectSt atusType.N O_STATUS);
  446                    imag e.setImage ViewStatus (StudyObje ctStatusTy pe.NO_STAT US);
  447                    
  448                    
  449                    imag e.setThumb nailImageU ri(""); //  no thumbn ail for ar tifacts
  450                    imag e.setDiagn osticImage Uri("image URN=" + im age.getIma geId() + " &imageQual ity=" + Im ageQuality .DIAGNOSTI CUNCOMPRES SED.getCan onical() +  "&content Type=" + d ocument.ge tMediaType ().toStrin g().toLowe rCase());
  451                    imag e.setRefer enceImageU ri("");
  452                    
  453                    // P atch 122 f ields
  454                    imag e.setAssoc iatedNoteR esulted("" );             
  455                    imag e.setImage HasAnnotat ions(false );
  456                    
  457                    retu rn image;
  458           }
  459           
  460           pr ivate stat ic StudyIm ageType tr anslate(Im age image)
  461           {
  462                    Stud yImageType  result =  new StudyI mageType() ;
  463                    
  464                    if(i mage == nu ll)
  465                             return  result;
  466                    
  467                    Stri ng imageId  = image.g etImageUrn ().toStrin g(SERIALIZ ATION_FORM AT.VFTP);
  468                    
  469                    resu lt.setImag eId( image Id );            
  470                    
  471                    // E xchange fi elds
  472                    // r eturn null  for the U ID instead  of the em pty string  to be con sistent wi th the WSD L - DKB
  473                    if ( image.getI mageUid()! = null &&  image.getI mageUid(). trim().len gth() > 0)
  474                    {
  475                             result .setDicomU id(image.g etImageUid ().trim()) ;
  476                    }
  477                    
  478                    
  479                    if ( image.getI mageNumber () != null  && image. getImageNu mber().tri m().length () > 0)
  480                    {
  481                             try
  482                             {
  483                                      Integer  imageNumbe r = new In teger(imag e.getImage Number());
  484                                      result.s etImageNum ber(imageN umber);
  485                             }
  486                             catch  (NumberFor matExcepti on ex)
  487                             {
  488                                      // not a  number -  return nul l
  489                                      result.s etImageNum ber(null);
  490                             }
  491                    }
  492                    else
  493                    {
  494                             result .setImageN umber(null );
  495                    }
  496                    
  497                    // C linical Di splay fiel ds
  498                    resu lt.setDico mImageNumb er(image.g etDicomIma geNumberFo rDisplay() );
  499                    resu lt.setDico mSequenceN umber(imag e.getDicom SequenceNu mberForDis play());
  500                    
  501                    Vist aImageType  vistaImag eType = Vi staImageTy pe.valueOf ImageType( image.getI mgType());
  502                    resu lt.setImag eType(vist aImageType  == null ?  "" : vist aImageType .name());
  503                    bool ean isDico m = false;
  504                    if(v istaImageT ype != nul l) {
  505                             switch (vistaImag eType)
  506                             {
  507                                      case DIC OM:
  508                                      case XRA Y:
  509                                      case ECG :
  510                                               isDicom =  true;
  511                                      default:
  512                                               isDicom =  false;
  513                             }
  514                             
  515                    }
  516                    resu lt.setDico m(isDicom) ;
  517                    resu lt.setThum bnailImage Uri(getThu mbnailImag eUri(image , imageId) );
  518                    resu lt.setRefe renceImage Uri(getRef erenceImag eFullUri(i mage, imag eId));
  519                    resu lt.setDiag nosticImag eUri(getDi agnosticIm ageUri(ima ge, imageI d));
  520  
  521                    resu lt.setImag eModality( image.getI mageModali ty());               
  522                    resu lt.setAsso ciatedNote Resulted(i mage.getAs sociatedNo teResulted ());
  523                    resu lt.setImag eHasAnnota tions(imag e.isImageH asAnnotati ons());
  524                    
  525                    resu lt.setCapt ureDate(im age.getCap tureDate() );
  526                    resu lt.setDocu mentDate(i mage.getDo cumentDate ());
  527                    resu lt.setSens itive(imag e.isSensit ive());
  528                    resu lt.setImag eViewStatu s(translat e(image.ge tImageView Status())) ;
  529                    resu lt.setImag eStatus(tr anslate(im age.getIma geStatus() ));
  530                    
  531                    retu rn result;
  532           }
  533           
  534           pr ivate stat ic String  getThumbna ilImageUri (Image ima ge, String  imageUrn)
  535           {
  536                    if(( image.getA bsFilename () != null ) && (imag e.getAbsFi lename().s tartsWith( "-1")))
  537                    {
  538                             return  "";
  539                    }
  540                    else
  541                    {
  542                             return  "imageURN =" + image Urn + "&im ageQuality =20&conten tType=" +  getContent Type(image , ImageQua lity.THUMB NAIL, 
  543                                               getStudyFa cadeConfig uration()) ;
  544                    }
  545           }
  546           
  547           pr ivate  sta tic String  getRefere nceImageFu llUri(Imag e image, S tring imag eUrn)
  548           {
  549                    bool ean isRadI mage = isR adImage(im age);
  550                    if(( image.getF ullFilenam e() != nul l) && (ima ge.getFull Filename() .startsWit h("-1")))
  551                    {
  552                             return  "";
  553                    }
  554                    else
  555                    {
  556                             // in  this inter face, if a  rad image  then ther e is a ref erence qua lity, if n ot rad the n no ref q uality - j ust diagno stic
  557                             if(isR adImage)
  558                             {
  559                                      int imag eQuality =  ImageQual ity.REFERE NCE.getCan onical();
  560                                      return " imageURN="  + imageUr n + "&imag eQuality="  + imageQu ality + "& contentTyp e=" + getC ontentType (image, 
  561                                                       Im ageQuality .REFERENCE , getStudy FacadeConf iguration( )); 
  562                             }
  563                             else
  564                             {
  565                                      return " ";
  566                             }
  567                    }
  568           }
  569           
  570           pr ivate stat ic String  getDiagnos ticImageUr i(Image im age, Strin g imageUrn )
  571           {
  572                    bool ean isRadI mage = isR adImage(im age);          
  573                    if(( image.getB igFilename () != null ) && (imag e.getBigFi lename().s tartsWith( "-1")))
  574                    {
  575                             return  "";
  576                    }
  577                    else
  578                    {
  579                             if(isR adImage)
  580                             {
  581                                      return " imageURN="  + imageUr n + "&imag eQuality=9 0&contentT ype=" + 
  582                                               getContent Type(image , ImageQua lity.DIAGN OSTIC, get StudyFacad eConfigura tion());
  583                             }
  584                             else
  585                             {
  586                                      return " imageURN="  + imageUr n + "&imag eQuality="  + ImageQu ality.DIAG NOSTICUNCO MPRESSED.g etCanonica l() + "&co ntentType= " + getCon tentType(i mage, 
  587                                                       Im ageQuality .REFERENCE , getStudy FacadeConf iguration( ));
  588                             }
  589                    }                 
  590           }
  591           
  592           pr ivate stat ic StudyOb jectStatus Type trans late(Objec tStatus ob jectStatus )
  593           {
  594                    for( Entry<Obje ctStatus,  StudyObjec tStatusTyp e> entry :  objectSta tusMap.ent rySet())
  595                    {
  596                             if(ent ry.getKey( ) == objec tStatus)
  597                                      return e ntry.getVa lue();
  598                    }
  599                    retu rn StudyOb jectStatus Type.UNKNO WN;
  600           }
  601  
  602           pr ivate stat ic StudyFa cadeConfig uration ge tStudyFaca deConfigur ation()
  603           {
  604                    retu rn StudyFa cadeConfig uration.ge tConfigura tion();
  605           }
  606           
  607           pu blic stati c LoadedSt udyType tr anslateLoa dedStudy(S tudy study )
  608           th rows Trans lationExce ption
  609           {
  610                    Stud yType stud yType = tr anslate(st udy, true) ;
  611                    if(s tudyType = = null)
  612                             return  null;
  613                    retu rn (Loaded StudyType) studyType;
  614           }
  615           
  616           pr ivate stat ic StoredF ilterType  translate( StoredStud yFilter st oredStudyF ilter)
  617           {
  618                    Stor edFilterTy pe result  = new Stor edFilterTy pe();
  619                    resu lt.setId(s toredStudy Filter.get StoredStud yFilterUrn ().toStrin g());
  620                    resu lt.setName (storedStu dyFilter.g etName());
  621                    retu rn result;
  622           }
  623           
  624           pu blic stati c StoredFi ltersType  translateS toredFilte rs(List<St oredStudyF ilter> sto redStudyFi lters)
  625           {
  626                    if(s toredStudy Filters ==  null)
  627                             return  null;
  628                    
  629                    Stor edFilterTy pe [] resu lt = new S toredFilte rType[stor edStudyFil ters.size( )];
  630                    for( int i = 0;  i < store dStudyFilt ers.size() ; i++)
  631                    {
  632                             result [i] = tran slate(stor edStudyFil ters.get(i ));
  633                    }
  634                    
  635                    retu rn new Sto redFilters Type(resul t);
  636           }
  637           
  638           pu blic stati c StudiesT ype transl ateStudies (List<Stud y> studies )
  639           th rows Trans lationExce ption
  640           {
  641                    if(s tudies ==  null)
  642                             return  null;
  643                    
  644                    Stud yType [] r esult = ne w StudyTyp e[studies. size()]; 
  645                    for( int i = 0;  i < studi es.size();  i++)
  646                    {
  647                             Study  study = st udies.get( i);
  648                             StudyT ype studyT ype = tran slate(stud y, true);
  649                             if(stu dyType !=  null)
  650                                      result[i ] = studyT ype;
  651                    }
  652                    
  653                    retu rn new Stu diesType(r esult);
  654           }
  655   }
  656