269. EPMO Open Source Coordination Office Redaction File Detail Report

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

269.1 Files compared

# Location File Last Modified
1 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\ImagingDicomDCFCommon\src\java\gov\va\med\imaging\dicom\dcftoolkit\common\impl DicomDataSetImpl.java Mon Dec 4 21:35:26 2017 UTC
2 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\ImagingDicomDCFCommon\src\java\gov\va\med\imaging\dicom\dcftoolkit\common\impl DicomDataSetImpl.java Mon Dec 4 22:02:20 2017 UTC

269.2 Comparison summary

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

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

269.4 Active regular expressions

No regular expressions were active.

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