62. EPMO Open Source Coordination Office Redaction File Detail Report

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

62.1 Files compared

# Location File Last Modified
1 MHV_2017.2.0.0 Code In Flight.zip\Secure Messaging\mhv-sm-admin\src\main\java\gov\va\med\mhv\sm\web\actions ManageStaff.java Fri Feb 10 18:58:26 2017 UTC
2 MHV_2017.2.0.0 Code In Flight.zip\Secure Messaging\mhv-sm-admin\src\main\java\gov\va\med\mhv\sm\web\actions ManageStaff.java Fri Mar 24 18:29:32 2017 UTC

62.2 Comparison summary

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

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

62.4 Active regular expressions

No regular expressions were active.

62.5 Comparison detail

  1   package go v.va.med.m hv.sm.web. actions;
  2  
  3   import gov .va.med.mh v.foundati on.service .response. Collection ServiceRes ponse;
  4   import gov .va.med.mh v.foundati on.service .response. ServiceRes ponse;
  5   import gov .va.med.mh v.sm.ad.AD QueryResul t;
  6   import gov .va.med.mh v.sm.dao.U serDao;
  7   import gov .va.med.mh v.sm.model .Administr ator;
  8   import gov .va.med.mh v.sm.model .ClinicalU serType;
  9   import gov .va.med.mh v.sm.model .Clinician ;
  10   import gov .va.med.mh v.sm.model .Facility;
  11   import gov .va.med.mh v.sm.servi ce.UserMan agementSer vice;
  12   import gov .va.med.mh v.sm.wscli ent.adminq ueriessvc. User;
  13  
  14   import jav a.io.File;
  15   import jav a.io.Input Stream;
  16   import jav a.io.Input StreamRead er;
  17   import jav a.io.Reade r;
  18   import jav a.util.Arr ayList;
  19   import jav a.util.Col lection;
  20   import jav a.util.Has hMap;
  21   import jav a.util.Lis t;
  22   import jav a.util.Map ;
  23   import jav a.util.Tre eSet;
  24  
  25   import org .apache.co mmons.lang .StringUti ls;
  26   import org .apache.co mmons.logg ing.Log;
  27   import org .apache.co mmons.logg ing.LogFac tory;
  28   import org .apache.co mmons.vali dator.Emai lValidator ;
  29   import org .apache.st ruts2.Serv letActionC ontext;
  30   import org .springfra mework.web .context.W ebApplicat ionContext ;
  31   import org .springfra mework.web .context.s upport.Web Applicatio nContextUt ils;
  32  
  33   import com .opensymph ony.xwork2 .Preparabl e;
  34  
  35   public cla ss ManageS taff exten ds BaseSMA dminAction  implement s Preparab le {
  36  
  37           @S uppressWar nings("unu sed")
  38           pr ivate stat ic final L og log = L ogFactory. getLog(Man ageStaff.c lass);
  39  
  40           pr ivate stat ic final S tring CANC EL = "canc el";
  41           pr ivate stat ic final S tring FAIL ED = "fail ed";
  42           pr ivate stat ic final S tring SELE CT_STAFF =  "selectSt aff";
  43           pr ivate stat ic final S tring QUER Y_RESULTS_ IR = "quer yResults_I R";
  44           pr ivate stat ic final S tring BULK _ACTIVATIO N = "bulkA ctivation" ;
  45           pr ivate User Management Service us erManageme ntService;
  46           pr ivate User Dao userDa o;
  47           pr ivate Coll ection<Fac ility> vis ns;
  48           pr ivate Coll ection<Fac ility> fac ilities;
  49           pr ivate Long  visnId;
  50           pr ivate Long  facilityI d;
  51           pr ivate Stri ng selecte dVisnName;
  52           pr ivate Stri ng selecte dFacilityN ame;
  53           pr ivate List <Clinician > clinicia ns;
  54           pr ivate List <Clinician > selected Users;
  55           pr ivate List <ClinicalU serType> s taffMember Types;
  56           // private Ht tpServletR equest req uest;
  57           pr ivate Stri ng searchC rit;
  58           pr ivate Stri ng emailAD ;
  59           pr ivate Stri ng firstNa me;
  60           pr ivate Stri ng lastNam e;
  61           pr ivate Stri ng middleN ame;
  62           pr ivate Stri ng duz;
  63           pr ivate Stri ng phone;
  64           pr ivate Stri ng title;
  65           pr ivate Stri ng email;
  66           pr ivate Stri ng suffix;
  67           pr ivate Stri ng prefix;
  68           pr ivate Stri ng activeF lag;
  69           pr ivate Stri ng network Id;
  70           pr ivate Long  memberTyp eId;
  71           pr ivate Stri ng memberT ype;
  72           pr ivate Stri ng firstNa meAD;
  73           pr ivate Stri ng lastNam eAD;
  74           pr ivate Stri ng phoneAD ;
  75           pr ivate Stri ng titleAD ;
  76           pr ivate Stri ng network IdAD;
  77           pr ivate Stri ng selectA ction;
  78           //  File uplo ad info fo r bulk act ivation
  79           pr ivate File  upload;
  80       privat e String u ploadConte ntType;
  81       privat e String u ploadFileN ame;
  82       privat e int adde d; // numb er of bulk  load staf f members  activated.
  83       privat e static S tring FILE _SIZE_LIMI T_ERROR =  "The file  you are tr ying to up load excee ds the 2MB  limit. "  +
  84                                                                                            "Please r educe the  file size  and try ag ain.";
  85       privat e static i nt FILE_SI ZE_LIMIT_2 MB = 2 * 1 024 * 1024 ;
  86           pu blic Manag eStaff() {
  87                    supe r();
  88           }
  89  
  90  
  91           pu blic void  prepare()  throws Exc eption {
  92                    supe r.prepare( );
  93                    WebA pplication Context ct x = WebApp licationCo ntextUtils
  94                                      .getWebA pplication Context(Se rvletActio nContext
  95                                                       .g etServletC ontext());
  96                    user Management Service =  (UserManag ementServi ce) ctx.ge tBean("use rManagemen tService") ;
  97  
  98  
  99                    user Dao = (Use rDao) ctx. getBean("u serDao");
  100           }
  101  
  102  
  103           pu blic Strin g manageSt affMembers () {
  104  
  105                    clea rSessionAt tr();
  106  
  107                    retu rn SUCCESS ;
  108           }
  109  
  110           pu blic Strin g selectEn tryMethod( ) {
  111  
  112                    if(a ppliedCanc el()){ ret urn CANCEL ;     }
  113                    clea rSessionAt tr();
  114                    faci lities = n ew TreeSet <Facility> ();
  115  
  116                    if(( selectActi on != null ) && (sele ctAction.e qualsIgnor eCase("Ina ctivate a  Staff Memb er"))){
  117                             setSes sionAttrib ute("activ ationType" ,"inactiva te");
  118                             return  SELECT_ST AFF;
  119                    }
  120                    if(( selectActi on != null ) && (sele ctAction.e qualsIgnor eCase("Rea ctivate a  Staff Memb er"))){
  121                             setSes sionAttrib ute("activ ationType" ,"reactiva te");
  122                             return  SELECT_ST AFF;
  123                    }
  124                    retu rn SUCCESS ;
  125           }
  126  
  127  
  128           pu blic Strin g selectSe archCrit()  {
  129  
  130                    if(a ppliedCanc el()){ ret urn CANCEL ;     }
  131                    clea rSessionAt tr();
  132                    faci lities = n ew TreeSet <Facility> ();
  133                    if(( selectActi on != null ) && ((sel ectAction. trim()).eq ualsIgnore Case("Bulk  Activatio n from CSV  File"))){
  134                             return  BULK_ACTI VATION;
  135                    }
  136  
  137                    retu rn SUCCESS ;
  138           }
  139  
  140  
  141           pu blic Strin g selectVi sn(){
  142  
  143                    getS taffSessio nAttr();
  144  
  145                    if(v isnId == - 1L){
  146                             addAct ionError(" Please sel ect a VISN .");
  147                             return  SELECT_ST AFF;
  148                    }
  149  
  150                    for( Facility v : getAdmin isteredVis ns()){
  151                             if(v.g etId().equ als(visnId )){
  152                                      selected VisnName =  v.getName ();
  153                                      faciliti es = getAd ministered Facilities InVisn(v);
  154                             }
  155                    }
  156  
  157                    if(S tringUtils .isBlank(s electedVis nName)){
  158                             addAct ionError(" Please sel ect a VISN .");
  159                             return  SELECT_ST AFF;
  160                    }
  161  
  162                    setS essionAttr ibute("fac ilities",f acilities) ;
  163                    setS essionAttr ibute("sel ectedVisnN ame",selec tedVisnNam e);
  164  
  165                    retu rn SELECT_ STAFF;
  166  
  167           }
  168  
  169           pu blic Strin g selectFa cility(){
  170  
  171                    getS taffSessio nAttr();
  172  
  173                    // i f the visn  hasn't be en selecte d first
  174                    if(S tringUtils .isBlank(s electedVis nName)){
  175                             addAct ionError(" Please sel ect a VISN .");
  176                             return  SELECT_ST AFF;
  177                    }
  178  
  179                    // m ake sure a  facility  has been c hosen
  180                    if(f acilityId  == -1){
  181                             addAct ionError(" Please sel ect a Faci lity.");
  182                             return  SELECT_ST AFF;
  183                    }
  184  
  185                    Stri ng station Number = n ull;
  186  
  187                    if(f acilities  != null){
  188                             for(Fa cility f:  facilities ){
  189                                      if(f.get Id().equal s(facility Id)){
  190                                               selectedFa cilityName  = f.getNa me();
  191                                               stationNum ber = f.ge tStationNu mber();
  192                                      }
  193                             }
  194                    }
  195  
  196                    setS essionAttr ibute("sel ectedFacil ityName",s electedFac ilityName) ;
  197                    setS essionAttr ibute("sta tionNumber ",stationN umber);
  198  
  199                    retu rn SELECT_ STAFF;
  200           }
  201  
  202           pu blic Strin g searchSt affMembers () {
  203                    if(a ppliedCanc el()){ ret urn CANCEL ;     }
  204  
  205                    getS taffSessio nAttr();
  206                    if(S tringUtils .isBlank(s electedVis nName)){
  207                             addAct ionError(" Please sel ect a VISN .");
  208                             return  SELECT_ST AFF;
  209                    }
  210  
  211                    if(S tringUtils .isBlank(s electedFac ilityName) ){
  212                             addAct ionError(" Please sel ect a Faci lity.");
  213                             return  SELECT_ST AFF;
  214                    }
  215  
  216  
  217                    List <User> sta ffMembers=  new Array List<User> ();
  218                    clin icians = n ew ArrayLi st<Clinici an>();
  219                    Clin ician clin  = null;
  220                    Stri ng station Number = n ull;
  221                    faci lities = n ew TreeSet <Facility> ();
  222  
  223                    getS taffSessio nAttr();
  224                    Stri ng activat ionType =  null;
  225  
  226                    if(( (String)ge tSessionAt tribute("a ctivationT ype")) !=  null){
  227                             activa tionType =  (String)g etSessionA ttribute(" activation Type");
  228                    }
  229                    if(( (String)ge tSessionAt tribute("s tationNumb er")) != n ull){
  230                             statio nNumber =  (String)ge tSessionAt tribute("s tationNumb er");
  231                    }
  232  
  233                    if(( selectActi on != null ) && (sele ctAction.e qualsIgnor eCase("Sea rch"))){
  234  
  235                             if(sea rchCrit ==  null){
  236                                      addActio nError("Pl ease selec t a radio  button.");
  237                                      return S ELECT_STAF F;
  238                             }
  239                             if(sta tionNumber  == null){
  240                                      log.info ("selected VisnName:   " + selec tedVisnNam e);
  241                                      if(Strin gUtils.isB lank(selec tedVisnNam e)){
  242                                               addActionE rror("Plea se select  a VISN.");
  243                                               return SEL ECT_STAFF;
  244                                      }else{
  245                                               addActionE rror("Plea se select  a facility .");
  246                                               return SEL ECT_STAFF;
  247                                      }
  248                             }
  249                             log.in fo("statio nNumber: "  + station Number);
  250                             try{
  251                                      if(searc hCrit.equa lsIgnoreCa se("0")){
  252                                               if((lastNa me == null ) || ((las tName.trim ()).equals (""))){
  253                                                       ad dActionErr or("Please  enter the  last Name  and selec t the 'Sea rch by Nam e' radio b utton.");
  254                                                       re turn SELEC T_STAFF;
  255                                               }
  256                                               log.info(" last name: " + lastNa me.toStrin g());
  257                                               if((firstN ame == nul l) || ((fi rstName.tr im()).equa ls(""))){f irstName =  null;}
  258  
  259                                               if(firstNa me !=null)  firstName  = firstNa me.trim();
  260                                               if(lastNam e !=null)  lastName =  lastName. trim();
  261  
  262                                               if((activa tionType ! = null) &&  (activati onType.equ alsIgnoreC ase("inact ivate"))){
  263                                                       cl inicians =  (List<Cli nician>) u serManagem entService .searchFor Clinicians (firstName , lastName , stationN umber, tru e).getColl ection();
  264                                               }else if(( activation Type != nu ll) && (ac tivationTy pe.equalsI gnoreCase( "reactivat e"))){
  265                                                       cl inicians =  (List<Cli nician>) u serManagem entService .searchFor Clinicians (firstName , lastName , stationN umber, fal se).getCol lection();
  266                                               }else{
  267                                                       Co llectionSe rviceRespo nse<User>  response =  getAdminS ervice().f indVistaCl inician(la stName, fi rstName, s tationNumb er);
  268                                                       ha ndleErrorM essages(re sponse.get Messages() );
  269                                                       st affMembers  = (List<U ser>)respo nse.getCol lection();
  270  
  271                                                       Li st userMan agementSta ffMembers  = (List<Cl inician>)  userManage mentServic e.searchFo rClinician s(firstNam e, lastNam e, station Number).ge tCollectio n();
  272  
  273                                                       if (staffMemb ers == nul l){
  274                                                                addA ctionError ("A search  of the Vi stA databa se did not  produce a  match for  the infor mation giv en.");
  275                                                                retu rn SELECT_ STAFF;
  276                                                       }
  277                                                       st affMembers  = filterS taffMember s(staffMem bers,userM anagementS taffMember s);
  278                                               }
  279                                      }else{
  280                                               if((duz ==  null) ||  ((duz.trim ()).equals (""))){
  281                                               addActionE rror("Plea se enter D UZ and sel ect 'Searc h by DUZ'  radio butt on");
  282                                               return SEL ECT_STAFF;
  283                                               }
  284                                               log.info(" duz:" + du z.toString ());
  285  
  286                                               if(duz !=n ull) duz=d uz.trim();
  287                                               if((activa tionType ! = null) &&  (activati onType.equ alsIgnoreC ase("inact ivate"))){
  288                                                       Se rviceRespo nse<Clinic ian> respo nse = user Management Service.ge tClinician ForStation AndDuz(sta tionNumber , duz, tru e);
  289                                                       cl in = respo nse.getPay load();
  290                                               }else if(( activation Type != nu ll) && (ac tivationTy pe.equalsI gnoreCase( "reactivat e"))){
  291                                                       Se rviceRespo nse<Clinic ian> respo nse = user Management Service.ge tClinician ForStation AndDuz(sta tionNumber , duz, fal se);
  292                                                       cl in = respo nse.getPay load();
  293  
  294                                               }else{
  295                                                       Co llectionSe rviceRespo nse<User>  response =  getAdminS ervice().f indVistaCl inician(du z, station Number);
  296                                                       ha ndleErrorM essages(re sponse.get Messages() );
  297                                                       st affMembers  = (List<U ser>)respo nse.getCol lection();
  298                                                       Cl inician cl inician =   userDao.f indAuthCli nicianBySt ationAndDu z(stationN umber,duz) ;
  299                                                       Ar rayList<Cl inician> u serManagem entStaffMe mbers = ne w ArrayLis t<Clinicia n>();
  300                                                       if (clinician  !=null)
  301                                                                user Management StaffMembe rs.add(cli nician);
  302  
  303                                                       if (staffMemb ers == nul l){
  304                                                                addA ctionError ("A search  of the Vi stA databa se did not  produce a  match for  the infor mation giv en.");
  305                                                       }
  306                                                       if (userManag ementStaff Members.si ze()!=0)
  307                                                                staf fMembers =  filterSta ffMembers( staffMembe rs,userMan agementSta ffMembers) ;
  308                                               }
  309  
  310                                               if(clin!=n ull){
  311                                                       cl inicians.a dd(clin);
  312                                                       }
  313                                               }
  314  
  315                             }catch (Exception  e){
  316                                      log.erro r( e.getMe ssage() );
  317                                      addActio nError("An  error occ urred whil e finding  the users. ");
  318                             }
  319  
  320                             setSes sionAttrib ute("staff Members",s taffMember s);
  321                             setSes sionAttrib ute("clini cians",cli nicians);
  322  
  323  
  324                             if((ac tivationTy pe != null ) && ((act ivationTyp e.equalsIg noreCase(" inactivate ")) || (ac tivationTy pe.equalsI gnoreCase( "reactivat e")))){
  325                                      return Q UERY_RESUL TS_IR;
  326                             }
  327  
  328                             return  SUCCESS;
  329  
  330                    }
  331  
  332                    try{
  333                             String  cf = getP arameter(" changeFaci lity");
  334                             if(!St ringUtils. isBlank(cf ) && cf.eq ualsIgnore Case("yes" )){
  335                                      selected FacilityNa me = null;
  336                             }
  337                    }cat ch(Excepti on e){
  338                             log.in fo("Except ion occurr ed in chan geFacility ");
  339                    }
  340  
  341                    retu rn SELECT_ STAFF;
  342           }
  343  
  344           /* *
  345            *  filteredS tffMembers
  346            *  @param vi staStaffMe mbers
  347            *  @param us erManageme ntStaffMem bers
  348            *  @return L ist<User>
  349            * /
  350           pr ivate List <User> fil terStaffMe mbers(List <User> vis taStaffMem bers,List< Clinician>  userManag ementStaff Members){
  351  
  352                    Arra yList<User > filtered StaffMembe rs = new A rrayList<U ser>();
  353                    Arra yList<Stri ng> active Clinicians  = new Arr ayList<Str ing>();
  354                    for( Clinician  clinician: userManage mentStaffM embers){
  355                             if(cli nician.get Duz()!=nul l){
  356                                      activeCl inicians.a dd(clinici an.getDuz( ));
  357                             }
  358                    }
  359                    for( User user: vistaStaff Members){
  360                             if(!ac tiveClinic ians.conta ins(user.g etIEN())){
  361                                      filtered StaffMembe rs.add(use r);
  362                             }
  363                    }
  364                    retu rn filtere dStaffMemb ers;
  365           }
  366  
  367           pu blic Strin g associat eNetworkId (){
  368  
  369                    if(a ppliedCanc el()){ ret urn CANCEL ;     }
  370                    User  selectedV istaUser =  null;
  371                    try{
  372                             duz =  (getParame ter("ien")  == null)? "":getPara meter("ien ");
  373                             if(duz  == null){
  374                                      addActio nError("Co uld not fi nd IEN for  the selec ted user." );
  375                             }
  376                             List<U ser> searc hedUsers =  (List<Use r>)getSess ionAttribu te("staffM embers");
  377                             if(sea rchedUsers  != null){
  378                                      for(User  u:searche dUsers){
  379                                               if(duz.equ alsIgnoreC ase(u.getI EN())){
  380                                                       se lectedVist aUser = u;
  381                                               }
  382                                      }
  383                             }
  384                             setSes sionAttrib ute("selec tedVistaUs er",select edVistaUse r);
  385                             setSes sionAttrib ute("duz", duz);
  386                             getUse rInformati on();
  387                    }cat ch(Excepti on e){
  388                             log.in fo("Except ion occurr ed while g etting sel ected user  details." );
  389                    }
  390  
  391                    retu rn SUCCESS ;
  392           }
  393           
  394           pu blic void  getUserInf ormation() {
  395                    User  selectedV istAUser =  (User)get SessionAtt ribute("se lectedVist aUser");
  396                    Syst em.out.pri ntln("Sess ion=>Selec tedVistAUs er"+getSes sion().get Attribute( "selectedV istaUser") );
  397                    Syst em.out.pri ntln("sele ctedVistAU ser...."+s electedVis tAUser);
  398                    if(s electedVis tAUser!=nu ll){
  399                             System .out.print ln("select edVistAUse r111...."+ selectedVi stAUser);
  400                             firstN ame = (sel ectedVistA User.getFi rstName()  == null)?" ":selected VistAUser. getFirstNa me();
  401                             lastNa me = (sele ctedVistAU ser.getLas tName() ==  null)?"": selectedVi stAUser.ge tLastName( );
  402                             middle Name = (se lectedVist AUser.getM iddleName( ) == null) ?"":select edVistAUse r.getMiddl eName();
  403                             title  = (selecte dVistAUser .getTitle( ) == null) ?"":select edVistAUse r.getTitle ();
  404                             phone  = (selecte dVistAUser .getPhone( ) == null) ?"":select edVistAUse r.getPhone ();
  405                             duz =  (selectedV istAUser.g etIEN() ==  null)?"": selectedVi stAUser.ge tIEN();
  406                             suffix  = (select edVistAUse r.getSuffi x() == nul l)?"":sele ctedVistAU ser.getSuf fix();
  407                             prefix  = (select edVistAUse r.getPrefi x() == nul l)?"":sele ctedVistAU ser.getPre fix();
  408                             active Flag = (se lectedVist AUser.getA ctiveFlag( ) == null) ?"":select edVistAUse r.getActiv eFlag();
  409                    }
  410           }
  411  
  412           pu blic Strin g verifyWi thADResult s(){
  413                    getU serInforma tion();
  414                    if(a ppliedCanc el()){ ret urn CANCEL ;     }
  415  
  416                    getS taffSessio nAttr();
  417  
  418                    if(i sNewSearch ()){ retur n SELECT_S TAFF; }
  419  
  420                    if(( networkId  == null) | | ((networ kId.trim() ).equals(" "))){
  421                             addAct ionError(" Please ent er the Net work ID.") ;
  422                             return  FAILED;
  423                    }
  424  
  425                    Stri ng station Number = n ull;
  426                    if(( (String)ge tSessionAt tribute("s tationNumb er")) != n ull){
  427                             statio nNumber =  (String)ge tSessionAt tribute("s tationNumb er");
  428                    }
  429  
  430                    if ( stationNum ber == nul l) {
  431                             addAct ionError(" Please sel ect a faci lity.");
  432                             return  SELECT_ST AFF;
  433                    }
  434  
  435                    Clin ician exis tingClinic ian = user Dao.findCl inicianByS tationAndU sername(st ationNumbe r, network Id);
  436                    if ( existingCl inician !=  null) {
  437                             addAct ionError(" Network ID  " +
  438                                                           networkId  +
  439                                                           " is alre ady in use  at this s tation by  " +
  440                                                           (existing Clinician. isActive()  ? "active " : "inact ive") +
  441                                                           " staff m ember " +
  442                                                           existingC linician.g etName());
  443                             return  FAILED;
  444                    }
  445  
  446                    ADQu eryResult  staffADRes ults = nul l;
  447                    firs tNameAD =  "";
  448                    last NameAD = " ";
  449                    phon eAD = "";
  450                    titl eAD = "";
  451                    netw orkIdAD =  "";
  452                    emai lAD = "";
  453                    try{
  454                             log.in fo("findAD Account -  networkId: " + networ kId.toStri ng());
  455                             Servic eResponse< ADQueryRes ult> respo nse = getA dminServic e().findAD Account(ne tworkId);
  456                             staffA DResults =  response. getPayload ();
  457                             if(sta ffADResult s == null) {
  458                                      log.info ("AD Resul ts: Null") ;
  459                                      addActio nError("An  Email Add ress could  not be fo und in Out look using  the VistA  search re sults.");
  460                                      return F AILED;
  461                             }else{
  462  
  463                                      firstNam eAD = (sta ffADResult s.getFirst Name() ==  null)?"":s taffADResu lts.getFir stName();
  464                                      lastName AD = (staf fADResults .getLastNa me() == nu ll)?"":sta ffADResult s.getLastN ame();
  465                                      phoneAD  = (staffAD Results.ge tTelephone Number() = = null)?"" :staffADRe sults.getT elephoneNu mber();
  466                                      titleAD  = (staffAD Results.ge tTitle() = = null)?"" :staffADRe sults.getT itle();
  467                                      emailAD  = (staffAD Results.ge tEmail() = = null)?"" :staffADRe sults.getE mail();
  468                                      setSessi onAttribut e("email", emailAD);
  469                                      networkI dAD = netw orkId;
  470                                      this.set Email(emai lAD);
  471                                      staffADR esults.set UserName(n etworkId);
  472                             }
  473                    }cat ch(Excepti on e){
  474                             log.er ror( e.get Message()  );
  475                             addAct ionError(" Error occu rred while  accessing  the activ e director y.");
  476                    }
  477  
  478                    setS essionAttr ibute("sta ffADResult s",staffAD Results);
  479  
  480                    retu rn SUCCESS ;
  481           }
  482  
  483           pu blic Strin g assignSt affMemberT ype(){
  484  
  485  
  486                    if(a ppliedCanc el()){ ret urn CANCEL ;     }
  487                    getU serInforma tion();
  488                    getS taffSessio nAttr();
  489  
  490                    if(i sNewSearch ()){ retur n SELECT_S TAFF; }
  491                    duz  = (String) getSession Attribute( "duz");
  492                    staf fMemberTyp es = (List <ClinicalU serType>)g etAdminSer vice().get ClinicalUs erTypes(). getCollect ion();
  493                    retu rn SUCCESS ;
  494           }
  495  
  496           pu blic Strin g activate StaffMembe r(){
  497  
  498                    if(a ppliedCanc el()){ ret urn CANCEL ;     }
  499  
  500                    getS taffSessio nAttr();
  501  
  502                    if(i sNewSearch ()){ retur n SELECT_S TAFF; }
  503  
  504                    Clin icalUserTy pe clinica lUserType  = null;
  505                    bool ean userTy peSelected  = false;
  506                    duz  = (String) getSession Attribute( "duz");
  507                    Stri ng station Number = ( String)get SessionAtt ribute("st ationNumbe r");
  508                    User  selectedV istaUser =  (User)get SessionAtt ribute("se lectedVist aUser");
  509                    ADQu eryResult  adr = (ADQ ueryResult )getSessio nAttribute ("staffADR esults");
  510  
  511                    staf fMemberTyp es = (List <ClinicalU serType>)g etAdminSer vice().get ClinicalUs erTypes(). getCollect ion();
  512                    if(s taffMember Types != n ull){
  513                             for(Cl inicalUser Type cu: s taffMember Types){
  514                                      if((cu.g etId()).eq uals(membe rTypeId)){
  515                                               clinicalUs erType = c u;
  516                                               memberType  = cu.getN ame();
  517                                               userTypeSe lected = t rue;
  518                                      }
  519                             }
  520                    }
  521                    if(! userTypeSe lected){
  522                             addAct ionError(" Please sel ect a user  type.");
  523                             setSes sionAttrib ute("email ",getEmail ());
  524                             return  FAILED;
  525                    }
  526  
  527                    // T he followi ng conditi on has bee n implemen ted for th e part of  CR#4652(Cl inician mu st have va lid email  address).
  528                    if(g etEmail()= =null || g etEmail(). equals("") ){
  529                             addAct ionError(" Email Addr ess cannot  be blank. ");
  530                             return  FAILED;
  531                    }
  532                    else
  533                    {
  534                             EmailV alidator e mailValida tor = Emai lValidator .getInstan ce();
  535                             if(!em ailValidat or.isValid (email)){
  536                                      addActio nError(ema il + " is  not a Vali d Email Ad dress.");
  537                                      setEmail (getEmail( ));
  538                                      setSessi onAttribut e("email", getEmail() );
  539                                      return F AILED;
  540                             }
  541                             else
  542                             {
  543                                      adr.setE mail(getEm ail());
  544                                      setSessi onAttribut e("email", getEmail() );
  545                             }
  546                    }
  547  
  548                    Admi nistrator  admin = (A dministrat or)getSess ionAttribu te(CURRENT _USER);
  549                    Clin ician clin  = null;
  550  
  551                    try{
  552                             if (lo g.isInfoEn abled())
  553                                      log.info (selectedV istaUser.g etFirstNam e()+" "+se lectedVist aUser.getL astName()+ " "+select edVistaUse r.getProvi derIndicat or());
  554                             Servic eResponse< Clinician>  response  = getAdmin Service(). createClin icianAccou nt(station Number, se lectedVist aUser, adr ,clinicalU serType, a dmin);
  555                             clin =  response. getPayload ();
  556  
  557                    }cat ch(Excepti on e){
  558                             log.er ror( e.get Message()  );
  559  
  560                    }
  561  
  562                    if ( clin == nu ll){
  563                             addAct ionError(" Error occu rred while  activatin g the acco unt.");
  564                             return  FAILED;
  565                    }
  566                    getU serInforma tion();
  567                    retu rn SUCCESS ;
  568           }
  569  
  570           pu blic Strin g activate AnotherSta ffMember() {
  571  
  572                    if(( selectActi on!=null)  && ((selec tAction.tr im()).equa lsIgnoreCa se("Done") )){
  573                             clearS essionAttr ();
  574                             return  CANCEL;
  575                    }
  576                    getS taffSessio nAttr();
  577  
  578                    retu rn SELECT_ STAFF;
  579           }
  580  
  581  
  582           pu blic Strin g showMemb erDetails( ){
  583  
  584                    if(a ppliedCanc el()){ ret urn CANCEL ;     }
  585                    Clin ician clin  = null;
  586                    try{
  587                             duz =  (getParame ter("duz")  == null)? "":getPara meter("duz ");
  588                             if(duz  == null){
  589                                      addActio nError("Co uld not fi nd DUZ for  the selec ted user." );
  590                             }
  591                             List<C linician>  searchedUs ers = (Lis t<Clinicia n>)getSess ionAttribu te("clinic ians");
  592                             if(sea rchedUsers  != null){
  593                                      for(Clin ician u:se archedUser s){
  594                                               if(duz.equ alsIgnoreC ase(u.getD uz())){
  595                                                       cl in = u;
  596                                               }
  597                                      }
  598                             }
  599                             if(cli n != null) {
  600                                      firstNam e = (clin. getFirstNa me() == nu ll)?"":cli n.getFirst Name();
  601                                      lastName  = (clin.g etLastName () == null )?"":clin. getLastNam e();
  602                                      networkI d = (clin. getUsernam e() == nul l)?"":clin .getUserna me();
  603                                      middleNa me = (clin .getMiddle Name() ==  null)?"":c lin.getMid dleName();
  604                                      title =  (clin.getT itle() ==  null)?"":c lin.getTit le();
  605                                      phone =( clin.getPh one() == n ull)?"":cl in.getPhon e(); 
  606                                      suffix =  (clin.get Suffix() = = null)?"" :clin.getS uffix();
  607                                      prefix = (clin.getP refix() ==  null)?"": clin.getPr efix();
  608                                      activeFl ag = (clin .getDiUser () == null )?"":clin. getDiUser( );
  609                                      Clinical UserType c u = (Clini calUserTyp e)clin.get ClinicalUs erType();
  610                                      if(cu !=  null){
  611                                               memberType  = (cu.get Name() ==  null)?"":c u.getName( );
  612                                      }
  613                             }
  614                             setSes sionAttrib ute("selec tedUser",c lin);
  615                             setSes sionAttrib ute("duz", duz);
  616                    }cat ch(Excepti on e){
  617                             log.in fo("Except ion occurr ed while g etting sel ected user  details." );
  618                    }
  619  
  620                    retu rn SUCCESS ;
  621  
  622           }
  623  
  624  
  625           pu blic Strin g inactiva teReactiva teMember() {
  626  
  627                    if(a ppliedCanc el()){ ret urn CANCEL ;     }
  628  
  629                    getS taffSessio nAttr();
  630  
  631                    if(i sNewSearch ()){ retur n SELECT_S TAFF; }
  632                    Stri ng activat ionType =  (String)ge tSessionAt tribute("a ctivationT ype");
  633                    try  {
  634                             Clinic ian c = (C linician)g etSessionA ttribute(" selectedUs er");
  635                             if(c ! = null){
  636                                      if((acti vationType  != null)  && (activa tionType.e qualsIgnor eCase("ina ctivate")) ){
  637                                               c = (Clini cian) user Management Service.in activateRe activateCl inician(c,  false).ge tPayload() ;
  638                                      }else if ((activati onType !=  null) && ( activation Type.equal sIgnoreCas e("reactiv ate"))){
  639                                               c = (Clini cian) user Management Service.in activateRe activateCl inician(c,  true).get Payload();
  640                                      }
  641                             }
  642                    } ca tch (Excep tion e) {
  643                             log.in fo("Except ion occurr ed while i nactivatin g the sele cted user. ");
  644                             addAct ionError(" Error occu rred while  inactivat ing the se lected use r.");
  645                    }
  646  
  647                    retu rn SUCCESS ;
  648  
  649           }
  650  
  651           pu blic Strin g inactiva tionReacti vationComp lete(){
  652  
  653                    clea rSessionAt tr();
  654                    retu rn CANCEL;
  655  
  656           }
  657  
  658           pu blic Strin g bulkActi vation() {
  659                    if(a ppliedCanc el()){ ret urn CANCEL ;     }
  660                    clea rSessionAt tr();
  661                    List <User> sta ffMembers=  new Array List<User> ();
  662                    bool ean activa tionSucces s = true;
  663                    try{
  664  
  665                             log.in fo("file n ame: " + u ploadFileN ame);
  666                             upload FileName =  (uploadFi leName ==  null)?"":u ploadFileN ame;
  667                             if(upl oadFileNam e.equals(" ")){
  668                                      if(!chec kFileSizeM essage()){
  669                                               addActionE rror("Plea se select  a file");
  670                                      }
  671                                      return F AILED;
  672                             }
  673                             log.in fo("Conten t type: "  + getUploa dContentTy pe());
  674                             Object  rawConten t = getUpl oad().toUR L().getCon tent();
  675  
  676                             InputS tream is =  (InputStr eam)rawCon tent;
  677                             Reader  reader =  new InputS treamReade r(is);
  678                             String Builder co ntent = ne w StringBu ilder();
  679                             int re ad = 0;
  680                             while  ( read > - 1 ) {
  681                                      char[] b uffer = ne w char[102 4];
  682                                      read = r eader.read (buffer);
  683                                      content. append(buf fer);
  684                                      if(FILE_ SIZE_LIMIT _2MB<conte nt.length( )) {
  685                                               addActionE rror(FILE_ SIZE_LIMIT _ERROR);
  686                                               return FAI LED;
  687                                      }
  688                             }
  689                             if(log .isInfoEna bled()){
  690                                      log.info ("Contents :\n" + con tent.toStr ing().trim ());
  691                             }
  692                             String  fileConte nt = conte nt.toStrin g().trim() ;
  693                             if(fil eContent.l ength() ==  0){
  694                                      addActio nError("Th e bulk add ition of u ser record s failed"  +
  695                                                       "  because of  the follo wing recor ds. " +
  696                                                       "C orrect the se records  and repea t bulk add ition:");
  697  
  698                                      addActio nError("Li ne 1-incor rectly for matted.");
  699                                      addActio nError("No  Secure Me ssaging St aff Member s have bee n activate d.");
  700                                      return F AILED;
  701                             }
  702                             String [] rows =  fileConten t.split("\ r\n");
  703                             //Vali date the B ulk Record  File
  704                             if(val idateBulkR ecordFile( rows)){
  705                                      addActio nError("No  Secure Me ssaging St aff Member s have bee n activate d.");
  706                                      return F AILED;
  707                             }else{
  708                                      String r ecordType;
  709                                      String f irstName;
  710                                      String l astName;
  711                                      String s tationNumb er;
  712                                      added=0;
  713                                      int line Number = 0 ;
  714                                      for (int  i=0; i<ro ws.length;  i++){
  715                                               log.info(" Line" + i  + ":" + ro ws[i]);
  716                                               String row Data = row s[i];
  717                                               String[] f ields = ro wData.spli t(",");
  718                                               recordType   = fields [0].trim() ;
  719                                               firstName   = fields[ 1].trim();
  720                                               lastName   = fields[2 ].trim();
  721                                               duz  = fie lds[3].tri m();
  722                                               stationNum ber  = fie lds[4].tri m();
  723                                               networkId   = fields[ 5].trim();
  724                                               Long clini calUserTyp eId  = Lon g.valueOf( fields[6]. trim());
  725                                               lineNumber  = i + 1;
  726                                               log.info(" firstName=  "+firstNa me);
  727                                               log.info(" lastName=  "+lastName );
  728                                               log.info(" duz:" + du z.toString ());
  729                                               log.info(" stationNum ber:" + st ationNumbe r.toString ());
  730                                               log.info(" clinicalUs erTypeId:"  + clinica lUserTypeI d.toString ());
  731                                               log.info(" networkId: " + networ kId.toStri ng());
  732                                               boolean is Added = ac tivateBulk StaffMembe r(lineNumb er, duz,st ationNumbe r, clinica lUserTypeI d, network Id, firstN ame, lastN ame);
  733                                               if(isAdded ){
  734                                                       ad ded++;
  735                                               }
  736                                               activation Success =  activation Success &&  isAdded;
  737                                      }
  738                             }
  739                    }cat ch (java.i o.FileNotF oundExcept ion e)         {
  740                             addAct ionError(" The bulk a ddition of  user reco rds failed " +
  741                                               " because  of the fol lowing rec ords. " +
  742                                               "Correct t hese recor ds and rep eat bulk a ddition:") ;
  743  
  744                             addAct ionError(" Line 1-inc orrectly f ormatted." );
  745                             addAct ionError(" No Secure  Messaging  Staff Memb ers have b een activa ted.");
  746                             log.er ror(e);
  747                             return  FAILED;
  748  
  749                    } ca tch(Except ion e) {
  750                             log.er ror(e);
  751                             return  FAILED;
  752                    }
  753  
  754                    if(a ctivationS uccess){
  755                             return  SUCCESS;
  756                }else{
  757                    retu rn FAILED;
  758                }
  759           }
  760  
  761           /* *
  762            *  There are  two limit s for file  upload si ze struts. multipart. maxSize an d maximumS ize in the  action
  763            *  intercept or. The pr oblem is f or bug :53 91 providi ng custom  message is  not easy  as the
  764            *  error mes sage is ha rdcoded in  MultiPart Request. I n the foll owing code  the excep tion is
  765            *  trapped a nd replace d with the  message a s stated i n specific ation.
  766            * /
  767  
  768           pr ivate bool ean checkF ileSizeMes sage() {
  769                    bool ean hasSiz eError = f alse;
  770                    Coll ection<?>  tmp = getA ctionError s();
  771                    if(t mp!= null) {
  772                             Collec tion<Strin g> errors  = new Arra yList<Stri ng>();
  773                             for (O bject o :  tmp) {
  774                                      if(o !=  null){
  775                                           if  (o.toStrin g().contai ns("the re quest was  rejected b ecause its  size")) {
  776                                             h asSizeErro r = true;
  777                                             e rrors.add( FILE_SIZE_ LIMIT_ERRO R);
  778                                           } e lse {
  779                                             e rrors.add( o.toString ());
  780                                           }
  781                                      }
  782                             }
  783  
  784                             setAct ionErrors( errors);
  785                    }
  786                    retu rn hasSize Error;
  787           }
  788  
  789           /*
  790            *  Validate  the Bulk R ecord File , it is a  Comma Sepa rated Valu es (CSV) f ile where  each row i s expected  to
  791            *  have a ce rtain numb er and typ e of field s. Text fi elds are e nclosed in  quotes.
  792            *  BR3902 Th e Bulk Rec ord Schema
  793            *  Retruns t rue if fil e is not f ormating i s wrong.
  794            *  C,FNAME,L NAME,DUZ,S TATION_NO, EXTERNAL_U SERNAME,CL INICAL_USE R_TYPE_ID
  795            C,JOHN,DOE ,12345,994 ,         JDOE,1
  796            * /
  797           pr ivate bool ean valida teBulkReco rdFile(Str ing[] rows ){
  798                    //ke ep track o f duplicat es in curr ent file u sers
  799                    Map  currentFil eUsers = n ew HashMap ();
  800  
  801                    bool ean fileFa iled = fal se;
  802                    for  (int i=0;  i<rows.len gth; i++){
  803  
  804                             log.in fo("Line"  + i + ":"  + rows[i]) ;
  805                             boolea n failed =  false;
  806                             int li neNumber =  i + 1;
  807                             String  rowData =  rows[i];
  808                             String [] fields  = rowData. split(",") ;
  809                             //chec k if this  row has al l fields
  810                             if(fie lds.length  == 7){
  811                                      String l recordType   = fields [0].trim() ;
  812                                      //check  if Record  Type is no t null and  maximum l ength is 1
  813                                      if(lreco rdType== n ull || lre cordType.l ength() >1 ){
  814                                               failed = t rue;
  815                                      }
  816                                      //check  first name
  817                                      String l firstName   = fields[ 1].trim();
  818                                      if(lfirs tName == n ull || lfi rstName.le ngth() >50 ){
  819                                               failed = t rue;
  820                                      }
  821                                      //check  last name
  822                                      String l lastName   = fields[2 ].trim();
  823                                      if(llast Name == nu ll || llas tName.leng th() >50){
  824                                               failed = t rue;
  825                                      }
  826                                      //check  DUZ
  827                                      String l duz  = fie lds[3].tri m();
  828                                      if(lduz  == null ||  lduz.leng th() >20){
  829                                               failed = t rue;
  830                                      }
  831                                      //check  STATION_NO
  832                                      String l stationNum ber  = fie lds[4].tri m();
  833                                      if(lstat ionNumber  == null ||  lstationN umber.leng th() >10){
  834                                               failed = t rue;
  835                                      }
  836                                      //check  EXTERNAL_U SER_NAME
  837                                      String l networkId   = fields[ 5].trim();
  838                                      if(lnetw orkId == n ull || lne tworkId.le ngth() >50 ){
  839                                               failed = t rue;
  840                                      }
  841                                      //check  CLINICAL_U SER_TYPE_I D
  842                                      try{
  843                                               Long lclin icalUserTy peId  = Lo ng.valueOf (fields[6] .trim());
  844                                               if(lclinic alUserType Id == null ){
  845                                                       fa iled = tru e;
  846                                               }
  847                                      }catch(j ava.lang.N umberForma tException  ex){
  848                                               //the clin ical user  type if is  not a num ber.
  849                                               failed = t rue;
  850                                      }
  851  
  852                                      //if fai led becaus e of forma t
  853                                      if(faile d){
  854                                               if(!fileFa iled){
  855                                                       fi leFailed =  true;
  856                                                       ad dActionErr or("The bu lk additio n of user  records fa iled" +
  857                                                                         " beca use of the  following  records.  " +
  858                                                                         "Corre ct these r ecords and  repeat bu lk additio n:");
  859                                               }
  860                                               addActionE rror("Line  " + lineN umber + "- incorrectl y formatte d.");
  861                                      }else{
  862                                               String tmp StationNum ber = (Str ing)curren tFileUsers .get(lnetw orkId);
  863  
  864                                               if(tmpStat ionNumber! =null){
  865                                                       if (tmpStatio nNumber.eq uals(lstat ionNumber) ){
  866                                                                if(! fileFailed ){
  867                                                                         fileFa iled = tru e;
  868                                                                         addAct ionError(" The bulk a ddition of  user reco rds failed " +
  869                                                                                           " because  of the fol lowing rec ords. " +
  870                                                                                           "Correct t hese recor ds and rep eat bulk a ddition:") ;
  871                                                                }
  872                                                                addA ctionError ("Line " +  lineNumbe r + "- Dup licate Net work ID "  +lnetworkI d +
  873                                                                                              " is al ready list ed in this  file at t his statio n by" +
  874                                                                                              " staff  member "  +
  875                                                                                              lfirstN ame+","+ll astName);
  876  
  877                                                       }
  878  
  879  
  880                                               }else{
  881                                                       cu rrentFileU sers.put(l networkId, lstationNu mber);
  882                                               }
  883  
  884  
  885                                               //ensure t hat you ca n never ac tivate new  staff mem bers that  have the s ame extern al_user_na me and sta tion_no
  886                                               Clinician  existingCl inician =  userDao.fi ndClinicia nByStation AndUsernam e(lstation Number, ln etworkId);
  887                                               if (existi ngClinicia n != null)  {
  888                                                       if (!fileFail ed){
  889                                                                file Failed = t rue;
  890                                                                addA ctionError ("The bulk  addition  of user re cords fail ed" +
  891                                                                                  " becaus e of the f ollowing r ecords. "  +
  892                                                                                  "Correct  these rec ords and r epeat bulk  addition: ");
  893                                                       }
  894                                                       ad dActionErr or("Line "   + lineNu mber + "-  Network ID  " +lnetwo rkId +
  895                                                                                     " is  already in  use at th is station  by " +
  896                                                                                     (exis tingClinic ian.isActi ve() ? "ac tive" : "i nactive")  +
  897                                                                                     " sta ff member  " +
  898                                                                                     exist ingClinici an.getName ());
  899  
  900                                               }
  901                                      }
  902                             }else{
  903                                      if(!file Failed){
  904                                               fileFailed  = true;
  905                                               addActionE rror("The  bulk addit ion of use r records  failed" +
  906                                                                " be cause of t he followi ng records . " +
  907                                                                "Cor rect these  records a nd repeat  bulk addit ion:");
  908                                      }
  909                                      addActio nError("Li ne " + lin eNumber +  "-incorrec tly format ted.");
  910                             }
  911                    }
  912                    retu rn fileFai led;
  913  
  914           }
  915  
  916           pu blic boole an activat eBulkStaff Member(int  lineNumbe r, String  duz,String  stationNu mber, Long  clinicalU serTypeId,  String ne tworkId, S tring firs tName, Str ing lastNa me){
  917                    bool ean succes sfullyActi vated = tr ue;
  918  
  919                    Clin ician clin  = null;
  920                    Admi nistrator  admin = (A dministrat or)getSess ionAttribu te(CURRENT _USER);
  921                    log. info("Admi n isNation al???..... ...."+admi n.isNation al());
  922  
  923                    bool ean permis sion = fal se;
  924  
  925                    //If  logged-in  user is N ational Ad min, they  have right s to manag e the any  facility u ser.
  926                    if(a dmin.isNat ional()){
  927                             permis sion = tru e;
  928                    }
  929  
  930                    // I f logged-i n user is  VISN Admin , they hav e rights t o manage a ny facilit ies under  the visn.
  931                    if(a dmin.getVi sns() !=nu ll) {
  932                             log.in fo("admin. getVisins( )......"+a dmin.getVi sns());
  933                             for (F acility vi sn: admin. getVisns() )
  934                             {
  935                                      Collecti on<Facilit y> facilit ies = getF acilitySer vice().get Facilities ForVisn(vi sn).getCol lection();
  936                                      for(Faci lity f1 :  facilities ){
  937                                               log.info(" f1.getId() ...."+f1.g etId());
  938                                               log.info(" f1.getName ...."+f1.g etName());
  939                                               log.info(" f1.getStat ionNumber( )......."+ f1.getStat ionNumber( ));
  940                                               if(f1.getS tationNumb er().equal sIgnoreCas e(stationN umber)){
  941                                                       pe rmission =  true;
  942                                                       br eak;
  943                                               }
  944                                      }
  945                             }
  946                    }
  947  
  948                    // I f logged-i n user is  Facility A dmin, they  have righ ts to mana ge only th e associat ed user fa cilities.
  949                    for( Facility f :admin.get Facilities ()) {
  950                             if( f. getStation Number().e qualsIgnor eCase(stat ionNumber)  ) {
  951                                      permissi on = true;
  952                                      break;
  953                             }
  954                    }
  955  
  956                    log. info("perm ission.... ....."+per mission);
  957  
  958  
  959                    if(  !permissio n ) {
  960                             addAct ionError(" Line " + l ineNumber  + ": The s taff membe r's facili ty doesn't  match a f acility yo u can mana ge.");
  961                             succes sfullyActi vated = fa lse;
  962                    }
  963  
  964                    User  selectedV istaUser =  null;
  965                    List <User> sta ffMembers=  new Array List<User> ();
  966                    Coll ectionServ iceRespons e<User> re sponse = g etAdminSer vice().fin dVistaClin ician(duz,  stationNu mber);
  967                    hand leErrorMes sages(resp onse.getMe ssages());
  968                    staf fMembers =  (List<Use r>)respons e.getColle ction();
  969                    if(s taffMember s == null) {
  970                             addAct ionError(" Line " + l ineNumber  + ": A sea rch of the  VistA dat abase did  not produc e a match  for the in formation  given.");
  971                             succes sfullyActi vated = fa lse;
  972                    }els e{
  973                             for(Us er u:staff Members){
  974                                               if(duz.equ alsIgnoreC ase(u.getI EN())){
  975                                               selectedVi staUser =  u;
  976                                      }
  977                             }
  978                    }
  979                    if(s electedVis taUser ==  null){
  980                             addAct ionError(" Line " + l ineNumber  + ": A sea rch of the  VistA dat abase did  not produc e a match  for the in formation  given.");
  981                             succes sfullyActi vated = fa lse;
  982                    }
  983  
  984                    Clin icalUserTy pe clinica lUserType  = null;
  985                    staf fMemberTyp es = (List <ClinicalU serType>)g etAdminSer vice().get ClinicalUs erTypes(). getCollect ion();
  986                    if(s taffMember Types != n ull){
  987                             for(Cl inicalUser Type cu: s taffMember Types){
  988                                      if((cu.g etId()).eq uals(clini calUserTyp eId)){
  989                                               clinicalUs erType = c u;
  990                                      }
  991                             }
  992                    }
  993                    if(c linicalUse rType == n ull){
  994                             log.in fo("clinic alUserType : Null");
  995                             addAct ionError(" Line " + l ineNumber  + ": A sea rch for cl inical use r type cou ld not pro duce a mat ch");
  996                             succes sfullyActi vated = fa lse;
  997                    }
  998  
  999                    ADQu eryResult  staffADRes ults = nul l;
  1000                    Serv iceRespons e<ADQueryR esult> fin dADAccount Response =  getAdminS ervice().f indADAccou nt(network Id);
  1001                    staf fADResults  = findADA ccountResp onse.getPa yload();
  1002                    if(s taffADResu lts == nul l){
  1003                             log.in fo("AD Res ults: Null ");
  1004                             addAct ionError(" Line " + l ineNumber  + ": An Em ail Addres s could no t be found  in Outloo k using th e VistA se arch resul ts.");
  1005                             succes sfullyActi vated = fa lse;
  1006                    }els e{
  1007                             staffA DResults.s etUserName (networkId );
  1008                    }
  1009  
  1010                    if(n ull!=staff ADResults  && null!=s taffADResu lts.getFir stName() & & !staffAD Results.ge tFirstName ().equalsI gnoreCase( firstName)  ) {
  1011  
  1012                             log.in fo("AD fir stname did n't match  bulk recor d: " + sta ffADResult s.getFirst Name() + " , " + firs tName);
  1013                             addAct ionError(" Line " + l ineNumber  + ": " + ( lastName== null?"null ":lastName ) + ", " +  firstName  + " is no t recogniz ed as an O utlook ema il account .");
  1014                             succes sfullyActi vated = fa lse;
  1015                    }
  1016  
  1017                    if(n ull!=staff ADResults  && !staffA DResults.g etLastName ().equalsI gnoreCase( lastName)  ) {
  1018                             log.in fo("AD las tname didn 't match b ulk record : " + staf fADResults .getLastNa me() + ",  " + lastNa me);
  1019                             addAct ionError(" Line " + l ineNumber  + ": " + l astName +  ", " + (fi rstName==n ull?"null" :firstName ) + " is n ot recogni zed as an  Outlook em ail accoun t.");
  1020                             succes sfullyActi vated = fa lse;
  1021                    }
  1022  
  1023                    if(s taffADResu lts.getEma il()!=null  && !staff ADResults. getEmail() .equals("" )){
  1024                             EmailV alidator e mailValida tor = Emai lValidator .getInstan ce();
  1025                             if(!em ailValidat or.isValid (staffADRe sults.getE mail())){
  1026                                      addActio nError("Li ne " + lin eNumber +   ": Outloo k Email Ad dress is i nvalid.");
  1027                                      successf ullyActiva ted = fals e;
  1028                             }
  1029                    }
  1030                    else
  1031                    {
  1032                             addAct ionError(" Line "+ li neNumber +  ": Outloo k Email Ad dress can' t be blank .");
  1033                             succes sfullyActi vated = fa lse;
  1034                    }
  1035  
  1036                    try  {
  1037                             if( tr ue == succ essfullyAc tivated )  {
  1038                                      ServiceR esponse<Cl inician> r esponse1 =  getAdminS ervice().c reateClini cianAccoun t(stationN umber, sel ectedVista User, staf fADResults , clinical UserType,  admin);
  1039                                      clin = r esponse1.g etPayload( );
  1040                             }
  1041                    } ca tch(Except ion e){
  1042                             succes sfullyActi vated = fa lse;
  1043                             log.er ror( e.get Message()  );
  1044                    }
  1045  
  1046                    if ( clin == nu ll){
  1047                             addAct ionError(" Line " + l ineNumber  + ": Error  occurred  while acti vating the  account." );
  1048                             succes sfullyActi vated = fa lse;
  1049                    }
  1050  
  1051                    retu rn success fullyActiv ated;
  1052           }
  1053  
  1054           pu blic Strin g bulkActi vationComp lete() {
  1055  
  1056                    clea rSessionAt tr();
  1057                    if(( selectActi on!=null)  && ((selec tAction.tr im()).equa lsIgnoreCa se("Done") )){
  1058                             return  CANCEL;
  1059                    }
  1060  
  1061                    retu rn SUCCESS ;
  1062           }
  1063  
  1064  
  1065           pu blic void  getStaffSe ssionAttr( ){
  1066  
  1067                    if(( (Collectio n<Facility >)getSessi onAttribut e("facilit ies")) !=  null){
  1068                             facili ties = (Co llection<F acility>)g etSessionA ttribute(" facilities ");
  1069                    }els e{
  1070                             facili ties = new  ArrayList <Facility> ();
  1071                    }
  1072                    if(( (String)ge tSessionAt tribute("s electedVis nName")) ! = null){
  1073                             select edVisnName  = (String )getSessio nAttribute ("selected VisnName") ;
  1074                    }
  1075                    if(( (String)ge tSessionAt tribute("s electedFac ilityName" )) != null ){
  1076                             select edFacility Name = (St ring)getSe ssionAttri bute("sele ctedFacili tyName");
  1077                    }
  1078  
  1079           }
  1080  
  1081           pu blic void  clearSessi onAttr(){
  1082                    remo veSessionA ttribute(" facilities ");
  1083                    remo veSessionA ttribute(" selectedVi snName");
  1084                    remo veSessionA ttribute(" selectedFa cilityName ");
  1085                    remo veSessionA ttribute(" stationNum ber");
  1086                    remo veSessionA ttribute(" staffMembe rs");
  1087                    remo veSessionA ttribute(" activation Type");
  1088           }
  1089  
  1090           pu blic boole an applied Cancel() {
  1091  
  1092                    if(( selectActi on!=null)  && ((selec tAction.tr im()).equa lsIgnoreCa se("Cancel "))){
  1093                             clearS essionAttr ();
  1094                             return  true;
  1095                    }
  1096                    retu rn false;
  1097  
  1098           }
  1099  
  1100           pu blic boole an isNewSe arch() {
  1101  
  1102                    if(( selectActi on!=null)  && ((selec tAction.tr im()).equa lsIgnoreCa se("New Se arch"))){
  1103                             return  true;
  1104                    }
  1105                    retu rn false;
  1106  
  1107           }
  1108  
  1109  
  1110           pu blic void  setVisns(C ollection< Facility>  visns) {
  1111                             this.v isns = vis ns;
  1112           }
  1113  
  1114           pu blic Colle ction<Faci lity> getV isns() {
  1115                             return  visns;
  1116           }
  1117  
  1118           pu blic void  setFacilit ies(Collec tion<Facil ity> facil ities) {
  1119                             this.f acilities  = faciliti es;
  1120           }
  1121  
  1122           pu blic Colle ction<Faci lity> getF acilities( ) {
  1123                             return  this.faci lities;
  1124           }
  1125  
  1126           pu blic void  setSelecte dVisnName( String sel ectedVisnN ame) {
  1127                             this.s electedVis nName = se lectedVisn Name;
  1128           }
  1129  
  1130           pu blic Strin g getSelec tedVisnNam e() {
  1131                             return  selectedV isnName;
  1132           }
  1133  
  1134           pu blic void  setSelecte dFacilityN ame(String  selectedF acilityNam e) {
  1135                             this.s electedFac ilityName  = selected FacilityNa me;
  1136           }
  1137  
  1138           pu blic Strin g getSelec tedFacilit yName() {
  1139                             return  selectedF acilityNam e;
  1140           }
  1141  
  1142           pu blic void  setVisnId( Long visnI d) {
  1143                             this.v isnId = vi snId;
  1144           }
  1145  
  1146           pu blic Long  getVisnId( ) {
  1147                             return  this.visn Id;
  1148           }
  1149  
  1150           pu blic void  setFacilit yId(Long f acilityId)  {
  1151                             this.f acilityId  = facility Id;
  1152           }
  1153  
  1154           pu blic Long  getFacilit yId() {
  1155                             return  this.faci lityId;
  1156           }
  1157  
  1158           pu blic void  setClinici ans(List<C linician>  clinicians ) {
  1159                             this.c linicians  = clinicia ns;
  1160           }
  1161  
  1162           pu blic List< Clinician>  getClinic ians() {
  1163                             return  clinician s;
  1164           }
  1165  
  1166           pu blic void  setSelectA ction(Stri ng selectA ction) {
  1167                    this .selectAct ion = sele ctAction;
  1168           }
  1169  
  1170           pu blic Strin g getSelec tAction()  {
  1171                    retu rn selectA ction;
  1172           }
  1173  
  1174           pu blic void  setSelecte dUsers(Lis t<Clinicia n> selecte dUsers) {
  1175                             this.s electedUse rs = selec tedUsers;
  1176           }
  1177  
  1178           pu blic List< Clinician>  getSelect edUsers()  {
  1179                             return  selectedU sers;
  1180           }
  1181  
  1182           pu blic void  setSearchC rit(String  searchCri t) {
  1183                             this.s earchCrit  = searchCr it;
  1184           }
  1185  
  1186           pu blic Strin g getSearc hCrit() {
  1187                             return  searchCri t;
  1188           }
  1189  
  1190           pu blic void  setDuz(Str ing duz) {
  1191                             this.d uz = duz;
  1192           }
  1193  
  1194           pu blic Strin g getDuz()  {
  1195                             return  duz;
  1196           }
  1197  
  1198           pu blic void  setFirstNa me(String  firstName)  {
  1199                             this.f irstName =  firstName ;
  1200           }
  1201  
  1202           pu blic Strin g getFirst Name() {
  1203                             return  firstName ;
  1204           }
  1205  
  1206           pu blic void  setLastNam e(String l astName) {
  1207                             this.l astName =  lastName;
  1208           }
  1209  
  1210           pu blic Strin g getLastN ame() {
  1211                             return  lastName;
  1212           }
  1213  
  1214           pu blic void  setPhone(S tring phon e) {
  1215                             this.p hone = pho ne;
  1216           }
  1217  
  1218           pu blic Strin g getPhone () {
  1219                             return  phone;
  1220           }
  1221  
  1222           pu blic void  setTitle(S tring titl e) {
  1223                             this.t itle = tit le;
  1224           }
  1225  
  1226           pu blic Strin g getTitle () {
  1227                             return  title;
  1228           }
  1229  
  1230           pu blic void  setNetwork Id(String  networkId)  {
  1231                             this.n etworkId =  networkId ;
  1232           }
  1233  
  1234           pu blic Strin g getNetwo rkId() {
  1235                             return  networkId ;
  1236           }
  1237  
  1238           pu blic void  setStaffMe mberTypes( List<Clini calUserTyp e> staffMe mberTypes)  {
  1239                             this.s taffMember Types = st affMemberT ypes;
  1240           }
  1241  
  1242           pu blic List< ClinicalUs erType> ge tStaffMemb erTypes()  {
  1243                             return  staffMemb erTypes;
  1244           }
  1245  
  1246           pu blic void  setMemberT ypeId(Long  memberTyp eId) {
  1247                             this.m emberTypeI d = member TypeId;
  1248           }
  1249  
  1250           pu blic Long  getMemberT ypeId() {
  1251                             return  memberTyp eId;
  1252           }
  1253  
  1254           pu blic void  setMemberT ype(String  memberTyp e) {
  1255                             this.m emberType  = memberTy pe;
  1256           }
  1257  
  1258           pu blic Strin g getMembe rType() {
  1259                             return  memberTyp e;
  1260           }
  1261  
  1262           pu blic void  setFirstNa meAD(Strin g firstNam eAD) {
  1263                             this.f irstNameAD  = firstNa meAD;
  1264           }
  1265  
  1266           pu blic Strin g getFirst NameAD() {
  1267                             return  firstName AD;
  1268           }
  1269  
  1270           pu blic void  setLastNam eAD(String  lastNameA D) {
  1271                             this.l astNameAD  = lastName AD;
  1272           }
  1273  
  1274           pu blic Strin g getLastN ameAD() {
  1275                             return  lastNameA D;
  1276           }
  1277  
  1278           pu blic void  setPhoneAD (String ph oneAD) {
  1279                             this.p honeAD = p honeAD;
  1280           }
  1281  
  1282           pu blic Strin g getPhone AD() {
  1283                             return  phoneAD;
  1284           }
  1285  
  1286  
  1287           pu blic void  setTitleAD (String ti tleAD) {
  1288                             this.t itleAD = t itleAD;
  1289           }
  1290  
  1291           pu blic Strin g getTitle AD() {
  1292                             return  titleAD;
  1293           }
  1294  
  1295           pu blic void  setNetwork IdAD(Strin g networkI dAD) {
  1296                             this.n etworkIdAD  = network IdAD;
  1297           }
  1298  
  1299           pu blic Strin g getNetwo rkIdAD() {
  1300                             return  networkId AD;
  1301           }
  1302  
  1303           pu blic Strin g getUploa dContentTy pe() {
  1304                    retu rn uploadC ontentType ;
  1305           }
  1306  
  1307           pu blic void  setUploadC ontentType (String co ntentType)  {
  1308                    this .uploadCon tentType =  contentTy pe;
  1309           }
  1310  
  1311           pu blic File  getUpload( ) {
  1312                    retu rn upload;
  1313           }
  1314  
  1315           pu blic void  setUpload( File file)  {
  1316                    this .upload =  file;
  1317           }
  1318  
  1319           pu blic Strin g getUploa dFileName( ) {
  1320                    retu rn uploadF ileName;
  1321           }
  1322  
  1323           pu blic void  setUploadF ileName(St ring filen ame) {
  1324                    this .uploadFil eName = fi lename;
  1325           }
  1326  
  1327           pu blic Strin g getEmail AD() {
  1328                    retu rn emailAD ;
  1329           }
  1330  
  1331           pu blic void  setEmailAD (String em ailAD) {
  1332                    this .emailAD =  emailAD;
  1333           }
  1334  
  1335           pu blic Strin g getEmail () {
  1336                    retu rn email;
  1337           }
  1338  
  1339           pu blic void  setEmail(S tring emai l) {
  1340                    this .email = e mail;
  1341           }
  1342  
  1343           pu blic UserD ao getUser Dao() {
  1344                    retu rn userDao ;
  1345           }
  1346  
  1347           pu blic void  setUserDao (UserDao u serDao) {
  1348                    this .userDao =  userDao;
  1349           }
  1350  
  1351  
  1352           pu blic int g etAdded()  {
  1353                    retu rn added;
  1354           }
  1355  
  1356  
  1357           pu blic void  setAdded(i nt added)  {
  1358                    this .added = a dded;
  1359           }
  1360  
  1361           pu blic Strin g getMiddl eName() {
  1362                    retu rn middleN ame;
  1363           }
  1364  
  1365  
  1366           pu blic void  setMiddleN ame(String  middleNam e) {
  1367                    this .middleNam e = middle Name;
  1368           }
  1369  
  1370  
  1371           pu blic Strin g getSuffi x() {
  1372                    retu rn suffix;
  1373           }
  1374  
  1375  
  1376           pu blic void  setSuffix( String suf fix) {
  1377                    this .suffix =  suffix;
  1378           }
  1379  
  1380  
  1381           pu blic Strin g getPrefi x() {
  1382                    retu rn prefix;
  1383           }
  1384  
  1385  
  1386           pu blic void  setPrefix( String pre fix) {
  1387                    this .prefix =  prefix;
  1388           }
  1389  
  1390  
  1391           pu blic Strin g getActiv eFlag() {
  1392                    retu rn activeF lag;
  1393           }
  1394  
  1395  
  1396           pu blic void  setActiveF lag(String  activeFla g) {
  1397                    this .activeFla g = active Flag;
  1398           }
  1399  
  1400  
  1401   }