Пример #1
0
        private void DefineAppointmentColors()
        {
            if (this.Scheduler != null && this.Scheduler.View.IsGrouped)
            {
                ResourceGroup group = this.ParentItemsControl.DataContext as ResourceGroup;
                if (group.Resource != null && group.ResourceStyleMapping != null)
                {
                    this.MouseOverBackground = group.ResourceStyleMapping.MouseOverAppointmentBrush;
                    this.SelectedBackground  = group.ResourceStyleMapping.SelectedAppointmentBrush;
                    this.Background          = group.ResourceStyleMapping.AppointmentBrush;
                }
            }
            AppointmentSlot app = this.DataContext as AppointmentSlot;

            if (app != null)
            {
                var appointment = app.Occurrence.Appointment as AppointmentBase;
                if (appointment != null && appointment.Category != null)
                {
                    this.SelectedBackground = this.MouseOverBackground = this.Background = appointment.Category.CategoryBrush;
                }
                this.IsFlickering = appointment.IsFlickering;
                this.IsEnabled    = appointment.CanEdit;
            }
        }
Пример #2
0
        private void GenerateContainers()
        {
            var source     = this.AppointmentItemsControl.ItemsSource as AppointmentSlotCollection;
            var generator  = this.ItemContainerGenerator;
            int childIndex = 0;

            for (int i = 0; i < this.columns.Count; i++)
            {
                var columnInfo = this.columns[i];
                for (int j = 0; j < columnInfo.Count; j++)
                {
                    var column = columnInfo[j];
                    foreach (var appInfo in column)
                    {
                        AppointmentSlot appSlot     = appInfo.AppointmentSlot;
                        Rect            arrangeRect = this.GetArrangeRectForHorizontalOrientation(appInfo, j, columnInfo.Count);

                        int       itemIndex = source.IndexOf(appSlot);
                        UIElement child     = ((System.Windows.Controls.ItemContainerGenerator) this.ItemContainerGenerator).ContainerFromIndex(itemIndex) as UIElement;

                        if (child == null)
                        {
                            GeneratorPosition position = generator.GeneratorPositionFromIndex(itemIndex);
                            child = this.GenerateContainerAtPosition(position, ref childIndex);
                        }

                        if (child != null)
                        {
                            child.Measure(arrangeRect.Size);
                        }
                    }
                }
            }
        }
Пример #3
0
        public async Task SearchAppointmentsByDateAsync_should_return_aggregate_given_appointment_exists()
        {
            var config = new AppointmentConfig()
            {
                AvailableIntervalStart = new LocalDate(2021, 5, 5),
                AvailableIntervalEnd   = new LocalDate(2021, 5, 5),
            };
            await configManager !.SaveConfigAsync(config);

            var slot = new AppointmentSlot()
            {
                From        = new LocalDateTime(2021, 5, 5, 10, 0),
                Duration    = Period.FromHours(1),
                CountOfSlot = 1,
            };

            db !.Slots.Add(slot);

            var appointment = new Appointment()
            {
                From     = new LocalDateTime(2021, 5, 5, 10, 0),
                Duration = Period.FromHours(1),
            };

            db !.Appointments.Add(appointment);
            await db !.SaveChangesAsync();

            var aggregatesForDay = await sut !.SearchAppointmentsByDateAsync(new LocalDate(2021, 5, 5));

            Assert.IsTrue(aggregatesForDay.AllSlots.First().Appointments.Any());
        }
Пример #4
0
        public async Task FindAppointmentSlotByIdAsync_should_return_slot_given_appointment_exists()
        {
            var slot = new AppointmentSlot()
            {
                From        = new LocalDateTime(2021, 5, 5, 10, 0),
                Duration    = Period.FromHours(1),
                CountOfSlot = 1,
            };

            db !.Slots.Add(slot);

            var appointment = new Appointment()
            {
                From     = new LocalDateTime(2021, 5, 5, 10, 0),
                Duration = Period.FromHours(1),
            };

            db !.Appointments.Add(appointment);
            await db !.SaveChangesAsync();

            var aggregate = await sut !.FindAppointmentSlotByIdAsync(slot.Id);

            Assert.IsNotNull(aggregate);
            Assert.IsTrue(aggregate.Appointments.Any());
        }
Пример #5
0
        /// <summary>
        /// Initializes an instance of the <see cref="AppointmentDetails"/> class
        /// </summary>
        public AppointmentDetails(User medicalPractitioner, AppointmentSlot appointmentSlot)
        {
            if (medicalPractitioner == null)
            {
                throw new ArgumentNullException(nameof(medicalPractitioner));
            }

            if (appointmentSlot == null)
            {
                throw new ArgumentNullException(nameof(appointmentSlot));
            }

            State = appointmentSlot.State;
            AppointmentDateTime       = appointmentSlot.AppointmentDateTime;
            AppointmentDurationInMins = appointmentSlot.AppointmentDurationInMins;
            AppointmentSlotId         = appointmentSlot.Id;

            if (appointmentSlot.PatientId != null)
            {
                PatientId = (int)appointmentSlot.PatientId;
            }
            PatientFirstname = appointmentSlot?.Patient?.Firstname;
            PatientLastname  = appointmentSlot?.Patient?.Lastname;


            if (medicalPractitioner.JobDescription != null & medicalPractitioner.EmployeeDetails != null)
            {
                MedicalPractitionerDetails = new MedicalPractitionerDetails(
                    medicalPractitioner.Id,
                    medicalPractitioner.JobDescription.Description,
                    medicalPractitioner.EmployeeDetails);
            }
        }
Пример #6
0
        /// <summary>
        /// Provides the behavior for the Arrange pass of Silverlight layout. Classes can override this method to define their own Arrange pass behavior.
        /// </summary>
        /// <param name="finalSize">The final area within the parent that this object should use to arrange itself and its children.</param>
        /// <returns>
        /// The actual size used once the element is arranged.
        /// </returns>
        protected override Size ArrangeOverride(Size finalSize)
        {
            bool isHorizontal = this.Orientation == Orientation.Horizontal;
            var  source       = this.AppointmentItemsControl.ItemsSource as AppointmentSlotCollection;

            if (!this.containersGenerated)
            {
                this.containersGenerated = true;
                this.Dispatcher.BeginInvoke(new Action(() => this.InvalidateMeasure()));

                return(base.ArrangeOverride(finalSize));
            }
            else if (isHorizontal)
            {
                for (int i = 0; i < this.columns.Count; i++)
                {
                    var columnInfo = this.columns[i];
                    for (int j = 0; j < columnInfo.Count; j++)
                    {
                        var column = columnInfo[j];
                        foreach (var appInfo in column)
                        {
                            AppointmentSlot appSlot     = appInfo.AppointmentSlot;
                            Rect            arrangeRect = this.GetArrangeRectForHorizontalOrientation(appInfo, j, columnInfo.Count);
                            UIElement       appItem     = ((System.Windows.Controls.ItemContainerGenerator) this.ItemContainerGenerator).ContainerFromItem(appSlot) as UIElement;
                            if (appItem != null)
                            {
                                appItem.Arrange(arrangeRect);
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (var slot in this.slots)
                {
                    foreach (var app in slot.Appointments)
                    {
                        var appSlot = app.Value;
                        if (appSlot.TimeSlot.Start == slot.TimeSlot.Start)
                        {
                            Rect      arrangeRect     = this.GetLayoutSlot(appSlot);
                            UIElement appointmentItem = ((System.Windows.Controls.ItemContainerGenerator) this.ItemContainerGenerator).ContainerFromItem(appSlot) as UIElement;
                            if (appointmentItem != null)
                            {
                                double desiredHeight = appointmentItem.DesiredSize.Height;
                                arrangeRect.Y     += app.Key * desiredHeight;
                                arrangeRect.Height = desiredHeight;

                                appointmentItem.Arrange(arrangeRect);
                            }
                        }
                    }
                }
            }

            return(finalSize);
        }
Пример #7
0
        private Rect GetLayoutSlot(AppointmentSlot appSlot)
        {
            var timeSlotGroup = appSlot.TimeSlot as TimeSlotGroup;

            Debug.Assert(timeSlotGroup != null, "TimeSlot should be TimeSlotGroup");
            if (timeSlotGroup == null)
            {
                return(new Rect());
            }

            var firstTimeSlot = timeSlotGroup.TimeSlots.FirstOrDefault();

            Debug.Assert(firstTimeSlot != null, "TimeSlotGroup TimeSlots should not be empty");
            if (firstTimeSlot == null)
            {
                return(new Rect());
            }

            var lastTimeSlot = timeSlotGroup.TimeSlots.LastOrDefault();

            Debug.Assert(lastTimeSlot != null, "TimeSlotGroup TimeSlots should not be empty");
            if (lastTimeSlot == null)
            {
                return(new Rect());
            }

            var timeSlotItemsControl = this.TimeSlotItemsControl;

            Debug.Assert(timeSlotItemsControl != null, "TimeSlotItemsControl should not be null");
            if (timeSlotItemsControl == null)
            {
                return(new Rect());
            }

            TimeSlotItem firstTimeSlotItem = timeSlotItemsControl.ItemContainerGenerator.ContainerFromItem(firstTimeSlot) as TimeSlotItem;

            Debug.Assert(firstTimeSlotItem != null, "First TimeSlotItem should not be null");
            if (firstTimeSlotItem == null)
            {
                return(new Rect());
            }

            TimeSlotItem lastTimeSlotItem = timeSlotItemsControl.ItemContainerGenerator.ContainerFromItem(lastTimeSlot) as TimeSlotItem;

            Debug.Assert(lastTimeSlotItem != null, "Last TimeSlotItem should not be null");
            if (lastTimeSlotItem == null)
            {
                return(new Rect());
            }

            var firstContentHost = firstTimeSlotItem.ContentHost ?? firstTimeSlotItem;
            var lastContentHost  = lastTimeSlotItem.ContentHost ?? lastTimeSlotItem;

            Point topLeft     = firstContentHost.TransformToVisual(this).Transform(new Point());
            Point bottomRight = lastContentHost.TransformToVisual(this).Transform(new Point(lastContentHost.ActualWidth, lastContentHost.ActualHeight));

            return(new Rect(topLeft, bottomRight));
        }
Пример #8
0
        private int GetAppointmentSlotDuration(AppointmentSlot appSlot)
        {
            RadScheduler scheduler = this.AppointmentItemsControl != null ? this.AppointmentItemsControl.Scheduler : null;

            if (scheduler != null)
            {
                TimelineViewDefinition viewDefinition = scheduler.ActiveViewDefinition as TimelineViewDefinition;
                if (viewDefinition != null && viewDefinition.CustomTimeSlotLength != DateTimeInterval.Zero)
                {
                    TimeSpan customTimeSpan;

                    var customTimeSlotLength = viewDefinition.CustomTimeSlotLength;
                    if (customTimeSlotLength.Months > 0)
                    {
                        DateTime date      = appSlot.TimeSlot.Start;
                        DateTime startDate = appSlot.TimeSlot.Start;
                        DateTime endDate   = appSlot.TimeSlot.End;
                        TimeSpan duration  = endDate - startDate;

                        int daysInMonth = DateTime.DaysInMonth(date.Year, date.Month);
                        int span        = 0;
                        while (duration.TotalSeconds > 0)
                        {
                            duration   -= TimeSpan.FromDays(daysInMonth);
                            date        = date.AddMonths(1);
                            daysInMonth = DateTime.DaysInMonth(date.Year, date.Month);
                            span++;
                        }

                        if (span < 1)
                        {
                            return(1);
                        }
                        else
                        {
                            return(span);
                        }
                    }
                    else if (customTimeSlotLength.Weeks > 0)
                    {
                        customTimeSpan = TimeSpan.FromDays(customTimeSlotLength.Weeks * 7);
                    }
                    else
                    {
                        customTimeSpan = new TimeSpan(customTimeSlotLength.Days, customTimeSlotLength.Hours, 0, 0, 0);
                    }

                    return((int)(appSlot.TimeSlot.Duration().TotalSeconds / customTimeSpan.TotalSeconds));
                }
                else
                {
                    return((int)(appSlot.TimeSlot.Duration().TotalSeconds / this.timeSlotTimeSpan.TotalSeconds));
                }
            }

            return(1);
        }
Пример #9
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            AppointmentSlot = await _context.AppointmentSlots.FirstOrDefaultAsync(m => m.Id == id);

            if (AppointmentSlot == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Пример #10
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            AppointmentSlot = await _context.AppointmentSlots.FindAsync(id);

            if (AppointmentSlot != null)
            {
                _context.AppointmentSlots.Remove(AppointmentSlot);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Пример #11
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            AppointmentSlot = await _context.AppointmentSlots.FirstOrDefaultAsync(m => m.Id == id);

            if (AppointmentSlot == null)
            {
                return(NotFound());
            }

            Doctors = new SelectList(_context.Doctors.OrderBy(d => d.DoctorCategoryId), nameof(Doctor.Id), nameof(Doctor.FullName), AppointmentSlot.DoctorId);
            return(Page());
        }
        private void EndResize()
        {
            this.RaiseAppointmentEditedEvent(this.resizedAppointmentSlot.Occurrence.Appointment);

            this.itemsControl.IsResizing = false;

            this.MakeControlsHitTestVisible(true);

            this.resizedAppointmentSlot = null;
            this.resizeOffset           = null;
            if (Application.Current != null)
            {
                Application.Current.MainWindow.Cursor = this.cursor;
            }
            this.AppointmentsControl.RemoveMouseUpHandler(this.OnAppointmentsControlMouseUp);

            this.UnhookTimeSlotItemsMouseEnter();
        }
        public void OnAppointmentResizeElementMouseDown(AppointmentItem item, object sender, MouseButtonEventArgs e)
        {
            e.Handled = true;

            if (item.AppointmentSlot.Occurrence.CanResizeOrMove() && !this.itemsControl.Scheduler.IsReadOnly)
            {
                var editingEvent = this.RaiseAppointmentEditingEvent(item.AppointmentSlot.Occurrence.Appointment, AppointmentEditAction.Resize);
                if (!editingEvent.Cancel)
                {
                    this.resizedAppointmentSlot = item.AppointmentSlot;

                    AppointmentResizeMode appointmentResizeMode = item.ResizeStartElement == sender
                                                                  ? AppointmentResizeMode.Start
                                                                  : AppointmentResizeMode.End;

                    this.StartResize(appointmentResizeMode, item.ResizeStartElement.Cursor);
                }
            }
        }
Пример #14
0
        /// <summary>
        /// Cancel a booked appointment for a patient
        /// </summary>
        /// <returns></returns>
        public async Task <AppointmentBookResults> CancelAppointmentAsync(AppointmentSlot slot)
        {
            if (slot == null)
            {
                throw new ArgumentNullException(nameof(slot));
            }

            // Reset the slot status to Available
            slot.State            = SlotState.Available;
            slot.AppointmentState = AppointmentState.Available;
            slot.Patient          = null;
            // Update the slot in the Db
            await _apptSlotDal.UpdateAsync(slot);

            return(new AppointmentBookResults()
            {
                ResultCode = ServiceResultStatusCode.Success
            });
        }
Пример #15
0
        public async Task <AvailableTimeSlot> ExecuteAsync(int timeSlotId)
        {
            AppointmentSlot slot = await DbContext.AppointmentSlots.Where(slot => slot.Id == timeSlotId).FirstOrDefaultAsync();

            if (slot == null)
            {
                return(null);
            }

            return(new AvailableTimeSlot
            {
                Id = slot.Id,
                StartTime = slot.StartTime,
                Doctor = new AvailableDoctor
                {
                    Id = slot.Doctor.Id,
                    Name = slot.Doctor.Name,
                    Surname = slot.Doctor.Surname,
                    MiddleName = slot.Doctor.MiddleName,
                    Category = slot.Doctor.DoctorCategory
                }
            });
        }
 internal AppointmentItem GetAppointmentContainer(AppointmentSlot slot)
 {
     return(this.ItemContainerGenerator.ContainerFromItem(slot) as AppointmentItem);
 }