Esempio n. 1
0
 ///<summary>Fills visProvs, visOps, forCurView, apptRows, and rowsPerIncr based on the appointment view passed in and whether it is for the week view or not.  This method uses 'out' variables so that the encompassing logic doesn't ALWAYS affect the global static variables used to draw the appointment views.  We don't want the following logic to affect the global static variables in the case where we are trying to get information needed to filter the waiting room.</summary>
 public static void FillForApptView(bool isWeekly, ApptView apptViewCur, out List <Provider> visProvs, out List <Operatory> visOps,
                                    out List <ApptViewItem> forCurView, out List <ApptViewItem> apptRows, out int rowsPerIncr, bool isFillVisProvs = true)
 {
     forCurView = new List <ApptViewItem>();
     visProvs   = new List <Provider>();
     visOps     = new List <Operatory>();
     apptRows   = new List <ApptViewItem>();
     //If there are no appointment views set up (therefore, none selected), then use a hard-coded default view.
     if (ApptViews.IsNoneView(apptViewCur))
     {
         //make visible ops exactly the same as the short ops list (all except hidden)
         visOps.AddRange(
             Operatories.GetWhere(x => !PrefC.HasClinicsEnabled ||                  //if clinics disabled
                                  Clinics.ClinicNum == 0 ||              //or if program level ClinicNum set to Headquarters
                                  x.ClinicNum == Clinics.ClinicNum                 //or this is the program level ClinicNum
                                  , true)
             );
         if (isFillVisProvs)
         {
             if (PrefC.HasClinicsEnabled)
             {
                 foreach (Operatory op in visOps)
                 {
                     Provider provDent = Providers.GetProv(op.ProvDentist);
                     Provider provHyg  = Providers.GetProv(op.ProvHygienist);
                     if (provDent != null)
                     {
                         visProvs.Add(provDent);
                     }
                     if (provHyg != null)
                     {
                         visProvs.Add(provHyg);
                     }
                 }
             }
             else
             {
                 //make visible provs exactly the same as the prov list (all except hidden)
                 visProvs.AddRange(Providers.GetDeepCopy(true));
             }
         }
         //Hard coded elements showing
         apptRows.Add(new ApptViewItem("PatientName", 0, Color.Black));
         apptRows.Add(new ApptViewItem("ASAP", 1, Color.DarkRed));
         apptRows.Add(new ApptViewItem("MedUrgNote", 2, Color.DarkRed));
         apptRows.Add(new ApptViewItem("PremedFlag", 3, Color.DarkRed));
         apptRows.Add(new ApptViewItem("Lab", 4, Color.DarkRed));
         apptRows.Add(new ApptViewItem("Procs", 5, Color.Black));
         apptRows.Add(new ApptViewItem("Note", 6, Color.Black));
         rowsPerIncr = 1;
     }
     //An appointment view is selected, so add provs and ops from the view to our lists of indexes.
     else
     {
         List <ApptViewItem> listApptViewItems = ApptViewItems.GetWhere(x => x.ApptViewNum == apptViewCur.ApptViewNum);
         for (int i = 0; i < listApptViewItems.Count; i++)
         {
             forCurView.Add(listApptViewItems[i]);
             if (listApptViewItems[i].OpNum > 0)                   //op
             {
                 if (apptViewCur.OnlyScheduledProvs && !isWeekly)
                 {
                     continue;                            //handled below in AddOpsForScheduledProvs
                 }
                 Operatory op = Operatories.GetFirstOrDefault(x => x.OperatoryNum == listApptViewItems[i].OpNum, true);
                 if (op != null)
                 {
                     visOps.Add(op);
                 }
             }
             else if (listApptViewItems[i].ProvNum > 0)                   //prov
             {
                 if (!isFillVisProvs)
                 {
                     continue;
                 }
                 Provider prov = Providers.GetFirstOrDefault(x => x.ProvNum == listApptViewItems[i].ProvNum, true);
                 if (prov != null)
                 {
                     visProvs.Add(prov);
                 }
             }
             else                      //element or apptfielddef
             {
                 apptRows.Add(listApptViewItems[i]);
             }
         }
         rowsPerIncr = apptViewCur.RowsPerIncr;
     }
     //Remove any duplicates before return.
     visOps = visOps.GroupBy(x => x.OperatoryNum).Select(x => x.First()).ToList();
     if (isFillVisProvs)
     {
         visProvs = visProvs.GroupBy(x => x.ProvNum).Select(x => x.First()).ToList();
     }
 }