38. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 1/19/2019 1:19:09 PM Eastern 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.

38.1 Files compared

# Location File Last Modified
1 VIRP_Build_6_Dec_2018_CG.zip\Registries VIRP Web Site\Custom\EFR\LabOrders LabOrder.aspx.cs Thu Jan 17 17:41:06 2019 UTC
2 VIRP_Build_6_Dec_2018_CG.zip\Registries VIRP Web Site\Custom\EFR\LabOrders LabOrder.aspx.cs Sat Jan 19 18:02:35 2019 UTC

38.2 Comparison summary

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

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

38.4 Active regular expressions

No regular expressions were active.

38.5 Comparison detail

  1   using Syst em;
  2   using Syst em.Web;
  3   using Syst em.Collect ions.Gener ic;
  4   using Syst em.Linq;
  5   using Syst em.Web.UI. WebControl s;
  6   using Anti XssEnc = M icrosoft.S ecurity.Ap plication;
  7   using VIRP ;
  8   using VIRP _WEB.BaseC ode;
  9   using VIRP _WEB.SoaSe rvices;
  10  
  11   namespace  VIRP_WEB.C ustom.EFR
  12   {
  13       public  partial c lass LabOr der : EfrB asePage
  14       {
  15           pr ivate cons t string R eferralKey  = "LabOrd er_Referre r";
  16  
  17           // private re adonly Lab OrderManag er manager ;
  18           // private WK F_CASE_ACT IVITY acti vity;
  19           pr ivate EfrI nterfaceMa nager mana ger;
  20  
  21           pr ivate int?  REFERRAL_ ID
  22           {
  23                //get
  24                //{
  25                //    in t? rEFERRA L_ID = 0;
  26  
  27                //    if  (ViewStat e["REFERRA L_ID"] ==  null)
  28                //    {
  29                //         //wkfCas e = Servic eInterface Manager.RE GISTRY_COH ORT_DATA_G ET_ALL_BY_ REGISTRY(H ttpContext .Current.U ser.Identi ty.Name, U serSession .CurrentRe gistryId);
  30                //         ViewStat e["REFERRA L_ID"] = r EFERRAL_ID ;
  31                //    }
  32                //    el se
  33                //    {
  34                //         rEFERRAL _ID = View State["REF ERRAL_ID"]  as int?;
  35                //    }
  36  
  37                //    re turn rEFER RAL_ID;
  38                //}
  39                set
  40                {
  41                    View State["REF ERRAL_ID"]  = value;
  42                }
  43           }
  44  
  45           pr ivate WKF_ CASE WkfCa se
  46           {
  47                get
  48                {
  49                    WKF_ CASE wkfCa se = null;
  50  
  51                    if ( ViewState[ "WkfCase"]  == null)
  52                    {
  53                         //wkfCase  = ServiceI nterfaceMa nager.REGI STRY_COHOR T_DATA_GET _ALL_BY_RE GISTRY(Htt pContext.C urrent.Use r.Identity .Name, Use rSession.C urrentRegi stryId);
  54                         ViewState[ "WkfCase"]  = wkfCase ;
  55                    }
  56                    else
  57                    {
  58                         wkfCase =  ViewState[ "WkfCase"]  as WKF_CA SE;
  59                    }
  60  
  61                    retu rn wkfCase ;
  62                }
  63                set
  64                {
  65                    View State["Wkf Case"] = v alue;
  66                }
  67           }
  68  
  69           pr ivate WKF_ CASE_ACTIV ITY Activi ty
  70           {
  71                get
  72                {
  73                    WKF_ CASE_ACTIV ITY activi ty = null;
  74  
  75                    if ( ViewState[ "Activity" ] == null)
  76                    {
  77                         //wkfCase  = ServiceI nterfaceMa nager.REGI STRY_COHOR T_DATA_GET _ALL_BY_RE GISTRY(Htt pContext.C urrent.Use r.Identity .Name, Use rSession.C urrentRegi stryId);
  78                         ViewState[ "Activity" ] = activi ty;
  79                    }
  80                    else
  81                    {
  82                         activity =  ViewState ["Activity "] as WKF_ CASE_ACTIV ITY;
  83                    }
  84  
  85                    retu rn activit y;
  86                }
  87                set
  88                {
  89                    View State["Act ivity"] =  value;
  90                }
  91           }
  92  
  93           pr ivate List <VIRP.EFR. BO.LAB_ORD ER> LabOrd ers
  94           {
  95                get
  96                {
  97                    List <VIRP.EFR. BO.LAB_ORD ER> labOrd ers = null ;
  98  
  99                    if ( ViewState[ "LabOrders "] == null )
  100                    {
  101                         //wkfCase  = ServiceI nterfaceMa nager.REGI STRY_COHOR T_DATA_GET _ALL_BY_RE GISTRY(Htt pContext.C urrent.Use r.Identity .Name, Use rSession.C urrentRegi stryId);
  102                         ViewState[ "LabOrders "] = labOr ders;
  103                    }
  104                    else
  105                    {
  106                         labOrders  = ViewStat e["LabOrde rs"] as Li st<VIRP.EF R.BO.LAB_O RDER>;
  107                    }
  108  
  109                    retu rn labOrde rs;
  110                }
  111                set
  112                {
  113                    View State["Lab Orders"] =  value;
  114                }
  115           }
  116  
  117           pr ivate stat ic IReadOn lyList<str ing> navig ationSourc es = new L ist<string >
  118           {
  119                "/Custom /EFR/LabOr ders/LabOr ders.aspx" ,
  120                "/Custom /EFR/Patie nts/Patien tWorkflows .aspx",
  121                "/Custom /EFR/LabRe sults/LabR esultDetai ls.aspx"
  122           };
  123  
  124           pu blic LabOr der()
  125           {
  126                //manage r = new La bOrderMana ger();
  127                manager  = new EfrI nterfaceMa nager();
  128  
  129                Navigati onSources  = navigati onSources;
  130           }
  131  
  132           pr otected ov erride voi d Page_Loa d(object s ender, Eve ntArgs e)
  133           {
  134                //Replac ePageTitle ();
  135  
  136                if (!IsP ostBack)
  137                {
  138                    int  orderId;
  139                    if ( int.TryPar se(Request .QueryStri ng["activi tyId"], ou t orderId) )
  140                    {
  141                         GetRefresh LabOrder(o rderId);
  142  
  143                         //ViewStat e["Referra lCaseId"]  = Activity .WKF_CASE. REFERRAL_I D;
  144                         REFERRAL_I D = WkfCas e.REFERRAL _ID;
  145                         //only for  biologica l
  146                         if (Activi ty.STD_WKF ACTIVITYTY PE_ID == 3 )
  147                             SetupB ioLabOrder ();
  148                    }
  149  
  150                    SetR eferringPa ge();
  151  
  152                    Uri  from = Vie wState["re ferrer"] a s Uri;
  153                    if ( VIRP.EFR.B O.UriUtili ty.IsValid PathSource (Navigatio nSources,  from))
  154                    {
  155                         SetOrigina lReferring Page(Refer ralKey);
  156                    }
  157                }
  158  
  159                RangeVal idatorLabR equestDate IsDate.Max imumValue  = RangeVal idatorLabe lSampleRec eivedDateI sDate.Maxi mumValue =  DateTime. Today.ToSh ortDateStr ing();
  160           }
  161  
  162           pr ivate void  GetRefres hLabOrder( int oId)
  163           {
  164                WKF_CASE _ACTIVITY  activity =  ServiceIn terfaceMan ager.WKF_C ASE_ACTIVI TY_GET(Htt pContext.C urrent.Use r.Identity .Name, Use rSession.C urrentRegi stryId, oI d);
  165                if (acti vity != nu ll)
  166                {
  167                    WkfC ase = Serv iceInterfa ceManager. WKF_CASE_G ET(HttpCon text.Curre nt.User.Id entity.Nam e, UserSes sion.Curre ntRegistry Id, activi ty.WKF_CAS E_ID);
  168                    LabO rders = VI RP.EFR.BLL .LAB_ORDER Manager.Ge tItemsByAc tivity(Htt pContext.C urrent.Use r.Identity .Name, Use rSession.C urrentRegi stryId, ac tivity.WKF _CASE_ACTI VITY_ID);
  169                }
  170  
  171                Activity  = activit y;
  172                //Activi ty = manag er.getLabO rderByOrde rID(oId);
  173                //Activi ty.SetAsCh angeTracki ngRoot();
  174  
  175                ReplaceP ageTitle(" My Tasks >  Lab Order s > " + Ac tivity.STD _WKFACTIVI TYSTS.NAME  + " > Wor kflow ID :  " + Activ ity.WKF_CA SE_ID.ToSt ring());
  176           }
  177  
  178           pr ivate void  SetupBioL abOrder()
  179           {
  180                string t empText =  string.Emp ty;
  181                lblSampl eType.Text  = "URINE" ;
  182                if (WkfC ase != nul l && WkfCa se.PATIENT  != null & & WkfCase. PATIENT.SP ATIENT !=  null)
  183                    temp Text = VIR P_WEB.Base Code.Helpe rs.FullNam e(WkfCase. PATIENT).S ubstring(0 , 1) + Wkf Case.PATIE NT.SPATIEN T.PatientS num.Substr ing(WkfCas e.PATIENT. SPATIENT.P atientSnum .Length -  4, 4);
  184                else
  185                    temp Text = "N/ A";
  186                lblSampl eIDNumber. Text = Ant iXssEnc.En coder.Html Encode(tem pText);
  187  
  188                List<VIR P.EFR.BO.L AB_ORDER>  labOrders  = LabOrder s;
  189  
  190                if (labO rders != n ull && lab Orders.Cou nt > 0)
  191                {
  192                    VIRP .EFR.BO.LA B_ORDER or der = labO rders.Firs t();
  193  
  194                    stri ng shortDa te = order .LAB_SEND_ DATE.HasVa lue ? orde r.LAB_SEND _DATE.Valu e.ToString ("yy") : D ateTime.To day.ToStri ng("yy");
  195                    temp Text = sho rtDate + "  - " + "TE F" + order .LAB_ORDER _ID.ToStri ng().PadLe ft(5, '0') ;
  196                    lblL abRequestN umber.Text  = AntiXss Enc.Encode r.HtmlEnco de(tempTex t);
  197  
  198                    if ( order.LAB_ SEND_DATE. HasValue)
  199                    {
  200                         LabRequest Date.Text  = order.LA B_SEND_DAT E.Value.To ShortDateS tring();
  201                    }
  202                    else
  203                    {
  204                         if (Activi ty.STD_WKF ACTIVITYST S_ID == (i nt)VIRP.EF R.BO.Workf lowCaseAct ivityStatu s.Voided)
  205                         {
  206                             LabReq uestDate.T ext = Stri ng.Empty;
  207                         }
  208                         else
  209                         {
  210                             LabReq uestDate.T ext = Date Time.Now.T oShortDate String();
  211                         }
  212                    }
  213  
  214                    if ( order.LAB_ RECEIVED_D ATE.HasVal ue)
  215                    {
  216                         tempText =  order.LAB _RECEIVED_ DATE.Value .ToShortDa teString() ;
  217                         LabSampleR eceivedDat e.Text = A ntiXssEnc. Encoder.Ht mlEncode(t empText);
  218                    }
  219                    if ( order.LAB_ RETURN_DAT E.HasValue )
  220                    {
  221                         tempText =  order.LAB _RETURN_DA TE.Value.T oShortDate String();
  222                         LabelLabRe portDate.T ext = Anti XssEnc.Enc oder.HtmlE ncode(temp Text);
  223                    }
  224                    txtB SONumber.T ext = orde r.BSO_NUMB ER;
  225                    txtT rackingNum ber.Text =  order.SHI PMENT_TRAC KING_NUMBE R;
  226                    txtS ampleInstr uctions.Te xt = order .SPECIAL_I NSTRUCTION ;
  227                    txtS ampleDescr iption.Tex t = order. SAMPLE_DES C;
  228  
  229                    Setu pAnalytes( order);
  230                }
  231                else
  232                {
  233                    //ne w lab orde r doesn't  have assoc iated lab  order befo re you sav e it 1st
  234                    LabR equestDate .Text = Da teTime.Tod ay.ToStrin g("d");
  235                }
  236  
  237                switch ( Activity.S TD_WKFACTI VITYSTS_ID )
  238                {
  239                    case  (int)VIRP .EFR.BO.Wo rkflowCase ActivitySt atus.New:
  240  
  241                         LabelForLa bLabelRepo rtDate.Vis ible = fal se;
  242                         LabelLabRe portDate.V isible = f alse;
  243                         PrintButto n.Enabled  = false;
  244                         VoidButton .Enabled =  true;
  245                         SaveButton .Enabled =  false;
  246                         CompleteBu tton.Enabl ed = true;
  247                         LabRequest Date.Enabl ed = true;
  248                         ReOpenLabO rder.Enabl ed = false ;
  249                         SaveButton .Text = "S ave";
  250  
  251                         RequiredFi eldValidat orLabReque stDate.Ena bled = tru e;
  252  
  253                         SaveButton .Validatio nGroup = " ";
  254  
  255                         break;
  256  
  257                    case  (int)VIRP .EFR.BO.Wo rkflowCase ActivitySt atus.Await ingResults :
  258  
  259                         LabelForLa bLabelRepo rtDate.Vis ible = fal se;
  260                         LabelLabRe portDate.V isible = f alse;
  261                         PrintButto n.Enabled  = true;
  262                         VoidButton .Enabled =  false;
  263                         SaveButton .Enabled =  true;
  264                         CompleteBu tton.Enabl ed = false ;
  265                         LabRequest Date.Enabl ed = false ;
  266                         RequiredFi eldValidat orLabReque stDate.Ena bled = tru e;
  267                         ReOpenLabO rder.Enabl ed = false ;
  268                         CancelButt on.Text =  "Back";
  269                         SaveButton .Validatio nGroup = " LabOrderVa lidation";
  270                         SaveButton .Text = "S ave";
  271                         ReOpenLabO rder.Enabl ed = false ;
  272  
  273                         break;
  274  
  275                    //Cl osed statu s
  276                    case  (int)VIRP .EFR.BO.Wo rkflowCase ActivitySt atus.Close d:
  277                         LabelForLa bLabelRepo rtDate.Vis ible = tru e;
  278                         LabelLabRe portDate.V isible = t rue;
  279                         CompleteBu tton.Enabl ed = false ;
  280                         SaveButton .Enabled =  false;
  281                         PrintButto n.Enabled  = true;
  282                         VoidButton .Enabled =  false;
  283                         LabRequest Date.Enabl ed = false ;
  284                         ReOpenLabO rder.Enabl ed = Check WkfCaseSta tusForReOp en(Activit y.WKF_CASE _ID, VIRP. EFR.BO.Wor kFlowActiv ityTypes.L abResult)  ? true : f alse;
  285                         //ReOpenLa bOrder.Ena bled = man ager.Check WkfCaseSta tusForReOp en(Activit y.WKF_CASE _ID, VIRP. EFR.BO.Wor kFlowActiv ityTypes.L abResult)  ? true : f alse;
  286                         RequiredFi eldValidat orLabReque stDate.Ena bled = tru e;
  287                         CancelButt on.Text =  "Back";
  288                         SaveButton .Validatio nGroup = " ";
  289                         SaveButton .Text = "S ave";
  290                         break;
  291  
  292                    //vo id status
  293                    case  (int)VIRP .EFR.BO.Wo rkflowCase ActivitySt atus.Voide d:
  294                         LabelForLa bLabelRepo rtDate.Vis ible = fal se;
  295                         LabelLabRe portDate.V isible = f alse;
  296                         CompleteBu tton.Enabl ed = false ;
  297                         SaveButton .Enabled =  true;
  298                         PrintButto n.Enabled  = false;
  299                         VoidButton .Enabled =  false;
  300                         LabRequest Date.Enabl ed = false ;
  301                         ReOpenLabO rder.Enabl ed = false ;
  302                         RequiredFi eldValidat orLabReque stDate.Ena bled = fal se;
  303                         CancelButt on.Text =  "Back";
  304                         SaveButton .Text = "U n-Void";
  305                         SaveButton .Validatio nGroup = " LabOrderVa lidation";
  306  
  307                         break;
  308                }
  309           }
  310  
  311           pr ivate void  SaveCompl eteLabOrde r(Func<str ing> opera tion)
  312           {
  313                VIRP.EFR .BO.LAB_OR DER order  = null;
  314  
  315                if (LabO rders != n ull && Lab Orders.Cou nt > 0)
  316                {
  317                    orde r = LabOrd ers.First( );
  318  
  319                    Save LabOrder(r ef order);
  320                }
  321                else
  322                {
  323                    orde r = new VI RP.EFR.BO. LAB_ORDER( );
  324  
  325                    Save LabOrder(r ef order);
  326  
  327                    orde r.WKF_CASE _ACTIVITY_ ID = Activ ity.WKF_CA SE_ACTIVIT Y_ID;
  328                    //La bOrders =  VIRP.EFR.B LL.LAB_ORD ERManager. GetItemsBy Activity(H ttpContext .Current.U ser.Identi ty.Name, U serSession .CurrentRe gistryId,  order.WKF_ CASE_ACTIV ITY_ID);
  329                    //Ac tivity.LAB _ORDERs.Ad d(order);
  330                }
  331                order.LA B_ORDER_ID  = VIRP.EF R.BLL.LAB_ ORDERManag er.Save(Ht tpContext. Current.Us er.Identit y.Name, Us erSession. CurrentReg istryId, o rder);
  332  
  333                //set qu estionnair e in-proce ss status
  334  
  335                OpenClos eReferralA ndWorkflow Case(WkfCa se, operat ion);
  336  
  337                Activity .WKF_CASE_ ACTIVITY_I D = Servic eInterface Manager.WK F_CASE_ACT IVITY_SAVE (HttpConte xt.Current .User.Iden tity.Name,  UserSessi on.Current RegistryId , Activity );
  338                //manage r.Update(A ctivity);
  339                //FormVi ewWorkflow Informatio n.DataBind ();
  340                GetRefre shLabOrder (Activity. WKF_CASE_A CTIVITY_ID );
  341           }
  342  
  343           // this is th e function  that gets  all value s from pag e controls  to eventu ally save  them in a  database  
  344           pr ivate void  SaveLabOr der(ref VI RP.EFR.BO. LAB_ORDER  labOrder)
  345           {
  346                labOrder .LAB_SEND_ DATE = Hel pers.Conve rtStringTo Nullable<D ateTime>(L abRequestD ate.Text.T rim());
  347                labOrder .LAB_RECEI VED_DATE =  Helpers.C onvertStri ngToNullab le<DateTim e>(LabSamp leReceived Date.Text. Trim());
  348                labOrder .LAB_RETUR N_DATE = H elpers.Con vertString ToNullable <DateTime> (LabelLabR eportDate. Text.Trim( ));
  349  
  350                labOrder .BSO_NUMBE R = txtBSO Number.Tex t.Trim();
  351                labOrder .SHIPMENT_ TRACKING_N UMBER = tx tTrackingN umber.Text .Trim();
  352  
  353                labOrder .SPECIAL_I NSTRUCTION  = txtSamp leInstruct ions.Text. Trim();
  354                labOrder .SAMPLE_DE SC = txtSa mpleDescri ption.Text .Trim();
  355  
  356                labOrder .STD_REGIS TRY_ID = U serSession .CurrentRe gistryId;
  357  
  358                SaveAnal ytes(labOr der);
  359           }
  360  
  361           pr ivate void  SetupAnal ytes(VIRP. EFR.BO.LAB _ORDER lab Order)
  362           {
  363                List<VIR P.EFR.BO.L AB_ORDER_D ETAIL> lis tDetails =  VIRP.EFR. BLL.LAB_OR DER_DETAIL Manager.Ge tItemsByLa bOrder(Htt pContext.C urrent.Use r.Identity .Name, Use rSession.C urrentRegi stryId, la bOrder.LAB _ORDER_ID) ;
  364                if (list Details !=  null)
  365                {
  366                    var  selected =  0;
  367                    fore ach (VIRP. EFR.BO.LAB _ORDER_DET AIL detail  in listDe tails)
  368                    {
  369                         int analyt eTypeId =  detail.STD _ANALYTETY PE_ID;
  370                         //analyte  of "other"  type 
  371                         if (analyt eTypeId ==  15)
  372                         {
  373                             OtherA nalyteChec k.Checked  = true;
  374                             OtherA nalyteText .Text = de tail.OTHER _ANALYTE_N AME;
  375                         }
  376                         else
  377                         {
  378                             ListIt em item =  AnalytesLi st.Items.F indByValue (analyteTy peId.ToStr ing());
  379                             if (it em != null )
  380                             {
  381                                 // if we find  factor no thing else  to do her
  382                                 it em.Selecte d = true;
  383                                 se lected++;
  384                             }
  385                         }
  386                    }
  387  
  388                    if ( selected = = 14)
  389                         AnalytesLi st.Items.F indByValue ("0").Sele cted = tru e;
  390                }
  391           }
  392           pr ivate void  SaveAnaly tes(VIRP.E FR.BO.LAB_ ORDER orde r)
  393           {
  394                List<VIR P.EFR.BO.L AB_ORDER_D ETAIL> det ails = VIR P.EFR.BLL. LAB_ORDER_ DETAILMana ger.GetIte msByLabOrd er(HttpCon text.Curre nt.User.Id entity.Nam e, UserSes sion.Curre ntRegistry Id, order. LAB_ORDER_ ID);
  395                if (deta ils != nul l)
  396                {
  397                    var  otherValue  = 15;
  398                    //ad d other An alyte
  399                    if ( OtherAnaly teCheck.Ch ecked)
  400                    {
  401                         if (!other Value.In(d etails.Sel ect(lod =>  lod.STD_A NALYTETYPE _ID).ToLis t()))
  402                         {
  403                             VIRP.E FR.BO.LAB_ ORDER_DETA IL detail  = new VIRP .EFR.BO.LA B_ORDER_DE TAIL();
  404  
  405                             detail .LAB_ORDER _ID = orde r.LAB_ORDE R_ID;
  406                             detail .STD_ANALY TETYPE_ID  = otherVal ue;
  407                             detail .OTHER_ANA LYTE_NAME  = OtherAna lyteText.T ext.Trim() ;
  408  
  409                             detail .LAB_ORDER _DETAIL_ID  = VIRP.EF R.BLL.LAB_ ORDER_DETA ILManager. Save(HttpC ontext.Cur rent.User. Identity.N ame, UserS ession.Cur rentRegist ryId, deta il);
  410                             //orde r.LAB_ORDE R_DETAILs. Add(detail );
  411                         }
  412                    }
  413                    else
  414                    {
  415                         if (otherV alue.In(de tails.Sele ct(lod =>  lod.STD_AN ALYTETYPE_ ID).ToList ()))
  416                         {
  417                             //anal yte is in  a database  and was u nselected  so need to  delete it  
  418                             VIRP.E FR.BO.LAB_ ORDER_DETA IL detail  = details. Where(lod  => lod.STD _ANALYTETY PE_ID == o therValue) .Single();
  419                             if (de tail != nu ll)
  420                                 VI RP.EFR.BLL .LAB_ORDER _DETAILMan ager.Delet e(HttpCont ext.Curren t.User.Ide ntity.Name , UserSess ion.Curren tRegistryI d, detail. LAB_ORDER_ DETAIL_ID) ;
  421                             //deta il.SetAsDe leteOnSubm it();
  422                         }
  423                    }
  424  
  425                    fore ach (ListI tem item i n Analytes List.Items )
  426                    {
  427                         int value  = int.Pars e(item.Val ue);
  428  
  429                         if (value  > 0)
  430                         {
  431                             if (it em.Selecte d)
  432                             {
  433                                 if  (value.In (details.S elect(lod  => lod.STD _ANALYTETY PE_ID).ToL ist()))
  434                                 {
  435                                      //do not hing since  referral  is already  in 
  436                                 }
  437                                 el se
  438                                 {
  439                                      //need t o generate  and save  a new anal yte, as it 's not pre sently in  a database  
  440                                      VIRP.EFR .BO.LAB_OR DER_DETAIL  detail =  new VIRP.E FR.BO.LAB_ ORDER_DETA IL();
  441  
  442                                      detail.L AB_ORDER_I D = order. LAB_ORDER_ ID;
  443                                      detail.S TD_ANALYTE TYPE_ID =  value;
  444  
  445                                      detail.L AB_ORDER_D ETAIL_ID =  VIRP.EFR. BLL.LAB_OR DER_DETAIL Manager.Sa ve(HttpCon text.Curre nt.User.Id entity.Nam e, UserSes sion.Curre ntRegistry Id, detail );
  446                                      //order. LAB_ORDER_ DETAILs.Ad d(detail);
  447                                 }
  448                             }
  449                             else
  450                             {
  451                                 if  (value.In (details.S elect(lod  => lod.STD _ANALYTETY PE_ID).ToL ist()))
  452                                 {
  453                                      //analyt e is in a  database a nd was uns elected so  need to d elete it 
  454                                      VIRP.EFR .BO.LAB_OR DER_DETAIL  detail =  details.Wh ere(lod =>  lod.STD_A NALYTETYPE _ID == val ue).Single ();
  455                                      if (deta il != null )
  456                                          VIRP .EFR.BLL.L AB_ORDER_D ETAILManag er.Delete( HttpContex t.Current. User.Ident ity.Name,  UserSessio n.CurrentR egistryId,  detail.LA B_ORDER_DE TAIL_ID);
  457                                      //detail .SetAsDele teOnSubmit ();
  458                                 }
  459                                 el se
  460                                 {
  461                                      //analyt e is not i n a databa se so no n eed to do  anything
  462                                 }
  463                             }
  464                         }
  465                    }
  466                }
  467           }
  468  
  469           // protected  override v oid LoadVi ewState(ob ject saved State)
  470           // {
  471           //     base.L oadViewSta te(savedSt ate);
  472           //     string  activityX ml = (stri ng)ViewSta te["activi tyXml"];
  473           //     Activi ty = Seria lizerUtil. Deserializ e<WKF_CASE _ACTIVITY> (activityX ml);
  474           // }
  475  
  476           // protected  override o bject Save ViewState( )
  477           // {
  478           //     ViewSt ate["activ ityXml"] =  Activity. Serialize( );
  479           //     return  base.Save ViewState( );
  480           // }
  481  
  482           pr otected vo id SaveBut ton_Click( object sen der, Event Args e)
  483           {
  484                ServiceI nterfaceMa nager.LogI nformation ("POSTBACK _EVENT", s tring.Form at("{0}.{1 }", System .Reflectio n.MethodBa se.GetCurr entMethod( ).Declarin gType.Full Name, Syst em.Reflect ion.Method Base.GetCu rrentMetho d().Name),  HttpConte xt.Current .User.Iden tity.Name,  UserSessi on.Current RegistryId );
  485  
  486                try
  487                {
  488                    if ( Activity.S TD_WKFACTI VITYSTS_ID  == (int)V IRP.EFR.BO .WorkflowC aseActivit yStatus.Vo ided)
  489                         Activity.S TD_WKFACTI VITYSTS_ID  = (int)VI RP.EFR.BO. WorkflowCa seActivity Status.New ;
  490  
  491                    Save CompleteLa bOrder(()  => "Save") ;
  492  
  493                    //Se tSaveSucce ssMessage( );
  494  
  495                    Setu pBioLabOrd er();
  496  
  497                    Clie ntScript.R egisterSta rtupScript (this.GetT ype(), "al ertMessage ", "<scrip t type='te xt/javascr ipt'>alert ('Save Suc cessful'); </script>" );
  498                }
  499                catch (E xception e x)
  500                {
  501                    Serv iceInterfa ceManager. LogError(e x.Message,  string.Fo rmat("{0}. {1}", Syst em.Reflect ion.Method Base.GetCu rrentMetho d().Declar ingType.Fu llName, Sy stem.Refle ction.Meth odBase.Get CurrentMet hod().Name ), HttpCon text.Curre nt.User.Id entity.Nam e, UserSes sion.Curre ntRegistry Id);
  502                    thro w ex;
  503                }
  504           }
  505  
  506           pr otected vo id CancelB utton_Clic k(object s ender, Eve ntArgs e)
  507           {
  508                Redirect ToReferrin gPage();
  509  
  510                  // D N S  - Defect  827306
  511                //If red irect abov e fails, r edirect to  original  referrer
  512                var navi gatedFrom  = VIRP.EFR .BO.Sessio nItemRefer ence<Uri>. Get(Sessio n[Referral Key]);
  513                if (navi gatedFrom  != null)
  514                {
  515                    Sess ion.Remove (ReferralK ey);
  516                    Resp onse.Redir ect(naviga tedFrom.Pa thAndQuery );
  517                }
  518           }
  519  
  520           pr otected vo id Complet eButton_Cl ick(object  sender, E ventArgs e )
  521           {
  522                Activity .STD_WKFAC TIVITYSTS_ ID = (int) VIRP.EFR.B O.Workflow CaseActivi tyStatus.A waitingRes ults;
  523                //this u n-voids la b result s o have to  open or re -open work flow(case)  if it's n ot open
  524  
  525                bool lab ResultExis ts = Activ ityExists( Activity.W KF_CASE_ID , VIRP.EFR .BO.WorkFl owActivity Types.LabR esult);
  526  
  527                if (!lab ResultExis ts)
  528                {
  529                    //cr eate lab r esult _act ivity sinc e it's no  longer sim ulated 
  530                    WKF_ CASE_ACTIV ITY NewAct ivity = ne w WKF_CASE _ACTIVITY( );
  531  
  532                    NewA ctivity.CR EATED = Ne wActivity. UPDATED =  DateTime.N ow;
  533                    NewA ctivity.CR EATEDBY =  NewActivit y.UPDATEDB Y = HttpCo ntext.Curr ent.User.I dentity.Na me;
  534                    NewA ctivity.WK F_CASE_ID  = Activity .WKF_CASE_ ID;
  535                    NewA ctivity.ST D_WKFACTIV ITYTYPE_ID  = Convert .ToInt16(V IRP.EFR.BO .WorkFlowA ctivityTyp es.LabResu lt);
  536                    NewA ctivity.ST D_WKFACTIV ITYSTS_ID  = Convert. ToInt16(VI RP.EFR.BO. WorkflowCa seActivity Status.New );
  537                    NewA ctivity.RE PRESENTATI VE_NAME =  Activity.R EPRESENTAT IVE_NAME;
  538                    NewA ctivity.CO NTACT_NAME  = "Dr. Br own";
  539  
  540                    NewA ctivity.WK F_CASE_ACT IVITY_ID =  ServiceIn terfaceMan ager.WKF_C ASE_ACTIVI TY_SAVE(Ht tpContext. Current.Us er.Identit y.Name, Us erSession. CurrentReg istryId, N ewActivity );
  541  
  542                    //Ne wActivity. SetAsChang eTrackingR oot(Entity State.New,  true);
  543                    //Ne wActivity. SetAsInser tOnSubmit( );
  544                    //ma nager.Upda te(NewActi vity);
  545                }
  546  
  547                SaveComp leteLabOrd er(() => " Complete") ;
  548  
  549                SetupBio LabOrder() ;
  550  
  551                ClientSc ript.Regis terStartup Script(thi s.GetType( ), "alertM essage", " <script ty pe='text/j avascript' >alert('Sa ve Success ful');</sc ript>");
  552           }
  553  
  554           pr otected vo id PrintBu tton_Click (object se nder, Even tArgs e)
  555           {
  556                Suppress SaveSucces sMessage =  true;
  557  
  558                Response .Redirect( "~/Custom/ EFR/LabOrd ers/TefscL aboratoryR equestRepo rt.aspx?ac tivityId="  + Activit y.WKF_CASE _ACTIVITY_ ID.ToStrin g(), false );
  559           }
  560           pr otected vo id VoidBut ton_Click( object sen der, Event Args e)
  561           {
  562                LabReque stDate.Tex t = "";
  563                LabSampl eReceivedD ate.Text =  "";
  564  
  565                Activity .STD_WKFAC TIVITYSTS_ ID = (int) VIRP.EFR.B O.Workflow CaseActivi tyStatus.V oided;
  566  
  567                SaveComp leteLabOrd er(() => " Void");
  568  
  569                SetupBio LabOrder() ;
  570  
  571                ClientSc ript.Regis terStartup Script(thi s.GetType( ), "alertM essage", " <script ty pe='text/j avascript' >alert('Sa ve Success ful');</sc ript>");
  572           }
  573  
  574           pr ivate void  OpenClose ReferralAn dWorkflowC ase(WKF_CA SE parentC ase, Func< string> op eration)
  575           {
  576                //Copied  this code  from LabK itDetails
  577  
  578                REFERRAL  parentRef erral = Se rviceInter faceManage r.REFERRAL _GET(HttpC ontext.Cur rent.User. Identity.N ame, UserS ession.Cur rentRegist ryId, pare ntCase.REF ERRAL_ID.G etValueOrD efault());
  579                if (pare ntReferral  != null)
  580                {
  581                    if ( operation( ) == "Void ")
  582                    {
  583                         List<WKF_C ASE> cases  = Service InterfaceM anager.WKF _CASE_GET_ ALL_BY_REF ERRAL(Http Context.Cu rrent.User .Identity. Name, User Session.Cu rrentRegis tryId, par entReferra l.REFERRAL _ID);
  584                         if (cases  != null)
  585                         {
  586                             bool b lnIncomple te = false ;
  587                             foreac h (WKF_CAS E c in cas es)
  588                             {
  589                                 if  (c.WKF_CA SE_ID != p arentCase. WKF_CASE_I D && c.STD _WKFCASEST S_ID != (i nt)VIRP.EF R.BO.WorkF lowCaseSta tus.Comple ted)
  590                                 {
  591                                      blnIncom plete = tr ue;
  592                                      break;
  593                                 }
  594                             }
  595                             if (!b lnIncomple te)
  596                                 pa rentReferr al.STD_REF ERRALSTS_I D = (int)V IRP.EFR.BO .ReferralS tatus.Comp leted;
  597                         }
  598  
  599                         parentCase .STD_WKFCA SESTS_ID =  (int)VIRP .EFR.BO.Wo rkFlowCase Status.Com pleted;
  600                    }
  601                    else
  602                    {
  603                         if (parent Referral.S TD_REFERRA LSTS_ID !=  (int)VIRP .EFR.BO.Re ferralStat us.InProce ss)
  604                             parent Referral.S TD_REFERRA LSTS_ID =  (int)VIRP. EFR.BO.Ref erralStatu s.InProces s;
  605  
  606                         if (parent Case.STD_W KFCASESTS_ ID != (int )VIRP.EFR. BO.WorkFlo wCaseStatu s.InProces s)
  607                             parent Case.STD_W KFCASESTS_ ID = (int) VIRP.EFR.B O.WorkFlow CaseStatus .InProcess ;
  608                    }
  609  
  610                    Supp ressSaveSu ccessMessa ge = true;
  611                    pare ntCase.WKF _CASE_ID =  ServiceIn terfaceMan ager.WKF_C ASE_SAVE(H ttpContext .Current.U ser.Identi ty.Name, U serSession .CurrentRe gistryId,  parentCase );
  612                    pare ntReferral .REFERRAL_ ID = Servi ceInterfac eManager.R EFERRAL_SA VE(HttpCon text.Curre nt.User.Id entity.Nam e, UserSes sion.Curre ntRegistry Id, parent Referral);
  613  
  614                    Supp ressSaveSu ccessMessa ge = false ;
  615                }
  616           }
  617  
  618           // private vo id OpenClo seReferral AndWorkflo wCase(Func <string> o peration)
  619           // {
  620           //     Referr alManager  rm = new R eferralMan ager();
  621  
  622           //     int wf CaseRefId;
  623           //     if (in t.TryParse (ViewState ["Referral CaseId"].T oString(),  out wfCas eRefId))
  624           //     {
  625           //         EF R_REFERRAL  parentRef erral = rm .getReferr alByReferr alID(wfCas eRefId);
  626  
  627           //         pa rentReferr al = Seria lizerUtil. Deserializ e<EFR_REFE RRAL>(pare ntReferral .Serialize ());
  628           //         pa rentReferr al.SetAsCh angeTracki ngRoot();
  629  
  630           //         WK F_CASE par entCase =  parentRefe rral.WKF_C ASEs.Where (a => a.WK F_CASE_ID  == Activit y.WKF_CASE _ID).First ();
  631  
  632           //         if  (operatio n() == "Vo id")
  633           //         {
  634           //              parentCa se.STD_WKF CASESTS_ID  = (int)VI RP.EFR.BO. WorkFlowCa seStatus.C ompleted;
  635           //              var item s = parent Referral.W KF_CASEs.E xcept(new  List<WKF_C ASE> { par entCase },  new Workf lowCaseMan ager.Workf lowCaseCom parer());
  636  
  637           //              if (item s.Count(a  => a.STD_W KFCASESTS_ ID != (int )VIRP.EFR. BO.WorkFlo wCaseStatu s.Complete d) == 0)
  638  
  639           //                  pare ntReferral .STD_REFER RALSTS_ID  = (int)VIR P.EFR.BO.R eferralSta tus.Comple ted;
  640           //         }
  641           //         el se
  642           //         {
  643           //              if (pare ntReferral .STD_REFER RALSTS_ID  != (int)VI RP.EFR.BO. ReferralSt atus.InPro cess)
  644           //                  pare ntReferral .STD_REFER RALSTS_ID  = (int)VIR P.EFR.BO.R eferralSta tus.InProc ess;
  645  
  646           //              if (pare ntCase.STD _WKFCASEST S_ID != (i nt)VIRP.EF R.BO.WorkF lowCaseSta tus.InProc ess)
  647           //                  pare ntCase.STD _WKFCASEST S_ID = (in t)VIRP.EFR .BO.WorkFl owCaseStat us.InProce ss;
  648           //         }
  649  
  650           //         Su ppressSave SuccessMes sage = tru e;
  651           //         rm .Update(pa rentReferr al);
  652  
  653           //         Su ppressSave SuccessMes sage = fal se;
  654           //     }
  655           // }
  656  
  657           pr otected vo id Reopen_ LabOrder_C lick(objec t sender,  EventArgs  e)
  658           {
  659                ServiceI nterfaceMa nager.LogI nformation ("POSTBACK _EVENT", s tring.Form at("{0}.{1 }", System .Reflectio n.MethodBa se.GetCurr entMethod( ).Declarin gType.Full Name, Syst em.Reflect ion.Method Base.GetCu rrentMetho d().Name),  HttpConte xt.Current .User.Iden tity.Name,  UserSessi on.Current RegistryId );
  660  
  661                try
  662                {
  663                    Acti vity.STD_W KFACTIVITY STS_ID = ( int)VIRP.E FR.BO.Work flowCaseAc tivityStat us.Awaitin gResults;
  664                    Save CompleteLa bOrder(()  => "ReOpen ");
  665  
  666                    Setu pBioLabOrd er();
  667  
  668                    Clie ntScript.R egisterSta rtupScript (this.GetT ype(), "al ertMessage ", "<scrip t type='te xt/javascr ipt'>alert ('Save Suc cessful'); </script>" );
  669                }
  670                catch (E xception e x)
  671                {
  672                    Serv iceInterfa ceManager. LogError(e x.Message,  string.Fo rmat("{0}. {1}", Syst em.Reflect ion.Method Base.GetCu rrentMetho d().Declar ingType.Fu llName, Sy stem.Refle ction.Meth odBase.Get CurrentMet hod().Name ), HttpCon text.Curre nt.User.Id entity.Nam e, UserSes sion.Curre ntRegistry Id);
  673                    thro w ex;
  674                }
  675           }
  676  
  677           pr ivate bool  CheckWkfC aseStatusF orReOpen(i nt wkfId,  VIRP.EFR.B O.WorkFlow ActivityTy pes type)
  678           {
  679                bool isW orkflowVal idForReOpe n = false;
  680                List<WKF _CASE_ACTI VITY> acti vities = S erviceInte rfaceManag er.WKF_CAS E_ACTIVITY _GET_ALL_B Y_WORKSTRE AM(HttpCon text.Curre nt.User.Id entity.Nam e, UserSes sion.Curre ntRegistry Id, wkfId) ;
  681                if (acti vities !=  null)
  682                {
  683                    acti vities = a ctivities. Where(s =>  s.STD_WKF ACTIVITYTY PE_ID == ( int)type & & (s.STD_W KFACTIVITY STS_ID ==  (int)VIRP. EFR.BO.Wor kflowCaseA ctivitySta tus.InProc ess || s.S TD_WKFACTI VITYSTS_ID  == (int)V IRP.EFR.BO .WorkflowC aseActivit yStatus.Ne w) && s.AR CHIVED_FLA G == false ).ToList() ;
  684                    if ( activities .Count > 0 )
  685                         isWorkflow ValidForRe Open = tru e;
  686                }
  687  
  688                return i sWorkflowV alidForReO pen;
  689           }
  690  
  691           pu blic bool  ActivityEx ists(int w kfId, VIRP .EFR.BO.Wo rkFlowActi vityTypes  type)
  692           {
  693                bool act ivityExist s = false;
  694                List<WKF _CASE_ACTI VITY> acti vities = S erviceInte rfaceManag er.WKF_CAS E_ACTIVITY _GET_ALL_B Y_WORKSTRE AM(HttpCon text.Curre nt.User.Id entity.Nam e, UserSes sion.Curre ntRegistry Id, wkfId) ;
  695                if (acti vities !=  null)
  696                {
  697                    acti vities = a ctivities. Where(s =>  s.STD_WKF ACTIVITYTY PE_ID == ( int)type & & s.ARCHIV ED_FLAG ==  false).To List();
  698                    if ( activities .Count > 0 )
  699                         activityEx ists = tru e;
  700                }
  701  
  702                return a ctivityExi sts;
  703           }
  704  
  705           pr otected ov erride voi d Ds_Selec ting(objec t sender,  ObjectData SourceSele ctingEvent Args e)
  706           {
  707                ServiceI nterfaceMa nager.LogI nformation ("POSTBACK _EVENT", S tring.Form at("{0}.{1 }", System .Reflectio n.MethodBa se.GetCurr entMethod( ).Declarin gType.Full Name, Syst em.Reflect ion.Method Base.GetCu rrentMetho d().Name),  HttpConte xt.Current .User.Iden tity.Name,  UserSessi on.Current RegistryId );
  708  
  709                try
  710                {
  711                    //e. InputParam eters.Clea r();
  712  
  713                    //st ring txtSe arch = Tex tBoxSearch Criteria.T ext;
  714                    //st ring listF acility =  DropDownLi stFacility .SelectedV alue;
  715  
  716                    if ( e.InputPar ameters["C URRENT_USE R"] != nul l)
  717                         e.InputPar ameters["C URRENT_USE R"] = Http Context.Cu rrent.User .Identity. Name;
  718                    else
  719                         e.InputPar ameters.Ad d("CURRENT _USER", Ht tpContext. Current.Us er.Identit y.Name);
  720  
  721                    if ( e.InputPar ameters["C URRENT_REG ISTRY_ID"]  != null)
  722                         e.InputPar ameters["C URRENT_REG ISTRY_ID"]  = UserSes sion.Curre ntRegistry Id;
  723                    else
  724                         e.InputPar ameters.Ad d("CURRENT _REGISTRY_ ID", UserS ession.Cur rentRegist ryId);
  725  
  726                    //e. InputParam eters.Add( "lastName" , txtSearc h);
  727                    //e. InputParam eters.Add( "facilityI d", listFa cility);
  728                }
  729                catch (E xception e x)
  730                {
  731                    Serv iceInterfa ceManager. LogError(e x.Message,  String.Fo rmat("{0}. {1}", Syst em.Reflect ion.Method Base.GetCu rrentMetho d().Declar ingType.Fu llName, Sy stem.Refle ction.Meth odBase.Get CurrentMet hod().Name ), HttpCon text.Curre nt.User.Id entity.Nam e, UserSes sion.Curre ntRegistry Id);
  732                    thro w ex;
  733                }
  734           }
  735       }
  736   }