void DoctorColumnView_Loaded(object sender, RoutedEventArgs e)
        {
            DayInformationViewModel DIVM = (DayInformationViewModel)this.DataContext;

            DIVM.ScheduleShifted += new EventHandler <EventArgs>(OnScheduleAltered);

            OnScheduleAltered(null, new EventArgs());
        }
        void ShiftScheduleView(int amount)
        {
            DayInformationViewModel DIVM = (DayInformationViewModel)this.DataContext;

            if (DIVM.ShiftView.CanExecute(null))
            {
                DIVM.ShiftView.Execute(amount);
            }
        }
Exemple #3
0
        public void Search(string searchTerm)
        {
            DayInformationViewModel divm = App.Current.MainWindow.DataContext as DayInformationViewModel;

            //Sanitize input
            searchTerm = new String(searchTerm.Where(c => Char.IsLetterOrDigit(c) || Char.IsWhiteSpace(c)).ToArray()).ToLower();

            //Only search if searchTerm exists
            if (!String.IsNullOrWhiteSpace(searchTerm))
            {
                string[] searchTerms = searchTerm.Split(' ');

                Dictionary <int, Patient> patientDict = divm.PVM.GetPatientDatabaseModel().GetPatientDictionary();

                foreach (KeyValuePair <int, Patient> entry in patientDict)
                {
                    //Check for match or partial match of
                    if (entry.Key.ToString().Contains(searchTerm))
                    {
                        _resultPatients.Add(entry.Value);
                    }
                    else
                    {
                        foreach (string term in searchTerms)
                        {
                            if (!String.IsNullOrWhiteSpace(term))
                            {
                                //Check for a match to first name
                                if (!String.IsNullOrEmpty(entry.Value.FirstName) && entry.Value.FirstName.ToLower().Contains(term))
                                {
                                    _resultPatients.Add(entry.Value);
                                    break;
                                }

                                //Check for last name match
                                if (!String.IsNullOrEmpty(entry.Value.LastName) && entry.Value.LastName.ToLower().Contains(term))
                                {
                                    _resultPatients.Add(entry.Value);
                                    break;
                                }

                                //Check middle name match
                                if (!String.IsNullOrEmpty(entry.Value.MiddleName) && entry.Value.MiddleName.ToLower().Contains(term))
                                {
                                    _resultPatients.Add(entry.Value);
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            UpdatePatientResultList();
        }
        private void OnScrollDayShifter(object sender, MouseWheelEventArgs e)
        {
            DayInformationViewModel DIVM = (DayInformationViewModel)this.DataContext;

            if (DIVM.ShiftView.CanExecute(null))
            {
                if (e.Delta > 0)
                {
                    ShiftScheduleView(3);
                }
                else
                {
                    ShiftScheduleView(-3);
                }
            }
        }
Exemple #5
0
        private void OnMouseLeftRelease_Delete(object sender, MouseButtonEventArgs e)
        {
            MessageBoxResult result =

                MessageBox.Show
                (
                    "Are you sure you wish to delete this appointment?",
                    "Confirm Selection",
                    MessageBoxButton.YesNo,
                    MessageBoxImage.Asterisk
                );

            if (result == MessageBoxResult.No || result == MessageBoxResult.None)
            {
                return;
            }


            DayInformationViewModel DIVM = this.DataContext as DayInformationViewModel;

            Appointment appt = DIVM.AVM._appointmentLookup[Int32.Parse(DIVM.AVM._activeAppointment.ID)];

            if (DIVM.AVM._activeAppointment.Type == "Consultation")
            {
                Appointment apptThatFollows = DIVM.AVM.FindAppointmentThatFollows(appt);
                DIVM.AVM._appointmentLookup[Int32.Parse(apptThatFollows.ID)].Visibility = "Visible";

                // Set the appointment slot that was holding the consultation back to a 15 minute empty place holder
                appt.EndTime -= 15;

                if (appt.EndTime % 100 > 60)
                {
                    appt.EndTime += 40;
                }
            }

            appt.Comments   = "";
            appt.Height     = "35";
            appt.Margin     = "0,1,0,0";
            appt.Missed     = false;
            appt.Arrived    = false;
            appt.Opacity    = "0";
            appt.Patient    = "";
            appt.Type       = "";
            appt.Waitlisted = false;
        }
        private void OnMouseUpAppointmentSlot(object sender, MouseButtonEventArgs e)
        {
            DayInformationViewModel DIVM = (DayInformationViewModel)this.DataContext;

            Rectangle apptSlot   = (Rectangle)sender;
            string    apptSlotID = apptSlot.Tag.ToString();


            Appointment appt = DIVM.AVM._appointmentLookup[Int32.Parse(apptSlotID)];

            //            Application.Current.MainWindow.OpacityMask = Brushes.Black;
            //            Application.Current.MainWindow.Opacity = 0.2;
            //            Application.Current.MainWindow.IsHitTestVisible = false;


            DIVM.AVM._activeAppointment.Colour     = appt.Colour;
            DIVM.AVM._activeAppointment.Comments   = appt.Comments;
            DIVM.AVM._activeAppointment.Cursor     = appt.Cursor;
            DIVM.AVM._activeAppointment.DateTime   = appt.DateTime;
            DIVM.AVM._activeAppointment.DoctorName = appt.DoctorName;
            DIVM.AVM._activeAppointment.EndTime    = appt.EndTime;
            DIVM.AVM._activeAppointment.Height     = appt.Height;
            DIVM.AVM._activeAppointment.ID         = appt.ID;
            DIVM.AVM._activeAppointment.Margin     = appt.Margin;
            DIVM.AVM._activeAppointment.Missed     = appt.Missed;
            DIVM.AVM._activeAppointment.Opacity    = appt.Opacity;
            DIVM.AVM._activeAppointment.Patient    = appt.Patient;
            DIVM.AVM._activeAppointment.RowSpan    = appt.RowSpan;
            DIVM.AVM._activeAppointment.StartTime  = appt.StartTime;
            DIVM.AVM._activeAppointment.Type       = appt.Type;
            DIVM.AVM._activeAppointment.Waitlisted = appt.Waitlisted;
            DIVM.AVM._activeAppointment.Visibility = appt.Visibility;

            DIVM._activeDate.Day      = appt.DateTime.Day;
            DIVM._activeDate.Month    = appt.DateTime.Month;
            DIVM._activeDate.Year     = appt.DateTime.Year;
            DIVM._activeDate.Time24Hr = appt.StartTime;

            Home h = App.Current.MainWindow as Home;

            h.SidebarView.SetSidebarView(new AppointmentDetailsSidebar());
        }
Exemple #7
0
        private void OnMouseLeftRelease_CheckIn(object sender, MouseButtonEventArgs e)
        {
            DayInformationViewModel DIVM = this.DataContext as DayInformationViewModel;
            Button checkIn = sender as Button;

            //Color a = (Color)ColorConverter.ConvertFromString("#FFA5DFFF");
            //Color b = (Color)ColorConverter.ConvertFromString("#FF789DEC");
            //Color c = (Color)ColorConverter.ConvertFromString("#FFA0BAFF");
            //Color d = (Color)ColorConverter.ConvertFromString("#FF86ABF7");


            //LinearGradientBrush gradientBrush = new LinearGradientBrush(
            //    a,
            //    b,
            //    new Point(0.8, 0),
            //    new Point(0.8, 1));


            if (checkIn.Content.ToString() == "Check In")
            {
                checkIn.Content = "Undo Check-In";
                checkIn.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
                checkIn.ToolTip = "Click To Undo Check In";
                DIVM.AVM._appointmentLookup[Int32.Parse(DIVM.AVM._activeAppointment.ID)].Arrived = true;
            }
            else
            {
                checkIn.Content = "Check In";
                checkIn.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
                checkIn.ToolTip = "Click To Check Patient In";
                DIVM.AVM._appointmentLookup[Int32.Parse(DIVM.AVM._activeAppointment.ID)].Arrived = false;
            }


            Window w = new EditPatientEmergencyContacts();

            w.Show();
        }
        // I should be able to use this.findCommonVisualAncestor or something similar to simplify this.
        void OnScheduleAltered(Object sender, EventArgs e)
        {
            int    drColumn;
            int    singleDayColumn;
            string bindingCode = "";
            int    numPreceeding;

            DayInformationViewModel DIVM = (DayInformationViewModel)this.DataContext;

            // Every DoctorColumnView is a child of a Grid in a SingleDayView
            Grid SingleDayViewGrid = (Grid)this.Parent;

            // Get all sibling DrColumns then find this one's position by name.
            var DrColumns = SingleDayViewGrid.Children.OfType <DoctorColumnView>();

            for (drColumn = 0; drColumn < DrColumns.Count(); drColumn++)
            {
                if (DrColumns.ElementAt(drColumn).Name == this.Name)
                {
                    break;
                }
            }

            // Get the SingleDayView that is an ancestor of this DoctorColumnView
            SingleDayView SDV = (SingleDayView)SingleDayViewGrid.Parent;

            Console.WriteLine("Single Day View: " + SDV.Name);


            // Since the SingleDayView is in a ScrollViewer, i get that as it's parent
            ScrollViewer SingleDayScrollViewer = (ScrollViewer)SDV.Parent;

            Console.WriteLine("Scroll Viewer: " + SingleDayScrollViewer.Name);


            // Then I get the Grid that represents the ThreeDayView
            Grid ThreeDayViewGrid = (Grid)SingleDayScrollViewer.Parent;

            // Get all SingleDayViews of the ThreeDayView
            var SVs   = ThreeDayViewGrid.Children.OfType <ScrollViewer>();
            int count = (int)SVs.Count();

            Console.WriteLine("Number of Scroll Viewers: " + count);

            // Get number of scroll viewer children that are not single day columns that preceed the first single day column
            // All single day scroll viewers must follow a naming convention; x:Name="Day<xxx>Scroller"
            for (numPreceeding = 0; numPreceeding < SVs.Count(); numPreceeding++)
            {
                if (SVs.ElementAt(numPreceeding).Name.Contains("Day"))
                {
                    break;
                }
            }

            // Break when i = the position of the SDV that contains the DoctorColumn in reference.
            for (singleDayColumn = 0; singleDayColumn < SVs.Count(); singleDayColumn++)
            {
                if (SVs.ElementAt(singleDayColumn).Name == SingleDayScrollViewer.Name)
                {
                    break;
                }
            }


            // binding code is dr column
            Console.WriteLine("Day Column: " + singleDayColumn);

            bindingCode += drColumn + 1;
            bindingCode += DIVM._dayCodes.ElementAt(singleDayColumn - numPreceeding);

            Console.WriteLine("Binding Code: " + bindingCode);

            if (DIVM.AVM._drScheduleMap.ContainsKey(Int32.Parse(bindingCode)))
            {
                this.DrColumnItemsControl.ItemsSource = DIVM.AVM._drScheduleMap[Int32.Parse(bindingCode)];
            }
            else
            {
                if (drColumn == 0)
                {
                    this.DrColumnItemsControl.ItemsSource = DIVM.AVM.PearsonEmpty;
                }
                else if (drColumn == 1)
                {
                    this.DrColumnItemsControl.ItemsSource = DIVM.AVM.SpecterEmpty;
                }
                else
                {
                    this.DrColumnItemsControl.ItemsSource = DIVM.AVM.PaulsenEmpty;
                }
            }
        }
        // Logic for when an item is dropped (mouse released after drag onto appt slot).
        private void OnDropInAppointmentSlot(object sender, DragEventArgs e)
        {
            DayInformationViewModel DIVM = (DayInformationViewModel)this.DataContext;
            Appointment             sourceAppointment;
            Appointment             targetAppointment;
            string keyForSourceAppointment;
            string keyForTargetAppointment;


            if (e.Data.GetDataPresent(DataFormats.StringFormat))
            {
                Appointment apptFollowingTarget = null;
                Appointment apptFollowingSource = null;

                keyForSourceAppointment = (string)e.Data.GetData(DataFormats.StringFormat);
                sourceAppointment       = DIVM.AVM._appointmentLookup[Int32.Parse(keyForSourceAppointment)];

                keyForTargetAppointment = ((Rectangle)sender).Tag.ToString();
                targetAppointment       = DIVM.AVM._appointmentLookup[Int32.Parse(keyForTargetAppointment)];

                Console.WriteLine("Source Appointment Date: " + sourceAppointment.DateTime);
                Console.WriteLine("Target Appointment Date: " + targetAppointment.DateTime);

                if (targetAppointment.Type.Length != 0)
                {
                    return;
                }

                // If the source is a consultation, collapse the empty appointment following the target to make room for two appointments.
                // Expand the collapsed (by default) appointment following the source appointment.
                if (sourceAppointment.Type.Equals("Consultation"))
                {
                    apptFollowingTarget = DIVM.AVM.FindAppointmentThatFollows(targetAppointment);
                    if (apptFollowingTarget == null || apptFollowingTarget.Type.Length != 0)
                    {
                        return;
                    }
                    else
                    {
                        apptFollowingTarget.Visibility = "Collapsed";
                    }

                    // Cannot be null since every consultation has a collapsed empty appointment following it by default. \
                    apptFollowingSource            = DIVM.AVM.FindAppointmentThatFollows(sourceAppointment);
                    apptFollowingSource.Visibility = "Visible";

                    targetAppointment.EndTime = targetAppointment.StartTime + 30;
                }


                if (targetAppointment.EndTime % 100 >= 60)
                {
                    targetAppointment.EndTime += 40;
                }
                targetAppointment.Height     = sourceAppointment.Height;
                targetAppointment.Margin     = sourceAppointment.Margin;
                targetAppointment.Missed     = sourceAppointment.Missed;
                targetAppointment.Arrived    = sourceAppointment.Arrived;
                targetAppointment.Opacity    = sourceAppointment.Opacity;
                targetAppointment.Patient    = sourceAppointment.Patient;
                targetAppointment.RowSpan    = sourceAppointment.RowSpan;
                targetAppointment.Type       = sourceAppointment.Type;
                targetAppointment.Waitlisted = sourceAppointment.Waitlisted;


                sourceAppointment.EndTime = sourceAppointment.StartTime + 15;
                if (sourceAppointment.EndTime % 100 >= 60)
                {
                    sourceAppointment.EndTime += 40;
                }
                sourceAppointment.Comments   = "";
                sourceAppointment.Height     = "35";
                sourceAppointment.Margin     = "0,1,0,0";
                sourceAppointment.Missed     = false;
                sourceAppointment.Arrived    = false;
                sourceAppointment.Opacity    = "0";
                sourceAppointment.Patient    = "";
                sourceAppointment.Type       = "";
                sourceAppointment.Waitlisted = false;
            }
        }
        private void OnMouseLeftRelease_Save(object sender, MouseButtonEventArgs e)
        {
            DayInformationViewModel DIVM = this.DataContext as DayInformationViewModel;
            //don't think I need active appointment, will make when done gettting values from boxes
            Appointment targetAppointment     = null;
            Appointment apptThatFollowsTarget = null;

            string stTime  = ((Time)StartTime.SelectedItem).TimeString;
            string timeCmp = stTime;

            stTime = stTime.Substring(0, stTime.IndexOf(':')) + stTime.Substring(stTime.IndexOf(':') + 1);

            string endTime = EndTime.Text;

            endTime = endTime.Substring(0, endTime.IndexOf(':')) + endTime.Substring(endTime.IndexOf(':') + 1, 2);

            string type = ApptTypeComboBox.SelectedValue.ToString();

            type = type.Substring(type.LastIndexOf(':') + 2); //ask what this does

            string drName     = ((Doctor)DoctorComboBox.SelectedItem).DoctorName;
            string dateString = DatePicker.InputText.TextField.Text;

            // Build the key to look up the appointment slot they wish to book in.
            int time = Int32.Parse(stTime);
            int year = Int32.Parse(dateString.Substring(0, dateString.IndexOf('-')));

            int firstInd  = dateString.IndexOf('-') + 1;
            int secondInd = dateString.LastIndexOf('-');
            int month     = Int32.Parse(dateString.Substring(firstInd, secondInd - firstInd));

            int day = Int32.Parse(dateString.Substring(dateString.LastIndexOf('-') + 1));

            // The hashcode of the DateTime + <DrColumn> form the key for appointment lookups.
            DateTime dt       = new DateTime(year, month, day, time / 100, time % 100, 0);
            int      drColumn = DIVM.AVM.FindDrColumnForDrName(drName);
            int      key      = dt.GetHashCode() + drColumn;

            targetAppointment = DIVM.AVM._appointmentLookup[key];
            if (targetAppointment != null)
            {
                if (type == "Consultation")
                {
                    apptThatFollowsTarget = DIVM.AVM.FindAppointmentThatFollows(targetAppointment);
                }

                if ((targetAppointment.Type != "") || (type == "Consultation" && apptThatFollowsTarget.Type != ""))
                {
                    MessageBox.Show(
                        "The Time Slot Specified Is Taken!",
                        "Unable to Modify Appointment",
                        MessageBoxButton.OK,
                        MessageBoxImage.Asterisk);

                    return;
                }

                if ((!DIVM.AVM.DoctorsOnShift.ElementAt(drColumn).IsAvailable(Int32.Parse(stTime))) ||
                    (!DIVM.AVM.DoctorsOnShift.ElementAt(drColumn).IsAvailable(Int32.Parse(endTime))))
                {
                    MessageBox.Show(
                        "The Doctor Specified Is Unavaliable At That Time!",
                        "Unable to Modify Appointment",
                        MessageBoxButton.OK,
                        MessageBoxImage.Asterisk);

                    return;
                }
            }

            DIVM._activeDate.HasChanged = false;

            Appointment _newAppointment = new Appointment();

            targetAppointment.DoctorName        = ((Doctor)DoctorComboBox.SelectedItem).DoctorName;
            targetAppointment.Type              = type;
            targetAppointment.StartTime         = Int32.Parse(stTime);
            targetAppointment.EndTime           = Int32.Parse(endTime);
            targetAppointment.ReminderType      = ((ComboBoxItem)RemType.SelectedItem).Content.ToString();
            targetAppointment.ReminderTimeOfDay = ((ComboBoxItem)RemTOD.SelectedItem).Content.ToString();
            targetAppointment.ReminderDays      = ((ComboBoxItem)RemDays.SelectedItem).Content.ToString();
            targetAppointment.Comments          = CommentBox.Text;
            targetAppointment.Height            = (type == "Consultation" ? "70" : "35");
            targetAppointment.Patient           = DIVM.PVM.ActivePatient.FirstName; //I tried to make this update to the active patient value that will be set by search bar
            targetAppointment.Opacity           = "0";

            if (targetAppointment.Type == "Consultation")
            {
                apptThatFollowsTarget.Visibility = "Collapsed";
            }



            //if (activeAppt.Type == "Consultation")
            //{
            //    Appointment apptThatFollowsActive = DIVM.AVM.FindAppointmentThatFollows(activeAppt);
            //    apptThatFollowsActive.Visibility = "Visible";
            //}

            DIVM.AVM.AddAppointment(targetAppointment, key);
        }
        private void OnMouseLeftRelease_Save(object sender, MouseButtonEventArgs e)
        {
            DayInformationViewModel DIVM                  = this.DataContext as DayInformationViewModel;
            Appointment             activeAppt            = DIVM.AVM._appointmentLookup[Int32.Parse(DIVM.AVM._activeAppointment.ID)];
            Appointment             targetAppointment     = null;
            Appointment             apptThatFollowsTarget = null;

            string stTime  = ((Time)StartTime.SelectedItem).TimeString;
            string timeCmp = stTime;

            stTime = stTime.Substring(0, stTime.IndexOf(':')) + stTime.Substring(stTime.IndexOf(':') + 1);

            string endTime = EndTime.Text;

            endTime = endTime.Substring(0, endTime.IndexOf(':')) + endTime.Substring(endTime.IndexOf(':') + 1, 2);

            string type = ApptTypeComboBox.SelectedValue.ToString();

            type = type.Substring(type.LastIndexOf(':') + 2);

            string drName     = ((Doctor)DoctorComboBox.SelectedItem).DoctorName;
            string dateString = DatePicker.InputText.TextField.Text;

            // Build the key to look up the appointment slot they wish to book in.
            int time = Int32.Parse(stTime);
            int year = Int32.Parse(dateString.Substring(0, dateString.IndexOf('-')));

            int firstInd  = dateString.IndexOf('-') + 1;
            int secondInd = dateString.LastIndexOf('-');
            int month     = Int32.Parse(dateString.Substring(firstInd, secondInd - firstInd));

            int day = Int32.Parse(dateString.Substring(dateString.LastIndexOf('-') + 1));

            // The hashcode of the DateTime + <DrColumn> form the key for appointment lookups.
            DateTime dt       = new DateTime(year, month, day, time / 100, time % 100, 0);
            int      drColumn = DIVM.AVM.FindDrColumnForDrName(drName);
            int      key      = dt.GetHashCode() + drColumn;

            targetAppointment = DIVM.AVM._appointmentLookup[key];
            if (targetAppointment != null)
            {
                if (type == "Consultation")
                {
                    apptThatFollowsTarget = DIVM.AVM.FindAppointmentThatFollows(targetAppointment);
                }

                if ((targetAppointment.Type != "") || (type == "Consultation" && apptThatFollowsTarget.Type != ""))
                {
                    MessageBox.Show(
                        "The Time Slot Specified Is Taken!",
                        "Unable to Modify Appointment",
                        MessageBoxButton.OK,
                        MessageBoxImage.Asterisk);

                    return;
                }

                if ((!DIVM.AVM.DoctorsOnShift.ElementAt(drColumn).IsAvailable(Int32.Parse(stTime))) ||
                    (!DIVM.AVM.DoctorsOnShift.ElementAt(drColumn).IsAvailable(Int32.Parse(endTime))))
                {
                    MessageBox.Show(
                        "The Doctor Specified Is Unavaliable At That Time!",
                        "Unable to Modify Appointment",
                        MessageBoxButton.OK,
                        MessageBoxImage.Asterisk);

                    return;
                }
            }

            DIVM._activeDate.HasChanged = false;


            targetAppointment.DoctorName        = ((Doctor)DoctorComboBox.SelectedItem).DoctorName;
            targetAppointment.Type              = type;
            targetAppointment.StartTime         = Int32.Parse(stTime);
            targetAppointment.EndTime           = Int32.Parse(endTime);
            targetAppointment.ReminderType      = ((ComboBoxItem)RemType.SelectedItem).Content.ToString();
            targetAppointment.ReminderTimeOfDay = ((ComboBoxItem)RemTOD.SelectedItem).Content.ToString();
            targetAppointment.ReminderDays      = ((ComboBoxItem)RemDays.SelectedItem).Content.ToString();
            targetAppointment.Comments          = CommentBox.Text;
            targetAppointment.Height            = (type == "Consultation" ? "70" : "35");
            targetAppointment.Patient           = activeAppt.Patient;
            targetAppointment.Opacity           = activeAppt.Opacity;

            if (targetAppointment.Type == "Consultation")
            {
                apptThatFollowsTarget.Visibility = "Collapsed";
            }



            if (activeAppt.Type == "Consultation")
            {
                Appointment apptThatFollowsActive = DIVM.AVM.FindAppointmentThatFollows(activeAppt);
                apptThatFollowsActive.Visibility = "Visible";
            }

            activeAppt.Arrived  = false;
            activeAppt.Height   = "35";
            activeAppt.Opacity  = "0";
            activeAppt.Type     = "";
            activeAppt.Patient  = "";
            activeAppt.Comments = "";
            activeAppt.EndTime  = activeAppt.StartTime + 15;
            if (activeAppt.EndTime % 100 > 60)
            {
                activeAppt.EndTime += 40;
            }


            DIVM.AVM._activeAppointment = targetAppointment;

            Home h = App.Current.MainWindow as Home;

            h.SidebarView.SetSidebarView(new AppointmentDetailsSidebar());
        }