private void butOK_Click(object sender, System.EventArgs e) { if (textDescription.Text == "") { MsgBox.Show(this, "Description 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") } }; 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: if (comboActionObject.SelectedIndex == -1) { MsgBox.Show(this, "A sheet definition must be selected."); return; } if (SheetDefs.GetDeepCopy()[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 = SheetDefs.GetDeepCopy()[comboActionObject.SelectedIndex].SheetDefNum; break; case AutomationAction.SetApptStatus: if (comboActionObject.SelectedIndex == -1) { MsgBox.Show(this, "An appointment status must be selected."); return; } AutoCur.AptStatus = _listApptStatuses[comboActionObject.SelectedIndex]; 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; } #endregion Automation Action Automations.Update(AutoCur); //Because always inserted before opening this form. DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, System.EventArgs e) { if (textDescription.Text == "") { MsgBox.Show(this, "Description not allowed to be blank."); return; } if (comboTrigger.SelectedIndex == (int)AutomationTrigger.CompleteProcedure) { 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[] arrayCodes = textProcCodes.Text.Split(','); for (int i = 0; i < arrayCodes.Length; i++) { if (!ProcedureCodes.IsValidCode(arrayCodes[i])) { MessageBox.Show(arrayCodes[i] + Lan.g(this, " is not a valid procedure code.")); return; } } } if (comboAction.SelectedIndex == (int)AutomationAction.CreateCommlog) { if (comboCommType.SelectedIndex == -1) { MsgBox.Show(this, "A CommType must be selected."); return; } } if (comboAction.SelectedIndex == (int)AutomationAction.PopUp) { if (textMessage.Text.Trim() == string.Empty) { MsgBox.Show(this, "Message cannot be blank."); return; } } if (comboAction.SelectedIndex == (int)AutomationAction.PrintPatientLetter) { if (comboSheetDef.SelectedIndex == -1) { MsgBox.Show(this, "A SheetDef must be selected."); return; } if (SheetDefC.Listt[comboSheetDef.SelectedIndex].SheetType != SheetTypeEnum.PatientLetter) { MsgBox.Show(this, "The selected sheet type must be a patient letter."); return; } } if (comboAction.SelectedIndex == (int)AutomationAction.PrintReferralLetter) { if (comboSheetDef.SelectedIndex == -1) { MsgBox.Show(this, "A SheetDef must be selected."); return; } if (SheetDefC.Listt[comboSheetDef.SelectedIndex].SheetType != SheetTypeEnum.ReferralLetter) { MsgBox.Show(this, "The selected sheet type must be a referral letter."); return; } } if (comboAction.SelectedIndex == (int)AutomationAction.ShowExamSheet) { if (comboSheetDef.SelectedIndex == -1) { MsgBox.Show(this, "A SheetDef must be selected."); return; } if (SheetDefC.Listt[comboSheetDef.SelectedIndex].SheetType != SheetTypeEnum.ExamSheet) { MsgBox.Show(this, "The selected sheet type must be an exam sheet."); return; } } AutoCur.Description = textDescription.Text; AutoCur.Autotrigger = (AutomationTrigger)comboTrigger.SelectedIndex; if (comboTrigger.SelectedIndex == (int)AutomationTrigger.CompleteProcedure) { AutoCur.ProcCodes = textProcCodes.Text; } else { AutoCur.ProcCodes = ""; } AutoCur.AutoAction = (AutomationAction)comboAction.SelectedIndex; if (comboAction.SelectedIndex == (int)AutomationAction.PrintPatientLetter || comboAction.SelectedIndex == (int)AutomationAction.PrintReferralLetter || comboAction.SelectedIndex == (int)AutomationAction.ShowExamSheet) { AutoCur.SheetDefNum = SheetDefC.Listt[comboSheetDef.SelectedIndex].SheetDefNum; } else { AutoCur.SheetDefNum = 0; } if (comboAction.SelectedIndex == (int)AutomationAction.CreateCommlog) { AutoCur.CommType = DefC.Short[(int)DefCat.CommLogTypes][comboCommType.SelectedIndex].DefNum; AutoCur.MessageContent = textMessage.Text; } else { AutoCur.CommType = 0; AutoCur.MessageContent = ""; } if (comboAction.SelectedIndex == (int)AutomationAction.PopUp) { AutoCur.MessageContent = textMessage.Text; } //MessageContent was already set blank if not PopUp or Commlog above. Automations.Update(AutoCur); //Because always inserted before opening this form. DialogResult = DialogResult.OK; }