371. EPMO Open Source Coordination Office Redaction File Detail Report

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

371.1 Files compared

# Location File Last Modified
1 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\StudyWebApp\main\src\java\gov\va\med\imaging\study\rest\translator RestStudyTranslator.java Mon Dec 4 21:35:26 2017 UTC
2 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\StudyWebApp\main\src\java\gov\va\med\imaging\study\rest\translator RestStudyTranslator.java Mon Dec 4 22:05:55 2017 UTC

371.2 Comparison summary

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

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

371.4 Active regular expressions

No regular expressions were active.

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