776. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 10/18/2018 2:02:19 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.

776.1 Files compared

# Location File Last Modified
1 VIX_SIV_v3_0_patch_201_build_8.zip\v3.0_patch_201_build_8\VISA\Java\ImagingDicomDCFCommon\src\java\gov\va\med\imaging\dicom\dcftoolkit\common\impl DicomDataSetImpl.java Thu Oct 11 13:30:11 2018 UTC
2 VIX_SIV_v3_0_patch_201_build_8.zip\v3.0_patch_201_build_8\VISA\Java\ImagingDicomDCFCommon\src\java\gov\va\med\imaging\dicom\dcftoolkit\common\impl DicomDataSetImpl.java Wed Oct 17 18:52:29 2018 UTC

776.2 Comparison summary

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

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

776.4 Active regular expressions

No regular expressions were active.

776.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: Octo ber 19, 20 05
  6     Site Nam e:  Washin gton OI Fi eld Office , Silver S pring, MD
  7       Developer:    
P II
  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   package go v.va.med.i maging.dic om.dcftool kit.common .impl;
  26  
  27   import gov .va.med.im aging.Stri ngUtil;
  28   import gov .va.med.im aging.dico m.common.i nterfaces. IDicomData Set;
  29   import gov .va.med.im aging.dico m.common.i nterfaces. IDicomElem ent;
  30   import gov .va.med.im aging.dico m.common.i nterfaces. IIODViolat ionList;
  31   import gov .va.med.im aging.dico m.dcftoolk it.common. impl.rdsr. RDSRProces sor;
  32   import gov .va.med.im aging.dico m.dcftoolk it.common. mapping.Bu sinessObje ctToDicomS CUTranslat or;
  33   import gov .va.med.im aging.dico m.dcftoolk it.common. mapping.Di comToBusin essObjectT ranslator;
  34   import gov .va.med.im aging.dico m.dcftoolk it.common. validation .DicomInst anceValida tor;
  35   import gov .va.med.im aging.exch ange.busin ess.Imagin gServiceRe quest;
  36   import gov .va.med.im aging.exch ange.busin ess.Reques tedProcedu re;
  37   import gov .va.med.im aging.exch ange.busin ess.Schedu ledProcedu reStep;
  38   import gov .va.med.im aging.exch ange.busin ess.dicom. DicomAE;
  39   import gov .va.med.im aging.exch ange.busin ess.dicom. DicomCorre ctInfo;
  40   import gov .va.med.im aging.exch ange.busin ess.dicom. DicomMap;
  41   import gov .va.med.im aging.exch ange.busin ess.dicom. DicomReque stParamete rs;
  42   import gov .va.med.im aging.exch ange.busin ess.dicom. DicomServe rConfigura tion;
  43   import gov .va.med.im aging.exch ange.busin ess.dicom. DicomUtils ;
  44   import gov .va.med.im aging.exch ange.busin ess.dicom. InstanceFi le;
  45   import gov .va.med.im aging.exch ange.busin ess.dicom. Instrument Config;
  46   import gov .va.med.im aging.exch ange.busin ess.dicom. MockDicomM ap;
  47   import gov .va.med.im aging.exch ange.busin ess.dicom. PatientRef ;
  48   import gov .va.med.im aging.exch ange.busin ess.dicom. PatientStu dyInfo;
  49   import gov .va.med.im aging.exch ange.busin ess.dicom. ProcedureR ef;
  50   import gov .va.med.im aging.exch ange.busin ess.dicom. SOPInstanc e;
  51   import gov .va.med.im aging.exch ange.busin ess.dicom. Series;
  52   import gov .va.med.im aging.exch ange.busin ess.dicom. StorageCom mitElement ;
  53   import gov .va.med.im aging.exch ange.busin ess.dicom. Study;
  54   import gov .va.med.im aging.exch ange.busin ess.dicom. exceptions .DicomExce ption;
  55   import gov .va.med.im aging.exch ange.busin ess.dicom. exceptions .IllegalQu eryDataExc eption;
  56   import gov .va.med.im aging.exch ange.busin ess.dicom. exceptions .UnknownSO PClassExce ption;
  57   import gov .va.med.im aging.exch ange.busin ess.dicom. exceptions .ValidateI ODExceptio n;
  58   import gov .va.med.im aging.exch ange.busin ess.dicom. exceptions .ValidateV RException ;
  59   import gov .va.med.im aging.exch ange.busin ess.dicom. rdsr.Dose;
  60  
  61   import jav a.io.ByteA rrayOutput Stream;
  62   import jav a.io.IOExc eption;
  63   import jav a.io.Unsup portedEnco dingExcept ion;
  64   import jav a.util.Arr ayList;
  65   import jav a.util.Has hMap;
  66   import jav a.util.Has hSet;
  67   import jav a.util.Ite rator;
  68   import jav a.util.Lis t;
  69   import jav a.util.Vec tor;
  70  
  71   import jav ax.xml.par sers.Parse rConfigura tionExcept ion;
  72   import jav ax.xml.tra nsform.Tra nsformerEx ception;
  73  
  74   import org .apache.lo gging.log4 j.LogManag er;
  75   import org .apache.lo gging.log4 j.Logger;
  76  
  77   import com .lbs.DCS.A ttributeTa g;
  78   import com .lbs.DCS.D CM;
  79   import com .lbs.DCS.D CSExceptio n;
  80   import com .lbs.DCS.D icomDataDi ctionary;
  81   import com .lbs.DCS.D icomDataSe t;
  82   import com .lbs.DCS.D icomElemen t;
  83   import com .lbs.DCS.D icomFileOu tput;
  84   import com .lbs.DCS.D icomSQElem ent;
  85   import com .lbs.DCS.D icomSessio nSettings;
  86   import com .lbs.DCS.D icomStream Writer;
  87   import com .lbs.DCS.U ID;
  88   import com .lbs.DCS.V RValidator ;
  89   import com .lbs.DCS.V alidationE rror;
  90   import com .lbs.DCS.V alidationE rrorList;
  91  
  92   /**
  93    *
  94    * TODO To  change th e template  for this  generated  type comme nt go to
  95    * Window  - Preferen ces - Java  - Code St yle - Code  Templates
  96    *
  97    *
  98    * @author  William P eterson
  99    *
  100    */
  101   public cla ss DicomDa taSetImpl  implements  IDicomDat aSet {
  102       
  103           pr ivate stat ic final S tring RADI ATION_DOSE _SOP_CLASS _UID = "1. 2.840.1000 8.5.1.4.1. 1.88.67";
  104  
  105           Di comDataSet  dataSet;
  106           
  107           //  Business  object ref erences
  108           Pa tientRef p atientRef  = null;
  109           Pr ocedureRef  procedure Ref = null ;
  110           Se ries serie s = null;
  111           St udy study  = null;
  112           SO PInstance  sopInstanc e = null;
  113           Im agingServi ceRequest  imagingSer viceReques t = null;
  114           Re questedPro cedure req uestedProc edure = nu ll;
  115           Sc heduledPro cedureStep  scheduled ProcedureS tep = null ;
  116           Di comRequest Parameters  serviceRe questParam eters = ne w DicomReq uestParame ters();
  117           Ha shSet<Dico mMap> serv iceMapping Set = new  HashSet<Di comMap>();
  118           Ha shSet<Dico mMap> HISM appingSet  = null;
  119       HashMa p<String,  String> HI SChanges =  null;
  120       String  acquisiti onSite;
  121       String  sourceAET ;
  122       String  receivedT ransferSyn tax;
  123       String  name;
  124       String  affectSOP Class;
  125       String  transacti onUID;
  126       String  aETDefaul tServiceTy pe = null;
  127  
  128       privat e static L ogger logg er = LogMa nager.getL ogger(Dico mDataSetIm pl.class);
  129           pr ivate stat ic final D icomServer Configurat ion config  = DicomSe rverConfig uration.ge tConfigura tion();
  130           pr ivate stat ic final S tring orig inalAttrib uteSequenc eTag = "04 00,0561";
  131  
  132  
  133           /* *
  134        * Con structor
  135        *
  136        */
  137       public  DicomData SetImpl()  {
  138           da taSet = ne w DicomDat aSet();
  139       }
  140       
  141       /**
  142        * Con structor
  143        * 
  144        * @pa ram arg0
  145        */
  146       public  DicomData SetImpl(Di comDataSet  arg0) {
  147           da taSet = ar g0;
  148       }
  149       /* (no n-Javadoc)
  150        * @se e gov.va.m ed.imaging .dicom.dcf toolkit.sc u.interfac es.IDicomD ataSet#get DicomDataS et()
  151        */
  152       public  Object ge tDicomData Set() {
  153           //
  154           re turn dataS et;
  155       }
  156  
  157       public  void setD icomDataSe t(Object d icomDataSe t) {
  158                    // T ODO Auto-g enerated m ethod stub
  159           }        
  160       
  161           /*  (non-Java doc)
  162            *  @see gov. va.med.ima ging.dicom .interface s.DicomDat aSet#getDi comElement (java.lang .String)
  163            * /
  164           pu blic IDico mElement g etDicomEle ment(Strin g dicomTag Name) thro ws DicomEx ception {
  165                    Dico mElementIm pl dicomEl ementImpl  = null;
  166                    
  167                    try  {
  168                             if (di comTagName  == null)        // d on't crash , if incom ing tag is  null 
  169                                      return d icomElemen tImpl;
  170                if(dataS et.contain sElement(n ew Attribu teTag(dico mTagName)) ){
  171                    Dico mElement e lement = d ataSet.fin dElement(n ew Attribu teTag(dico mTagName)) ;
  172                    dico mElementIm pl = new D icomElemen tImpl(elem ent);
  173                }
  174                    } 
  175                    catc h (DCSExce ption dcse
  176                    {
  177                logger.e rror(dcse. getMessage ());
  178                             logger .error(thi s.getClass ().getName ()+
  179                         " Could no t retrieve  Dicom Ele ment with  tag name:  " + dicomT agName);
  180                             throw  new DicomE xception(" Failure to  retrieve  DICOM Elem ent.", dcs e);
  181                    }
  182                    retu rn dicomEl ementImpl;
  183           }
  184  
  185    
  186           /*  (non-Java doc)
  187            *  @see gov. va.med.ima ging.dicom .interface s.DicomDat aSet#getDi comElement Value(java .lang.Stri ng, java.l ang.String )
  188            * /
  189           pu blic Strin g getDicom ElementVal ue(String  dicomTagNa me, String  dicomTag2 Name)
  190                             throws  DicomExce ption {
  191                    Stri ng strval  = null;
  192  
  193                    try  {
  194                             if (di comTagName  == null)  // don't c rash, retu rn null if  incoming
  195                                      // tag i s null
  196                                      return s trval;
  197                             if (di comTag2Nam e == null)  // top le vel elemen t
  198                                      strval =  dataSet.g etElementS tringValue (new Attri buteTag(
  199                                                       di comTagName ));
  200                             else {  // we dea l with a s equence el ement
  201                                      DicomSQE lement sq_ e = (Dicom SQElement)  dataSet
  202                                                       .f indElement (new Attri buteTag(di comTagName ));
  203                                      if (sq_e  != null)  {
  204                                               // remove  element fr om sequenc e dataset
  205                                               DicomDataS et sq_ds =  sq_e.SQ() ; // handl e 1 sequen ce element
  206                                               // only (f or now)
  207                                               strval = s q_ds.getEl ementStrin gValue(new  Attribute Tag(
  208                                                                dico mTag2Name) );
  209                                      }
  210                             }
  211                    } ca tch (DCSEx ception dc se) {
  212                             logger .error(dcs e.getMessa ge());
  213                             logger .error(thi s.getClass ().getName ()
  214                                               + "Could n ot get Dic om Element  value of  tag name:  "
  215                                               + dicomTag Name
  216                                               + ((dicomT ag2Name ==  null) ? "  " : (", "  + dicomTa g2Name)));
  217                             throw  new DicomE xception(" Failure to  retrieve  DICOM Elem ent value. ", dcse);
  218                    }
  219                    if ( (strval !=  null) &&  (!strval.i sEmpty()))
  220                             strval  = strval. trim();
  221                    retu rn strval;
  222           }
  223  
  224           // IMPROVE Ch ange retur n value to  void.  Co mpile and  test to se e if somet hing break s.
  225           /*
  226            *  
  227            * /
  228           pu blic IDico mElement i nsertDicom Element(St ring dicom TagName, S tring dico mTag2Name,  String va lue) throw s DicomExc eption {
  229           Di comElement Impl dicom ElementImp l = null;
  230           
  231           tr y {
  232                    if ( dicomTagNa me == null )       //  don't cra sh, return  null if i ncoming ta g is null 
  233                             return  dicomElem entImpl;
  234                    if ( dicomTag2N ame == nul l){ // top  level ele ment
  235                value =  formatStri ngValue(di comTagName , value);
  236                             dataSe t.insert(n ew Attribu teTag(dico mTagName),  value);
  237           }
  238                    else  {                                              // we  deal with  a sequence  element
  239                             DicomS QElement s q_e = null ;
  240                             if (da taSet.cont ainsElemen t(new Attr ibuteTag(d icomTagNam e))) {
  241                                      sq_e = ( DicomSQEle ment)dataS et.findEle ment(new A ttributeTa g(dicomTag Name));
  242                                      DicomDat aSet sq_ds  = sq_e.SQ (); // han dle 1 sequ ence eleme nt only (f or now)
  243                    Stri ng nuValue  = formatS tringValue (dicomTag2 Name, valu e);
  244                                      sq_ds.in sert(new A ttributeTa g(dicomTag 2Name), nu Value);
  245                                      DicomSQE lement nuS equence =  new DicomS QElement(n ew Attribu teTag(dico mTagName),  sq_ds);
  246                                      dataSet. insert(nuS equence);
  247                             } 
  248                             else{
  249                    Stri ng nuValue  = formatS tringValue (dicomTag2 Name, valu e);
  250                                      DicomDat aSet sq_ds  = new Dic omDataSet( );
  251                                      sq_ds.in sert(new A ttributeTa g(dicomTag 2Name), nu Value);
  252                                      sq_e = n ew DicomSQ Element(ne w Attribut eTag(dicom TagName),  sq_ds);                  
  253                                      dataSet. insert(sq_ e);
  254                             }
  255                    }
  256           }
  257           ca tch (DCSEx ception dc se) 
  258           {
  259           lo gger.error (dcse.getM essage());
  260                    logg er.error(t his.getCla ss().getNa me()+
  261                    "Cou ld not ins ert Dicom  Element wi th tag nam e: "
  262                                      + dicomT agName + ( (dicomTag2 Name==null )?" ":(",  " + dicomT ag2Name))) ;
  263                    thro w new Dico mException ("Failure  to insert  DICOM Elem ent.", dcs e);
  264           }
  265                    retu rn dicomEl ementImpl;
  266           }
  267           
  268       /* (no n-Javadoc)
  269        * @se e gov.va.m ed.imaging .dicom.dcf toolkit.sc u.interfac es.IDicomD ataSet#rem oveDicomEl ement(java .lang.Stri ng, java.l ang.String )
  270        */
  271       public  boolean r emoveDicom Element(St ring dicom TagName, S tring dico mTag2Name)
  272                throws D icomExcept ion {
  273                    bool ean remove d=false;
  274                    
  275                    try  {
  276                             if (di comTagName  == null)        // d on't crash , return n ull if inc oming tag  is null 
  277                                      return r emoved;
  278                             if (di comTag2Nam e == null)   // top l evel eleme nt
  279                                      removed  = dataSet. removeElem ent(new At tributeTag (dicomTagN ame));
  280                             else {                                               // we de al with a  sequence e lement
  281                                      DicomSQE lement sq_ e = (Dicom SQElement) dataSet.fi ndElement( new Attrib uteTag(dic omTagName) );
  282                                      if (sq_e !=null) {
  283                                               // remove  element fr om sequenc e dataset
  284                                               DicomDataS et sq_ds =  sq_e.SQ() ; // handl e 1 sequen ce element  only (for  now)
  285                                               removed =  sq_ds.remo veElement( new Attrib uteTag(dic omTag2Name ));
  286                                      }
  287                             }
  288                    }
  289                    catc h (DCSExce ption dcse
  290                    {
  291                logger.e rror(dcse. getMessage ());
  292                             logger .error(thi s.getClass ().getName ()+
  293                         "Could not  remove Di com Elemen t with tag  name: "
  294                                               + dicomTag Name + ((d icomTag2Na me==null)? " ":(", "  + dicomTag 2Name)));
  295                             throw  new DicomE xception(" Failure to  remove DI COM Elemen t.", dcse) ;
  296                    }
  297                    retu rn removed ;
  298           }
  299       
  300       /*
  301        * (no n-Javadoc)
  302        * @se e gov.va.m ed.imaging .dicom.com mon.interf aces.IDico mDataSet#c ontainsDic omElement( java.lang. String, ja va.lang.St ring)
  303        */
  304           pu blic boole an contain sDicomElem ent(String  dicomTagN ame, Strin g dicomTag 2Name){
  305                    bool ean elemen tExist = f alse;
  306                    try  {
  307                             if (di comTagName  == null){       // d on't crash , return n ull if inc oming tag  is null 
  308                                      throw ne w DCSExcep tion("Tag  is null");
  309                             }
  310                             if(dat aSet.conta insElement (new Attri buteTag(di comTagName ))){
  311                                      if (dico mTag2Name  == null){      // top  level ele ment found
  312                                               elementExi st = true;
  313                                      } else {                                             // we deal  with a se quence ele ment
  314                                               DicomSQEle ment sq_e  = (DicomSQ Element)da taSet.find Element(ne w Attribut eTag(dicom TagName));
  315                                               if (sq_e== null) // n o sequence  element f ound
  316                                                       el ementExist  = false;
  317                                               else {
  318                                                       //  remove el ement from  sequence  dataset
  319                                                       Di comDataSet  sq_ds = s q_e.SQ();  // handle  1 sequence  element o nly (for n ow)
  320                                                       el ementExist  = sq_ds.c ontainsEle ment(new A ttributeTa g(dicomTag 2Name));
  321                                               }
  322                                      }
  323                             }
  324                             else{
  325                                      elementE xist = fal se;
  326                             }
  327                    }
  328                    catc h (DCSExce ption dcse
  329                    {
  330                logger.e rror(dcse. getMessage ());
  331                             logger .error(thi s.getClass ().getName ()+
  332                         "Could not  determine  if Dicom  Element ex ist with t ag name(s) : " + dico mTagName +  ((dicomTa g2Name==nu ll)?"  nul l":dicomTa g2Name));
  333                             elemen tExist = f alse;
  334                    }
  335                    retu rn element Exist;
  336           }
  337  
  338       /*
  339        * (no n-Javadoc)
  340        * @se e gov.va.m ed.imaging .dicom.com mon.interf aces.IDico mDataSet#i nsertAndRe cordNewVal ue(java.la ng.String,  java.lang .String, j ava.lang.S tring, jav a.lang.boo lean)
  341        */
  342           pu blic boole an insertA ndRecordNe wValue (St ring tag,  String tag 2, String  value, boo lean ignor eNew)
  343           {
  344                    // c heck if va lue is new
  345                    Stri ng tagValu e=null;
  346                    try  {
  347                             if (co ntainsDico mElement(t ag, tag2))
  348                                      tagValue  = getDico mElementVa lue(tag, t ag2);      // fetch o ld value
  349                             else {
  350                                      ignoreNe w = true;                                                                               // force i nsert of n ew value
  351                                      tagValue  = "";                                                                                  // set old  value to  empty Stri ng
  352                             }
  353                             if (ig noreNew ||  ((tagValu e != null)  && (!tagV alue.equal s(value)))  ) {
  354                                      
  355                                      // do in sert old v alue to or iginal seq uence and  value to d ataset
  356                                      try {
  357                                               if (tag2== null) {
  358                                                       in sertDicomE lement(ori ginalAttri buteSequen ceTag, tag , tagValue );
  359                                              
  360                                               else {  //  sequence  tag
  361                                                       Di comDataSet  dataSet =  null;
  362                                                       Di comDataSet  sq_ds = n ull; // or ig SQ data set
  363                                                       da taSet = (D icomDataSe t) getDico mDataSet() ;
  364                                                       Di comSQEleme nt origSQ_ e = (Dicom SQElement)  dataSet.f indElement (new Attri buteTag(or iginalAttr ibuteSeque nceTag));
  365                                                       if  (origSQ_e  == null)  { // inser t orig SQ  with old t ag value i n belly to  parent da taset 
  366                                                                sq_d s = new Di comDataSet ();
  367                                               sq_ds.inse rt(new Att ributeTag( tag), tagV alue);
  368                                               origSQ_e =  new Dicom SQElement( new Attrib uteTag(ori ginalAttri buteSequen ceTag), sq _ds);
  369                                               dataSet.in sert(origS Q_e);
  370                                                       } 
  371                                                       el se {           // ori g SQ alrea dy exists
  372                                                                sq_d s = origSQ _e.SQ(); 
  373                                                                //FI XME-fix th is dead co de.  Not s ure what t o do with  the else s tatement.
  374                                                                if ( tag2==null ) { // ins ert old el ement to o rig SQ
  375                                                                         sq_ds. insert(new  Attribute Tag(tag),  tagValue);
  376                                                                } 
  377                                                                else  {           // find/ create old  SQ in ori g SQ
  378                                                                         DicomS QElement c hildSQ_e =  getChildS equenceEle ment(tag,  sq_ds);
  379                                                                         DicomD ataSet sq_ ds2 = null ; // child  SQ datase t
  380                                                                         if (ch ildSQ_e ==  null) { / / create c hild SQ wi th old ele ment in be lly and ad d child SQ  to orig S Q
  381                                                                                  sq_ds2 =  new Dicom DataSet();  
  382                                                                sq_d s2.insert( new Attrib uteTag(tag 2), tagVal ue);
  383                                                                chil dSQ_e = ne w DicomSQE lement(new  Attribute Tag(tag),  sq_ds2);
  384                                                                sq_d s.insert(c hildSQ_e);
  385                                                                         } else  {                                   // ins ert old SQ  element t o orig SQ' s child SQ
  386                                                                                  sq_ds2 =  childSQ_e .SQ();
  387                                                                                  sq_ds2.i nsert(new  AttributeT ag(tag2),  tagValue);         
  388                                                                         }
  389                                                                         
  390                                                                }
  391                                                       }
  392                                               }                                          
  393                                      } catch  (DCSExcept ion dcse)  {
  394                                               // do high  level log  only, Det ailed Erro r logged o n lower le vel
  395                                               logger.err or("Insert ing (" + t ag + ") wi th value "  + tagValu e + " to O riginal At tribute se quence Fai led ");
  396                                      }
  397                                      
  398                                      try {
  399                                               //now inse rt the new  value
  400                                               insertDico mElement(t ag, tag2,  value);
  401                                      } catch  (DicomExce ption de)  {
  402                                               // do high  level log  only, Det ailed Erro r logged o n lower le vel
  403                                               logger.err or("Insert ing (" + t ag + ") wi th value "  + value +  " to data set Failed  ");
  404  
  405                                      }
  406                             }
  407                    } ca tch (Dicom Exception  de) {
  408                             logger .error("Ge tting (" +  tag + ")  from datas et for che ck/update  failed ");
  409                    }
  410                    retu rn false;
  411           }
  412  
  413           pr ivate Dico mSQElement  getChildS equenceEle ment(Strin g tag, Dic omDataSet  sq_ds) thr ows DCSExc eption 
  414           {
  415                    try
  416                    {
  417                             return  (DicomSQE lement) sq _ds.findEl ement(new  AttributeT ag(tag));
  418                    }
  419                    catc h (DCSExce ption e)
  420                    {
  421                             
  422                    }
  423                    retu rn null;
  424           }
  425  
  426  
  427           /*
  428            *  
  429            * /
  430       public  HashSet<D icomMap> g etHISMappi ngSet() {
  431           re turn getHI SPropertyM appingSet( );
  432       }
  433  
  434       /*
  435        * (no n-Javadoc)
  436        * @se e gov.va.m ed.imaging .dicom.com mon.interf aces.IDico mDataSet#s etQueryMap pingSet(ja va.util.Ha shSet)
  437        */
  438       public  void setQ ueryMappin gSet(HashS et<DicomMa p> mapping Set) {
  439           th is.service MappingSet  = mapping Set;
  440       }
  441  
  442       /*
  443        * (no n-Javadoc)
  444        * @se e gov.va.m ed.imaging .dicom.com mon.interf aces.IDico mDataSet#g etQueryMap pingSet()
  445        */
  446       public  HashSet<D icomMap> g etQueryMap pingSet()  {
  447                    retu rn this.se rviceMappi ngSet;
  448           }        
  449  
  450           /*  (non-Java doc)
  451        * @se e gov.va.m ed.imaging .dicom.dcf toolkit.sc u.interfac es.IDicomD ataSet#get StudyInsta nceUID()
  452        */
  453       public  String ge tStudyInst anceUID()  {
  454           tr y {
  455                             return  dataSet.g etElementS tringValue (DCM.E_STU DY_INSTANC E_UID);
  456                    } ca tch (DCSEx ception e)  {
  457                             e.prin tStackTrac e();
  458                             return  null;
  459                    }
  460       }
  461  
  462       /*
  463        * (no n-Javadoc)
  464        * @se e gov.va.m ed.imaging .dicom.com mon.interf aces.IDico mDataSet#s etStudyIns tanceUID(j ava.lang.S tring)
  465        */
  466           pu blic void  setStudyIn stanceUID( String stu dyInstance UID)
  467           {
  468           tr y{
  469                    inse rtDicomEle ment("0020 ,000d", nu ll, studyI nstanceUID );
  470           }
  471           ca tch(DicomE xception d csX){
  472                    logg er.error(" Couldn't i nsert stud yInstanceU ID into th e dataSet" );
  473           }        
  474           }
  475           
  476       /* (no n-Javadoc)
  477        * @se e gov.va.m ed.imaging .dicom.dcf toolkit.sc u.interfac es.IDicomD ataSet#get SeriesInst anceUID()
  478        */
  479       public  String ge tSeriesIns tanceUID()  {
  480           tr y {
  481                             return  dataSet.g etElementS tringValue (DCM.E_SER IES_INSTAN CE_UID);
  482                    } ca tch (DCSEx ception e)  {
  483                             e.prin tStackTrac e();
  484                             return  null;
  485                    }
  486       }
  487  
  488       /*
  489        * (no n-Javadoc)
  490        * @se e gov.va.m ed.imaging .dicom.com mon.interf aces.IDico mDataSet#s etSeriesIn stanceUID( java.lang. String)
  491        */
  492           pu blic void  setSeriesI nstanceUID (String se riesInstan ceUID)
  493           {
  494           tr y{
  495                    inse rtDicomEle ment("0020 ,000e", nu ll, series InstanceUI D);
  496           }
  497           ca tch(DicomE xception d csX){
  498                    logg er.error(" Couldn't i nsert seri esInstance UID into t he dataSet ");
  499           }                 
  500           }
  501  
  502       /* (no n-Javadoc)
  503        * @se e gov.va.m ed.imaging .dicom.dcf toolkit.sc u.interfac es.IDicomD ataSet#get SOPInstanc eUID()
  504        */
  505       public  String ge tSOPInstan ceUID() {
  506           tr y {
  507                             return  dataSet.g etElementS tringValue (DCM.E_SOP INSTANCE_U ID);
  508                    } ca tch (DCSEx ception e)  {
  509                             e.prin tStackTrac e();
  510                             return  null;
  511                    }
  512       }
  513       
  514       /*
  515        * (no n-Javadoc)
  516        * @se e gov.va.m ed.imaging .dicom.com mon.interf aces.IDico mDataSet#s etSOPInsta nceUID(jav a.lang.Str ing)
  517        */
  518           pu blic void  setSOPInst anceUID(St ring sopIn stanceUID)
  519           {
  520           tr y{
  521                    inse rtDicomEle ment("0008 ,0018", nu ll, sopIns tanceUID);
  522           }
  523           ca tch(DicomE xception d csX){
  524                    logg er.error(" Couldn't i nsert sopI nstanceUID  into the  dataSet");
  525          }         
  526           }
  527           
  528       /* (no n-Javadoc)
  529        * @se e gov.va.m ed.imaging .dicom.dcf toolkit.sc u.interfac es.IDicomD ataSet#get SeriesInst anceUID(ja va.lang.St ring)
  530        */
  531       public  boolean g etStudyIns tanceUID(S tring stud yInstanceU ID) {
  532           re turn false ;
  533       }
  534       
  535       /* (no n-Javadoc)
  536        * @se e gov.va.m ed.imaging .dicom.dcf toolkit.sc u.interfac es.IDicomD ataSet#get SeriesInst anceUID(ja va.lang.St ring)
  537        */
  538       public  boolean g etSeriesIn stanceUID( String ser iesInstanc eUID) {
  539           re turn false ;
  540       }
  541       
  542       /* (no n-Javadoc)
  543        * @se e gov.va.m ed.imaging .dicom.dcf toolkit.sc u.interfac es.IDicomD ataSet#get SOPInstanc eUID(java. lang.Strin g)
  544        */
  545       public  boolean g etSOPInsta nceUID(Str ing sopIns tanceUID)  {
  546           re turn false ;
  547       }
  548  
  549       /*
  550        * (no n-Javadoc)
  551        * @se e gov.va.m ed.imaging .dicom.com mon.interf aces.IDico mDataSet#u pdateHISCh angesToDDS (java.util .HashMap)
  552        */
  553       public  void upda teHISChang esToDDS(Ha shMap<Stri ng, String > HISChang es)throws  DicomExcep tion{
  554           if (HISChange s != null) {
  555                sanitize HISChanges (HISChange s);
  556                Business ObjectToDi comSCUTran slator.upd ateDataSet FromHISCha nges(this,  HISChange s, 
  557                             getHIS MappingSet ());
  558           }
  559       }
  560      
  561       /* (no n-Javadoc)
  562        * @se e gov.va.m ed.imaging .dicom.dcf toolkit.sc u.interfac es.IDicomD ataSet#get Acquisitio nSite()
  563        */
  564       public  String ge tAcquisiti onSite() {
  565           re turn this. acquisitio nSite;
  566       }
  567       
  568       /* (no n-Javadoc)
  569        * @se e gov.va.m ed.imaging .dicom.dcf toolkit.sc u.interfac es.IDicomD ataSet#set Acquisitio nSite(java .lang.Stri ng)
  570        */
  571       public  void setA cquisition Site(Strin g site) {
  572       }
  573       
  574       /*
  575        * (no n-Javadoc)
  576        * @se e gov.va.m ed.imaging .dicom.com mon.interf aces.IDico mDataSet#g etSOPClass ()
  577        */
  578           pu blic Strin g getSOPCl ass(){
  579           tr y {
  580                             return  dataSet.g etElementS tringValue (DCM.E_SOP CLASS_UID) ;
  581                    } ca tch (DCSEx ception e)  {
  582                             e.prin tStackTrac e();
  583                             return  null;
  584                    }
  585           }
  586       
  587  
  588           
  589       /* (no n-Javadoc)
  590            *  @see gov. va.med.ima ging.dicom .common.in terfaces.I DicomDataS et#getManu facturer()
  591            * /
  592           pu blic Strin g getManuf acturer()  {
  593           tr y {
  594                             return  dataSet.g etElementS tringValue (DCM.E_MAN UFACTURER) ;
  595                    } ca tch (DCSEx ception e)  {
  596                             e.prin tStackTrac e();
  597                             return  null;
  598                    }
  599           }
  600  
  601           /*  (non-Java doc)
  602            *  @see gov. va.med.ima ging.dicom .common.in terfaces.I DicomDataS et#getMode lName()
  603            * /
  604           pu blic Strin g getModel Name() {
  605           tr y {
  606                             return  dataSet.g etElementS tringValue (DCM.E_MAN UFACTURERS _MODEL_NAM E);
  607                    } ca tch (DCSEx ception e)  {
  608                             e.prin tStackTrac e();
  609                             return  null;
  610                    }
  611           }
  612  
  613           
  614           /*  (non-Java doc)
  615            *  @see gov. va.med.ima ging.dicom .common.in terfaces.I DicomDataS et#part10B uffer()
  616            * /
  617           pu blic byte[ ] part10Bu ffer(boole an updateO nly) {
  618  
  619           by te[] data  = null;
  620  
  621           tr y {
  622                    Stri ng outputT S=UID.TRAN SFERLITTLE ENDIAN; //  Little En dian Impli cit VR (de fault)
  623                    if (  updateOnl y ) { 
  624                             String  inputTS=g etReceived TransferSy ntax();
  625                             if (in putTS != n ull && inp utTS.start sWith("1.2 .840.10008 .1.2.4"))  {
  626                                      // for U pdates onl y, do not  decompress  already c ompressed  DICOM Obje cts
  627                                      outputTS =inputTS;
  628                             }
  629                    }
  630                    Dico mSessionSe ttings ss  = new Dico mSessionSe ttings();
  631                    Byte ArrayOutpu tStream bo s = new By teArrayOut putStream( );
  632                    Dico mStreamWri ter writer  = new Dic omStreamWr iter( bos,  ss );
  633                    Dico mFileOutpu t dfo = ne w DicomFil eOutput(
  634                                               writer,
  635                                               outputTS,
  636                                               true, true , ss );
  637                    dfo. open();
  638                    dfo. writeDataS et( dataSe t );
  639                    data  = bos.toB yteArray() ;
  640                    bos. flush();
  641                    // d fo.close() ;
  642                    retu rn (data);
  643           }
  644           ca tch(DCSExc eption dcs e){
  645                return d ata;
  646           }
  647           ca tch(IOExce ption ioe) {
  648                return d ata;
  649           }
  650       }
  651       
  652                    
  653       /*
  654        * (no n-Javadoc)
  655        * @se e gov.va.m ed.imaging .dicom.com mon.interf aces.IDico mDataSet#c reatePatie ntQueryReq uestParame ters()
  656        */
  657       public  DicomRequ estParamet ers create PatientQue ryRequestP arameters( )
  658           th rows Illeg alQueryDat aException  // -- fro m getreque stFromData Set
  659           {
  660                    // R eturn the  the query  request fr om the DCF  DicomData Set in non -DICOM for mat
  661                    if ( serviceMap pingSet ==  null){
  662                             servic eMappingSe t = new Ha shSet<Dico mMap>();
  663                    }
  664                    else {
  665                             servic eMappingSe t.clear();
  666                    }
  667  
  668                    Hash Set<DicomM ap> tempMa ppingSet =  getFindPr opertyMapp ingSet(); 
  669                    Iter ator<Dicom Map> iter  = tempMapp ingSet.ite rator();
  670                    whil e (iter.ha sNext()){
  671                             DicomM ap mapping  = iter.ne xt();
  672                             try{
  673                                      if(dataS et.contain sElement(n ew Attribu teTag(mapp ing.getTag ()))){
  674                                               serviceMap pingSet.ad d(mapping) ;
  675                                      }
  676                             }
  677                             catch( DCSExcepti on dcsX){
  678                                      //do not hing
  679                             }
  680                    }
  681  
  682                    serv iceRequest Parameters  = DicomTo BusinessOb jectTransl ator.getRe questFromD ataSet(
  683                                                                                  this,
  684                                                                                  serviceM appingSet) ;
  685                    retu rn service RequestPar ameters;
  686           }
  687  
  688           /*
  689            *  (non-Java doc)
  690            *  @see gov. va.med.ima ging.dicom .common.in terfaces.I DicomDataS et#createS tudyQueryR equestPara meters()
  691            * /
  692           pu blic Dicom RequestPar ameters cr eateStudyQ ueryReques tParameter s()
  693                             throws  IllegalQu eryDataExc eption
  694           {
  695                    retu rn createP atientQuer yRequestPa rameters() ;
  696           }
  697  
  698           /*
  699            *  (non-Java doc)
  700            *  @see gov. va.med.ima ging.dicom .common.in terfaces.I DicomDataS et#createM oveRequest Parameters ()
  701            * /
  702           pu blic Dicom RequestPar ameters cr eateMoveRe questParam eters()
  703           th rows Illeg alQueryDat aException  // -- fro m getreque stFromData Set
  704           {
  705                    // R eturn the  Move reque st from th e DCF Dico mDataSet i n non-DICO M format ( feedable t o persiste nce)
  706                    serv iceMapping Set = getM ovePropert yMappingSe t();
  707                    
  708                    serv iceRequest Parameters  = DicomTo BusinessOb jectTransl ator.getRe questFromD ataSet(
  709                                               this,
  710                                               serviceMap pingSet);
  711                    retu rn service RequestPar ameters;
  712           }
  713  
  714           /*
  715            *  (non-Java doc)
  716            *  @see gov. va.med.ima ging.dicom .common.in terfaces.I DicomDataS et#getPart ialDicomCo rrectInfo( )
  717            * /
  718           pu blic Dicom CorrectInf o getParti alDicomCor rectInfo() {
  719                    
  720           St ring patie ntName = n ull;
  721           St ring nonDC MPatientNa me = null;
  722           St ring patie ntID = nul l;
  723           St ring acces sionNumber  = null;
  724           St ring caseN umber = nu ll;
  725           // String ser viceType =  null;
  726           St ring study InstanceUI D = null;
  727           St ring sopIn stanceUID  = null;
  728           
  729           tr y{
  730                patientN ame = data Set.getEle mentString Value(DCM. E_PATIENTS _NAME);
  731                if(patie ntName !=  null){
  732                    pati entName =  patientNam e.trim();
  733                    nonD CMPatientN ame = pati entName.to String();
  734                }
  735           }
  736           ca tch(DCSExc eption dcs X){
  737                logger.w arn(dcsX.g etMessage( ));
  738                             logger .warn(this .getClass( ).getName( )+": Could  not retri eve Patien t Name Dic om Element ");
  739           }
  740           tr y{
  741                patientI D = dataSe t.getEleme ntStringVa lue(DCM.E_ PATIENT_ID );
  742                if(patie ntID != nu ll){
  743                    pati entID = pa tientID.tr im();
  744                }
  745           }
  746           ca tch(DCSExc eption dcs X){
  747                logger.w arn(dcsX.g etMessage( ));
  748                             logger .warn(this .getClass( ).getName( )+": Could  not retri eve Patien t ID Dicom  Element") ;
  749           }
  750           tr y{
  751                accessio nNumber =  dataSet.ge tElementSt ringValue( DCM.E_ACCE SSION_NUMB ER);
  752                if(acces sionNumber  != null){
  753                    acce ssionNumbe r = access ionNumber. trim();
  754                    case Number = a ccessionNu mber;
  755                }
  756           }
  757           ca tch(DCSExc eption dcs X){
  758                logger.w arn(dcsX.g etMessage( ));
  759                             logger .warn(this .getClass( ).getName( )+": Could  not retri eve Access ion Number  Dicom Ele ment");
  760           }
  761           tr y{
  762                studyIns tanceUID =  dataSet.g etElementS tringValue (DCM.E_STU DY_INSTANC E_UID);
  763                if(study InstanceUI D != null) {
  764                    stud yInstanceU ID = study InstanceUI D.trim();
  765                }
  766           }
  767           ca tch(DCSExc eption dcs X){
  768                logger.w arn(dcsX.g etMessage( ));
  769                             logger .warn(this .getClass( ).getName( )+": Could  not retri eve Study  Instance U ID Dicom E lement");
  770           }
  771           tr y{
  772                sopInsta nceUID = d ataSet.get ElementStr ingValue(D CM.E_SOPIN STANCE_UID );
  773                if(sopIn stanceUID  != null){
  774                    sopI nstanceUID  = sopInst anceUID.tr im();
  775                }
  776           }
  777           ca tch(DCSExc eption dcs X){
  778                logger.w arn(dcsX.g etMessage( ));
  779                             logger .warn(this .getClass( ).getName( )+": Could  not retri eve SOP In stance UID  Dicom Ele ment");
  780           }
  781                                      
  782                    Dico mCorrectIn fo dicomCo rrectInfo  = new Dico mCorrectIn fo(patient ID, patien tName, non DCMPatient Name, case Number, ac cessionNum ber, 
  783                                                                         sopIns tanceUID,  studyInsta nceUID);
  784                    retu rn dicomCo rrectInfo;
  785           }
  786  
  787           
  788           /*
  789            *  (non-Java doc)
  790            *  @see gov. va.med.ima ging.dicom .common.in terfaces.I DicomDataS et#validat eIOD()
  791            * /
  792           // @Override
  793           pu blic IIODV iolationLi st validat eIOD() thr ows Valida teIODExcep tion, Unkn ownSOPClas sException  {
  794           
  795                    IODV iolationLi stImpl vio lationList  = null;
  796                    try{
  797                    viol ationList  = DicomIns tanceValid ator.getIn stance().v alidate(da taSet);
  798           }
  799           ca tch(Parser Configurat ionExcepti on pcX){
  800                    logg er.error(t his.getCla ss().getNa me()+": Pa rser Confi guration E xception:  /n"+pcX.ge tMessage() );
  801                    thro w new Vali dateIODExc eption("IO D Validati on Parser  problem.") ;
  802           }
  803           ca tch(Transf ormerExcep tion tX){
  804                    logg er.error(t his.getCla ss().getNa me()+": Tr ansformer  Exception:  /n"+tX.ge tMessage() );
  805                    thro w new Vali dateIODExc eption("IO D Validati on Transfo rmer probl em.");
  806           }
  807           ca tch(Unsupp ortedEncod ingExcepti on ueX){
  808                    logg er.error(t his.getCla ss().getNa me()+": Un supported  Encoding E xception:  /n"+ueX.ge tMessage() );
  809                    thro w new Vali dateIODExc eption("IO D Validati on Unsuppo rted Encod ing proble m.");
  810           }
  811                    //Ad ded Throwa ble in cas e of memor y heap spa ce error.
  812                    catc h(Throwabl e T){
  813                    logg er.error(t his.getCla ss().getNa me()+": Er ror or Exc eption: /n "+T.getMes sage());
  814                    thro w new Vali dateIODExc eption("IO D Validati on general  problem." );                        
  815                    }
  816           re turn (IIOD ViolationL ist)violat ionList;
  817           }
  818           
  819           /*
  820            *  (non-Java doc)
  821            *  @see gov. va.med.ima ging.dicom .common.in terfaces.I DicomDataS et#validat eVR()
  822            * /
  823       public  void vali dateVR()
  824           th rows Valid ateVRExcep tion{
  825           
  826           VR Validator  validator  = VRValida tor.instan ce();
  827           Va lidationEr rorList li st = valid ator.valid ateDataSet (dataSet);
  828           if (list.hasE rrors()){
  829                    int  errorCount  = list.ge tErrorCoun t();
  830                    Vect or<Validat ionError>  vectorList  = list.ge tErrorVect or();
  831                    Iter ator<Valid ationError > iter = v ectorList. iterator() ;
  832                    whil e(iter.has Next()){
  833                             Valida tionError  error = (V alidationE rror)iter. next();
  834                             DicomE lement ele ment = err or.getElem ent();
  835                             if(ele ment.lengt h() == 0){
  836                                      errorCou nt--;
  837                             }
  838                    }
  839                    if(e rrorCount  > 0){
  840                             logger .error("Th e DICOMDat aSet has t he followi ng VR erro rs. ");
  841                             logger .error(lis t.toString ());
  842                             throw  new Valida teVRExcept ion();                                   
  843                    }
  844           }
  845       }   
  846  
  847           /*  (non-Java doc)
  848            *  @see gov. va.med.ima ging.dicom .interface s.DicomDat aSet#getPa tientRef()
  849            * /
  850           pu blic Patie ntRef getP atientRef( ) {
  851                    Stri ng creatin gEntity =  ""; // loc al siteID,  stationID  or divisi onID -- th e creating  (DB) enti ty of the  ID
  852                    if ( config !=  null)
  853                             creati ngEntity =  config.ge tSiteId();  // this i s the Stat ion# not t he IEN in  institutio n file!)
  854                    
  855                    retu rn new Pat ientRef("" , "V", cre atingEntit y, "D"); / / DFN valu e will be  resolved a fter Patie nt Lookup
  856           }
  857           
  858           /*  (non-Java doc)
  859            *  @see gov. va.med.ima ging.dicom .interface s.DicomDat aSet#getPr ocedureRef ()
  860            * /
  861           pu blic Proce dureRef ge tProcedure Ref(Instru mentConfig  instrumen t) {
  862                    Proc edureRef p rocRef = n ew Procedu reRef (nul l, null, n ull, null,  null, nul l);
  863                    Stri ng accessi onNumber =  getString ValueFromE lement("00 08,0050",  ""); // if  no ACC# w e don't ad d to new D B anyway,  But DICOM  Correct
  864                    proc Ref.setDic omAccessio nNumber(ac cessionNum ber); // t his is the  in-proces sing ACC#  from heade r! not fro m ProcRef  domain!
  865                    proc Ref.setPro cedureID(a ccessionNu mber);
  866                    proc Ref.setAss igningAuth ority("V") ;
  867                    Stri ng creatin gEntity =  ""; // loc al siteID,  stationID  or divisi onID -- th e creating  (DB) enti ty of the  ID
  868                    if ( config !=  null)
  869                             creati ngEntity =  config.ge tSiteId();  // this i s the Stat ion# not t he IEN in  institutio n file!)
  870                    proc Ref.setCre atingEntit y(creating Entity);
  871                    
  872                    if(i nstrument. isConsultI nstrument( ))
  873                    {
  874                    proc Ref.setPac kageIX("CO NS");
  875           }
  876           el se
  877           { 
  878                    // T ODO: Check  for other  entities  based on A CC# format ?
  879                    proc Ref.setPac kageIX(ins trument.ge tService() );
  880           }
  881  
  882                    proc Ref.setPro cedureIDTy pe(instrum ent.getSer vice());
  883  
  884                    Stri ng stdTime  = getStri ngValueFro mElement(" 0040,2005" , ""); //  Imaging Se rvice Requ est Issue  Time
  885                    if ( !stdTime.i sEmpty())
  886                             stdTim e = "." +  stdTime;
  887                    Stri ng procDT  = (getStri ngValueFro mElement(" 0040,2004" , "") + st dTime); //  ISR Issue  Date&Time
  888                    if ( procDT.isE mpty()) {
  889                             stdTim e = getStr ingValueFr omElement( "0008,0030 ", ""); //  study tim e
  890                             if (!s tdTime.isE mpty())
  891                                      stdTime  = "." + st dTime;
  892                             procDT  = (getStr ingValueFr omElement( "0008,0020 ", "") + s tdTime); / / study Da te&Time
  893  
  894                    }
  895                    proc Ref.setPro cedureExam DateTime(p rocDT);
  896                    
  897                    retu rn procRef ;
  898           }
  899           
  900           /*  (non-Java doc)
  901            *  @see gov. va.med.ima ging.dicom .interface s.DicomDat aSet#getSt udy()
  902            * /
  903           pu blic Study  getStudy( ) {
  904                    // R eturn the  Study usin g the data  from the  DCF DicomD ataSet
  905                    Stri ng stdDate  = getStri ngValueFro mElement(" 0008,0020" , "");
  906                    Stri ng stdTime  = getStri ngValueFro mElement(" 0008,0030" , "");
  907                    Stri ng stdTime WithSepara tor = stdT ime;
  908                    if ( !stdTimeWi thSeparato r.isEmpty( ))
  909                             stdTim eWithSepar ator = "."  + stdTime WithSepara tor;
  910                    
  911                    Stud y study =  new Study(
  912                                      getStrin gValueFrom Element("0 020,000d",  ""), // s tudyIUID - - needs op tional Fil l-in after  Study UID  Check!
  913                                      "", // o riginalStu dyIUID,--  needs opti onal Fill- in after S tudy UID C heck!
  914                                      getStrin gValueFrom Element("0 020,0010",  ""), // s tudyID
  915                                      getStrin gValueFrom Element("0 008,1030",  ""), // d escription
  916                                      getStrin gValueFrom Element("0 008,0061",  ""), // m odalitiesI nStudy
  917                                      (getStri ngValueFro mElement(" 0008,0020" , "") + st dTimeWithS eparator),  // studyD ateTime
  918                                      getStrin gValueFrom Element("0 040,1002",  ""), // r easonForSt udy
  919                                      "A", //  Acq. in pr ogress ("A "), partia lly comple te ("P") o r complete d ("C")
  920                                      "V", //  originIX =  'V'A / 'D 'OD / 'F'E E / 'O'the r
  921                                      getStrin gValueFrom Element("0 040,1003",  "R"), //  priority ‘ S'TAT, ‘R' OUTINE, 'L 'OW or 'H' IGH
  922                                      getStrin gValueFrom Element("0 008,0050",  "") // Ac cession Nu mber for P ete
  923                                      );
  924                    stud y.setStudy Date(stdDa te);
  925                    stud y.setStudy Time(stdTi me);
  926                    stud y.setRefer ringPhysic ian(DicomU tils.refor matDicomNa me(getStri ngValueFro mElement(" 0008,0090" , "")));
  927                    
  928                    retu rn study;
  929           }
  930           /*  (non-Java doc)
  931            *  @see gov. va.med.ima ging.dicom .interface s.DicomDat aSet#getSe ries()
  932            * /
  933           pu blic Serie s getSerie s(DicomAE  dicomAE,In strumentCo nfig instr ument) {
  934                    // R eturn the  Series usi ng the dat a from the  DCF Dicom DataSet
  935                    Stri ng serTime  = getStri ngValueFro mElement(" 0008,0031" , "");
  936                    Stri ng remoteA ETitle = ( dicomAE !=  null) ? d icomAE.get RemoteAETi tle() : "" ;
  937                    Stri ng localAE Title = (d icomAE !=  null) ? di comAE.getL ocalAETitl e() : "";
  938                    Stri ng acqLoca tion = (in strument ! = null) ?  instrument .getSiteId () : Dicom ServerConf iguration. getConfigu ration().g etSiteId() ;
  939                    if ( !serTime.i sEmpty())
  940                             serTim e = "." +  serTime;
  941                    Seri es series  = new Seri es(
  942                                      getStrin gValueFrom Element("0 020,000e",  ""), // s eriesIUID  -- needs o ptional Fi ll-in afte r Series U ID Check!
  943                                      "", // o riginalSer iesIUID, - - needs op tional Fil l-in after  Series UI D Check!
  944                                      getStrin gValueFrom Element("0 020,0011",  ""), // s erNum
  945                                      getStrin gValueFrom Element("0 008,103e",  ""), // s eries desc ription
  946                                      getStrin gValueFrom Element("0 008,0060",  ""), // m odality
  947                                      getStrin gValueFrom Element("0 008,0015",  ""), // b odypart
  948                                      //The pu rpose of t his is to  assign the  Site Numb er of wher e the DICO M object c ame from.   This is b ased on th
  949                                      // Instr umentConfi g object.   We added  it to over ride the H DIG's Site  Number.
  950                                      acqLocat ion, // ac qSite
  951                                      (getStri ngValueFro mElement(" 0008,0021" , "") + se rTime), //  series Da te.Time
  952                                      getStrin gValueFrom Element("0 008,0070",  ""), // s eries Crea tor -- Man ufacturer
  953                                      getStrin gValueFrom Element("0 008,1090",  ""), // s eries Crea ter Device  Model --  Manuf. Mod el
  954                                      getStrin gValueFrom Element("0 020,0052",  ""), // F rame Of Re ference UI D
  955                                      getStrin gValueFrom Element("0 020,0060",  ""), // l aterality
  956                                      getStrin gValueFrom Element("0 018,5100",  ""), // S patial Pos ition
  957                                      remoteAE Title,
  958                                      localAET itle,
  959                                      "1", //  "DICOM Sto rage", vIA cqEntryPoi nt
  960                                 "0 ", // IODV iolationDe tected - n one
  961                                 "C LIN",
  962                                 "" ,  // proc EventIX
  963                                 "" ,  // spec SubSpecIX
  964                                 "" ); // tiuN oteReferen ce
  965                    
  966                    // N ew fields  for DICOM  Importer
  967                    seri es.setFaci lity(getSt ringValueF romElement ("0008,008 0", ""));
  968                    seri es.setInst itutionAdd ress(getSt ringValueF romElement ("0008,008 1", ""));
  969                    
  970                    retu rn series;
  971           }
  972           
  973           /*  (non-Java doc)
  974            *  @see gov. va.med.ima ging.dicom .interface s.DicomDat aSet#getSO PInstance( )
  975            * /
  976           pu blic SOPIn stance get SOPInstanc e() {
  977                    // R eturn the  Instance u sing the d ata in the  DCF Dicom DataSet
  978                    Stri ng sopTime  = getStri ngValueFro mElement(" 0008,0033" , "");
  979                    if ( !sopTime.i sEmpty())
  980                             sopTim e = "." +  sopTime;
  981                    SOPI nstance so pInstance  = new SOPI nstance(
  982                             getStr ingValueFr omElement( "0008,0018 ", ""), //  SOPInstan ceUID -- n eeds optio nal Fill-i n after SO P UID Chec k!
  983                             "", //  originalS OPInstance UID -- nee ds optiona l Fill-in  after SOP  UID Check!
  984                             getStr ingValueFr omElement( "0008,0016 ", ""), //  SOPClassU ID
  985                             "IMAGE ", // type IX by natu ral key.
  986                             "", //  image des cription
  987                             (getSt ringValueF romElement ("0008,002 3", "") +  sopTime),  // acqDate Time
  988                             getStr ingValueFr omElement( "0020,0012 ", ""), //  acqNumber
  989                             getStr ingValueFr omElement( "0020,0013 ", ""), //  instanceN umber
  990                             "", //  is Key im age? - 1 o r 0
  991                             "", //  image Not  OK? - 1 o r 0
  992                             getStr ingValueFr omElement( "0018,0010 ", ""), //  contrastB olusAgent
  993                             getStr ingValueFr omElement( "0020,0032 ", ""), //  imagePosi tion
  994                             getStr ingValueFr omElement( "0020,0037 ", ""), //  imageOrie ntation
  995                             getStr ingValueFr omElement( "0020,0020 ", ""), //  patientOr ientation
  996                             getStr ingValueFr omElement( "0028,0004 ", ""), //  photometr icInterpta tion
  997                             getStr ingValueFr omElement( "0028,0008 ", ""), //  numberOfF rames
  998                             getStr ingValueFr omElement( "0028,0010 ", ""), //  rows
  999                             getStr ingValueFr omElement( "0028,0011 ", ""), //  columns
  1000                             getStr ingValueFr omElement( "0028,0030 ", ""), //  pixelSpac ing
  1001                             getStr ingValueFr omElement( "0028,0002 ", ""), //  samplesPe rPixel
  1002                             getStr ingValueFr omElement( "0028,0100 ", ""), //  bitsAlloc ated
  1003                             getStr ingValueFr omElement( "0028,0101 ", ""), //  bitsStore d
  1004                             getStr ingValueFr omElement( "0028,0102 ", ""), //  highBit
  1005                             getStr ingValueFr omElement( "0028,0103 ", ""), //  pixelRepr esentation
  1006                             getStr ingValueFr omElement( "0028,1052 ", ""), //  rescaleIn tercept
  1007                             getStr ingValueFr omElement( "0028,1053 ", ""), //  rescaleSl ope
  1008                             getStr ingValueFr omElement( "0028,1050 ", ""), //  windowCen ter 
  1009                             getStr ingValueFr omElement( "0028,1051 ", ""), //  windowWid th
  1010                             getStr ingValueFr omElement( "0018,1004 ", ""), //  plateID
  1011                             getStr ingValueFr omElement( "0018,0050 ", ""), //  sliceThic kness
  1012                             getStr ingValueFr omElement( "0018,1100 ", ""), //  reconstru ctionDiame ter
  1013                             getStr ingValueFr omElement( "0018,0020 ", ""), //  scanningS equence 
  1014                             getStr ingValueFr omElement( "0018,0021 ", ""), //  scanningV ariant 
  1015                             getStr ingValueFr omElement( "0018,0023 ", ""), //  mrAcqType
  1016                             getStr ingValueFr omElement( "0040,0556 ", ""), //  acqContex tDescripti on
  1017                             getStr ingValueFr omElement( "0018,0080 ", ""), //  repetitio nTime
  1018                             getStr ingValueFr omElement( "0018,0081 ", ""), //  echoTime
  1019                             (getSt ringValueF romElement ("0018,115 0", "") +  "\\" + get StringValu eFromEleme nt("0018,1 155", "")) , // refer encedSOPIn stances
  1020                             "0018, 1150\\0018 ,1155",
  1021                             "", //  Microscop icObjectiv e
  1022                             "", //  lab Slice  Id
  1023                         "", // his tological  Stain n/a  for RAD st udies
  1024                             getStr ingValueFr omElement( "0020,0062 ", "") //  imageLater ality (L,  R, B or U)                      
  1025                    );
  1026                    
  1027                    // N ew fields  for DICOM  Importer
  1028                    sopI nstance.se tTransferS yntaxUid(g etStringVa lueFromEle ment("0004 ,1512", "" ));
  1029                    retu rn sopInst ance;
  1030           }
  1031  
  1032           /*  (non-Java doc)
  1033            *  @see gov. va.med.ima ging.dicom .interface s.DicomDat aSet#getIn stanceFile ()
  1034            * /
  1035           pu blic Insta nceFile ge tInstanceF ile() {
  1036                    Inst anceFile i nstanceFil e = new In stanceFile (
  1037                                      "", // A rtifactTok en
  1038                                      "0", //  isConfiden tial
  1039                                      "1", //  isOriginal
  1040                                      "", // d eleteDateT ime in the  format YY YMMDD.HHMM SS
  1041                                      "", // d eletedBy
  1042                                      "", // d eleteReaso n
  1043                                      getStrin gValueFrom Element("0 008,0008",  ""), // i mageType
  1044                                      getStrin gValueFrom Element("0 008,2111",  ""), // d erivationD esc
  1045                                      getStrin gValueFrom Element("0 008,2112",  ""), // c ompression Ratio
  1046                                      getStrin gValueFrom Element("0 008,2114",  ""),  //  compressio nMethod
  1047                                      0);
  1048                    retu rn instanc eFile;
  1049           }
  1050  
  1051           /*
  1052            *  (non-Java doc)
  1053            *  @see gov. va.med.ima ging.dicom .common.in terfaces.I DicomDataS et#getSour ceAET()
  1054            * /
  1055           pu blic Strin g getSourc eAET() {
  1056                    retu rn sourceA ET;
  1057           }
  1058  
  1059           /*
  1060            *  (non-Java doc)
  1061            *  @see gov. va.med.ima ging.dicom .common.in terfaces.I DicomDataS et#setSour ceAET(java .lang.Stri ng)
  1062            * /
  1063           pu blic void  setSourceA ET(String  sourceAET)  {
  1064           }
  1065  
  1066           /*
  1067            *  (non-Java doc)
  1068            *  @see gov. va.med.ima ging.dicom .common.in terfaces.I DicomDataS et#getRece ivedTransf erSyntax()
  1069            * /
  1070           pu blic Strin g getRecei vedTransfe rSyntax()  {
  1071                    retu rn receive dTransferS yntax;
  1072           }
  1073  
  1074           /*
  1075            *  (non-Java doc)
  1076            *  @see gov. va.med.ima ging.dicom .common.in terfaces.I DicomDataS et#setRece ivedTransf erSyntax(j ava.lang.S tring)
  1077            * /
  1078           pu blic void  setReceive dTransferS yntax(Stri ng receive dTransferS yntax) {
  1079                    this .receivedT ransferSyn tax = rece ivedTransf erSyntax;
  1080           }
  1081           
  1082           // CODECR #IM AG00000440  - SSN For mat issue.
  1083           /*
  1084            *  
  1085            * /
  1086       public  void chan geDataPres entation() {
  1087  
  1088                    if(D icomServer Configurat ion.getCon figuration ().isForma tPatientID withDashes ()){
  1089                             try{
  1090                                      if(dataS et.contain sElement(D CM.E_PATIE NT_ID)){
  1091                                               String pat ientID = d ataSet.get ElementStr ingValue(D CM.E_PATIE NT_ID, "") ;
  1092                                               if(!patien tID.equals ("")){
  1093                                                       St ring out =  StringUti l.formatPa tientIDWit hDashes(pa tientID);
  1094                                                       da taSet.inse rt(DCM.E_P ATIENT_ID,  out);
  1095                                               }
  1096                                      }
  1097                             }
  1098                             catch( DCSExcepti on dX){
  1099                                      logger.e rror("Fail ed to re-f ormat the  Patient ID .");
  1100                             }
  1101                    }
  1102       }
  1103       
  1104       /*
  1105        * (no n-Javadoc)
  1106        * @se e gov.va.m ed.imaging .dicom.com mon.interf aces.IDico mDataSet#g etQueryRet rieveLevel ()
  1107        */
  1108       public  String ge tQueryRetr ieveLevel( ){
  1109           St ring qrLev el = dataS et.getElem entStringV alue( DCM. E_QUERYRET RIEVE_LEVE L, "" );
  1110           if (qrLevel ! = null){
  1111                    qrLe vel = qrLe vel.trim() ;
  1112           }
  1113           re turn qrLev el;
  1114       }
  1115  
  1116       /*
  1117        *      (non-Java doc)
  1118        * @se e gov.va.m ed.imaging .dicom.com mon.interf aces.IDico mDataSet#g etPatientS tudyInfo(g ov.va.med. imaging.ex change.bus iness.dico m.Instrume ntConfig)
  1119        */
  1120           pu blic Patie ntStudyInf o getPatie ntStudyInf o(Instrume ntConfig i nstrument)  throws Di comExcepti on {
  1121                    
  1122                    Pati entStudyIn fo patient StudyInfo  = new Pati entStudyIn fo();
  1123  
  1124                    // E xtract val ues from D ICOM data  set
  1125                    Stri ng accessi onNumber =  getString ValueFromE lement("00 08,0050",  "");
  1126  
  1127                    Stri ng patient Name = get StringValu eFromEleme nt("0010,0 010", "");
  1128                    Stri ng patient Id = getSt ringValueF romElement ("0010,002 0", "");
  1129                    Stri ng patient BirthDate  = getStrin gValueFrom Element("0 010,0030",  "");
  1130                    Stri ng patient Sex = getS tringValue FromElemen t("0010,00 40", "");
  1131                    Stri ng patient ICN = "";
  1132  
  1133                    // S et propert ies on pat ientStudyI nfo object
  1134                    pati entStudyIn fo.setStud yAccession Number(acc essionNumb er);
  1135                    pati entStudyIn fo.setStud yImagingSe rvice(inst rument.get Service()) ;
  1136                    pati entStudyIn fo.setPati entName(pa tientName) ;
  1137                    pati entStudyIn fo.setPati entID(pati entId);
  1138                    pati entStudyIn fo.setPati entBirthDa te(patient BirthDate) ;
  1139                    pati entStudyIn fo.setPati entSex(pat ientSex);
  1140                    pati entStudyIn fo.setPati entICN(pat ientICN);
  1141                    
  1142                    retu rn patient StudyInfo;
  1143           }
  1144       
  1145           /* *
  1146            *  @return t he name
  1147            * /
  1148           pu blic Strin g getName( ) {
  1149                    retu rn name;
  1150           }
  1151  
  1152           /* *
  1153            *  @param na me the nam e to set
  1154            * /
  1155           pu blic void  setName(St ring name)  {
  1156           }
  1157  
  1158           /*  (non-Java doc)
  1159            *  @see gov. va.med.ima ging.dicom .common.in terfaces.I DicomDataS et#getAffe ctedSOPCla ss()
  1160            * /
  1161           pu blic Strin g getAffec tedSOPClas s() {
  1162           tr y {
  1163                             return  dataSet.g etElementS tringValue (DCM.E_AFF ECTED_SOPC LASS_UID);
  1164                    } ca tch (DCSEx ception e)  {
  1165                             e.prin tStackTrac e();
  1166                             return  null;
  1167                    }
  1168           }
  1169  
  1170           /*  (non-Java doc)
  1171            *  @see gov. va.med.ima ging.dicom .common.in terfaces.I DicomDataS et#setAffe ctedSOPCla ss(java.la ng.String)
  1172            * /
  1173           pu blic void  setAffecte dSOPClass( String sop Class) {
  1174           tr y{
  1175                    inse rtDicomEle ment("0008 ,0016", nu ll, sopCla ss);
  1176           }
  1177           ca tch(DicomE xception d csX){
  1178                    logg er.error(" Couldn't i nsert SOP  Class UID  into the d ataSet");
  1179           }                 
  1180  
  1181           }
  1182  
  1183       /* (no n-Javadoc)
  1184            *  @see gov. va.med.ima ging.dicom .common.in terfaces.I DicomDataS et#setServ iceType(ja va.lang.St ring)
  1185            * /
  1186           pu blic void  setAETDefa ultService Type(Strin g type) {
  1187                    this .aETDefaul tServiceTy pe = type;
  1188                    
  1189           }
  1190  
  1191           /*  (non-Java doc)
  1192            *  @see gov. va.med.ima ging.dicom .common.in terfaces.I DicomDataS et#getServ iceType()
  1193            * /
  1194           pu blic Strin g getAETDe faultServi ceType() {
  1195                    retu rn this.aE TDefaultSe rviceType;
  1196           }
  1197  
  1198           /*
  1199            *  (non-Java doc)
  1200            *  @see gov. va.med.ima ging.dicom .common.in terfaces.I DicomDataS et#insertT oOriginalA ttributeSe quence(jav a.lang.Str ing, java. lang.Strin g, java.la ng.String)
  1201            * /
  1202           pu blic void  insertToOr iginalAttr ibuteSeque nce(String  tag, Stri ng tagValu e, String  context) {
  1203                    try  {
  1204                             insert DicomEleme nt(origina lAttribute SequenceTa g, tag, ta gValue);
  1205                    } ca tch (Dicom Exception  de) {
  1206                    logg er.error(" Inserting  (" + tag +  ") with U ID " + tag Value + "  to Origina l Attribut e sequence  Failed "  + context) ;
  1207                    }
  1208           }
  1209  
  1210           /*
  1211            *  (non-Java doc)
  1212            *  @see gov. va.med.ima ging.dicom .common.in terfaces.I DicomDataS et#insertT oOriginalA ttributeSe quence(jav a.lang.Str ing, java. lang.Strin g)
  1213            * /
  1214           pu blic void  insertToOr iginalAttr ibuteSeque nce(String  tag, Stri ng context ) {
  1215                    try  {
  1216                             insert DicomEleme nt(origina lAttribute SequenceTa g, tag, ge tStringVal ueFromElem ent(tag, n ull));
  1217                    } ca tch (Dicom Exception  de) {
  1218                    logg er.error(" Inserting  (" + tag +  ") to Ori ginal Attr ibute sequ ence Faile d " + cont ext);
  1219                    }
  1220           }
  1221  
  1222           pu blic Strin g getTrans actionUID( ){
  1223           tr y {
  1224                             return  dataSet.g etElementS tringValue (DCM.E_TRA NSACTION_U ID);
  1225                    } ca tch (DCSEx ception e)  {
  1226                             e.prin tStackTrac e();
  1227                             return  null;
  1228                    }
  1229           }
  1230  
  1231           /*
  1232            *  this meth od inserts  DICOM SOP  Class/Ins tance elem ent pairs  into a sto rage commi tment stru cture.
  1233            *  This sequ ence is us ed to keep  track of  Storage Co mmitment r equests un til a resp onse is de livered to  the sende r.
  1234            * /
  1235           pu blic List< StorageCom mitElement > getRefSO PUIDList()  {
  1236                    List <StorageCo mmitElemen t> sCEs= n ew ArrayLi st<Storage CommitElem ent>();
  1237                    sCEs .clear();
  1238                    
  1239                    int  i=0;
  1240                    try  {
  1241                             DicomS QElement s q_e = (Dic omSQElemen t) dataSet .findEleme nt(DCM.E_R EFERENCED_ SOP_SEQUEN CE);
  1242                             if (sq _e != null ) {
  1243                                      // extra ct element s from seq uence data set
  1244                                      for (i=0 ; ; i++) {  // took ( back) out  correct lo oking code : "i<sq_e. length()"  -- did not  fill list !!!
  1245                                               DicomDataS et sq_ds =  sq_e.SQ(i ); // hand le sequenc e elements
  1246                                               StorageCom mitElement  sCE = new  StorageCo mmitElemen t();
  1247                                               sCE.setSop ClassUid(s q_ds.getEl ementStrin gValue(DCM .E_REFEREN CED_SOPCLA SS_UID));
  1248                                               sCE.setSOP InstanceUI D(sq_ds.ge tElementSt ringValue( DCM.E_REFE RENCED_SOP INSTANCE_U ID));
  1249                                               sCEs.add(s CE);
  1250                                      }
  1251                             }
  1252                    }
  1253                    catc h (DCSExce ption de)  {
  1254                                      if (i==0 )
  1255                                               logger.err or("Error  extracting  SOP refer ences from  Storage C ommit Requ est");
  1256                             }
  1257                             
  1258                    retu rn sCEs;
  1259           }
  1260  
  1261           /* *
  1262        * ret urns the D ICOM Study  Root, Stu dy level C -FIND DICO M to java  mapping se t. (to be  used
  1263        * for  Query Req uest DataS et transla tion.)
  1264        * The  mapping s et is hard coded for  legacy but  queried f rom persis tence mapp ing table  for RE
  1265        * @re turn HashS et contain ing the ma pping set:  ("gggg,ee ee", value ) for lega cy, (field Name, valu e) otherwi se
  1266        */
  1267       privat e HashSet< DicomMap>  getHISProp ertyMappin gSet()
  1268       {
  1269                    // C reate the  HashSet
  1270                    Hash Set<DicomM ap> hashSe t = new Ha shSet<Dico mMap>();
  1271  
  1272                    //       feed s tatic tabl e for lega cy(could b e in M per sistence!! !!)
  1273                    hash Set.add(ne w MockDico mMap("0008 ,0018", nu ll, "HISUp date", "SO PInstanceU ID", 1));
  1274                    hash Set.add(ne w MockDico mMap("0008 ,0020", nu ll, "HISUp date", "St udyDate",  1));
  1275                    hash Set.add(ne w MockDico mMap("0008 ,0050", nu ll, "HISUp date", "Ac cessionNum ber", 1));
  1276           ha shSet.add( new MockDi comMap("00 08,0090",  null, "HIS Update", " ReferringP hysiciansN ame", 1));
  1277           ha shSet.add( new MockDi comMap("00 08,1030",  null, "HIS Update", " Procedure" , 1));
  1278           ha shSet.add( new MockDi comMap("00 08,1032",  "0008,0100 ", "HISUpd ate", "CPT Code", 1)) ;
  1279                    hash Set.add(ne w MockDico mMap("0008 ,1032", "0 008,0102",  "HISUpdat e", "CodeS chemeDesig nator", 1) );
  1280                    hash Set.add(ne w MockDico mMap("0008 ,1032", "0 008,0104",  "HISUpdat e", "CodeM eaning", 1 ));
  1281           ha shSet.add( new MockDi comMap("00 08,1050",  null, "HIS Update", " Performing Physician" , 1));
  1282  
  1283           ha shSet.add( new MockDi comMap("00 10,0010",  null, "HIS Update", " PatientNam e", 1));
  1284                    hash Set.add(ne w MockDico mMap("0010 ,0020", nu ll, "HISUp date", "Pa tientId",  1));
  1285           ha shSet.add( new MockDi comMap("00 10,0030",  null, "HIS Update", " PatientBir thDate", 1 ));
  1286           ha shSet.add( new MockDi comMap("00 10,0032",  null, "HIS Update", " PatientBir thTime", 1 ));
  1287           ha shSet.add( new MockDi comMap("00 10,0040",  null, "HIS Update", " PatientSex ", 1));
  1288           ha shSet.add( new MockDi comMap("00 10,1000",  null, "HIS Update", " OtherPatie ntIDs", 1) );
  1289           ha shSet.add( new MockDi comMap("00 10,1040",  null, "HIS Update", " PatientAdd ress", 1)) ;
  1290           ha shSet.add( new MockDi comMap("00 10,2000",  null, "HIS Update", " MedicalAle rts", 1));
  1291           ha shSet.add( new MockDi comMap("00 10,2160",  null, "HIS Update", " PatientRac e", 1));
  1292  
  1293                    hash Set.add(ne w MockDico mMap("0020 ,000D", nu ll, "HISUp date", "St udyInstanc eUID", 1)) ;
  1294           ha shSet.add( new MockDi comMap("00 20,000E",  null, "HIS Update", " SeriesInst anceUID",  1));
  1295                    
  1296           ha shSet.add( new MockDi comMap("00 32,1032",  null, "HIS Update", " Requesting PhysicianN ame", 1));
  1297                    hash Set.add(ne w MockDico mMap("0032 ,1033", nu ll, "HISUp date", "Re questingSe rvice", 1) );
  1298           ha shSet.add( new MockDi comMap("00 32,1060",  null, "HIS Update", " RequestedP rocedureDe scription" , 1));
  1299           ha shSet.add( new MockDi comMap("00 32,1064",  "0008,0100 ", "HISUpd ate", "CPT Code", 1)) ;
  1300                    hash Set.add(ne w MockDico mMap("0032 ,1064", "0 008,0102",  "HISUpdat e", "CodeS chemeDesig nator", 1) );
  1301                    hash Set.add(ne w MockDico mMap("0032 ,1064", "0 008,0104",  "HISUpdat e", "CodeM eaning", 1 ));
  1302  
  1303                    hash Set.add(ne w MockDico mMap("0038 ,0300", nu ll, "HISUp date", "Cu rrentPatie ntLocation ",  1));
  1304                    hash Set.add(ne w MockDico mMap("0032 ,1020", nu ll, "HISUp date", "Sc heduled St udy Locati on", 1));
  1305           
  1306                    retu rn hashSet ;    
  1307       }
  1308       
  1309           /* *
  1310            *  returns t he DICOM S tudy Root,  Study lev el C-FIND  DICOM to j ava mappin g set. (to  be used
  1311            *  for Query  Request D ataSet tra nslation.)
  1312            *  The mappi ng set is  hardcoded  for legacy  but queri ed from pe rsistence  mapping ta ble for RE
  1313            *  @return H ashSet con taining th e mapping  set: ("ggg g,eeee", v alue) for  legacy, (f ieldName,  value) oth erwise
  1314            * /
  1315           pr ivate Hash Set<DicomM ap> getFin dPropertyM appingSet( )
  1316           {
  1317                    // C reate the  HashSet
  1318                    Hash Set<DicomM ap> hashSe t = new Ha shSet<Dico mMap>();
  1319             
  1320                    //       feed s tatic tabl e for Stud y Root Stu dy level q uery (coul d be in M  persistenc e!!!!)
  1321                    hash Set.add(ne w MockDico mMap("0008 ,0020", nu ll, "Query Request",  "StudyDate ", 1)); //  DA -> Str ing
  1322                    hash Set.add(ne w MockDico mMap("0008 ,0030", nu ll, "Query Request",  "StudyDate ", 1)); //  TM -> Str ing(
  1323                    hash Set.add(ne w MockDico mMap("0008 ,0050", nu ll, "Query Request",  "Accession Number", 1 )); // SH  -> String( 16)
  1324           ha shSet.add( new MockDi comMap("00 08,0052",  null, "Que ryRequest" , "Level",  1)); // D A -> Strin g
  1325           ha shSet.add( new MockDi comMap("00 08,0061",  null, "Que ryRequest" , "Modalit ies in Stu dy", 1));  // DA -> S tring
  1326                    hash Set.add(ne w MockDico mMap("0010 ,0010", nu ll, "Query Request",  "Name", 1) ); // PN - > String(6 4)
  1327                    hash Set.add(ne w MockDico mMap("0010 ,0020", nu ll, "Query Request",  "PatientId ", 1)); //  LO -> Str ing(64)
  1328                    hash Set.add(ne w MockDico mMap("0020 ,0010", nu ll, "Query Request",  "StudyId",  1)); // S H -> Strin g(16)
  1329                    hash Set.add(ne w MockDico mMap("0020 ,000D", nu ll, "Query Request",  "StudyInst anceUID",  1)); // UI  -> String (64)
  1330                    hash Set.add(ne w MockDico mMap("0008 ,0090", nu ll, "Query Request",  "Referring PhysicianN ame", 1));  // PN ->  String(64)
  1331                    hash Set.add(ne w MockDico mMap("0008 ,1030", nu ll, "Query Request",  "Descripti on", 1));  // LO -> S tring(64)
  1332                    hash Set.add(ne w MockDico mMap("0008 ,1032", "0 008,0100",  "QueryReq uest", "Me dicalSpeci altyProced ureCode",  1)); // SQ /SH -> Str ing(16)
  1333                    hash Set.add(ne w MockDico mMap("0008 ,1032", "0 008,0102",  "QueryReq uest", "Co deSchemeDe signator",  1)); // S Q/SH -> St ring(16)
  1334                    hash Set.add(ne w MockDico mMap("0008 ,1032", "0 008,0103",  "QueryReq uest", "Co deSchemeVe rsion", 1) ); // SQ/S H -> Strin g(16)
  1335                    hash Set.add(ne w MockDico mMap("0008 ,1032", "0 008,0104",  "QueryReq uest", "Co deMeaning" , 1)); //  SQ/LO -> S tring(64)
  1336                    hash Set.add(ne w MockDico mMap("0008 ,1060", nu ll, "Query Request",  "ReadingPh ysician",   1)); // n *PN -> 5*S tring(64)
  1337                    hash Set.add(ne w MockDico mMap("0010 ,0030", nu ll, "Query Request",  "DateOfBir th", 1));  // DA -> S tring(15)
  1338                    hash Set.add(ne w MockDico mMap("0010 ,0032", nu ll, "Query Request",  "TimeOfBir th", 1));  // DA -> S tring(15)
  1339                    hash Set.add(ne w MockDico mMap("0010 ,0040", nu ll, "Query Request",  "Sex", 1)) ; // CS ->  String(1)
  1340                    hash Set.add(ne w MockDico mMap("0010 ,1000", nu ll, "Query Request",  "OtherPati entIds", 1 )); // LO  -> String( 64)
  1341                    hash Set.add(ne w MockDico mMap("0010 ,1001", nu ll, "Query Request",  "OtherPati entNames",  1)); // P N -> Strin g(64)
  1342                    hash Set.add(ne w MockDico mMap("0010 ,1010", nu ll, "Query Request",  "PatientAg e", 1)); / / AS -> St ring(4)
  1343                    hash Set.add(ne w MockDico mMap("0010 ,2160", nu ll, "Query Request",  "EthnicGro up", 1));  // SH -> S tring(16)
  1344                    hash Set.add(ne w MockDico mMap("0010 ,2180", nu ll, "Query Request",  "Occupatio n", 1)); / / SH -> St ring(16)
  1345                    hash Set.add(ne w MockDico mMap("0010 ,21B0", nu ll, "Query Request",  "adddition alPatientH istory", 1 )); // LT  -> String( 10240)
  1346                    hash Set.add(ne w MockDico mMap("0020 ,1206", nu ll, "Query Request",  "NumberOfS tudySeries ", 1)); //  IS -> Str ing(12)
  1347                    hash Set.add(ne w MockDico mMap("0020 ,1208", nu ll, "Query Request",  "NumberOfS tudyInstan ces", 1));  // IS ->  String(12)
  1348                    hash Set.add(ne w MockDico mMap("4008 ,010C", nu ll, "Query Request",  "Interpret attionAuth or", 1));  // PN -> S tring(64)
  1349                                      
  1350                    retu rn hashSet
  1351           }
  1352  
  1353           /* *
  1354            *  returns t he DICOM S tudy Root,  Study lev el C-MOVE  DICOM to j ava mappin g set. (to  be used
  1355            *  for Move  (Study) Da taSet tran slation.)
  1356            *  The mappi ng set is  hardcoded  for legacy  but queri ed from pe rsistence  mapping ta ble for RE
  1357            *  @return H ashSet con taining th e mapping  set: ("ggg g,eeee", v alue) for  legacy, (f ieldName,  value) oth erwise
  1358            * /
  1359           pr ivate Hash Set<DicomM ap> getMov ePropertyM appingSet( )
  1360           {
  1361           // FUTURE Nee d to find  out if thi s method e ven gets c alled.  I  do not thi nk so.  If  not,
  1362           //   remove i t.
  1363                             
  1364                    // C reate the  HashSet
  1365                    Hash Set<DicomM ap> hashSe t = new Ha shSet<Dico mMap>();
  1366  
  1367                    //       feed s tatic tabl e for lega cy Study R oot Study  level move  (could be  in M pers istence!!! !)
  1368                    hash Set.add(ne w MockDico mMap("0008 ,0052", nu ll, "MoveR equest", " Level", 1) ); // DA - > String
  1369                    hash Set.add(ne w MockDico mMap("0020 ,000D", nu ll, "MoveR equest", " InstanceUI D", 1)); / / UI -> St ring(64)                                      
  1370  
  1371                    retu rn hashSet ;
  1372           }
  1373           
  1374       privat e void san itizeHISCh anges(Hash Map<String , String>  HISChanges ){
  1375           //  1. if (00 32,1064) i s present  in HISchan ges and (0 008,1032)  is present  in the Da taSet,
  1376           //  copy (003 2,1064) to  (0008,103 2) in HIS  Changes
  1377           if  (HISChang es.contain sKey("0032 ,1064 0008 ,0100") &&  (dataSet. containsEl ement(DCM. E_PROCEDUR E_CODE_SEQ UENCE))) {
  1378                    Stri ng value =  (String)H ISChanges. get("0032, 1064 0008, 0100");
  1379                    HISC hanges.put ("0008,103 2 0008,010 0", value) ;
  1380                    valu e = (Strin g)HISChang es.get("00 32,1064 00 08,0102");
  1381                    HISC hanges.put ("0008,103 2 0008,010 2", value) ;
  1382                    valu e = (Strin g)HISChang es.get("00 32,1064 00 08,0104");
  1383                    HISC hanges.put ("0008,103 2 0008,010 4", value) ;
  1384           }
  1385       }
  1386       
  1387       privat e String f ormatStrin gValue(Str ing tag, S tring valu e){
  1388           St ring forma ttedValue  = value;
  1389           
  1390           tr y{
  1391                Attribut eTag dicom Tag = new  AttributeT ag(tag);
  1392                short vr  = DicomDa taDictiona ry.getElem entVR(dico mTag);
  1393                String v m = DicomD ataDiction ary.getEle mentVM(dic omTag);
  1394                if(value  == null){
  1395                    retu rn value;
  1396                }
  1397                
  1398                if(vr ==  DicomData Dictionary .getVR("PN ")){
  1399                    //Ch eck if ele ment allow s for mult iple value s.
  1400                    if(v m.equals(" 1")){
  1401                         //If only  1 value al lowed, str ip off eve rything el se.
  1402                         String[] v alues  = v alue.split ("\\\\", 2 );
  1403                         formattedV alue = val ues[0];
  1404                    }
  1405                    else {
  1406                         formattedV alue = val ue;
  1407                    }
  1408                    //Co nvert comm as to cara ts to meet  DICOM sta ndard.
  1409                    form attedValue  = formatt edValue.re place(',',  '^');
  1410                }
  1411                else{
  1412                    form attedValue  = value;
  1413                }
  1414           }
  1415           ca tch(DCSExc eption dcs e){
  1416                logger.w arn(this.g etClass(). getName()+ ": Warning  thrown wh ile format ting Strin g Value.") ;
  1417                return v alue;
  1418           }
  1419           re turn forma ttedValue;
  1420       }
  1421       
  1422           pr ivate Stri ng getStri ngValueFro mElement(S tring tagN ame, Strin g defaultV alue)
  1423           {
  1424                    Stri ng value =  "";
  1425                    try
  1426                    {
  1427                             // Ext ract value s from DIC OM data se t
  1428                             value  = dataSet. getElement StringValu e(new Attr ibuteTag(t agName), d efaultValu e);
  1429                             if ((v alue!=null ) && !valu e.isEmpty( ))
  1430                                      value =  value.trim (); // tak e out lead ing and tr ailing whi tespaces
  1431                    }
  1432                    catc h (DCSExce ption dcse
  1433                    {
  1434                logger.w arn(dcse.g etMessage( )+ "; Defa ultValue ( " + ((defa ultValue== null)?"nul l":default Value) + " ) used.");
  1435                return d efaultValu e;
  1436                    }
  1437                    
  1438                    retu rn removeC ontrolChar acters(val ue);
  1439           }
  1440           
  1441           //  This code  replaces  the loop o ver each c har found  in the ori ginal code ...
  1442           pr ivate Stri ng removeC ontrolChar acters(Str ing string ToClean)
  1443           {
  1444                    Stri ng CONTROL _CHARACTER _REGEX = " \\p{Cntrl} ";
  1445                    
  1446                    if ( stringToCl ean != nul l)
  1447                    {
  1448                             return  stringToC lean.repla ceAll(CONT ROL_CHARAC TER_REGEX,  "");
  1449                    }
  1450                    else
  1451                    {
  1452                             return  null;
  1453                    }
  1454           }
  1455  
  1456           pu blic boole an isRadia tionDoseSt ructuredRe port() 
  1457           {
  1458                    retu rn getSOPC lass().equ als(RADIAT ION_DOSE_S OP_CLASS_U ID);
  1459           }
  1460  
  1461           pu blic List< Dose> getD ose() 
  1462           {
  1463                    RDSR Processor  processor  = new RDSR Processor( this);
  1464                    
  1465                    retu rn process or.getDose (getSOPIns tance());
  1466           }
  1467  
  1468   }