Example #1
0
        public override void Start()
        {
            _procedureTypeLookupHandler = new ProcedureTypeLookupHandler(this.Host.DesktopWindow);
            this.Validation.Add(new ValidationRule("CheckedIn",
                                                   delegate
            {
                // This validation does not apply if the procedure is not checked in
                if (!this.CheckedIn)
                {
                    return(new ValidationResult(true, ""));
                }

                string alertMessage;
                var checkInTime = Platform.Time;
                var success     = CheckInSettings.ValidateResult.Success == CheckInSettings.Validate(this.ScheduledTime, checkInTime, out alertMessage);
                return(new ValidationResult(success, alertMessage));
            }));

            this.Validation.Add(new ValidationRule("SelectedModality",
                                                   delegate
            {
                return(new ValidationResult(IsModalityValidForFacility(this.SelectedModality, this.SelectedFacility),
                                            "This modality is not valid for this performing facility."));
            }));

            base.Start();
        }
        private ValidationResult ValidateCheckInTime()
        {
            var checkInTime = Platform.Time;

            foreach (var r in _requisitions)
            {
                // Use the edited property if the property is being edited
                var checkedIn     = this.IsCheckedInEditable ? this.CheckedIn : r.CheckedIn;
                var scheduledTime = this.IsScheduledDateTimeEditable ? this.ScheduledTime : r.ScheduledTime;

                if (!checkedIn)
                {
                    continue;
                }

                string alertMessage;
                if (CheckInSettings.ValidateResult.Success ==
                    CheckInSettings.Validate(scheduledTime, checkInTime, out alertMessage))
                {
                    continue;
                }

                // Validation failed.
                if (this.IsCheckedInEditable && this.IsScheduledDateTimeEditable)
                {
                    // If user is modifying both checkIn and scheduledDateTime, give them a more detail alert message.
                    return(new ValidationResult(false, alertMessage));
                }

                // Otherwise, they must edit each procedure individually.
                return(new ValidationResult(false, SR.MessageAlertMultipleProceduresCheckInValidation));
            }

            return(new ValidationResult(true, string.Empty));
        }