示例#1
0
        public AppointmentSet(IClientPatientRepository patientRepository,
                              IClientLabelRepository labelRepository,
                              IEnumerable <AppointmentTransferData> initialAppointmentData,
                              ClientMedicalPracticeData medicalPractice,
                              Action <string> errorCallback)
        {
            this.patientRepository = patientRepository;
            this.labelRepository   = labelRepository;
            this.medicalPractice   = medicalPractice;

            ObservableAppointments = new ObservableAppointmentCollection();

            foreach (var appointmentTransferData in initialAppointmentData)
            {
                AddAppointment(appointmentTransferData.PatientId,
                               appointmentTransferData.Description,
                               appointmentTransferData.StartTime,
                               appointmentTransferData.EndTime,
                               appointmentTransferData.Day,
                               appointmentTransferData.TherapyPlaceId,
                               appointmentTransferData.Id,
                               appointmentTransferData.LabelId,
                               errorCallback);
            }
        }
        private void SetRoomData(Date date, Guid medicalPracticeId)
        {
            if (medicalPracticeId == Guid.Empty)
            {
                return;
            }

            medicalPracticeRepository.RequestMedicalPractice(
                medicalPractice =>
            {
                if (medicalPractice.Id == currentMedicalPractice?.Id &&
                    medicalPractice.Version == currentMedicalPractice?.Version)
                {
                    return;
                }

                Application.Current.Dispatcher.Invoke(() =>
                {
                    currentMedicalPractice       = medicalPractice;
                    currentSelectableRoomFilters = medicalPractice.Rooms.ToList();

                    AvailableRoomFilters = currentSelectableRoomFilters.Select(room => new RoomSelectorData(room.Name, room.Id, room.DisplayedColor))
                                           .Append(allRoomFilter)
                                           .ToObservableCollection();

                    SelectedRoomFilter = AvailableRoomFilters.Last();
                });
            },
                medicalPracticeId,
                date,
                errorCallback
                );
        }
        public ClosedDayGridViewModel(AggregateIdentifier identifier,
                                      ClientMedicalPracticeData medicalPractice,
                                      IViewModelCommunication viewModelCommunication,
                                      ISharedStateReadOnly <Size> appointmentGridSizeVariable)
        {
            this.viewModelCommunication      = viewModelCommunication;
            this.appointmentGridSizeVariable = appointmentGridSizeVariable;

            Identifier = identifier;
            IsActive   = false;

            viewModelCommunication.RegisterViewModelAtCollection <IAppointmentGridViewModel, AggregateIdentifier>(
                Constants.ViewModelCollections.AppointmentGridViewModelCollection,
                this
                );

            appointmentGridSizeVariable.StateChanged += OnGridSizeChanged;

            TimeGridViewModel = new TimeGridViewModel(Identifier, viewModelCommunication,
                                                      medicalPractice, appointmentGridSizeVariable.Value);

            TherapyPlaceRowViewModels = new ObservableCollection <ITherapyPlaceRowViewModel>();

            PracticeIsClosedAtThisDay = true;
        }
示例#4
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);
        }
        public PrintTimeGridViewModel(AggregateIdentifier identifier,
                                      ClientMedicalPracticeData medicalPractice,
                                      Size initalSize)
        {
            Identifier = identifier;

            timeSlotStart = medicalPractice.HoursOfOpening.GetOpeningTime(identifier.Date);
            timeSlotEnd   = medicalPractice.HoursOfOpening.GetClosingTime(identifier.Date);

            TimeSlotLines  = new ObservableCollection <TimeSlotLine>();
            TimeSlotLabels = new ObservableCollection <TimeSlotLabel>();

            SetnewSize(initalSize);
        }
示例#6
0
        public override void Handle(GetMedicalPracticeRequest request)
        {
            if (!IsRequestValid(request.SessionId, request.UserId, request.MedicalPracticeId))
            {
                return;
            }

            var medicalPractice = request.MedicalPraciceVersion == uint.MaxValue
                                                                                ? dataCenter.GetMedicalPractice(request.MedicalPracticeId)
                                                                                : dataCenter.GetMedicalPractice(request.MedicalPracticeId, request.MedicalPraciceVersion);

            var practiceData = new ClientMedicalPracticeData(medicalPractice);

            Socket.SendNetworkMsg(new GetMedicalPracticeResponse(practiceData));
        }
        public FixedAppointmentSet(ClientMedicalPracticeData medicalPractice,
                                   IClientPatientRepository patientsRepository,
                                   IClientLabelRepository labelRepository,
                                   IEnumerable <AppointmentTransferData> initialAppointmentData,
                                   uint aggregateVersion,
                                   AggregateIdentifier identifier,
                                   Action <string> errorCallback)
        {
            AggregateVersion = aggregateVersion;
            Identifier       = identifier;

            var appointmentSet = new AppointmentSet(patientsRepository, labelRepository, initialAppointmentData,
                                                    medicalPractice, errorCallback);

            Appointments = appointmentSet.AppointmentList;
        }
示例#8
0
        public AppointmentGridViewModel(AggregateIdentifier identifier,
                                        ClientMedicalPracticeData medicalPractice,
                                        IViewModelCommunication viewModelCommunication,
                                        ISharedStateReadOnly <Size> gridSizeVariable,
                                        ISharedStateReadOnly <Guid?> roomFilterVariable,
                                        ISharedStateReadOnly <Guid> displayedMedicalPracticeVariable,
                                        ISharedState <AppointmentModifications> appointmentModificationsVariable,
                                        IAppointmentViewModelBuilder appointmentViewModelBuilder,
                                        AppointmentsOfADayReadModel readModel,
                                        IEnumerable <ITherapyPlaceRowViewModel> therapyPlaceRowViewModels,
                                        Action <string> errorCallback)
        {
            this.medicalPractice                  = medicalPractice;
            this.viewModelCommunication           = viewModelCommunication;
            this.gridSizeVariable                 = gridSizeVariable;
            this.roomFilterVariable               = roomFilterVariable;
            this.displayedMedicalPracticeVariable = displayedMedicalPracticeVariable;
            this.appointmentModificationsVariable = appointmentModificationsVariable;
            this.appointmentViewModelBuilder      = appointmentViewModelBuilder;
            this.readModel     = readModel;
            this.errorCallback = errorCallback;

            // Initial appointment-Creation is done at the AppointmentGridBuilder

            IsActive = false;
            PracticeIsClosedAtThisDay = false;

            gridSizeVariable.StateChanged   += OnGridSizeChanged;
            roomFilterVariable.StateChanged += OnGlobalRoomFilterVariableChanged;

            viewModelCommunication.RegisterViewModelAtCollection <IAppointmentGridViewModel, AggregateIdentifier>(
                Constants.ViewModelCollections.AppointmentGridViewModelCollection,
                this
                );

            Identifier = identifier;

            readModel.AppointmentChanged += OnReadModelAppointmentChanged;

            TimeGridViewModel = new TimeGridViewModel(Identifier, viewModelCommunication,
                                                      medicalPractice, gridSizeVariable.Value);

            TherapyPlaceRowViewModels = new ObservableCollection <ITherapyPlaceRowViewModel>(therapyPlaceRowViewModels);


            OnGlobalRoomFilterVariableChanged(roomFilterVariable.Value);
        }
        private void ComputeTimeSlots(IClientMedicalPracticeRepository medicalPracticeRepository, Guid medicalPracticeId)
        {
            medicalPracticeRepository.RequestMedicalPractice(
                loadedPractice =>
            {
                readModelRepository.RequestAppointmentSetOfADay(
                    fixAppointmentSet =>
                {
                    medicalPractice = loadedPractice;

                    IDictionary <TherapyPlaceRowIdentifier, IEnumerable <TimeSlot> > allSlots =
                        new Dictionary <TherapyPlaceRowIdentifier, IEnumerable <TimeSlot> >();

                    IDictionary <TherapyPlace, IList <Appointment> > sortedAppointments =
                        new Dictionary <TherapyPlace, IList <Appointment> >();

                    foreach (var therapyPlace in medicalPractice.GetAllTherapyPlaces())
                    {
                        sortedAppointments.Add(therapyPlace, new List <Appointment>());
                    }

                    fixAppointmentSet.Appointments.Do(appointment => sortedAppointments[appointment.TherapyPlace].Add(appointment));

                    var openingTime = medicalPractice.HoursOfOpening.GetOpeningTime(creationDate);
                    var closingTime = medicalPractice.HoursOfOpening.GetClosingTime(creationDate);

                    foreach (var therapyRowData in sortedAppointments)
                    {
                        var slots = ComputeSlots(openingTime, closingTime, therapyRowData.Value);

                        allSlots.Add(
                            new TherapyPlaceRowIdentifier(new AggregateIdentifier(creationDate, medicalPractice.Id), therapyRowData.Key.Id),
                            slots);
                    }

                    allAvailableTimeSlots = allSlots;
                },
                    new AggregateIdentifier(creationDate, loadedPractice.Id, loadedPractice.Version),
                    errorCallback
                    );
            },
                medicalPracticeId,
                creationDate,
                errorCallback
                );
        }
示例#10
0
        public PrintAppointmentGridViewModel(AggregateIdentifier identifier,
                                             ClientMedicalPracticeData medicalPractice,
                                             IEnumerable <Appointment> appointments,
                                             Size initalSize)
        {
            TimeGridViewModel = new PrintTimeGridViewModel(identifier, medicalPractice, initalSize);

            TherapyPlaceRowViewModels = medicalPractice.Rooms
                                        .SelectMany(room => room.TherapyPlaces)
                                        .Select(therapyPlaceRow => new PrintTherapyPlaceRowViewModel(appointments.Where(appointment => appointment.TherapyPlace.Id == therapyPlaceRow.Id)
                                                                                                     .Select(appointment => new PrintAppointmentViewModel(appointment.StartTime,
                                                                                                                                                          appointment.EndTime,
                                                                                                                                                          $"{appointment.Patient.Name} (*{appointment.Patient.Birthday.Year})")),
                                                                                                     medicalPractice.HoursOfOpening.GetOpeningTime(identifier.Date),
                                                                                                     medicalPractice.HoursOfOpening.GetClosingTime(identifier.Date),
                                                                                                     therapyPlaceRow.Name))
                                        .Cast <IPrintTherapyPlaceRowViewModel>()
                                        .ToObservableCollection();
        }
        public AppointmentsOfADayReadModel(IClientEventBus eventBus,
                                           IClientPatientRepository patientsRepository,
                                           IClientLabelRepository labelRepository,
                                           ClientMedicalPracticeData medicalPractice,
                                           IEnumerable <AppointmentTransferData> initialAppointmentData,
                                           AggregateIdentifier identifier,
                                           uint initialAggregateVersion,
                                           Action <string> errorCallback)
            : base(eventBus)
        {
            this.errorCallback = errorCallback;

            AggregateVersion = initialAggregateVersion;
            Identifier       = identifier;

            var initialAppointmentList = initialAppointmentData.ToList();

            appointmentSet = new AppointmentSet(patientsRepository, labelRepository,
                                                initialAppointmentList, medicalPractice,
                                                errorCallback);
        }
        public TimeGridViewModel(AggregateIdentifier identifier,
                                 IViewModelCommunication viewModelCommunication,
                                 ClientMedicalPracticeData medicalPractice,
                                 Size initalSize)
        {
            this.viewModelCommunication = viewModelCommunication;

            viewModelCommunication.RegisterViewModelAtCollection <ITimeGridViewModel, AggregateIdentifier>(
                Constants.ViewModelCollections.TimeGridViewModelCollection,
                this
                );

            Identifier = identifier;

            timeSlotStart = medicalPractice.HoursOfOpening.GetOpeningTime(identifier.Date);
            timeSlotEnd   = medicalPractice.HoursOfOpening.GetClosingTime(identifier.Date);

            TimeSlotLines  = new ObservableCollection <TimeSlotLine>();
            TimeSlotLabels = new ObservableCollection <TimeSlotLabel>();

            SetnewSize(initalSize);
        }
 public GetMedicalPracticeResponse(ClientMedicalPracticeData medicalPractice)
     : base(NetworkMessageType.GetMedicalPracticeResponse)
 {
     MedicalPractice = medicalPractice;
 }
示例#14
0
        private void ComputeBoundariesOfCurrentTimeSlot()
        {
            medicalPracticeRepository.RequestMedicalPractice(
                practice =>
            {
                currentMedicalPracticeVersion = practice;

                currentDayOpeningTime = currentMedicalPracticeVersion.HoursOfOpening.GetOpeningTime(CurrentLocation.PlaceAndDate.Date);
                currentDayClosingTime = currentMedicalPracticeVersion.HoursOfOpening.GetClosingTime(CurrentLocation.PlaceAndDate.Date);

                readModelRepository.RequestAppointmentSetOfADay(
                    fixedAppointmentSet =>
                {
                    var appointmentWithCorrectStartAndEnd = new Appointment(OriginalAppointment.Patient,
                                                                            OriginalAppointment.Description,
                                                                            OriginalAppointment.TherapyPlace,
                                                                            OriginalAppointment.Day,
                                                                            BeginTime,
                                                                            EndTime,
                                                                            OriginalAppointment.Id,
                                                                            OriginalAppointment.Label);

                    var appointmentsWithinTheSameRow = fixedAppointmentSet.Appointments
                                                       .Where(appointment => appointment.TherapyPlace.Id == CurrentLocation.TherapyPlaceId)
                                                       .Where(appointment => appointment.Id != OriginalAppointment.Id)
                                                       .Append(appointmentWithCorrectStartAndEnd)
                                                       .ToList();

                    appointmentsWithinTheSameRow.Sort((appointment, appointment1) => appointment.StartTime.CompareTo(appointment1.StartTime));
                    var indexOfThisAppointment = appointmentsWithinTheSameRow.IndexOf(appointmentWithCorrectStartAndEnd);

                    if (appointmentsWithinTheSameRow.Count == 1)
                    {
                        currentSlotBegin = currentDayOpeningTime;
                        currentSlotEnd   = currentDayClosingTime;
                    }
                    else if (indexOfThisAppointment == 0)
                    {
                        currentSlotBegin = currentDayOpeningTime;
                        currentSlotEnd   = appointmentsWithinTheSameRow[indexOfThisAppointment + 1].StartTime;
                    }
                    else if (indexOfThisAppointment == appointmentsWithinTheSameRow.Count - 1)
                    {
                        currentSlotBegin = appointmentsWithinTheSameRow[indexOfThisAppointment - 1].EndTime;
                        currentSlotEnd   = currentDayClosingTime;
                    }
                    else
                    {
                        currentSlotBegin = appointmentsWithinTheSameRow[indexOfThisAppointment - 1].EndTime;
                        currentSlotEnd   = appointmentsWithinTheSameRow[indexOfThisAppointment + 1].StartTime;
                    }
                },
                    CurrentLocation.PlaceAndDate,
                    errorCallback
                    );
            },
                CurrentLocation.PlaceAndDate.MedicalPracticeId,
                CurrentLocation.PlaceAndDate.Date,
                errorCallback
                );
        }