Exemple #1
0
        public TherapyPlaceRowViewModel(IViewModelCommunication viewModelCommunication,
                                        IClientTherapyPlaceTypeRepository therapyPlaceTypeRepository,
                                        TherapyPlace therapyPlace,
                                        Color roomDisplayColor,
                                        TherapyPlaceRowIdentifier identifier,
                                        AdornerControl adornerControl,
                                        Time timeSlotBegin,
                                        Time timeSlotEnd,
                                        ISharedStateReadOnly <AppointmentModifications> appointmentModificationsVariable,
                                        Width initialGridWidth,
                                        Action <string> errorCallback)
        {
            this.viewModelCommunication     = viewModelCommunication;
            this.therapyPlaceTypeRepository = therapyPlaceTypeRepository;
            this.therapyPlace = therapyPlace;
            this.appointmentModificationsVariable = appointmentModificationsVariable;

            therapyPlaceTypeRepository.UpdatedTherapyPlaceTypeAvailable += OnUpdatedTherapyPlaceTypeAvailable;

            IsVisible             = true;
            RoomColor             = roomDisplayColor;
            Identifier            = identifier;
            TherapyPlaceName      = therapyPlace.Name;
            AppointmentViewModels = new ObservableCollection <IAppointmentViewModel>();

            viewModelCommunication.RegisterViewModelAtCollection <ITherapyPlaceRowViewModel, TherapyPlaceRowIdentifier>(
                Constants.ViewModelCollections.TherapyPlaceRowViewModelCollection,
                this
                );

            appointmentModificationsVariable.StateChanged += OnAppointmentModificationsChanged;
            OnAppointmentModificationsChanged(appointmentModificationsVariable.Value);

            TimeSlotBegin = timeSlotBegin;
            TimeSlotEnd   = timeSlotEnd;

            AdornerControl = adornerControl;

            GridWidth = initialGridWidth;

            therapyPlaceTypeRepository.RequestTherapyPlaceTypes(
                placeType =>
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    PlaceTypeIcon = GetIconForTherapyPlaceType(placeType.IconType);
                });
            },
                therapyPlace.TypeId,
                errorCallback
                );
        }
Exemple #2
0
        public AppointmentModifications(Appointment originalAppointment,
                                        Guid medicalPracticeId,
                                        IClientMedicalPracticeRepository medicalPracticeRepository,
                                        IClientReadModelRepository readModelRepository,
                                        IViewModelCommunication viewModelCommunication,
                                        ISharedState <Date> selectedDateVariable,
                                        ISharedStateReadOnly <Size> gridSizeVariable,
                                        bool isInitialAdjustment,
                                        Action <string> errorCallback)
        {
            OriginalAppointment            = originalAppointment;
            IsInitialAdjustment            = isInitialAdjustment;
            this.medicalPracticeRepository = medicalPracticeRepository;
            this.selectedDateVariable      = selectedDateVariable;
            this.gridSizeVariable          = gridSizeVariable;
            this.errorCallback             = errorCallback;
            this.readModelRepository       = readModelRepository;
            this.viewModelCommunication    = viewModelCommunication;

            versions = new VersionManager <ModificationDataSet>(100);

            versions.CurrentVersionChanged    += OnCurrentVersionChanged;
            versions.PropertyChanged          += OnVersionsManagerPropertyChanged;
            selectedDateVariable.StateChanged += OnSelectedDateVariableChanged;
            gridSizeVariable.StateChanged     += OnGridSizeVariableChanged;

            OnGridSizeVariableChanged(gridSizeVariable.Value);

            var aggregateIdentifier = new AggregateIdentifier(originalAppointment.Day, medicalPracticeId);

            InitialLocation = new TherapyPlaceRowIdentifier(aggregateIdentifier, originalAppointment.TherapyPlace.Id);

            medicalPracticeRepository.RequestMedicalPractice(
                practice =>
            {
                Application.Current.Dispatcher.Invoke(() => currentMedicalPracticeVersion = practice);
            },
                InitialLocation.PlaceAndDate.MedicalPracticeId,
                InitialLocation.PlaceAndDate.Date,
                errorCallback
                );

            var initialDataSet = new ModificationDataSet(originalAppointment.StartTime,
                                                         originalAppointment.EndTime,
                                                         originalAppointment.Description,
                                                         originalAppointment.Label,
                                                         InitialLocation,
                                                         true);

            versions.AddnewVersion(initialDataSet);
        }
Exemple #3
0
 public ModificationDataSet(Time beginTime,
                            Time endTime,
                            string description,
                            Label label,
                            TherapyPlaceRowIdentifier location,
                            bool slotRecomputationRequired)
 {
     BeginTime   = beginTime;
     EndTime     = endTime;
     Description = description;
     Location    = location;
     SlotRecomputationRequired = slotRecomputationRequired;
     Label = label;
 }
Exemple #4
0
        public TherapyPlaceRowViewModelSampleData()
        {
            TherapyPlaceName = "place 1";
            RoomColor        = Colors.LightBlue;
            PlaceTypeIcon    = ImageLoader.LoadImage(new Uri(BasePath + "bed01.png"));

            AppointmentViewModels = new ObservableCollection <IAppointmentViewModel>
            {
                new AppointmentViewModelSampleData(new Time(9, 0), new Time(10, 30)),
                new AppointmentViewModelSampleData(new Time(10, 45), new Time(12, 0))
            };

            TimeSlotBegin = new Time(8, 0);
            TimeSlotEnd   = new Time(16, 0);
            GridWidth     = 600;
            IsVisible     = true;

            Identifier = new TherapyPlaceRowIdentifier(new AggregateIdentifier(Date.Dummy, new Guid()), new Guid());
        }
Exemple #5
0
        private void SetNewLocation(TherapyPlaceRowIdentifier therapyPlaceRowIdentifier, bool isInitialLocation)
        {
            if (!isInitialLocation)
            {
                ViewModelCommunication.SendTo(
                    Constants.ViewModelCollections.TherapyPlaceRowViewModelCollection,
                    currentLocation,
                    new RemoveAppointmentFromTherapyPlaceRow(this)
                    );
            }

            currentLocation = therapyPlaceRowIdentifier;

            ViewModelCommunication.SendTo(
                Constants.ViewModelCollections.TherapyPlaceRowViewModelCollection,
                therapyPlaceRowIdentifier,
                new AddAppointmentToTherapyPlaceRow(this)
                );
        }
Exemple #6
0
        public void SetNewLocation(TherapyPlaceRowIdentifier newLocation, Time newBeginTime, Time newEndTime)
        {
            var finalBeginTime      = GetTimeToSnap(newBeginTime);
            var appointmentDuration = new Duration(newBeginTime, newEndTime);
            var finalEndTime        = GetTimeToSnap(finalBeginTime + appointmentDuration);

            if (newLocation != CurrentLocation ||
                finalBeginTime != lastSetBeginTime ||
                finalEndTime != lastSetEndTime)
            {
                versions.AddnewVersion(new ModificationDataSet(finalBeginTime,
                                                               finalEndTime,
                                                               versions.CurrentVersion.Description,
                                                               versions.CurrentVersion.Label,
                                                               newLocation,
                                                               true));
            }
            else
            {
                BeginTime = finalBeginTime;
                EndTime   = finalEndTime;
            }
        }
Exemple #7
0
        public AppointmentViewModel(Appointment appointment,
                                    ICommandService commandService,
                                    IViewModelCommunication viewModelCommunication,
                                    TherapyPlaceRowIdentifier initialLocalisation,
                                    ISharedState <AppointmentModifications> appointmentModificationsVariable,
                                    ISharedState <Date> selectedDateVariable,
                                    IAppointmentModificationsBuilder appointmentModificationsBuilder,
                                    IWindowBuilder <EditDescription> editDescriptionWindowBuilder,
                                    AdornerControl adornerControl,
                                    Action <string> errorCallback)
        {
            this.appointment         = appointment;
            this.initialLocalisation = initialLocalisation;
            this.appointmentModificationsVariable = appointmentModificationsVariable;
            this.selectedDateVariable             = selectedDateVariable;
            ViewModelCommunication = viewModelCommunication;
            AdornerControl         = adornerControl;

            viewModelCommunication.RegisterViewModelAtCollection <IAppointmentViewModel, Guid>(
                Constants.ViewModelCollections.AppointmentViewModelCollection,
                this
                );

            SwitchToEditMode = new ParameterrizedCommand <bool>(
                isInitalAdjusting =>
            {
                if (appointmentModificationsVariable.Value == null)
                {
                    CurrentAppointmentModifications = appointmentModificationsBuilder.Build(appointment,
                                                                                            initialLocalisation.PlaceAndDate.MedicalPracticeId,
                                                                                            isInitalAdjusting,
                                                                                            errorCallback);

                    CurrentAppointmentModifications.PropertyChanged += OnAppointmentModificationsPropertyChanged;
                    appointmentModificationsVariable.Value           = CurrentAppointmentModifications;
                    OperatingMode = OperatingMode.Edit;
                    appointmentModificationsVariable.StateChanged += OnCurrentModifiedAppointmentChanged;
                }
            }
                );

            DeleteAppointment = new Command(
                async() =>
            {
                var dialog = new UserDialogBox("", "Wollen Sie den Termin wirklich löschen?",
                                               MessageBoxButton.OKCancel);
                var result = await dialog.ShowMahAppsDialog();

                if (result == MessageDialogResult.Affirmative)
                {
                    if (appointmentModificationsVariable.Value.IsInitialAdjustment)
                    {
                        viewModelCommunication.SendTo(                                                                                  //
                            Constants.ViewModelCollections.AppointmentViewModelCollection,                                              // do nothing but
                            appointmentModificationsVariable.Value.OriginalAppointment.Id,                                              // deleting the temporarly
                            new Dispose()                                                                                               // created Appointment
                            );                                                                                                          //
                    }
                    else
                    {
                        commandService.TryDeleteAppointment(
                            operationSuccessful =>
                        {
                            Application.Current.Dispatcher.Invoke(() =>
                            {
                                if (!operationSuccessful)
                                {
                                    Process(new RestoreOriginalValues());
                                    viewModelCommunication.Send(new ShowNotification("löschen des Termins fehlgeschlagen; bearbeitung wurde zurückgesetzt", 5));
                                }
                            });
                        },
                            currentLocation.PlaceAndDate,
                            appointment.Patient.Id,
                            appointment.Id,
                            appointment.Description,
                            appointment.StartTime,
                            appointment.EndTime,
                            appointment.TherapyPlace.Id,
                            appointment.Label.Id,
                            ActionTag.RegularAction,
                            errorCallback
                            );
                    }

                    appointmentModificationsVariable.Value = null;
                }
            }
                );

            EditDescription = new Command(
                () =>
            {
                viewModelCommunication.Send(new ShowDisabledOverlay());

                var dialog = editDescriptionWindowBuilder.BuildWindow();
                dialog.ShowDialog();

                viewModelCommunication.Send(new HideDisabledOverlay());
            }
                );

            ConfirmChanges = new Command(() => viewModelCommunication.Send(new ConfirmChanges()));
            RejectChanges  = new Command(() => viewModelCommunication.Send(new RejectChanges()));

            BeginTime   = appointment.StartTime;
            EndTime     = appointment.EndTime;
            Description = appointment.Description;
            LabelColor  = appointment.Label.Color;

            ShowDisabledOverlay = false;

            SetNewLocation(initialLocalisation, true);
        }