예제 #1
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textDateTL.errorProvider1.GetError(textDateTL) != ""
         )
     {
         MessageBox.Show(Lan.g(this, "Please fix data entry errors first."));
         return;
     }
     Cur.Descript = textDescript.Text;
     Cur.DateTL   = PIn.Date(textDateTL.Text);
     Cur.DateType = (TaskDateType)listDateType.SelectedIndex;
     if (!checkFromNum.Checked)            //user unchecked the box
     {
         Cur.FromNum = 0;
     }
     Cur.ObjectType           = (TaskObjectType)listObjectType.SelectedIndex;
     Cur.GlobalTaskFilterType = comboGlobalFilter.GetSelected <GlobalTaskFilterType>();
     try{
         if (IsNew)
         {
             TaskLists.Insert(Cur);
             SecurityLogs.MakeLogEntry(Permissions.TaskListCreate, 0, Cur.Descript + " " + Lan.g(this, "added"));
         }
         else
         {
             TaskLists.Update(Cur);
         }
     }
     catch (Exception ex) {
         MessageBox.Show(ex.Message);
         return;
     }
     DialogResult = DialogResult.OK;
 }
예제 #2
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textDescription.Text == "")
            {
                MsgBox.Show(this, "Description not allowed to be blank.");
                return;
            }
            if (comboAction.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Action not allowed to be blank.");
                return;
            }
            AutoCur.Description = textDescription.Text;
            AutoCur.Autotrigger = (AutomationTrigger)comboTrigger.SelectedIndex; //should never be <0
            #region ProcCodes
            AutoCur.ProcCodes = "";                                              //set to correct proc code string below if necessary
            if (new[] { AutomationTrigger.CompleteProcedure, AutomationTrigger.ScheduleProcedure }.Contains(AutoCur.Autotrigger))
            {
                if (textProcCodes.Text.Contains(" "))
                {
                    MsgBox.Show(this, "Procedure codes cannot contain any spaces.");
                    return;
                }
                if (textProcCodes.Text == "")
                {
                    MsgBox.Show(this, "Please enter valid procedure code(s) first.");
                    return;
                }
                string strInvalidCodes = string.Join(", ", textProcCodes.Text.Split(',').Where(x => !ProcedureCodes.IsValidCode(x)));
                if (!string.IsNullOrEmpty(strInvalidCodes))
                {
                    MessageBox.Show(Lan.g(this, "The following procedure code(s) are not valid") + ": " + strInvalidCodes);
                    return;
                }
                AutoCur.ProcCodes = textProcCodes.Text;
            }
            #endregion ProcCodes
            #region Automation Action
            //Dictionary linking actions to their associated sheet types and the string to add to the message box text.
            //Only valid for actions PrintPatientLetter, PrintReferralLetter, ShowExamSheet, and ShowConsentForm.
            Dictionary <AutomationAction, Tuple <SheetTypeEnum, string> > dictAutoActionSheetType = new Dictionary <AutomationAction, Tuple <SheetTypeEnum, string> >()
            {
                { AutomationAction.PrintPatientLetter, Tuple.Create(SheetTypeEnum.PatientLetter, "a patient letter") },
                { AutomationAction.PrintReferralLetter, Tuple.Create(SheetTypeEnum.ReferralLetter, "a referral letter") },
                { AutomationAction.ShowExamSheet, Tuple.Create(SheetTypeEnum.ExamSheet, "an exam sheet") },
                { AutomationAction.ShowConsentForm, Tuple.Create(SheetTypeEnum.Consent, "a consent form") },
                { AutomationAction.PrintRxInstruction, Tuple.Create(SheetTypeEnum.RxInstruction, "an Rx instruction sheet") }
            };
            AutoCur.AutoAction         = _listAutoActions[comboAction.SelectedIndex];
            AutoCur.SheetDefNum        = 0;
            AutoCur.CommType           = 0;
            AutoCur.MessageContent     = "";
            AutoCur.AptStatus          = ApptStatus.None;
            AutoCur.AppointmentTypeNum = 0;
            switch (AutoCur.AutoAction)
            {
            case AutomationAction.CreateCommlog:
                if (comboActionObject.SelectedIndex == -1)
                {
                    MsgBox.Show(this, "A commlog type must be selected.");
                    return;
                }
                AutoCur.CommType       = _listCommLogTypeDefs[comboActionObject.SelectedIndex].DefNum;
                AutoCur.MessageContent = textMessage.Text;
                break;

            case AutomationAction.PopUp:
            case AutomationAction.PopUpThenDisable10Min:
                if (string.IsNullOrEmpty(textMessage.Text.Trim()))
                {
                    MsgBox.Show(this, "The message cannot be blank.");
                    return;
                }
                AutoCur.MessageContent = textMessage.Text;
                break;

            case AutomationAction.PrintPatientLetter:
            case AutomationAction.PrintReferralLetter:
            case AutomationAction.ShowExamSheet:
            case AutomationAction.ShowConsentForm:
            case AutomationAction.PrintRxInstruction:
                if (comboActionObject.SelectedIndex == -1)
                {
                    MsgBox.Show(this, "A sheet definition must be selected.");
                    return;
                }
                List <SheetDef> listSheets = SheetDefs.GetDeepCopy().FindAll(x => !SheetDefs.IsDashboardType(x));
                if (listSheets[comboActionObject.SelectedIndex].SheetType != dictAutoActionSheetType[AutoCur.AutoAction].Item1)
                {
                    MessageBox.Show(this, Lan.g(this, "The selected sheet type must be") + " " + dictAutoActionSheetType[AutoCur.AutoAction].Item2 + ".");
                    return;
                }
                AutoCur.SheetDefNum = listSheets[comboActionObject.SelectedIndex].SheetDefNum;
                break;

            case AutomationAction.SetApptASAP:
                break;

            case AutomationAction.SetApptType:
                if (comboActionObject.SelectedIndex == -1)
                {
                    MsgBox.Show(this, "An appointment type must be selected.");
                    return;
                }
                AutoCur.AppointmentTypeNum = _listAptTypes[comboActionObject.SelectedIndex].AppointmentTypeNum;
                break;

            case AutomationAction.ChangePatStatus:
                if (comboAction.SelectedIndex == -1)
                {
                    MsgBox.Show(this, "A patient status must be selected.");
                    return;
                }
                AutoCur.PatStatus = comboActionObject.GetSelected <PatientStatus>();
                break;
            }
            #endregion Automation Action
            Automations.Update(AutoCur);            //Because always inserted before opening this form.
            DialogResult = DialogResult.OK;
        }