private void contrGrid_DoubleClick(object sender, System.EventArgs e) { int tempDay = (int)Math.Floor((double)(mousePos.X - contrGrid.NumW) / (double)contrGrid.ColW); if (tempDay == 7) { return; } if (tempDay == -1) { return; } int tempOpI = (int)Math.Floor((mousePos.X - contrGrid.NumW - (tempDay * contrGrid.ColW)) / contrGrid.opW); int tempMin = (int)((mousePos.Y - Math.Floor((double)mousePos.Y / (double)contrGrid.RowH / 6) * contrGrid.RowH * 6) / contrGrid.RowH) * 10; int tempHr = (int)Math.Floor((double)mousePos.Y / (double)contrGrid.RowH / (double)6); TimeSpan tempSpan = new TimeSpan(tempHr, tempMin, 0); //MessageBox.Show(tempDay.ToString()+","+tempHr.ToString()+":"+tempMin.ToString()); for (int i = 0; i < SchedDefaults.List.Length; i++) { if (SchedType == ScheduleType.Practice) //for practice { if (SchedDefaults.List[i].SchedType != ScheduleType.Practice) { continue; //only use practice blocks } } if (SchedType == ScheduleType.Provider) //for providers { if (SchedDefaults.List[i].SchedType != ScheduleType.Provider) { continue; //only use prov blocks } if (SchedDefaults.List[i].ProvNum != Providers.List[listProv.SelectedIndex].ProvNum) { continue; //only use blocks for this prov } } if (SchedType == ScheduleType.Blockout) //for blockouts //only use blockout blocks { if (SchedDefaults.List[i].SchedType != ScheduleType.Blockout) { continue; } //if op is zero (any), then don't filter if (SchedDefaults.List[i].Op != 0) { if (Operatories.GetOrder(SchedDefaults.List[i].Op) != tempOpI) { continue; } } } if (tempDay == SchedDefaults.List[i].DayOfWeek && tempSpan >= SchedDefaults.List[i].StartTime.TimeOfDay && tempSpan < SchedDefaults.List[i].StopTime.TimeOfDay) { FormSchedDefaultBlockEdit FormBE = new FormSchedDefaultBlockEdit(SchedDefaults.List[i]); FormBE.ShowDialog(); if (FormBE.DialogResult != DialogResult.OK) { return; } changed = true; FillGrid(); return; } } }
///<summary>When looking at a daily appointment module and the current appointment view is has 'OnlyScheduleProvs' turned on, this method will dynamically add additional operatories to visOps for providers that are scheduled to work.</summary> public static void AddOpsForScheduledProvs(bool isWeekly, List <Schedule> dailySched, ApptView apptViewCur, ref List <Operatory> visOps) { //if this appt view has the option to show only scheduled providers and this is daily view. //Remember that there is no intelligence in weekly view for this option, and it behaves just like it always did. if (ApptViews.IsNoneView(apptViewCur) || dailySched == null || visOps == null || !apptViewCur.OnlyScheduledProvs || isWeekly) { return; } //intelligently decide what ops to show. It's based on the schedule for the day. //visOps will be totally empty right now because it looped out of the above section of code. List <long> listSchedOps; bool opAdded; int indexOp; List <Operatory> listOpsShort = Operatories.GetDeepCopy(true); List <long> listApptViewOpNums = ApptViewItems.GetOpsForView(apptViewCur.ApptViewNum); for (int i = 0; i < listOpsShort.Count; i++) //loop through all ops for all views (except the hidden ones, of course) //If this operatory was not one of the selected Ops from the Appt View Edit window, skip it. { if (!listApptViewOpNums.Contains(listOpsShort[i].OperatoryNum)) { continue; } //find any applicable sched for the op opAdded = false; for (int s = 0; s < dailySched.Count; s++) { if (dailySched[s].SchedType != ScheduleType.Provider) { continue; } if (dailySched[s].StartTime == new TimeSpan(0)) //skip if block starts at midnight. { continue; } if (dailySched[s].StartTime == dailySched[s].StopTime) //skip if block has no length. { continue; } if (apptViewCur.OnlySchedAfterTime > new TimeSpan(0, 0, 0)) { if (dailySched[s].StartTime < apptViewCur.OnlySchedAfterTime || dailySched[s].StopTime < apptViewCur.OnlySchedAfterTime) { continue; } } if (apptViewCur.OnlySchedBeforeTime > new TimeSpan(0, 0, 0)) { if (dailySched[s].StartTime > apptViewCur.OnlySchedBeforeTime || dailySched[s].StopTime > apptViewCur.OnlySchedBeforeTime) { continue; } } //this 'sched' must apply to this situation. //listSchedOps is the ops for this 'sched'. listSchedOps = dailySched[s].Ops; //Add all the ops for this 'sched' to the list of visible ops for (int p = 0; p < listSchedOps.Count; p++) { //Filter the ops if the clinic option was set for the appt view. if (apptViewCur.ClinicNum > 0 && apptViewCur.ClinicNum != Operatories.GetOperatory(listSchedOps[p]).ClinicNum) { continue; } if (listSchedOps[p] == listOpsShort[i].OperatoryNum) { Operatory op = listOpsShort[i]; indexOp = Operatories.GetOrder(listSchedOps[p]); if (indexOp != -1 && !visOps.Contains(op)) //prevents adding duplicate ops { visOps.Add(op); opAdded = true; break; } } } //If the provider is not scheduled to any op(s), add their default op(s). if (listOpsShort[i].ProvDentist == dailySched[s].ProvNum && listSchedOps.Count == 0) //only if the sched does not specify any ops //Only add the op if the clinic option was not set in the appt view or if the op is assigned to that clinic. { if (apptViewCur.ClinicNum == 0 || apptViewCur.ClinicNum == listOpsShort[i].ClinicNum) { indexOp = Operatories.GetOrder(listOpsShort[i].OperatoryNum); if (indexOp != -1 && !visOps.Contains(listOpsShort[i])) { visOps.Add(listOpsShort[i]); opAdded = true; } } } if (opAdded) { break; //break out of the loop of schedules. Continue with the next op. } } } //Remove any duplicates before return. visOps = visOps.GroupBy(x => x.OperatoryNum).Select(x => x.First()).ToList(); }
///<summary>Gets (list)ForCurView, ApptDrawing.VisOps, ApptDrawing.VisProvs, and ApptRows. Also sets TwoRows. Works even if supply -1 to indicate no apptview is selected. Pass in null for the dailySched if this is a weekly view or if in FormApptViewEdit.</summary> public static void GetForCurView(ApptView av, bool isWeekly, List <Schedule> dailySched) { ApptViewCur = av; ForCurView = new List <ApptViewItem>(); ApptDrawing.VisProvs = new List <Provider>(); ApptDrawing.VisOps = new List <Operatory>(); ApptRows = new List <ApptViewItem>(); int index; //If there are no appointment views set up (therefore, none selected), then use a hard-coded default view. if (ApptViewCur == null) { //MessageBox.Show("apptcategorynum:"+ApptCategories.Cur.ApptCategoryNum.ToString()); //make visible ops exactly the same as the short ops list (all except hidden) for (int i = 0; i < OperatoryC.ListShort.Count; i++) { ApptDrawing.VisOps.Add(OperatoryC.ListShort[i]); } //make visible provs exactly the same as the prov list (all except hidden) for (int i = 0; i < ProviderC.ListShort.Count; i++) { ApptDrawing.VisProvs.Add(ProviderC.ListShort[i]); } //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)); ApptDrawing.RowsPerIncr = 1; } //An appointment view is selected, so add provs and ops from the view to our lists of indexes. else { for (int i = 0; i < ApptViewItemC.List.Length; i++) { if (ApptViewItemC.List[i].ApptViewNum == ApptViewCur.ApptViewNum) { ForCurView.Add(ApptViewItemC.List[i]); if (ApptViewItemC.List[i].OpNum > 0) //op { if (ApptViewCur.OnlyScheduledProvs && !isWeekly) { continue; //handled below } index = Operatories.GetOrder(ApptViewItemC.List[i].OpNum); if (index != -1) { ApptDrawing.VisOps.Add(OperatoryC.ListShort[index]); } } else if (ApptViewItemC.List[i].ProvNum > 0) //prov { index = Providers.GetIndex(ApptViewItemC.List[i].ProvNum); if (index != -1) { ApptDrawing.VisProvs.Add(ProviderC.ListShort[index]); } } else //element or apptfielddef { ApptRows.Add(ApptViewItemC.List[i]); } } } ApptDrawing.RowsPerIncr = ApptViewCur.RowsPerIncr; } //if this appt view has the option to show only scheduled providers and this is daily view. //Remember that there is no intelligence in weekly view for this option, and it behaves just like it always did. if (ApptViewCur != null && ApptViewCur.OnlyScheduledProvs && !isWeekly) { //intelligently decide what ops to show. It's based on the schedule for the day. //VisOps will be totally empty right now because it looped out of the above section of code. List <long> listSchedOps; bool opAdded; int indexOp; for (int i = 0; i < OperatoryC.ListShort.Count; i++) //loop through all ops for all views (except the hidden ones, of course) //find any applicable sched for the op { opAdded = false; for (int s = 0; s < dailySched.Count; s++) { if (dailySched[s].SchedType != ScheduleType.Provider) { continue; } if (dailySched[s].StartTime == new TimeSpan(0)) //skip if block starts at midnight. { continue; } if (dailySched[s].StartTime == dailySched[s].StopTime) //skip if block has no length. { continue; } if (ApptViewCur.OnlySchedAfterTime > new TimeSpan(0, 0, 0)) { if (dailySched[s].StartTime < ApptViewCur.OnlySchedAfterTime || dailySched[s].StopTime < ApptViewCur.OnlySchedAfterTime) { continue; } } if (ApptViewCur.OnlySchedBeforeTime > new TimeSpan(0, 0, 0)) { if (dailySched[s].StartTime > ApptViewCur.OnlySchedBeforeTime || dailySched[s].StopTime > ApptViewCur.OnlySchedBeforeTime) { continue; } } //this 'sched' must apply to this situation. //listSchedOps is the ops for this 'sched'. listSchedOps = dailySched[s].Ops; //Add all the ops for this 'sched' to the list of visible ops for (int p = 0; p < listSchedOps.Count; p++) { //Filter the ops if the clinic option was set for the appt view. if (ApptViewCur.ClinicNum > 0 && ApptViewCur.ClinicNum != Operatories.GetOperatory(listSchedOps[p]).ClinicNum) { continue; } if (listSchedOps[p] == OperatoryC.ListShort[i].OperatoryNum) { Operatory op = OperatoryC.ListShort[i]; indexOp = Operatories.GetOrder(listSchedOps[p]); if (indexOp != -1 && !ApptDrawing.VisOps.Contains(op)) //prevents adding duplicate ops { ApptDrawing.VisOps.Add(op); opAdded = true; break; } } } //If the provider is not scheduled to any op(s), add their default op(s). if (OperatoryC.ListShort[i].ProvDentist == dailySched[s].ProvNum && listSchedOps.Count == 0) //only if the sched does not specify any ops //Only add the op if the clinic option was not set in the appt view or if the op is assigned to that clinic. { if (ApptViewCur.ClinicNum == 0 || ApptViewCur.ClinicNum == OperatoryC.ListShort[i].ClinicNum) { indexOp = Operatories.GetOrder(OperatoryC.ListShort[i].OperatoryNum); if (indexOp != -1 && !ApptDrawing.VisOps.Contains(OperatoryC.ListShort[i])) { ApptDrawing.VisOps.Add(OperatoryC.ListShort[i]); opAdded = true; } } } if (opAdded) { break; //break out of the loop of schedules. Continue with the next op. } } } } ApptDrawing.VisOps.Sort(CompareOps); ApptDrawing.VisProvs.Sort(CompareProvs); }
///<summary>Gets (list)ForCurView, VisOps, VisProvs, and ApptRows. Also sets TwoRows. Works even if supply -1 to indicate no apptview is selected.</summary> public static void GetForCurView(ApptView ApptViewCur) { ArrayList tempAL = new ArrayList(); ArrayList ALprov = new ArrayList(); ArrayList ALops = new ArrayList(); ArrayList ALelements = new ArrayList(); if (ApptViewCur.ApptViewNum == 0) { //MessageBox.Show("apptcategorynum:"+ApptCategories.Cur.ApptCategoryNum.ToString()); //make visible ops exactly the same as the short ops list (all except hidden) for (int i = 0; i < Operatories.ListShort.Length; i++) { ALops.Add(i); } //make visible provs exactly the same as the prov list (all except hidden) for (int i = 0; i < Providers.List.Length; i++) { ALprov.Add(i); } //Hard coded elements showing ALelements.Add(new ApptViewItem("PatientName", 0, Color.Black)); ALelements.Add(new ApptViewItem("Lab", 1, Color.DarkRed)); ALelements.Add(new ApptViewItem("Procs", 2, Color.Black)); ALelements.Add(new ApptViewItem("Note", 3, Color.Black)); ContrApptSheet.RowsPerIncr = 1; } else { int index; for (int i = 0; i < List.Length; i++) { if (List[i].ApptViewNum == ApptViewCur.ApptViewNum) { tempAL.Add(List[i]); if (List[i].OpNum > 0) //op { index = Operatories.GetOrder(List[i].OpNum); if (index != -1) { ALops.Add(index); } } else if (List[i].ProvNum > 0) //prov { index = Providers.GetIndex(List[i].ProvNum); if (index != -1) { ALprov.Add(index); } } else //element { ALelements.Add(List[i]); } } } ContrApptSheet.RowsPerIncr = ApptViewCur.RowsPerIncr; } ForCurView = new ApptViewItem[tempAL.Count]; for (int i = 0; i < tempAL.Count; i++) { ForCurView[i] = (ApptViewItem)tempAL[i]; } VisOps = new int[ALops.Count]; for (int i = 0; i < ALops.Count; i++) { VisOps[i] = (int)ALops[i]; } Array.Sort(VisOps); VisProvs = new int[ALprov.Count]; for (int i = 0; i < ALprov.Count; i++) { VisProvs[i] = (int)ALprov[i]; } Array.Sort(VisProvs); ApptRows = new ApptViewItem[ALelements.Count]; for (int i = 0; i < ALelements.Count; i++) { ApptRows[i] = (ApptViewItem)ALelements[i]; } }
private void ContrSchedGrid_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { SolidBrush blockBrush = new SolidBrush(Color.White); float blockW = ColW; //set in each loop float opOffset = 0; if (SchedDefaults.List != null) { for (int i = 0; i < SchedDefaults.List.Length; i++) { if (SchedType == ScheduleType.Practice) //for practice { if (SchedDefaults.List[i].SchedType != ScheduleType.Practice) { continue; //only show practice blocks } } if (SchedType == ScheduleType.Provider) //for providers { if (SchedDefaults.List[i].SchedType != ScheduleType.Provider) { continue; //only show prov blocks } if (SchedDefaults.List[i].ProvNum != ProvNum) { continue; //only show blocks for this prov } } if (SchedType == ScheduleType.Blockout) //for blockouts //only show practice blocks and blockout blocks { if (SchedDefaults.List[i].SchedType == ScheduleType.Provider) { continue; } } if (SchedDefaults.List[i].SchedType == ScheduleType.Practice) //open block color { blockBrush = new SolidBrush(DefB.Long[(int)DefCat.AppointmentColors][0].ItemColor); blockW = ColW; opOffset = 0; } if (SchedDefaults.List[i].SchedType == ScheduleType.Provider) //open block color { blockBrush = new SolidBrush(DefB.Long[(int)DefCat.AppointmentColors][0].ItemColor); blockW = ColW; opOffset = 0; } if (SchedDefaults.List[i].SchedType == ScheduleType.Blockout) { blockBrush = new SolidBrush(DefB.GetColor(DefCat.BlockoutTypes , SchedDefaults.List[i].BlockoutType)); if (SchedDefaults.List[i].Op == 0) { blockW = ColW; } else { blockW = opW; } if (SchedDefaults.List[i].Op == 0) { opOffset = 0; } else { opOffset = Operatories.GetOrder(SchedDefaults.List[i].Op); if (opOffset == -1) //op not visible { continue; } opOffset = opOffset * opW; } } e.Graphics.FillRectangle(blockBrush , NumW + SchedDefaults.List[i].DayOfWeek * ColW + opOffset //usually 0 , SchedDefaults.List[i].StartTime.Hour * 6 * RowH + (int)SchedDefaults.List[i].StartTime.Minute / 10 * RowH , blockW , ((SchedDefaults.List[i].StopTime - SchedDefaults.List[i].StartTime).Hours * 6 + (SchedDefaults.List[i].StopTime - SchedDefaults.List[i].StartTime).Minutes / 10) * RowH); } } Pen bPen = new Pen(Color.Black); Pen gPen = new Pen(Color.LightGray); for (int y = 0; y < 24 * 6; y++) { e.Graphics.DrawLine(gPen, NumW, y * RowH, NumW + ColW * 7, y * RowH); } for (int y = 0; y < 25; y++) { e.Graphics.DrawLine(bPen, NumW, y * RowH * 6, NumW + ColW * 7, y * RowH * 6); } for (int x = 0; x < 8; x++) { e.Graphics.DrawLine(bPen, NumW + x * ColW, 0, NumW + x * ColW, RowH * 6 * 24); } if (SchedDefaults.List != null && SchedType == ScheduleType.Blockout) { for (int i = 0; i < SchedDefaults.List.Length; i++) { if (SchedDefaults.List[i].SchedType == ScheduleType.Blockout) { if (SchedDefaults.List[i].Op == 0) { blockW = ColW; } else { blockW = opW; } if (SchedDefaults.List[i].Op == 0) { opOffset = 0; } else { opOffset = Operatories.GetOrder(SchedDefaults.List[i].Op); if (opOffset == -1) //op not visible { continue; } opOffset = opOffset * opW; } e.Graphics.DrawString( DefB.GetName(DefCat.BlockoutTypes, SchedDefaults.List[i].BlockoutType) , blockFont, Brushes.Black , new RectangleF( NumW + SchedDefaults.List[i].DayOfWeek * ColW + opOffset //usually 0 , SchedDefaults.List[i].StartTime.Hour * 6 * RowH + (int)SchedDefaults.List[i].StartTime.Minute / 10 * RowH , blockW , 15)); } } } CultureInfo ci = (CultureInfo)CultureInfo.CurrentCulture.Clone(); string hFormat = Lan.GetShortTimeFormat(ci); for (int y = 0; y < 24; y++) { e.Graphics.DrawString((new DateTime(2000, 1, 1, y, 0, 0)).ToString(hFormat, ci) , timeFont, new SolidBrush(Color.Black), 0, y * RowH * 6 - 3); e.Graphics.DrawString((new DateTime(2000, 1, 1, y, 0, 0)).ToString(hFormat, ci) , timeFont, new SolidBrush(Color.Black), NumW + ColW * 7, y * RowH * 6 - 3); } Width = NumW * 2 + ColW * 7; Height = RowH * 24 * 6 + 1; }