private bool IsScheduled(ClinicianAppointmentDto dto)
 {
     return(dto != null
            &&
            (dto.VisitStatus == null ||
             dto.VisitStatus.WellKnownName.Equals(VisitStatus.Scheduled, StringComparison.InvariantCultureIgnoreCase)));
 }
 private void ExecuteDoubleClickAppointmentCommand(ClinicianAppointmentDto clinicianAppointmentDto)
 {
     _popupService.ShowPopup(
         "AppointmentDetailsView",
         "Edit",
         "Appointment Details",
         new[] { new KeyValuePair <string, string> ("VisitKey", clinicianAppointmentDto.Key.ToString()) });
 }
        /// <summary>
        /// Determines whether this instance [can execute appointment updated command] the specified clinician appointment dto.
        /// </summary>
        /// <param name="clinicianAppointmentDto">The clinician appointment dto.</param>
        /// <returns><c>true</c> if this instance [can execute appointment updated command] the specified clinician appointment dto; otherwise, <c>false</c>.</returns>
        public bool CanExecuteAppointmentUpdatedCommand(ClinicianAppointmentDto clinicianAppointmentDto)
        {
            if (clinicianAppointmentDto == null)
            {
                return(false);
            }

            return(IsScheduled(clinicianAppointmentDto) && clinicianAppointmentDto.ClinicianKey == ClinicianSchedule.ClinicianKey);
        }
        /// <summary>
        /// Determines whether this instance [can execute appointment deleted command] the specified clinician appointment dto.
        /// </summary>
        /// <param name="clinicianAppointmentDto">The clinician appointment dto.</param>
        /// <returns><c>true</c> if this instance [can execute appointment deleted command] the specified clinician appointment dto; otherwise, <c>false</c>.</returns>
        public bool CanExecuteAppointmentDeletedCommand(ClinicianAppointmentDto clinicianAppointmentDto)
        {
            if (clinicianAppointmentDto == null)
            {
                return(false);
            }

            return(IsScheduled(clinicianAppointmentDto));
        }
        private void UpdateClinicianAppointmentAsync(long clinicianKey, ClinicianAppointmentDto clinicianAppointmentDto)
        {
            var requestDispatcher = _asyncRequestDispatcherFactory.CreateAsyncRequestDispatcher();

            requestDispatcher.Add(
                new UpdateClinicianAppointmentRequest {
                ClinicianKey = clinicianKey, ClinicianAppointmentDto = clinicianAppointmentDto
            });
            IsLoading = true;
            requestDispatcher.ProcessRequests(HandleUpdateClinicianAppointmentCompleted, HandleUpdateClinicianAppointmentException);
        }
 private void ExecuteGoToPaymentCommand(ClinicianAppointmentDto clinicianAppointmentDto)
 {
     _navigationService.Navigate(
         RegionManager,
         "FrontDeskMainRegion",
         "BillingView",
         "MakePayment",
         new KeyValuePair <string, string> ("PatientKey", clinicianAppointmentDto.PatientKey.ToString()),
         new KeyValuePair <string, string> (
             "PatientFullName", string.Format("{0} {1}", clinicianAppointmentDto.PatientFirstName, clinicianAppointmentDto.PatientLastName)));
 }
 private void RaiseVisitChanged(ClinicianAppointmentDto clinicianAppointmentDto)
 {
     _eventAggregator.GetEvent <VisitChangedEvent> ().Publish(
         new VisitChangedEventArgs
     {
         Sender             = this,
         ClinicianKey       = ClinicianSchedule.ClinicianKey,
         VisitKey           = clinicianAppointmentDto.Key,
         VisitStartDateTime = clinicianAppointmentDto.AppointmentStartDateTime,
         PatientKey         = clinicianAppointmentDto.PatientKey
     });
 }
        private void ExecuteAppointmentAddedCommand(ClinicianAppointmentDto clinicianAppointmentDto)
        {
            if (clinicianAppointmentDto.Key != 0)
            {
                _previousClinicanKey = clinicianAppointmentDto.ClinicianKey;
                UpdateClinicianAppointmentAsync(ClinicianSchedule.ClinicianKey, clinicianAppointmentDto);

                _eventAggregator.GetEvent <AppointmentCreatedEvent> ().Publish(
                    new AppointmentCreatedEventArgs
                {
                    AppointmentKey =
                        clinicianAppointmentDto.Key,
                    ClinicianKey =
                        ClinicianSchedule.ClinicianKey,
                    EndDateTime =
                        clinicianAppointmentDto.AppointmentEndDateTime,
                    PatientKey =
                        clinicianAppointmentDto.PatientKey,
                    StartDateTime =
                        clinicianAppointmentDto.AppointmentStartDateTime
                });
            }
            else
            {
                //TODO: fix this to somehow be based off of how timeslots are setup
                var startTime = new DateTime(
                    clinicianAppointmentDto.Start.Year,
                    clinicianAppointmentDto.Start.Month,
                    clinicianAppointmentDto.Start.Day,
                    clinicianAppointmentDto.AppointmentStartDateTime.Hour,
                    0,
                    0);
                var parameters = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string> ("PatientKey", clinicianAppointmentDto.PatientKey.ToString()),
                    new KeyValuePair <string, string> ("PatientFirstName", clinicianAppointmentDto.PatientFirstName),
                    new KeyValuePair <string, string> ("PatientLastName", clinicianAppointmentDto.PatientLastName),
                    new KeyValuePair <string, string> ("StartDateTime", startTime.ToString()),
                    new KeyValuePair <string, string> ("EndTime", startTime.AddMinutes(59).ToString()),
                    new KeyValuePair <string, string> ("ClinicianKey", ClinicianSchedule.ClinicianKey.ToString()),
                    new KeyValuePair <string, string> ("ShouldReload", false.ToString())
                };
                if (clinicianAppointmentDto.VisitTemplateKey.HasValue)
                {
                    parameters.Add(
                        new KeyValuePair <string, string> ("VisitTemplateKey", clinicianAppointmentDto.VisitTemplateKey.Value.ToString()));
                }
                _navigationService.NavigateToActiveView("WorkspacesRegion", "CreateAppointment", parameters.ToArray());
                ClinicianSchedule.ClinicianAppointments.Remove(clinicianAppointmentDto);
            }
        }
 private void ExecuteGoToPatientProfileCommand(ClinicianAppointmentDto clinicianAppointmentDto)
 {
     _navigationService.Navigate(
         "WorkspacesRegion",
         "PatientWorkspaceView",
         "ViewPatient",
         new[]
     {
         new KeyValuePair <string, string> ("PatientKey", clinicianAppointmentDto.PatientKey.ToString()),
         new KeyValuePair <string, string> (
             "FullName", clinicianAppointmentDto.PatientFirstName + " " + clinicianAppointmentDto.PatientLastName),
         new KeyValuePair <string, string> ("SubViewName", "PatientEditorView"),
     });
 }
 /// <summary>
 /// Executes the appointment updated command.
 /// </summary>
 /// <param name="clinicianAppointmentDto">The clinician appointment dto.</param>
 public void ExecuteAppointmentUpdatedCommand(ClinicianAppointmentDto clinicianAppointmentDto)
 {
     if (clinicianAppointmentDto != null)
     {
         UpdateClinicianAppointmentAsync(ClinicianSchedule.ClinicianKey, clinicianAppointmentDto);
     }
     else
     {
         _userDialogService.ShowDialog(
             "No Appointment was sent, couldn't update appointment.",
             "Updating Appointment Failed",
             UserDialogServiceOptions.Ok);
     }
 }
 private void ExecuteAppointmentDeletedCommand(ClinicianAppointmentDto clinicianAppointmentDto)
 {
     if (clinicianAppointmentDto != null)
     {
         _previousClinicanKey = clinicianAppointmentDto.ClinicianKey;
         DeleteClinicianAppointmentAsync(clinicianAppointmentDto.Key);
     }
     else
     {
         _userDialogService.ShowDialog(
             "No Appointment was sent, couldn't delete appointment.",
             "Deleting Appointment Failed",
             UserDialogServiceOptions.Ok);
     }
 }
        private void ExecuteStatusUpdatedCommand(ClinicianAppointmentDto clinicianAppointmentDto)
        {
            var visitStatusUpdateDto = new VisitStatusUpdateDto
            {
                VisitKey       = clinicianAppointmentDto.Key,
                VisitStatus    = clinicianAppointmentDto.VisitStatus,
                UpdateDateTime = DateTime.Now
            };

            var requestDispatcher = _asyncRequestDispatcherFactory.CreateAsyncRequestDispatcher();

            requestDispatcher.Add(new UpdateVisitStatusRequest {
                VisitStatusUpdateDto = visitStatusUpdateDto
            });
            IsLoading = true;
            requestDispatcher.ProcessRequests(HandleUpdateVisitStatusCompleted, HandleUpdateVisitStatusException);

            RefreshView(this, null);
        }
        private void ExecuteDragStartingCommand(object obj)
        {
            var args = obj as DragDropQueryEventArgs;

            if (args != null)
            {
                var result = args.Options.Payload as PatientSearchResultDto;
                if (result != null)
                {
                    var appointmentDto = new ClinicianAppointmentDto();
                    appointmentDto.PatientFirstName         = result.FirstName;
                    appointmentDto.PatientLastName          = result.LastName;
                    appointmentDto.PatientKey               = result.Key;
                    appointmentDto.AppointmentStartDateTime = DateTime.Now;
                    appointmentDto.AppointmentEndDateTime   = DateTime.Now.AddHours(1);
                    var payload = new ScheduleViewDragDropPayload(null, new List <IOccurrence> {
                        appointmentDto
                    });
                    args.Options.Payload = payload;
                }
            }
        }
 /// <summary>
 /// Determines whether this instance [can execute double click appointment command] the specified clinician appointment dto.
 /// </summary>
 /// <param name="clinicianAppointmentDto">The clinician appointment dto.</param>
 /// <returns><c>true</c> if this instance [can execute double click appointment command] the specified clinician appointment dto; otherwise, <c>false</c>.</returns>
 public bool CanExecuteDoubleClickAppointmentCommand(ClinicianAppointmentDto clinicianAppointmentDto)
 {
     return(clinicianAppointmentDto != null);
 }