Exemplo n.º 1
0
        ///<summary>Used when printing recall cards to make a commlog entry for everyone at once.</summary>
        public static void InsertForRecallPostcard(int patNum)
        {
            int    recallType = Commlogs.GetTypeAuto(CommItemTypeAuto.RECALL);
            string command;

            if (recallType != 0)
            {
                command = "SELECT COUNT(*) FROM  commlog WHERE ";
                if (FormChooseDatabase.DBtype == DatabaseType.Oracle)
                {
                    command += "TO_DATE(CommDateTime) = " + POut.PDate(MiscData.GetNowDateTime());
                }
                else                  //Assume MySQL
                {
                    command += "DATE(CommDateTime) = CURDATE()";
                }
                command += " AND PatNum=" + POut.PInt(patNum) + " AND CommType=" + POut.PInt(recallType)
                           + " AND Mode_=2 AND SentOrReceived=1";
                if (General.GetCount(command) != "0")
                {
                    return;
                }
            }
            Commlog com = new Commlog();

            com.PatNum         = patNum;
            com.CommDateTime   = DateTime.Now;
            com.CommType       = recallType;
            com.Mode_          = CommItemMode.Mail;
            com.SentOrReceived = CommSentOrReceived.Sent;
            com.Note           = Lan.g("FormRecallList", "Sent recall postcard");
            Insert(com);
        }
Exemplo n.º 2
0
        ///<summary>Returns true if the commlog was able to save to the database.  Otherwise returns false.
        ///Set showMsg to true to show a meaningful message when the commlog cannot be saved.</summary>
        public bool SaveCommItem(bool showMsg)
        {
            Commlog commlog;

            if (!_view.TryGetCommItem(showMsg, out commlog))
            {
                return(false);
            }
            if (IsNew || IsPersistent)
            {
                _view.SetCommlogNum(Commlogs.Insert(commlog));
                SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, commlog.PatNum, "Insert");
                //Post insert persistent user preferences.
                if (IsPersistent)
                {
                    if (_userOdPrefClearNote == null || PIn.Bool(_userOdPrefClearNote.ValueString))
                    {
                        _view.ClearNote();
                    }
                    if (_userOdPrefEndDate == null || PIn.Bool(_userOdPrefEndDate.ValueString))
                    {
                        _view.ClearDateTimeEnd();
                    }
                    ODException.SwallowAnyException(() => {
                        FormOpenDental.S_RefreshCurrentModule();
                    });
                }
            }
            else
            {
                Commlogs.Update(commlog);
                SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, commlog.PatNum, "");
            }
            return(true);
        }
Exemplo n.º 3
0
        ///<summary>Sends text message to callfire.  If patNum=0 will not create commlog entry.</summary>
        private bool SendCallFire(long patNum, string wirelessPhone, string message)
        {
            string key = ProgramProperties.GetPropVal(ProgramName.CallFire, "Key From CallFire");
            string msg = wirelessPhone + "," + message.Replace(",", "");     //ph#,msg Commas in msg cause error.

            try {
                CallFireService.SMSService callFire = new CallFireService.SMSService();
                callFire.sendSMSCampaign(
                    key,
                    new string[] { msg },
                    "Open Dental");
            }
            catch (Exception ex) {
                MsgBox.Show(this, "Error sending text message.\r\n\r\n" + ex.Message);
                return(false);
            }
            if (patNum == 0)             //No patient selected, do not make commlog.
            {
                return(true);
            }
            Commlog commlog = new Commlog();

            commlog.CommDateTime   = DateTime.Now;
            commlog.DateTStamp     = DateTime.Now;
            commlog.CommType       = Commlogs.GetTypeAuto(CommItemTypeAuto.TEXT);
            commlog.Mode_          = CommItemMode.Text;
            commlog.Note           = msg;//phone,note
            commlog.PatNum         = patNum;
            commlog.SentOrReceived = CommSentOrReceived.Sent;
            commlog.UserNum        = Security.CurUser.UserNum;
            commlog.DateTimeEnd    = DateTime.Now;
            Commlogs.Insert(commlog);
            SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, commlog.PatNum, "Insert Text Message");
            return(true);
        }
Exemplo n.º 4
0
        private void butOK_Click(object sender, EventArgs e)
        {
            if (!Security.IsAuthorized(Permissions.SecurityAdmin))
            {
                return;
            }
            if (textDate.errorProvider1.GetError(textDate) != "")
            {
                MsgBox.Show(this, "Invalid date");
                return;
            }
            DateTime date = PIn.Date(textDate.Text);

            if (date < DateTime.Today.AddDays(-7))
            {
                if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Date is from more than one week ago.  Continue anyway?"))
                {
                    return;
                }
            }
            if (MessageBox.Show("Delete all " + labelCount.Text + " commlog entries?", "", MessageBoxButtons.OKCancel) != DialogResult.OK)
            {
                return;
            }
            Commlogs.RecallUndo(date);
            SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, 0, "Recall list undo tool ran");
            MsgBox.Show(this, "Done");
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 5
0
        /*
         * ///<summary>This button won't even be visible unless there is an email to view.</summary>
         * private void butEmail_Click(object sender, System.EventArgs e) {
         *      EmailMessage message=EmailMessages.Refresh(CommlogCur.EmailMessageNum);
         *      //If a date is entered, user will not be able to click Send
         *      FormEmailMessageEdit FormE=new FormEmailMessageEdit(message);
         *      FormE.ShowDialog();
         *      CommlogCur=Commlogs.GetOne(CommlogCur.CommlogNum);
         * }*/

        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textDateTime.Text == ""
                //|| textAmount.errorProvider1.GetError(textAmount)!=""
                )
            {
                MessageBox.Show(Lan.g(this, "Please enter a date first."));
                return;
            }
            try{
                DateTime.Parse(textDateTime.Text);
            }
            catch {
                MessageBox.Show(Lan.g(this, "Date and time invalid."));
                return;
            }
            CommlogCur.CommDateTime = PIn.PDateT(textDateTime.Text);
            //there will always be a commtype selected.
            CommlogCur.CommType       = (CommItemType)(listType.SelectedIndex + 1);
            CommlogCur.Mode_          = (CommItemMode)listMode.SelectedIndex;
            CommlogCur.SentOrReceived = (CommSentOrReceived)listSentOrReceived.SelectedIndex;
            CommlogCur.Note           = textNote.Text;
            if (IsNew)
            {
                Commlogs.Insert(CommlogCur);
            }
            else
            {
                Commlogs.Update(CommlogCur);
                //SecurityLogs.MakeLogEntry("Adjustment Edit",Adjustments.cmd.CommandText);
            }
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 6
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     //button not enabled if no permission
     if (textDateTime.Text == "")
     {
         MsgBox.Show(this, "Please enter a date first.");
         return;
     }
     try{
         DateTime.Parse(textDateTime.Text);
     }
     catch {
         MsgBox.Show(this, "Date / Time invalid.");
         return;
     }
     if (textDateTimeEnd.Text != "")
     {
         try {
             DateTime.Parse(textDateTimeEnd.Text);
         }
         catch {
             MsgBox.Show(this, "End date and time invalid.");
             return;
         }
         CommlogCur.DateTimeEnd = PIn.DateT(textDateTimeEnd.Text);
     }
     CommlogCur.CommDateTime = PIn.DateT(textDateTime.Text);
     //there may not be a commtype selected.
     if (listType.SelectedIndex == -1)
     {
         CommlogCur.CommType = 0;
     }
     else
     {
         CommlogCur.CommType = DefC.Short[(int)DefCat.CommLogTypes][listType.SelectedIndex].DefNum;
     }
     CommlogCur.Mode_          = (CommItemMode)listMode.SelectedIndex;
     CommlogCur.SentOrReceived = (CommSentOrReceived)listSentOrReceived.SelectedIndex;
     CommlogCur.Note           = textNote.Text;
     try {
         SaveSignature();
     }
     catch (Exception ex) {
         MessageBox.Show(Lan.g(this, "Error saving signature.") + "\r\n" + ex.Message);
         return;
     }
     if (IsNew)
     {
         Commlogs.Insert(CommlogCur);
         SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, CommlogCur.PatNum, "Insert");
     }
     else
     {
         Commlogs.Update(CommlogCur);
         SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, CommlogCur.PatNum, "");
     }
     DialogResult = DialogResult.OK;
 }
Exemplo n.º 7
0
        /// <summary>May be called from other parts of the program without showing this form. You must still create an instance of this form though. Checks CallFire bridge, if it is OK to send a text, etc. (Buttons to load this form are usually  disabled if it is not OK, but this is needed for Confirmations, Recalls, etc.) </summary>
        public void SendText(long patNum, string wirelessPhone, string message, YN txtMsgOk)
        {
            if (Plugins.HookMethod(this, "FormTxtMsgEdit.SendText_Start", patNum, wirelessPhone, message, txtMsgOk))
            {
                return;
            }
            if (wirelessPhone == "")
            {
                MsgBox.Show(this, "Please enter a phone number.");
                return;
            }
            if (!Programs.IsEnabled(ProgramName.CallFire))
            {
                MsgBox.Show(this, "CallFire Program Link must be enabled.");
                return;
            }
            if (txtMsgOk == YN.Unknown && PrefC.GetBool(PrefName.TextMsgOkStatusTreatAsNo))
            {
                MsgBox.Show(this, "It is not OK to text this patient.");
                return;
            }
            if (txtMsgOk == YN.No)
            {
                MsgBox.Show(this, "It is not OK to text this patient.");
                return;
            }
            string key = ProgramProperties.GetPropVal(ProgramName.CallFire, "Key From CallFire");
            string msg = wirelessPhone + "," + message.Replace(",", "");     //ph#,msg Commas in msg cause error.

            try {
                CallFireService.SMSService callFire = new CallFireService.SMSService();
                callFire.sendSMSCampaign(
                    key,
                    new string[] { msg },
                    "Open Dental");
            }
            catch (Exception ex) {
                MsgBox.Show(this, "Error sending text message.\r\n\r\n" + ex.Message);
                return;
            }
            Commlog commlog = new Commlog();

            commlog.CommDateTime   = DateTime.Now;
            commlog.DateTStamp     = DateTime.Now;
            commlog.CommType       = DefC.Short[(int)DefCat.CommLogTypes][0].DefNum; //The first one in the list.  We can enhance later.
            commlog.Mode_          = CommItemMode.Text;
            commlog.Note           = msg;                                            //phone,note
            commlog.PatNum         = patNum;
            commlog.SentOrReceived = CommSentOrReceived.Sent;
            commlog.UserNum        = Security.CurUser.UserNum;
            commlog.DateTimeEnd    = DateTime.Now;
            Commlogs.Insert(commlog);
            SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, commlog.PatNum, "Insert Text Message");
        }
Exemplo n.º 8
0
        private void butUndo_Click(object sender, System.EventArgs e)
        {
            if (textDate.errorProvider1.GetError(textDate) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            int rowsAffected = Commlogs.UndoStatements(PIn.PDate(textDate.Text));

            MessageBox.Show(rowsAffected.ToString() + " " + Lan.g(this, "statement entries deleted."));
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 9
0
 private void textDate_TextChanged(object sender, EventArgs e)
 {
     if (textDate.errorProvider1.GetError(textDate) == "")
     {
         int count = Commlogs.GetRecallUndoCount(PIn.Date(textDate.Text));
         labelCount.Text = count.ToString();
     }
     else
     {
         labelCount.Text = "";
     }
 }
Exemplo n.º 10
0
        private void butPostcards_Click(object sender, System.EventArgs e)
        {
            if (gridMain.Rows.Count < 1)
            {
                MessageBox.Show(Lan.g(this, "There are no Patients in the Recall table.  Must have at least one to print."));
                return;
            }
            if (gridMain.SelectedIndices.Length == 0)
            {
                gridMain.SetSelected(true);
            }
            int[] PatNums;
            PatNums = new int[gridMain.SelectedIndices.Length];
            for (int i = 0; i < PatNums.Length; i++)
            {
                PatNums[i] = PIn.PInt(table.Rows[gridMain.SelectedIndices[i]]["PatNum"].ToString());
                //((RecallItem)gridMain.Rows[gridMain.SelectedIndices[i]].Tag).PatNum;
            }
            if (MsgBox.Show(this, true, "Make a commlog entry of 'postcard sent' for all of the selected patients?"))
            {
                for (int i = 0; i < PatNums.Length; i++)
                {
                    //make commlog entries for each patient
                    Commlogs.InsertForRecallPostcard(PatNums[i]);
                }
            }
            AddrTable       = Recalls.GetAddrTable(PatNums, checkGroupFamilies.Checked);
            pagesPrinted    = 0;
            patientsPrinted = 0;
            pd                             = new PrintDocument();
            pd.PrintPage                  += new PrintPageEventHandler(this.pdCards_PrintPage);
            pd.OriginAtMargins             = true;
            pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
            if (PrefB.GetInt("RecallPostcardsPerSheet") == 1)
            {
                pd.DefaultPageSettings.PaperSize = new PaperSize("Postcard", 400, 600);
                pd.DefaultPageSettings.Landscape = true;
            }
            else if (PrefB.GetInt("RecallPostcardsPerSheet") == 3)
            {
                pd.DefaultPageSettings.PaperSize = new PaperSize("Postcard", 850, 1100);
            }
            else             //4
            {
                pd.DefaultPageSettings.PaperSize = new PaperSize("Postcard", 850, 1100);
                pd.DefaultPageSettings.Landscape = true;
            }
            int totalPages = (int)Math.Ceiling((double)AddrTable.Rows.Count / (double)PrefB.GetInt("RecallPostcardsPerSheet"));

            printPreview = new OpenDental.UI.PrintPreview(PrintSituation.Postcard, pd, totalPages);
            printPreview.ShowDialog();
        }
Exemplo n.º 11
0
 private void butDelete_Click(object sender, System.EventArgs e)
 {
     if (IsNew)
     {
         DialogResult = DialogResult.Cancel;
     }
     else
     {
         //SecurityLogs.MakeLogEntry("Adjustment Edit","Delete. patNum: "+Adjustments.Cur.PatNum.ToString());
         Commlogs.Delete(CommlogCur);
         DialogResult = DialogResult.OK;
     }
 }
Exemplo n.º 12
0
 public void AutoSaveCommItem(Commlog commlog)
 {
     if (IsNew)
     {
         //Insert
         _view.SetCommlogNum(Commlogs.Insert(commlog));
         SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, commlog.PatNum, "Autosave Insert");
         IsNew = false;
     }
     else
     {
         //Update
         Commlogs.Update(commlog);
     }
 }
Exemplo n.º 13
0
 private void butDelete_Click(object sender, System.EventArgs e)
 {
     //button not enabled if no permission
     if (IsNew)
     {
         DialogResult = DialogResult.Cancel;
         return;
     }
     if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Delete?"))
     {
         return;
     }
     SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, CommlogCur.PatNum, "Delete");
     Commlogs.Delete(CommlogCur);
     DialogResult = DialogResult.OK;
 }
Exemplo n.º 14
0
 private void AutoSaveCommItem()
 {
     if (_commlogOld.IsNew)
     {
         //Insert
         Commlogs.Insert(_commlogCur);
         textCommlogNum.Text = this._commlogCur.CommlogNum.ToString();
         SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, _commlogCur.PatNum, "Autosave Insert");
         _commlogCur.IsNew = false;
     }
     else
     {
         //Update
         Commlogs.Update(_commlogCur);
     }
     _commlogOld = _commlogCur.Copy();
 }
Exemplo n.º 15
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textDateTime.Text == ""
         //|| textAmount.errorProvider1.GetError(textAmount)!=""
         )
     {
         MessageBox.Show(Lan.g(this, "Please enter a date first."));
         return;
     }
     try{
         DateTime.Parse(textDateTime.Text);
     }
     catch {
         MessageBox.Show(Lan.g(this, "Date and time invalid."));
         return;
     }
     if (!checkIsStatementSent.Checked && listType.SelectedIndex == -1)
     {
         MsgBox.Show(this, "Please select a type.");
         return;
     }
     CommlogCur.CommDateTime = PIn.PDateT(textDateTime.Text);
     //there may not be a commtype selected.
     if (listType.SelectedIndex == -1)
     {
         CommlogCur.CommType = 0;
     }
     else
     {
         CommlogCur.CommType = DefB.Short[(int)DefCat.CommLogTypes][listType.SelectedIndex].DefNum;
     }
     CommlogCur.Mode_           = (CommItemMode)listMode.SelectedIndex;
     CommlogCur.SentOrReceived  = (CommSentOrReceived)listSentOrReceived.SelectedIndex;
     CommlogCur.Note            = textNote.Text;
     CommlogCur.IsStatementSent = checkIsStatementSent.Checked;
     if (IsNew)
     {
         Commlogs.Insert(CommlogCur);
     }
     else
     {
         Commlogs.Update(CommlogCur);
         //SecurityLogs.MakeLogEntry("Adjustment Edit",Adjustments.cmd.CommandText);
     }
     DialogResult = DialogResult.OK;
 }
Exemplo n.º 16
0
 private void butStationary_Click(object sender, EventArgs e)
 {
     if (PrefB.GetString("StationaryDocument") == "")
     {
         MsgBox.Show(this, "You must setup your stationary document and word processor path in Setup | Misc");
         return;
     }
     Cursor = Cursors.AppStarting;
     PtLetter_ToClipboard();
     try {
         this.Cursor = Cursors.AppStarting;
         string patFolder = ODFileUtils.CombinePaths(
             FormPath.GetPreferredImagePath(),
             PatCur.ImageFolder.Substring(0, 1),
             PatCur.ImageFolder);
         //string ProgName = @"C:\Program Files\OpenOffice.org 2.0\program\swriter.exe";
         //string ProgName = PrefB.GetString("WordProcessorPath");
         string TheFile = ODFileUtils.CombinePaths(patFolder, "Letter_" + DateTime.Now.ToFileTime() + ".doc");
         try{
             File.Copy(
                 ODFileUtils.CombinePaths(FormPath.GetPreferredImagePath(), PrefB.GetString("StationaryDocument")),
                 TheFile);
             DialogResult = DialogResult.OK;
         }
         catch {
         }
         try {
             Process.Start(TheFile);
         }
         catch {
         }
         this.Cursor = Cursors.Default;
         Commlog CommlogCur = new Commlog();
         CommlogCur.CommDateTime = DateTime.Now;
         CommlogCur.CommType     = Commlogs.GetTypeAuto(CommItemTypeAuto.MISC);
         CommlogCur.PatNum       = PatCur.PatNum;
         CommlogCur.Note         = Lan.g(this, "Letter sent: See Images for this date.");
         Commlogs.Insert(CommlogCur);
     }
     catch {
         Cursor = Cursors.Default;
         MsgBox.Show(this, "Cannot find stationary document. Or another problem exists.");
     }
 }
Exemplo n.º 17
0
        private void butPrint_Click(object sender, System.EventArgs e)
        {
            if (gridBill.SelectedIndices.Length == 0)
            {
                MessageBox.Show(Lan.g(this, "Please select items first."));
                return;
            }
            if (!MsgBox.Show(this, true, "Please be prepared to wait up to ten minutes while all the bills get processed.  Continue?"))
            {
                return;
            }
            Cursor = Cursors.WaitCursor;
            int[] guarNums = new int[gridBill.SelectedIndices.Length];
            for (int i = 0; i < gridBill.SelectedIndices.Length; i++)
            {
                guarNums[i] = AgingList[gridBill.SelectedIndices[i]].PatNum;
            }
            FormRpStatement FormS = new FormRpStatement();

            FormS.LoadAndPrint(guarNums, GeneralNote);
            Cursor = Cursors.Default;
                        #if DEBUG
            FormS.ShowDialog();
                        #endif
            if (MsgBox.Show(this, true, "Printing Statements Complete.  OK to make Commlog entries?"))
            {
                Commlog commlog;
                for (int i = 0; i < guarNums.Length; i++)
                {
                    commlog = new Commlog();
                    commlog.CommDateTime    = DateTime.Now;
                    commlog.CommType        = 0;
                    commlog.SentOrReceived  = CommSentOrReceived.Sent;
                    commlog.Mode_           = CommItemMode.Mail;
                    commlog.IsStatementSent = true;
                    commlog.PatNum          = guarNums[i];         //uaually the guarantor
                    Commlogs.Insert(commlog);
                }
            }
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 18
0
 ///<summary>Returns true if the commlog was able to save to the database.  Otherwise returns false.
 ///Set showMsg to true to show a meaningful message when the commlog cannot be saved.</summary>
 private bool SaveCommItem(bool showMsg)
 {
     if (!SyncCommlogWithUI(showMsg))
     {
         return(false);
     }
     if (_isPersistent && string.IsNullOrWhiteSpace(_commlogCur.Note))              //in persistent mode, we don't want to save empty commlogs
     {
         return(false);
     }
     if (_commlogOld.IsNew || _isPersistent)
     {
         Commlogs.Insert(_commlogCur);
         _commlogCur.IsNew   = false;
         _commlogOld         = _commlogCur.Copy();
         textCommlogNum.Text = _commlogCur.CommlogNum.ToString();
         SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, _commlogCur.PatNum, "Insert");
         //Post insert persistent user preferences.
         if (_isPersistent)
         {
             if (_userOdPrefClearNote == null || PIn.Bool(_userOdPrefClearNote.ValueString))
             {
                 ClearNote();
             }
             if (_userOdPrefEndDate == null || PIn.Bool(_userOdPrefEndDate.ValueString))
             {
                 ClearDateTimeEnd();
             }
             ODException.SwallowAnyException(() => {
                 FormOpenDental.S_RefreshCurrentModule();
             });
         }
     }
     else
     {
         Commlogs.Update(_commlogCur);
         SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, _commlogCur.PatNum, "");
     }
     return(true);
 }
Exemplo n.º 19
0
 ///<summary>When sub is set, fills customer group box with various information.
 ///When null, clears all fields.</summary>
 private void SetCustomerInfo(BugSubmission sub = null)
 {
     if (sub == null)
     {
         textStack.Text          = "";     //Also clear any submission specific fields.
         labelCustomerNum.Text   = "";
         labelCustomerName.Text  = "";
         labelCustomerState.Text = "";
         labelCustomerPhone.Text = "";
         labelSubNum.Text        = "";
         labelLastCall.Text      = "";
         FillOfficeInfoGrid(null);
         butGoToAccount.Enabled = false;
         butBugTask.Enabled     = false;
         return;
     }
     try {
         if (_patCur == null)
         {
             RegistrationKey key = RegistrationKeys.GetByKey(sub.RegKey);
             _patCur = Patients.GetPat(key.PatNum);
             if (_patCur == null)
             {
                 return;                        //Should not happen.
             }
         }
         labelCustomerNum.Text   = _patCur.PatNum.ToString();
         labelCustomerName.Text  = _patCur.GetNameLF();
         labelCustomerState.Text = _patCur.State;
         labelCustomerPhone.Text = _patCur.WkPhone;
         labelSubNum.Text        = POut.Long(sub.BugSubmissionNum);
         labelLastCall.Text      = Commlogs.GetDateTimeOfLastEntryForPat(_patCur.PatNum).ToString();
     }
     catch (Exception ex) {
         ex.DoNothing();
     }
     butGoToAccount.Enabled = true;
     butBugTask.Enabled     = true;
 }
Exemplo n.º 20
0
        ///<summary>Return false to indicate exit app.  Only called when program first starts up at the beginning of FormOpenDental.PrefsStartup.</summary>
        public bool Convert(string fromVersion, string toVersion, bool isSilent, Form currentForm = null)
        {
            FromVersion = new Version(fromVersion);
            ToVersion   = new Version(toVersion);        //Application.ProductVersion);
            if (FromVersion >= new Version("3.4.0") && PrefC.GetBool(PrefName.CorruptedDatabase))
            {
                FormOpenDental.ExitCode = 201;              //Database was corrupted due to an update failure
                if (!isSilent)
                {
                    MsgBox.Show(this, "Your database is corrupted because an update failed.  Please contact us.  This database is unusable and you will need to restore from a backup.");
                }
                return(false);               //shuts program down.
            }
            if (FromVersion == ToVersion)
            {
                return(true);                         //no conversion necessary
            }
            if (FromVersion.CompareTo(ToVersion) > 0) //"Cannot convert database to an older version."
            //no longer necessary to catch it here.  It will be handled soon enough in CheckProgramVersion
            {
                return(true);
            }
            if (FromVersion < new Version("2.8.0"))
            {
                FormOpenDental.ExitCode = 130;              //Database must be upgraded to 2.8 to continue
                if (!isSilent)
                {
                    MsgBox.Show(this, "This database is too old to easily convert in one step. Please upgrade to 2.1 if necessary, then to 2.8.  Then you will be able to upgrade to this version. We apologize for the inconvenience.");
                }
                return(false);
            }
            if (FromVersion < new Version("6.6.2"))
            {
                FormOpenDental.ExitCode = 131;              //Database must be upgraded to 11.1 to continue
                if (!isSilent)
                {
                    MsgBox.Show(this, "This database is too old to easily convert in one step. Please upgrade to 11.1 first.  Then you will be able to upgrade to this version. We apologize for the inconvenience.");
                }
                return(false);
            }
            if (FromVersion < new Version("3.0.1"))
            {
                if (!isSilent)
                {
                    MsgBox.Show(this, "This is an old database.  The conversion must be done using MySQL 4.1 (not MySQL 5.0) or it will fail.");
                }
            }
            if (FromVersion.ToString() == "2.9.0.0" || FromVersion.ToString() == "3.0.0.0" || FromVersion.ToString() == "4.7.0.0")
            {
                FormOpenDental.ExitCode = 190;              //Cannot convert this database version which was only for development purposes
                if (!isSilent)
                {
                    MsgBox.Show(this, "Cannot convert this database version which was only for development purposes.");
                }
                return(false);
            }
            if (FromVersion > new Version("4.7.0") && FromVersion.Build == 0)
            {
                FormOpenDental.ExitCode = 190;              //Cannot convert this database version which was only for development purposes
                if (!isSilent)
                {
                    MsgBox.Show(this, "Cannot convert this database version which was only for development purposes.");
                }
                return(false);
            }
            if (FromVersion >= LatestVersion)
            {
                return(true);               //no conversion necessary
            }
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                FormOpenDental.ExitCode = 140;              //Web client cannot convert database
                if (!isSilent)
                {
                    MsgBox.Show(this, "Web client cannot convert database.  Must be using a direct connection.");
                }
                return(false);
            }
            if (ReplicationServers.ServerIsBlocked())
            {
                FormOpenDental.ExitCode = 150;              //Replication server is blocked from performing updates
                if (!isSilent)
                {
                    MsgBox.Show(this, "This replication server is blocked from performing updates.");
                }
                return(false);
            }
#if TRIALONLY
            //Trial users should never be able to update a database.
            if (PrefC.GetString(PrefName.RegistrationKey) != "") //Allow databases with no reg key to update.  Needed by our conversion department.
            {
                FormOpenDental.ExitCode = 191;                   //Trial versions cannot connect to live databases
                if (!isSilent)
                {
                    MsgBox.Show(this, "Trial versions cannot connect to live databases.  Please run the Setup.exe in the AtoZ folder to reinstall your original version.");
                }
                return(false);
            }
#endif
            if (PrefC.GetString(PrefName.WebServiceServerName) != "" &&       //using web service
                !ODEnvironment.IdIsThisComputer(PrefC.GetString(PrefName.WebServiceServerName).ToLower()))                   //and not on web server
            {
                if (isSilent)
                {
                    FormOpenDental.ExitCode = 141;   //Updates are only allowed from a designated web server
                    return(false);                   //if you are in debug mode and you really need to update the DB, you can manually clear the WebServiceServerName preference.
                }
                //This will be handled in CheckProgramVersion, giving the user option to downgrade or exit program.
                return(true);
            }
            //If MyISAM and InnoDb mix, then try to fix
            if (DataConnection.DBtype == DatabaseType.MySql)           //not for Oracle
            {
                string namesInnodb = InnoDb.GetInnodbTableNames();     //Or possibly some other format.
                int    numMyisam   = DatabaseMaintenances.GetMyisamTableCount();
                if (namesInnodb != "" && numMyisam > 0)
                {
                    if (!isSilent)
                    {
                        MessageBox.Show(Lan.g(this, "A mixture of database tables in InnoDB and MyISAM format were found.  A database backup will now be made, and then the following InnoDB tables will be converted to MyISAM format: ") + namesInnodb);
                    }
                    if (!Shared.MakeABackup(isSilent, BackupLocation.ConvertScript, false))
                    {
                        Cursor.Current          = Cursors.Default;
                        FormOpenDental.ExitCode = 101;                      //Database Backup failed
                        return(false);
                    }
                    if (!DatabaseMaintenances.ConvertTablesToMyisam())
                    {
                        FormOpenDental.ExitCode = 102;                      //Failed to convert InnoDB tables to MyISAM format
                        if (!isSilent)
                        {
                            MessageBox.Show(Lan.g(this, "Failed to convert InnoDB tables to MyISAM format. Please contact support."));
                        }
                        return(false);
                    }
                    if (!isSilent)
                    {
                        MessageBox.Show(Lan.g(this, "All tables converted to MyISAM format successfully."));
                    }
                    namesInnodb = "";
                }
                if (namesInnodb == "" && numMyisam > 0)             //if all tables are myisam
                //but default storage engine is innodb, then kick them out.
                {
                    if (DatabaseMaintenances.GetStorageEngineDefaultName().ToUpper() != "MYISAM") //Probably InnoDB but could be another format.
                    {
                        FormOpenDental.ExitCode = 103;                                            //Default database .ini setting is innoDB
                        if (!isSilent)
                        {
                            MessageBox.Show(Lan.g(this, "The database tables are in MyISAM format, but the default database engine format is InnoDB. You must change the default storage engine within the my.ini (or my.cnf) file on the database server and restart MySQL in order to fix this problem. Exiting."));
                        }
                        return(false);
                    }
                }
            }
#if DEBUG
            if (!isSilent && MessageBox.Show("You are in Debug mode.  Your database can now be converted" + "\r"
                                             + "from version" + " " + FromVersion.ToString() + "\r"
                                             + "to version" + " " + ToVersion.ToString() + "\r"
                                             + "You can click Cancel to skip conversion and attempt to run the newer code against the older database."
                                             , "", MessageBoxButtons.OKCancel) != DialogResult.OK)
            {
                return(true);               //If user clicks cancel, then do nothing
            }
#else
            if (!isSilent && MessageBox.Show(Lan.g(this, "Your database will now be converted") + "\r"
                                             + Lan.g(this, "from version") + " " + FromVersion.ToString() + "\r"
                                             + Lan.g(this, "to version") + " " + ToVersion.ToString() + "\r"
                                             + Lan.g(this, "The conversion works best if you are on the server.  Depending on the speed of your computer, it can be as fast as a few seconds, or it can take as long as 10 minutes.")
                                             , "", MessageBoxButtons.OKCancel) != DialogResult.OK)
            {
                return(false);               //If user clicks cancel, then close the program
            }
#endif
            Cursor.Current = Cursors.WaitCursor;
            Action actionCloseConvertProgress = null;
#if !DEBUG
            if (!isSilent)
            {
                if (DataConnection.DBtype != DatabaseType.MySql &&
                    !MsgBox.Show(this, true, "If you have not made a backup, please Cancel and backup before continuing.  Continue?"))
                {
                    return(false);
                }
            }
            if (DataConnection.DBtype == DatabaseType.MySql)
            {
                if (!Shared.MakeABackup(isSilent, BackupLocation.ConvertScript, false))
                {
                    Cursor.Current          = Cursors.Default;
                    FormOpenDental.ExitCode = 101;                  //Database Backup failed
                    return(false);
                }
            }
            //We've been getting an increasing number of phone calls with databases that have duplicate preferences which is impossible
            //unless a user has gotten this far and another computer in the office is in the middle of an update as well.
            //The issue is most likely due to the blocking messageboxes above which wait indefinitely for user input right before upgrading the database.
            //This means that the cache for this computer could be stale and we need to manually refresh our cache to double check
            //that the database isn't flagged as corrupt, an update isn't in progress, or that the database version hasn't changed (someone successfully updated already).
            Prefs.RefreshCache();
            //Now check the preferences that should stop this computer from executing an update.
            if (PrefC.GetBool(PrefName.CorruptedDatabase) ||
                (PrefC.GetString(PrefName.UpdateInProgressOnComputerName) != "" && PrefC.GetString(PrefName.UpdateInProgressOnComputerName) != Environment.MachineName))
            {
                //At this point, the pref "corrupted database" being true means that a computer is in the middle of running the upgrade script.
                //There will be another corrupted database check on start up which will take care of the scenario where this is truly a corrupted database.
                //Also, we need to make sure that the update in progress preference is set to this computer because we JUST set it to that value before entering this method.
                //If it has changed, we absolutely know without a doubt that another computer is trying to update at the same time.
                FormOpenDental.ExitCode = 142;              //Update is already in progress from another computer
                if (!isSilent)
                {
                    MsgBox.Show(this, "An update is already in progress from another computer.");
                }
                return(false);
            }
            //Double check that the database version has not changed.  This check is here just in case another computer has successfully updated the database already.
            Version versionDatabase = new Version(PrefC.GetString(PrefName.DataBaseVersion));
            if (FromVersion != versionDatabase)
            {
                FormOpenDental.ExitCode = 143;              //Database has already been updated from another computer
                if (!isSilent)
                {
                    MsgBox.Show(this, "The database has already been updated from another computer.");
                }
                return(false);
            }
            try {
#endif
            if (FromVersion < new Version("7.5.17"))                     //Insurance Plan schema conversion
            {
                if (isSilent)
                {
                    FormOpenDental.ExitCode = 139;                          //Update must be done manually to fix Insurance Plan Schema
                    Application.Exit();
                    return(false);
                }
                Cursor.Current = Cursors.Default;
                YN InsPlanConverstion_7_5_17_AutoMergeYN = YN.Unknown;
                if (FromVersion < new Version("7.5.1"))
                {
                    FormInsPlanConvert_7_5_17 form = new FormInsPlanConvert_7_5_17();
                    if (PrefC.GetBoolSilent(PrefName.InsurancePlansShared, true))
                    {
                        form.InsPlanConverstion_7_5_17_AutoMergeYN = YN.Yes;
                    }
                    else
                    {
                        form.InsPlanConverstion_7_5_17_AutoMergeYN = YN.No;
                    }
                    form.ShowDialog();
                    if (form.DialogResult == DialogResult.Cancel)
                    {
                        MessageBox.Show("Your database has not been altered.");
                        return(false);
                    }
                    InsPlanConverstion_7_5_17_AutoMergeYN = form.InsPlanConverstion_7_5_17_AutoMergeYN;
                }
                ConvertDatabases.Set_7_5_17_AutoMerge(InsPlanConverstion_7_5_17_AutoMergeYN);                        //does nothing if this pref is already present for some reason.
                Cursor.Current = Cursors.WaitCursor;
            }
            if (!isSilent && FromVersion > new Version("16.3.0") && FromVersion < new Version("16.3.29") && ApptReminderRules.IsReminders)
            {
                //16.3.29 is more strict about reminder rule setup. Prompt the user and allow them to exit the update if desired.
                //Get all currently enabled reminder rules.
                List <bool> listReminderFlags = ApptReminderRules.Get_16_3_29_ConversionFlags();
                if (listReminderFlags?[0] ?? false)                        //2 reminders scheduled for same day of appointment. 1 will be converted to future day reminder.
                {
                    MsgBox.Show(this, "You have multiple appointment reminders set to send on the same day of the appointment. One of these will be converted to send 1 day prior to the appointment.  Please review automated reminder rule setup after update has finished.");
                }
                if (listReminderFlags?[1] ?? false)                        //2 reminders scheduled for future day of appointment. 1 will be converted to same day reminder.
                {
                    MsgBox.Show(this, "You have multiple appointment reminders set to send 1 or more days prior to the day of the appointment. One of these will be converted to send 1 hour prior to the appointment.  Please review automated reminder rule setup after update has finished.");
                }
            }
            if (FromVersion >= new Version("17.3.1") && FromVersion < new Version("17.3.23") && DataConnection.DBtype == DatabaseType.MySql &&
                (Tasks.HasAnyLongDescripts() || TaskNotes.HasAnyLongNotes() || Commlogs.HasAnyLongNotes()))
            {
                if (isSilent)
                {
                    FormOpenDental.ExitCode = 138;                          //Update must be done manually in order to get data loss notification(s).
                    Application.Exit();
                    return(false);
                }
                if (!MsgBox.Show(this, true, "Data will be lost during this update."
                                 + "\r\nContact support in order to retrieve the data from a backup after the update."
                                 + "\r\n\r\nContinue?"))
                {
                    MessageBox.Show("Your database has not been altered.");
                    return(false);
                }
            }
            if (FromVersion >= new Version("3.4.0"))
            {
                Prefs.UpdateBool(PrefName.CorruptedDatabase, true);
            }
            ConvertDatabases.FromVersion = FromVersion;
#if !DEBUG
            //Typically the UpdateInProgressOnComputerName preference will have already been set within FormUpdate.
            //However, the user could have cancelled out of FormUpdate after successfully downloading the Setup.exe
            //OR the Setup.exe could have been manually sent to our customer (during troubleshooting with HQ).
            //For those scenarios, the preference will be empty at this point and we need to let other computers know that an update going to start.
            //Updating the string (again) here will guarantee that all computers know an update is in fact in progress from this machine.
            Prefs.UpdateString(PrefName.UpdateInProgressOnComputerName, Environment.MachineName);
#endif
            //Show a progress window that will indecate to the user that there is an active update in progress.  Currently okay to show during isSilent.
            actionCloseConvertProgress = ODProgressOld.ShowProgressStatus("ConvertDatabases", hasMinimize: false, currentForm: currentForm);
            ConvertDatabases.To2_8_2();                //begins going through the chain of conversion steps
            InvokeConvertMethods();                    //continues going through the chain of conversion steps starting at v17.1.1 via reflection.
            actionCloseConvertProgress();
            Cursor.Current = Cursors.Default;
            if (FromVersion >= new Version("3.4.0"))
            {
                //CacheL.Refresh(InvalidType.Prefs);//or it won't know it has to update in the next line.
                Prefs.UpdateBool(PrefName.CorruptedDatabase, false, true);                      //more forceful refresh in order to properly change flag
            }
            Cache.Refresh(InvalidType.Prefs);
            if (!isSilent)
            {
                MsgBox.Show(this, "Database update successful");
            }
            return(true);

#if !DEBUG
        }

        catch (System.IO.FileNotFoundException e) {
            actionCloseConvertProgress?.Invoke();
            FormOpenDental.ExitCode = 160;                  //File not found exception
            if (!isSilent)
            {
                MessageBox.Show(e.FileName + " " + Lan.g(this, "could not be found. Your database has not been altered and is still usable if you uninstall this version, then reinstall the previous version."));
            }
            if (FromVersion >= new Version("3.4.0"))
            {
                Prefs.UpdateBool(PrefName.CorruptedDatabase, false);
            }
            return(false);
        }
        catch (System.IO.DirectoryNotFoundException) {
            actionCloseConvertProgress?.Invoke();
            FormOpenDental.ExitCode = 160;                  //ConversionFiles folder could not be found
            if (!isSilent)
            {
                MessageBox.Show(Lan.g(this, "ConversionFiles folder could not be found. Your database has not been altered and is still usable if you uninstall this version, then reinstall the previous version."));
            }
            if (FromVersion >= new Version("3.4.0"))
            {
                Prefs.UpdateBool(PrefName.CorruptedDatabase, false);
            }
            return(false);
        }
        catch (Exception ex) {
            actionCloseConvertProgress?.Invoke();
            FormOpenDental.ExitCode = 201;                  //Database was corrupted due to an update failure
            if (!isSilent)
            {
                MessageBox.Show(ex.Message + "\r\n\r\n"
                                + Lan.g(this, "Conversion unsuccessful. Your database is now corrupted and you cannot use it.  Please contact us."));
            }
            //Then, application will exit, and database will remain tagged as corrupted.
            return(false);
        }
#endif
        }
Exemplo n.º 21
0
        private void butPreview_Click(object sender, System.EventArgs e)
        {
#if !DISABLE_MICROSOFT_OFFICE
            if (listLetters.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select a letter first.");
                return;
            }
            LetterMerge letterCur = ListForCat[listLetters.SelectedIndex];
            letterCur.ImageFolder = comboImageCategory.SelectedTag <Def>().DefNum;
            string templateFile = ODFileUtils.CombinePaths(PrefC.GetString(PrefName.LetterMergePath), letterCur.TemplateName);
            string dataFile     = ODFileUtils.CombinePaths(PrefC.GetString(PrefName.LetterMergePath), letterCur.DataFileName);
            if (!File.Exists(templateFile))
            {
                MsgBox.Show(this, "Template file does not exist.");
                return;
            }
            if (!CreateDataFile(dataFile, letterCur))
            {
                return;
            }
            Word.MailMerge wrdMailMerge;
            //Create an instance of Word.
            Word.Application WrdApp;
            try{
                WrdApp = LetterMerges.WordApp;
            }
            catch {
                MsgBox.Show(this, "Error. Is Word installed?");
                return;
            }
            string errorMessage = "";
            //Open a document.
            try {
                Object oName = templateFile;
                wrdDoc = WrdApp.Documents.Open(ref oName, ref oMissing, ref oMissing,
                                               ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                               ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
                wrdDoc.Select();
            }
            catch (Exception ex) {
                errorMessage = Lan.g(this, "Error opening document:") + "\r\n" + ex.Message;
                MessageBox.Show(errorMessage);
                return;
            }
            //Attach the data file.
            try {
                wrdMailMerge = wrdDoc.MailMerge;
                wrdDoc.MailMerge.OpenDataSource(dataFile, ref oMissing, ref oMissing, ref oMissing,
                                                ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                                ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
                wrdMailMerge.Destination = Word.WdMailMergeDestination.wdSendToNewDocument;
                wrdMailMerge.Execute(ref oFalse);
            }
            catch (Exception ex) {
                errorMessage = Lan.g(this, "Error attaching data file:") + "\r\n" + ex.Message;
                MessageBox.Show(errorMessage);
                return;
            }
            if (letterCur.ImageFolder != 0)           //if image folder exist for this letter, save to AtoZ folder
            //Open document from the atoz folder.
            {
                try {
                    WrdApp.Activate();
                    string tempFilePath = ODFileUtils.CreateRandomFile(Path.GetTempPath(), GetFileExtensionForWordDoc(templateFile));
                    Object oFileName    = tempFilePath;
                    WrdApp.ActiveDocument.SaveAs(oFileName);                    //save the document to temp location
                    Document doc       = SaveToImageFolder(tempFilePath, letterCur);
                    string   patFolder = ImageStore.GetPatientFolder(PatCur, ImageStore.GetPreferredAtoZpath());
                    string   fileName  = ImageStore.GetFilePath(doc, patFolder);
                    if (!FileAtoZ.Exists(fileName))
                    {
                        throw new ApplicationException(Lans.g("LetterMerge", "Error opening document" + " " + doc.FileName));
                    }
                    FileAtoZ.StartProcess(fileName);
                    WrdApp.ActiveDocument.Close();                    //Necessary since we created an extra document
                    try {
                        File.Delete(tempFilePath);                    //Clean up the temp file
                    }
                    catch (Exception ex) {
                        ex.DoNothing();
                    }
                }
                catch (Exception ex) {
                    FriendlyException.Show(Lan.g(this, "Error saving file to the Image module:") + "\r\n" + ex.Message, ex);
                }
            }
            //Close the original form document since just one record.
            try {
                wrdDoc.Saved = true;
                wrdDoc.Close(ref oFalse, ref oMissing, ref oMissing);
            }
            catch (Exception ex) {
                errorMessage = Lan.g(this, "Error closing document:") + "\r\n" + ex.Message;
                MessageBox.Show(errorMessage);
                return;
            }
            //At this point, Word remains open with just one new document.
            try {
                WrdApp.Activate();
                if (WrdApp.WindowState == Word.WdWindowState.wdWindowStateMinimize)
                {
                    WrdApp.WindowState = Word.WdWindowState.wdWindowStateMaximize;
                }
            }
            catch (Exception ex) {
                errorMessage = Lan.g(this, "Error showing Microsoft Word:") + "\r\n" + ex.Message;
                MessageBox.Show(errorMessage);
                return;
            }
            wrdMailMerge = null;
            wrdDoc       = null;
            Commlog CommlogCur = new Commlog();
            CommlogCur.CommDateTime   = DateTime.Now;
            CommlogCur.CommType       = Commlogs.GetTypeAuto(CommItemTypeAuto.MISC);
            CommlogCur.Mode_          = CommItemMode.Mail;
            CommlogCur.SentOrReceived = CommSentOrReceived.Sent;
            CommlogCur.PatNum         = PatCur.PatNum;
            CommlogCur.Note           = "Letter sent: " + letterCur.Description + ". ";
            CommlogCur.UserNum        = Security.CurUser.UserNum;
            Commlogs.Insert(CommlogCur);
#else
            MessageBox.Show(this, "This version of Open Dental does not support Microsoft Word.");
#endif
            //this window now closes regardless of whether the user saved the comm item.
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 22
0
        private void butPrint_Click(object sender, System.EventArgs e)
        {
#if DISABLE_MICROSOFT_OFFICE
            MessageBox.Show(this, "This version of Open Dental does not support Microsoft Word.");
            return;
#endif
            if (listLetters.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select a letter first.");
                return;
            }
            LetterMerge letterCur = ListForCat[listLetters.SelectedIndex];
            letterCur.ImageFolder = comboImageCategory.SelectedTag <Def>().DefNum;
            string templateFile = ODFileUtils.CombinePaths(PrefC.GetString(PrefName.LetterMergePath), letterCur.TemplateName);
            string dataFile     = ODFileUtils.CombinePaths(PrefC.GetString(PrefName.LetterMergePath), letterCur.DataFileName);
            if (!File.Exists(templateFile))
            {
                MsgBox.Show(this, "Template file does not exist.");
                return;
            }
            PrintDocument pd = new PrintDocument();
            if (!PrinterL.SetPrinter(pd, PrintSituation.Default, PatCur.PatNum, "Letter merge " + letterCur.Description + " printed"))
            {
                return;
            }
            if (!CreateDataFile(dataFile, letterCur))
            {
                return;
            }
            Word.MailMerge wrdMailMerge;
            //Create an instance of Word.
            Word.Application WrdApp;
            try {
                WrdApp = LetterMerges.WordApp;
            }
            catch {
                MsgBox.Show(this, "Error.  Is MS Word installed?");
                return;
            }
            //Open a document.
            Object oName = templateFile;
            wrdDoc = WrdApp.Documents.Open(ref oName, ref oMissing, ref oMissing,
                                           ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                           ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
            wrdDoc.Select();
            wrdMailMerge = wrdDoc.MailMerge;
            //Attach the data file.
            wrdDoc.MailMerge.OpenDataSource(dataFile, ref oMissing, ref oMissing, ref oMissing,
                                            ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                            ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
            wrdMailMerge.Destination = Word.WdMailMergeDestination.wdSendToPrinter;
            //WrdApp.ActivePrinter=pd.PrinterSettings.PrinterName;
            //replaced with following 4 lines due to MS bug that changes computer default printer
            object   oWBasic   = WrdApp.WordBasic;
            object[] oWBValues = new object[] { pd.PrinterSettings.PrinterName, 1 };
            String[] sWBNames  = new String[] { "Printer", "DoNotSetAsSysDefault" };
            oWBasic.GetType().InvokeMember("FilePrintSetup", BindingFlags.InvokeMethod, null, oWBasic, oWBValues, null, null, sWBNames);
            wrdMailMerge.Execute(ref oFalse);
            if (letterCur.ImageFolder != 0)           //if image folder exist for this letter, save to AtoZ folder
            {
                try {
                    wrdDoc.Select();
                    wrdMailMerge.Destination = Word.WdMailMergeDestination.wdSendToNewDocument;
                    wrdMailMerge.Execute(ref oFalse);
                    WrdApp.Activate();
                    string tempFilePath = ODFileUtils.CreateRandomFile(Path.GetTempPath(), GetFileExtensionForWordDoc(templateFile));
                    Object oFileName    = tempFilePath;
                    WrdApp.ActiveDocument.SaveAs(oFileName);                    //save the document
                    WrdApp.ActiveDocument.Close();
                    SaveToImageFolder(tempFilePath, letterCur);
                }
                catch (Exception ex) {
                    FriendlyException.Show(Lan.g(this, "Error saving file to the Image module:") + "\r\n" + ex.Message, ex);
                }
            }
            //Close the original form document since just one record.
            wrdDoc.Saved = true;
            wrdDoc.Close(ref oFalse, ref oMissing, ref oMissing);
            //At this point, Word remains open with no documents.
            WrdApp.WindowState = Word.WdWindowState.wdWindowStateMinimize;
            wrdMailMerge       = null;
            wrdDoc             = null;
            Commlog CommlogCur = new Commlog();
            CommlogCur.CommDateTime   = DateTime.Now;
            CommlogCur.CommType       = Commlogs.GetTypeAuto(CommItemTypeAuto.MISC);
            CommlogCur.Mode_          = CommItemMode.Mail;
            CommlogCur.SentOrReceived = CommSentOrReceived.Sent;
            CommlogCur.PatNum         = PatCur.PatNum;
            CommlogCur.Note           = "Letter sent: " + letterCur.Description + ". ";
            CommlogCur.UserNum        = Security.CurUser.UserNum;
            Commlogs.Insert(CommlogCur);
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 23
0
        private void butPrint_Click(object sender, System.EventArgs e)
        {
            if (listLetters.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select a letter first.");
                return;
            }
            LetterMerge letterCur    = ListForCat[listLetters.SelectedIndex];
            string      templateFile = PrefB.GetString("LetterMergePath") + letterCur.TemplateName;
            string      dataFile     = PrefB.GetString("LetterMergePath") + letterCur.DataFileName;

            if (!File.Exists(templateFile))
            {
                MsgBox.Show(this, "Template file does not exist.");
                return;
            }
            PrintDocument pd = new PrintDocument();

            if (!Printers.SetPrinter(pd, PrintSituation.Default))
            {
                return;
            }
            if (!CreateDataFile(dataFile, letterCur))
            {
                return;
            }
            Word.MailMerge wrdMailMerge;
            //Create an instance of Word.
            Word.Application WrdApp = LetterMerges.WordApp;
            //Open a document.
            Object oName = templateFile;

            wrdDoc = WrdApp.Documents.Open(ref oName, ref oMissing, ref oMissing,
                                           ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                           ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
            wrdDoc.Select();
            wrdMailMerge = wrdDoc.MailMerge;
            //Attach the data file.
            wrdDoc.MailMerge.OpenDataSource(dataFile, ref oMissing, ref oMissing, ref oMissing,
                                            ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                            ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
            wrdMailMerge.Destination = Word.WdMailMergeDestination.wdSendToPrinter;
            WrdApp.ActivePrinter     = pd.PrinterSettings.PrinterName;
            wrdMailMerge.Execute(ref oFalse);
            //Close the original form document since just one record.
            wrdDoc.Saved = true;
            wrdDoc.Close(ref oFalse, ref oMissing, ref oMissing);
            //At this point, Word remains open with no documents.
            WrdApp.WindowState = Word.WdWindowState.wdWindowStateMinimize;
            wrdMailMerge       = null;
            wrdDoc             = null;
            Commlog CommlogCur = new Commlog();

            CommlogCur.CommDateTime   = DateTime.Now;
            CommlogCur.CommType       = CommItemType.Misc;
            CommlogCur.Mode_          = CommItemMode.Mail;
            CommlogCur.SentOrReceived = CommSentOrReceived.Sent;
            CommlogCur.PatNum         = PatCur.PatNum;
            CommlogCur.Note           = "Letter sent: " + letterCur.Description + ". ";
            Commlogs.Insert(CommlogCur);
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 24
0
 ///<summary>Tries to delete the commlog passed in.  Throws exceptions if anything goes wrong.</summary>
 private void DeleteCommlog(Commlog commlog, string logText = "Delete")
 {
     Commlogs.Delete(commlog);
     SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, commlog.PatNum, logText);
 }
Exemplo n.º 25
0
        private void butPreview_Click(object sender, System.EventArgs e)
        {
#if !DISABLE_MICROSOFT_OFFICE
            if (listLetters.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select a letter first.");
                return;
            }
            LetterMerge letterCur    = ListForCat[listLetters.SelectedIndex];
            string      templateFile = ODFileUtils.CombinePaths(PrefC.GetString(PrefName.LetterMergePath), letterCur.TemplateName);
            string      dataFile     = ODFileUtils.CombinePaths(PrefC.GetString(PrefName.LetterMergePath), letterCur.DataFileName);
            if (!File.Exists(templateFile))
            {
                MsgBox.Show(this, "Template file does not exist.");
                return;
            }
            if (!CreateDataFile(dataFile, letterCur))
            {
                return;
            }
            Word.MailMerge wrdMailMerge;
            //Create an instance of Word.
            Word.Application WrdApp;
            try{
                WrdApp = LetterMerges.WordApp;
            }
            catch {
                MsgBox.Show(this, "Error. Is Word installed?");
                return;
            }
            //Open a document.
            Object oName = templateFile;
            wrdDoc = WrdApp.Documents.Open(ref oName, ref oMissing, ref oMissing,
                                           ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                           ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
            wrdDoc.Select();
            wrdMailMerge = wrdDoc.MailMerge;
            //Attach the data file.
            wrdDoc.MailMerge.OpenDataSource(dataFile, ref oMissing, ref oMissing, ref oMissing,
                                            ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                            ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
            wrdMailMerge.Destination = Word.WdMailMergeDestination.wdSendToNewDocument;
            wrdMailMerge.Execute(ref oFalse);
            //Close the original form document since just one record.
            wrdDoc.Saved = true;
            wrdDoc.Close(ref oFalse, ref oMissing, ref oMissing);
            //At this point, Word remains open with just one new document.
            WrdApp.Activate();
            if (WrdApp.WindowState == Word.WdWindowState.wdWindowStateMinimize)
            {
                WrdApp.WindowState = Word.WdWindowState.wdWindowStateMaximize;
            }
            wrdMailMerge = null;
            wrdDoc       = null;
            Commlog CommlogCur = new Commlog();
            CommlogCur.CommDateTime   = DateTime.Now;
            CommlogCur.CommType       = Commlogs.GetTypeAuto(CommItemTypeAuto.MISC);
            CommlogCur.Mode_          = CommItemMode.Mail;
            CommlogCur.SentOrReceived = CommSentOrReceived.Sent;
            CommlogCur.PatNum         = PatCur.PatNum;
            CommlogCur.Note           = "Letter sent: " + letterCur.Description + ". ";
            CommlogCur.UserNum        = Security.CurUser.UserNum;
            Commlogs.Insert(CommlogCur);
#else
            MessageBox.Show(this, "This version of Open Dental does not support Microsoft Word.");
#endif
            //this window now closes regardless of whether the user saved the comm item.
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 26
0
        ///<summary>Called from Pin_Click and OK_Click.</summary>
        private void SaveRecall()
        {
            int newStatus;

            if (comboStatus.SelectedIndex == 0)
            {
                newStatus = 0;
            }
            else
            {
                newStatus = DefB.Short[(int)DefCat.RecallUnschedStatus][comboStatus.SelectedIndex - 1].DefNum;
            }
            if (newStatus != RecallCur.RecallStatus ||      //if the status has changed
                (RecallCur.Note == "" && textNote.Text != ""))               //or a note was added
            {
                //make a commlog entry
                //unless there is an existing recall commlog entry for today
                bool      recallEntryToday = false;
                Commlog[] CommlogList      = Commlogs.Refresh(PatCur.PatNum);
                for (int i = 0; i < CommlogList.Length; i++)
                {
                    if (CommlogList[i].CommDateTime.Date == DateTime.Today &&
                        CommlogList[i].CommType == CommItemType.Recall)
                    {
                        recallEntryToday = true;
                    }
                }
                if (!recallEntryToday)
                {
                    Commlog CommlogCur = new Commlog();
                    CommlogCur.CommDateTime = DateTime.Now;
                    CommlogCur.CommType     = CommItemType.Recall;
                    CommlogCur.PatNum       = PatCur.PatNum;
                    if (newStatus != RecallCur.RecallStatus)
                    {
                        //Commlogs.Cur.Note+=Lan.g(this,"Status changed to")+" ";
                        if (newStatus == 0)
                        {
                            CommlogCur.Note += Lan.g(this, "Status None");
                        }
                        else
                        {
                            CommlogCur.Note += DefB.GetName(DefCat.RecallUnschedStatus, newStatus);
                        }
                        if (RecallCur.Note == "" && textNote.Text != "")
                        {
                            CommlogCur.Note += ", ";
                        }
                    }
                    if (RecallCur.Note == "" && textNote.Text != "")
                    {
                        CommlogCur.Note += textNote.Text;
                    }
                    CommlogCur.Note += ".  ";
                    FormCommItem FormCI = new FormCommItem(CommlogCur);
                    FormCI.IsNew = true;
                    //forces user to at least consider a commlog entry
                    FormCI.ShowDialog();                    //typically saved in this window.
                }
            }
            RecallCur.RecallStatus = newStatus;
            RecallCur.Note         = textNote.Text;
            Recalls.Update(RecallCur);
            Patient PatOld = PatCur.Copy();

            PatCur.WkPhone            = textWkPhone.Text;
            PatCur.WirelessPhone      = textWirelessPhone.Text;
            PatCur.Email              = textEmail.Text;
            PatCur.PreferRecallMethod = (ContactMethod)comboRecallMethod.SelectedIndex;
            Patients.Update(PatCur, PatOld);
            Patients.UpdatePhoneAndNoteIfNeeded(textHmPhone.Text, textAddrNotes.Text, PatCur.PatNum);
        }
Exemplo n.º 27
0
        ///<summary>Sets given appt.AptStatus to broken.
        ///Provide procCode that should be charted, can be null but will not chart a broken procedure.
        ///Also considers various broken procedure based prefs.
        ///Makes its own securitylog entries.</summary>
        public static void BreakApptHelper(Appointment appt, Patient pat, ProcedureCode procCode)
        {
            //suppressHistory is true due to below logic creating a log with a specific HistAppointmentAction instead of the generic changed.
            DateTime datePrevious    = appt.DateTStamp;
            bool     suppressHistory = false;

            if (procCode != null)
            {
                suppressHistory = (procCode.ProcCode.In("D9986", "D9987"));
            }
            Appointments.SetAptStatus(appt, ApptStatus.Broken, suppressHistory); //Appointments S-Class handles Signalods
            if (appt.AptStatus != ApptStatus.Complete)                           //seperate log entry for completed appointments.
            {
                SecurityLogs.MakeLogEntry(Permissions.AppointmentEdit, pat.PatNum,
                                          appt.ProcDescript + ", " + appt.AptDateTime.ToString()
                                          + ", Broken from the Appts module.", appt.AptNum, datePrevious);
            }
            else
            {
                SecurityLogs.MakeLogEntry(Permissions.AppointmentCompleteEdit, pat.PatNum,
                                          appt.ProcDescript + ", " + appt.AptDateTime.ToString()
                                          + ", Broken from the Appts module.", appt.AptNum, datePrevious);
            }
            #region HL7
            //If there is an existing HL7 def enabled, send a SIU message if there is an outbound SIU message defined
            if (HL7Defs.IsExistingHL7Enabled())
            {
                //S15 - Appt Cancellation event
                MessageHL7 messageHL7 = MessageConstructor.GenerateSIU(pat, Patients.GetPat(pat.Guarantor), EventTypeHL7.S15, appt);
                //Will be null if there is no outbound SIU message defined, so do nothing
                if (messageHL7 != null)
                {
                    HL7Msg hl7Msg = new HL7Msg();
                    hl7Msg.AptNum    = appt.AptNum;
                    hl7Msg.HL7Status = HL7MessageStatus.OutPending;                  //it will be marked outSent by the HL7 service.
                    hl7Msg.MsgText   = messageHL7.ToString();
                    hl7Msg.PatNum    = pat.PatNum;
                    HL7Msgs.Insert(hl7Msg);
#if DEBUG
                    MessageBox.Show("Appointments", messageHL7.ToString());
#endif
                }
            }
            #endregion
            #region Charting the proc
            if (procCode != null)
            {
                switch (procCode.ProcCode)
                {
                case "D9986":                        //Missed
                    HistAppointments.CreateHistoryEntry(appt.AptNum, HistAppointmentAction.Missed);
                    break;

                case "D9987":                        //Cancelled
                    HistAppointments.CreateHistoryEntry(appt.AptNum, HistAppointmentAction.Cancelled);
                    break;
                }
                Procedure procedureCur = new Procedure();
                procedureCur.PatNum       = pat.PatNum;
                procedureCur.ProvNum      = (procCode.ProvNumDefault > 0 ? procCode.ProvNumDefault : appt.ProvNum);
                procedureCur.CodeNum      = procCode.CodeNum;
                procedureCur.ProcDate     = DateTime.Today;
                procedureCur.DateEntryC   = DateTime.Now;
                procedureCur.ProcStatus   = ProcStat.C;
                procedureCur.ClinicNum    = appt.ClinicNum;
                procedureCur.UserNum      = Security.CurUser.UserNum;
                procedureCur.Note         = Lans.g("AppointmentEdit", "Appt BROKEN for") + " " + appt.ProcDescript + "  " + appt.AptDateTime.ToString();
                procedureCur.PlaceService = (PlaceOfService)PrefC.GetInt(PrefName.DefaultProcedurePlaceService);              //Default proc place of service for the Practice is used.
                List <InsSub>  listInsSubs    = InsSubs.RefreshForFam(Patients.GetFamily(pat.PatNum));
                List <InsPlan> listInsPlans   = InsPlans.RefreshForSubList(listInsSubs);
                List <PatPlan> listPatPlans   = PatPlans.Refresh(pat.PatNum);
                InsPlan        insPlanPrimary = null;
                InsSub         insSubPrimary  = null;
                if (listPatPlans.Count > 0)
                {
                    insSubPrimary  = InsSubs.GetSub(listPatPlans[0].InsSubNum, listInsSubs);
                    insPlanPrimary = InsPlans.GetPlan(insSubPrimary.PlanNum, listInsPlans);
                }
                double procFee;
                long   feeSch;
                if (insPlanPrimary == null || procCode.NoBillIns)
                {
                    feeSch = FeeScheds.GetFeeSched(0, pat.FeeSched, procedureCur.ProvNum);
                }
                else                  //Only take into account the patient's insurance fee schedule if the D9986 procedure is not marked as NoBillIns
                {
                    feeSch = FeeScheds.GetFeeSched(insPlanPrimary.FeeSched, pat.FeeSched, procedureCur.ProvNum);
                }
                procFee = Fees.GetAmount0(procedureCur.CodeNum, feeSch, procedureCur.ClinicNum, procedureCur.ProvNum);
                if (insPlanPrimary != null && insPlanPrimary.PlanType == "p" && !insPlanPrimary.IsMedical)         //PPO
                {
                    double provFee = Fees.GetAmount0(procedureCur.CodeNum, Providers.GetProv(procedureCur.ProvNum).FeeSched, procedureCur.ClinicNum,
                                                     procedureCur.ProvNum);
                    procedureCur.ProcFee = Math.Max(provFee, procFee);
                }
                else
                {
                    procedureCur.ProcFee = procFee;
                }
                if (!PrefC.GetBool(PrefName.EasyHidePublicHealth))
                {
                    procedureCur.SiteNum = pat.SiteNum;
                }
                Procedures.Insert(procedureCur);
                //Now make a claimproc if the patient has insurance.  We do this now for consistency because a claimproc could get created in the future.
                List <Benefit>   listBenefits          = Benefits.Refresh(listPatPlans, listInsSubs);
                List <ClaimProc> listClaimProcsForProc = ClaimProcs.RefreshForProc(procedureCur.ProcNum);
                Procedures.ComputeEstimates(procedureCur, pat.PatNum, listClaimProcsForProc, false, listInsPlans, listPatPlans, listBenefits, pat.Age, listInsSubs);
                FormProcBroken FormPB = new FormProcBroken(procedureCur);
                FormPB.IsNew = true;
                FormPB.ShowDialog();
            }
            #endregion
            #region BrokenApptAdjustment
            if (PrefC.GetBool(PrefName.BrokenApptAdjustment))
            {
                Adjustment AdjustmentCur = new Adjustment();
                AdjustmentCur.DateEntry = DateTime.Today;
                AdjustmentCur.AdjDate   = DateTime.Today;
                AdjustmentCur.ProcDate  = DateTime.Today;
                AdjustmentCur.ProvNum   = appt.ProvNum;
                AdjustmentCur.PatNum    = pat.PatNum;
                AdjustmentCur.AdjType   = PrefC.GetLong(PrefName.BrokenAppointmentAdjustmentType);
                AdjustmentCur.ClinicNum = appt.ClinicNum;
                FormAdjust FormA = new FormAdjust(pat, AdjustmentCur);
                FormA.IsNew = true;
                FormA.ShowDialog();
            }
            #endregion
            #region BrokenApptCommLog
            if (PrefC.GetBool(PrefName.BrokenApptCommLog))
            {
                Commlog CommlogCur = new Commlog();
                CommlogCur.PatNum       = pat.PatNum;
                CommlogCur.CommDateTime = DateTime.Now;
                CommlogCur.CommType     = Commlogs.GetTypeAuto(CommItemTypeAuto.APPT);
                CommlogCur.Note         = Lan.g("Appointment", "Appt BROKEN for") + " " + appt.ProcDescript + "  " + appt.AptDateTime.ToString();
                CommlogCur.Mode_        = CommItemMode.None;
                CommlogCur.UserNum      = Security.CurUser.UserNum;
                FormCommItem FormCI = new FormCommItem();
                FormCI.ShowDialog(new CommItemModel()
                {
                    CommlogCur = CommlogCur
                }, new CommItemController(FormCI)
                {
                    IsNew = true
                });
            }
            #endregion
            AutomationL.Trigger(AutomationTrigger.BreakAppointment, null, pat.PatNum);
            Recalls.SynchScheduledApptFull(appt.PatNum);
        }
Exemplo n.º 28
0
        ///<summary>Sets given appt.AptStatus to broken.
        ///Provide procCode that should be charted, can be null but will not chart a broken procedure.
        ///Also considers various broken procedure based prefs.
        ///Makes its own securitylog entries.</summary>
        public static void BreakApptHelper(Appointment appt, Patient pat, ProcedureCode procCode)
        {
            //suppressHistory is true due to below logic creating a log with a specific HistAppointmentAction instead of the generic changed.
            DateTime datePrevious    = appt.DateTStamp;
            bool     suppressHistory = false;

            if (procCode != null)
            {
                suppressHistory = (procCode.ProcCode.In("D9986", "D9987"));
            }
            Appointments.SetAptStatus(appt, ApptStatus.Broken, suppressHistory); //Appointments S-Class handles Signalods
            if (appt.AptStatus != ApptStatus.Complete)                           //seperate log entry for completed appointments.
            {
                SecurityLogs.MakeLogEntry(Permissions.AppointmentEdit, pat.PatNum,
                                          appt.ProcDescript + ", " + appt.AptDateTime.ToString()
                                          + ", Broken from the Appts module.", appt.AptNum, datePrevious);
            }
            else
            {
                SecurityLogs.MakeLogEntry(Permissions.AppointmentCompleteEdit, pat.PatNum,
                                          appt.ProcDescript + ", " + appt.AptDateTime.ToString()
                                          + ", Broken from the Appts module.", appt.AptNum, datePrevious);
            }
            #region HL7
            //If there is an existing HL7 def enabled, send a SIU message if there is an outbound SIU message defined
            if (HL7Defs.IsExistingHL7Enabled())
            {
                //S15 - Appt Cancellation event
                MessageHL7 messageHL7 = MessageConstructor.GenerateSIU(pat, Patients.GetPat(pat.Guarantor), EventTypeHL7.S15, appt);
                //Will be null if there is no outbound SIU message defined, so do nothing
                if (messageHL7 != null)
                {
                    HL7Msg hl7Msg = new HL7Msg();
                    hl7Msg.AptNum    = appt.AptNum;
                    hl7Msg.HL7Status = HL7MessageStatus.OutPending;                  //it will be marked outSent by the HL7 service.
                    hl7Msg.MsgText   = messageHL7.ToString();
                    hl7Msg.PatNum    = pat.PatNum;
                    HL7Msgs.Insert(hl7Msg);
#if DEBUG
                    MessageBox.Show("Appointments", messageHL7.ToString());
#endif
                }
            }
            #endregion
            List <Procedure> listProcedures = new List <Procedure>();
            //splits should only exist on procs if they are using tp pre-payments
            List <PaySplit> listSplitsForApptProcs = new List <PaySplit>();
            bool            isNonRefundable        = false;
            double          brokenProcAmount       = 0;
            Procedure       brokenProcedure        = new Procedure();
            bool            wasBrokenProcDeleted   = false;
            if (PrefC.GetYN(PrefName.PrePayAllowedForTpProcs))
            {
                listProcedures = Procedures.GetProcsForSingle(appt.AptNum, false);
                if (listProcedures.Count > 0)
                {
                    listSplitsForApptProcs = PaySplits.GetPaySplitsFromProcs(listProcedures.Select(x => x.ProcNum).ToList());
                }
            }
            #region Charting the proc
            if (procCode != null)
            {
                switch (procCode.ProcCode)
                {
                case "D9986":                        //Missed
                    HistAppointments.CreateHistoryEntry(appt.AptNum, HistAppointmentAction.Missed);
                    break;

                case "D9987":                        //Cancelled
                    HistAppointments.CreateHistoryEntry(appt.AptNum, HistAppointmentAction.Cancelled);
                    break;
                }
                brokenProcedure.PatNum       = pat.PatNum;
                brokenProcedure.ProvNum      = (procCode.ProvNumDefault > 0 ? procCode.ProvNumDefault : appt.ProvNum);
                brokenProcedure.CodeNum      = procCode.CodeNum;
                brokenProcedure.ProcDate     = DateTime.Today;
                brokenProcedure.DateEntryC   = DateTime.Now;
                brokenProcedure.ProcStatus   = ProcStat.C;
                brokenProcedure.ClinicNum    = appt.ClinicNum;
                brokenProcedure.UserNum      = Security.CurUser.UserNum;
                brokenProcedure.Note         = Lans.g("AppointmentEdit", "Appt BROKEN for") + " " + appt.ProcDescript + "  " + appt.AptDateTime.ToString();
                brokenProcedure.PlaceService = (PlaceOfService)PrefC.GetInt(PrefName.DefaultProcedurePlaceService);              //Default proc place of service for the Practice is used.
                List <InsSub>  listInsSubs    = InsSubs.RefreshForFam(Patients.GetFamily(pat.PatNum));
                List <InsPlan> listInsPlans   = InsPlans.RefreshForSubList(listInsSubs);
                List <PatPlan> listPatPlans   = PatPlans.Refresh(pat.PatNum);
                InsPlan        insPlanPrimary = null;
                InsSub         insSubPrimary  = null;
                if (listPatPlans.Count > 0)
                {
                    insSubPrimary  = InsSubs.GetSub(listPatPlans[0].InsSubNum, listInsSubs);
                    insPlanPrimary = InsPlans.GetPlan(insSubPrimary.PlanNum, listInsPlans);
                }
                double procFee;
                long   feeSch;
                if (insPlanPrimary == null || procCode.NoBillIns)
                {
                    feeSch = FeeScheds.GetFeeSched(0, pat.FeeSched, brokenProcedure.ProvNum);
                }
                else                  //Only take into account the patient's insurance fee schedule if the D9986 procedure is not marked as NoBillIns
                {
                    feeSch = FeeScheds.GetFeeSched(insPlanPrimary.FeeSched, pat.FeeSched, brokenProcedure.ProvNum);
                }
                procFee = Fees.GetAmount0(brokenProcedure.CodeNum, feeSch, brokenProcedure.ClinicNum, brokenProcedure.ProvNum);
                if (insPlanPrimary != null && insPlanPrimary.PlanType == "p" && !insPlanPrimary.IsMedical)         //PPO
                {
                    double provFee = Fees.GetAmount0(brokenProcedure.CodeNum, Providers.GetProv(brokenProcedure.ProvNum).FeeSched, brokenProcedure.ClinicNum,
                                                     brokenProcedure.ProvNum);
                    brokenProcedure.ProcFee = Math.Max(provFee, procFee);
                }
                else if (listSplitsForApptProcs.Count > 0 && PrefC.GetBool(PrefName.TpPrePayIsNonRefundable) && procCode.ProcCode == "D9986")
                {
                    //if there are pre-payments, non-refundable pre-payments is turned on, and the broken appointment is a missed code then auto-fill
                    //the window with the sum of the procs for the appointment. Transfer money below after broken procedure is confirmed by the user.
                    brokenProcedure.ProcFee = listSplitsForApptProcs.Sum(x => x.SplitAmt);
                    isNonRefundable         = true;
                }
                else
                {
                    brokenProcedure.ProcFee = procFee;
                }
                if (!PrefC.GetBool(PrefName.EasyHidePublicHealth))
                {
                    brokenProcedure.SiteNum = pat.SiteNum;
                }
                Procedures.Insert(brokenProcedure);
                //Now make a claimproc if the patient has insurance.  We do this now for consistency because a claimproc could get created in the future.
                List <Benefit>   listBenefits          = Benefits.Refresh(listPatPlans, listInsSubs);
                List <ClaimProc> listClaimProcsForProc = ClaimProcs.RefreshForProc(brokenProcedure.ProcNum);
                Procedures.ComputeEstimates(brokenProcedure, pat.PatNum, listClaimProcsForProc, false, listInsPlans, listPatPlans, listBenefits, pat.Age, listInsSubs);
                FormProcBroken FormPB = new FormProcBroken(brokenProcedure, isNonRefundable);
                FormPB.IsNew = true;
                FormPB.ShowDialog();
                brokenProcAmount     = FormPB.AmountTotal;
                wasBrokenProcDeleted = FormPB.IsProcDeleted;
            }
            #endregion
            #region BrokenApptAdjustment
            if (PrefC.GetBool(PrefName.BrokenApptAdjustment))
            {
                Adjustment AdjustmentCur = new Adjustment();
                AdjustmentCur.DateEntry = DateTime.Today;
                AdjustmentCur.AdjDate   = DateTime.Today;
                AdjustmentCur.ProcDate  = DateTime.Today;
                AdjustmentCur.ProvNum   = appt.ProvNum;
                AdjustmentCur.PatNum    = pat.PatNum;
                AdjustmentCur.AdjType   = PrefC.GetLong(PrefName.BrokenAppointmentAdjustmentType);
                AdjustmentCur.ClinicNum = appt.ClinicNum;
                FormAdjust FormA = new FormAdjust(pat, AdjustmentCur);
                FormA.IsNew = true;
                FormA.ShowDialog();
            }
            #endregion
            #region BrokenApptCommLog
            if (PrefC.GetBool(PrefName.BrokenApptCommLog))
            {
                Commlog commlogCur = new Commlog();
                commlogCur.PatNum       = pat.PatNum;
                commlogCur.CommDateTime = DateTime.Now;
                commlogCur.CommType     = Commlogs.GetTypeAuto(CommItemTypeAuto.APPT);
                commlogCur.Note         = Lan.g("Appointment", "Appt BROKEN for") + " " + appt.ProcDescript + "  " + appt.AptDateTime.ToString();
                commlogCur.Mode_        = CommItemMode.None;
                commlogCur.UserNum      = Security.CurUser.UserNum;
                commlogCur.IsNew        = true;
                FormCommItem FormCI = new FormCommItem(commlogCur);
                FormCI.ShowDialog();
            }
            #endregion
            #region Transfer money from TP Procedures if necessary
            //Note this MUST come after FormProcBroken since clicking cancel in that window will delete the procedure.
            if (isNonRefundable && !wasBrokenProcDeleted && listSplitsForApptProcs.Count > 0)
            {
                //transfer what the user specified in the broken appointment window.
                //transfer up to the amount specified by the user
                foreach (Procedure proc in listProcedures)
                {
                    if (brokenProcAmount == 0)
                    {
                        break;
                    }
                    List <PaySplit> listSplitsForAppointmentProcedure = listSplitsForApptProcs.FindAll(x => x.ProcNum == proc.ProcNum);
                    foreach (PaySplit split in listSplitsForAppointmentProcedure)
                    {
                        if (brokenProcAmount == 0)
                        {
                            break;
                        }
                        double amt = Math.Min(brokenProcAmount, split.SplitAmt);
                        Payments.CreateTransferForTpProcs(proc, new List <PaySplit> {
                            split
                        }, brokenProcedure, amt);
                        double amtPaidOnApt = listSplitsForApptProcs.Sum(x => x.SplitAmt);
                        if (amtPaidOnApt > amt)
                        {
                            //If the original prepayment amount is greater than the amt being specified for the appointment break, transfer
                            //the difference to an Unallocated Unearned Paysplit on the account.
                            double remainingAmt = amtPaidOnApt - amt;
                            //We have to create a new transfer payment here to correlate to the split.
                            Payment txfrPayment = new Payment();
                            txfrPayment.PayAmt    = 0;
                            txfrPayment.PayDate   = DateTime.Today;
                            txfrPayment.ClinicNum = split.ClinicNum;
                            txfrPayment.PayNote   = "Automatic transfer from treatment planned procedure prepayment.";
                            txfrPayment.PatNum    = split.PatNum;                       //ultimately where the payment ends up.
                            txfrPayment.PayType   = 0;
                            Payments.Insert(txfrPayment);
                            PaymentEdit.IncomeTransferData transferData = PaymentEdit.IncomeTransferData.CreateTransfer(split, txfrPayment.PayNum, true, remainingAmt);
                            PaySplit offset         = transferData.ListSplitsCur.FirstOrDefault(x => x.FSplitNum != 0);
                            long     offsetSplitNum = PaySplits.Insert(offset);                      //Get the FSplitNum from the offset
                            PaySplit allocation     = transferData.ListSplitsCur.FirstOrDefault(x => x.FSplitNum == 0);
                            allocation.FSplitNum = offsetSplitNum;
                            PaySplits.Insert(allocation);                            //Insert so the split is now up to date
                            SecurityLogs.MakeLogEntry(Permissions.PaymentCreate, txfrPayment.PatNum, "Automatic transfer of funds for treatment plan procedure pre-payments.");
                        }
                        brokenProcAmount -= amt;
                    }
                }
            }
            //if broken appointment procedure was deleted (user cancelled out of the window) just keep money on the original procedure.
            #endregion
            AppointmentEvent.Fire(ODEventType.AppointmentEdited, appt);
            AutomationL.Trigger(AutomationTrigger.BreakAppointment, null, pat.PatNum);
            Recalls.SynchScheduledApptFull(appt.PatNum);
        }
Exemplo n.º 29
0
        private void Delete_Click()
        {
            if (!Security.IsAuthorized(Permissions.AppointmentEdit))
            {
                return;
            }
            if (grid.SelectedIndices.Length > 1)
            {
                if (!MsgBox.Show(MsgBoxButtons.OKCancel, "Delete all selected appointments permanently?"))
                {
                    return;
                }
            }
            List <Appointment> listApptsWithNote   = new List <Appointment>();
            List <long>        listSelectedAptNums = new List <long>();

            foreach (int i in grid.SelectedIndices)
            {
                listSelectedAptNums.Add(_listUnschedApt[i].AptNum);
                if (!string.IsNullOrEmpty(_listUnschedApt[i].Note))
                {
                    listApptsWithNote.Add(_listUnschedApt[i]);
                }
            }
            if (listApptsWithNote.Count > 0)           //There were notes in the appointment(s) we are about to delete and we must ask if they want to save them in a commlog.
            {
                string commlogMsg = "";
                if (grid.SelectedIndices.Length == 1)
                {
                    commlogMsg = Commlogs.GetDeleteApptCommlogMessage(listApptsWithNote[0].Note, listApptsWithNote[0].AptStatus);
                }
                else
                {
                    commlogMsg = "One or more appointments have notes.  Save appointment notes in CommLogs?";
                }
                DialogResult result = MessageBox.Show(commlogMsg, "Question...", MessageBoxButtons.YesNoCancel);
                if (result == DialogResult.Cancel)
                {
                    return;
                }
                else if (result == DialogResult.Yes)
                {
                    foreach (Appointment apptCur in listApptsWithNote)
                    {
                        Commlog commlogCur = new Commlog();
                        commlogCur.PatNum       = apptCur.PatNum;
                        commlogCur.CommDateTime = DateTime.Now;
                        commlogCur.CommType     = Commlogs.GetTypeAuto(CommItemTypeAuto.APPT);
                        commlogCur.Note         = Lan.g(this, "Deleted Appt. & saved note") + ": ";
                        if (apptCur.ProcDescript != "")
                        {
                            commlogCur.Note += apptCur.ProcDescript + ": ";
                        }
                        commlogCur.Note   += apptCur.Note;
                        commlogCur.UserNum = Security.CurUser.UserNum;
                        //there is no dialog here because it is just a simple entry
                        Commlogs.Insert(commlogCur);
                    }
                }
            }
            Appointments.Delete(listSelectedAptNums);
            foreach (int i in grid.SelectedIndices)
            {
                SecurityLogs.MakeLogEntry(Permissions.AppointmentEdit, _listUnschedApt[i].PatNum,
                                          Lan.g(this, "Appointment deleted from the Unscheduled list."), _listUnschedApt[i].AptNum, _listUnschedApt[i].DateTStamp);
            }
            FillGrid();
        }
Exemplo n.º 30
0
        public static List <DefCatOptions> GetOptionsForDefCats(Array defCatVals)
        {
            List <DefCatOptions> listDefCatOptions = new List <DefCatOptions>();

            foreach (DefCat defCatCur in defCatVals)
            {
                if (defCatCur.GetDescription() == "NotUsed")
                {
                    continue;
                }
                if (defCatCur.GetDescription().Contains("HqOnly") && !PrefC.IsODHQ)
                {
                    continue;
                }
                DefCatOptions defCOption = new DefCatOptions(defCatCur);
                switch (defCatCur)
                {
                case DefCat.AccountColors:
                    defCOption.CanEditName = false;
                    defCOption.EnableColor = true;
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Changes the color of text for different types of entries in Account Module");
                    break;

                case DefCat.AccountQuickCharge:
                    defCOption.CanDelete   = true;
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "Procedure Codes");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Account Proc Quick Add items.  Each entry can be a series of procedure codes separated by commas (e.g. D0180,D1101,D8220).  Used in the account module to quickly charge patients for items.");
                    break;

                case DefCat.AdjTypes:
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "+, -, or dp");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Plus increases the patient balance.  Minus decreases it.  Dp means discount plan.  Not allowed to change value after creating new type since changes affect all patient accounts.");
                    break;

                case DefCat.AppointmentColors:
                    defCOption.CanEditName = false;
                    defCOption.EnableColor = true;
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Changes colors of background in Appointments Module, and colors for completed appointments.");
                    break;

                case DefCat.ApptConfirmed:
                    defCOption.EnableColor = true;
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "Abbrev");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Color shows on each appointment if Appointment View is set to show ConfirmedColor.");
                    break;

                case DefCat.ApptProcsQuickAdd:
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "ADA Code(s)");
                    if (Clinics.IsMedicalPracticeOrClinic(Clinics.ClinicNum))
                    {
                        defCOption.HelpText = Lans.g("FormDefinitions", "These are the procedures that you can quickly add to the treatment plan from within the appointment editing window.  Multiple procedures may be separated by commas with no spaces. These definitions may be freely edited without affecting any patient records.");
                    }
                    else
                    {
                        defCOption.HelpText = Lans.g("FormDefinitions", "These are the procedures that you can quickly add to the treatment plan from within the appointment editing window.  They must not require a tooth number. Multiple procedures may be separated by commas with no spaces. These definitions may be freely edited without affecting any patient records.");
                    }
                    break;

                case DefCat.AutoDeposit:
                    defCOption.CanDelete   = true;
                    defCOption.CanHide     = true;
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "Account Number");
                    break;

                case DefCat.AutoNoteCats:
                    defCOption.CanDelete     = true;
                    defCOption.CanHide       = false;
                    defCOption.EnableValue   = true;
                    defCOption.IsValueDefNum = true;
                    defCOption.ValueText     = Lans.g("FormDefinitions", "Parent Category");
                    defCOption.HelpText      = Lans.g("FormDefinitions", "Leave the Parent Category blank for categories at the root level. Assign a Parent Category to move a category within another. The order set here will only affect the order within the assigned Parent Category in the Auto Note list. For example, a category may be moved above its parent in this list, but it will still be within its Parent Category in the Auto Note list.");
                    break;

                case DefCat.BillingTypes:
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "E, C, or CE");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "E=Email bill, C=Collection, CE=Collection Excluded.  It is recommended to use as few billing types as possible.  They can be useful when running reports to separate delinquent accounts, but can cause 'forgotten accounts' if used without good office procedures. Changes affect all patients.");
                    break;

                case DefCat.BlockoutTypes:
                    defCOption.EnableColor = true;
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Blockout types are used in the appointments module.");
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "Flags");
                    break;

                case DefCat.ChartGraphicColors:
                    defCOption.CanEditName = false;
                    defCOption.EnableColor = true;
                    if (Clinics.IsMedicalPracticeOrClinic(Clinics.ClinicNum))
                    {
                        defCOption.HelpText = Lans.g("FormDefinitions", "These colors will be used to graphically display treatments.");
                    }
                    else
                    {
                        defCOption.HelpText = Lans.g("FormDefinitions", "These colors will be used on the graphical tooth chart to draw restorations.");
                    }
                    break;

                case DefCat.ClaimCustomTracking:
                    defCOption.CanDelete   = true;
                    defCOption.CanHide     = false;
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "Days Suppressed");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Some offices may set up claim tracking statuses such as 'review', 'hold', 'riskmanage', etc.") + "\r\n"
                                             + Lans.g("FormDefinitions", "Set the value of 'Days Suppressed' to the number of days the claim will be suppressed from the Outstanding Claims Report "
                                                      + "when the status is changed to the selected status.");
                    break;

                case DefCat.ClaimErrorCode:
                    defCOption.CanDelete   = true;
                    defCOption.CanHide     = false;
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "Description");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Used to track error codes when entering claim custom statuses.");
                    break;

                case DefCat.ClaimPaymentTracking:
                    defCOption.ValueText = Lans.g("FormDefinitions", "Value");
                    defCOption.HelpText  = Lans.g("FormDefinitions", "EOB adjudication method codes to be used for insurance payments.  Last entry cannot be hidden.");
                    break;

                case DefCat.ClaimPaymentGroups:
                    defCOption.ValueText = Lans.g("FormDefinitions", "Value");
                    defCOption.HelpText  = Lans.g("FormDefinitions", "Used to group claim payments in the daily payments report.");
                    break;

                case DefCat.ClinicSpecialty:
                    defCOption.CanHide   = true;
                    defCOption.CanDelete = false;
                    defCOption.HelpText  = Lans.g("FormDefinitions", "You can add as many specialties as you want.  Changes affect all current records.");
                    break;

                case DefCat.CommLogTypes:
                    defCOption.EnableValue   = true;
                    defCOption.EnableColor   = true;
                    defCOption.DoShowNoColor = true;
                    string commItemTypes = string.Join(", ", Commlogs.GetCommItemTypes().Select(x => x.GetDescription(useShortVersionIfAvailable: true)));
                    defCOption.ValueText = Lans.g("FormDefinitions", "Usage");
                    defCOption.HelpText  = Lans.g("FormDefinitions", "Changes affect all current commlog entries.  Optionally set Usage to one of the following: "
                                                  + commItemTypes + ". Only one of each. This helps automate new entries.");
                    break;

                case DefCat.ContactCategories:
                    defCOption.HelpText = Lans.g("FormDefinitions", "You can add as many categories as you want.  Changes affect all current contact records.");
                    break;

                case DefCat.Diagnosis:
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "1 or 2 letter abbreviation");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "The diagnosis list is shown when entering a procedure.  Ones that are less used should go lower on the list.  The abbreviation is shown in the progress notes.  BE VERY CAREFUL.  Changes affect all patients.");
                    break;

                case DefCat.FeeColors:
                    defCOption.CanEditName = false;
                    defCOption.CanHide     = false;
                    defCOption.EnableColor = true;
                    defCOption.HelpText    = Lans.g("FormDefinitions", "These are the colors associated to fee types.");
                    break;

                case DefCat.ImageCats:
                    defCOption.ValueText = Lans.g("FormDefinitions", "Usage");
                    defCOption.HelpText  = Lans.g("FormDefinitions", "These are the categories that will be available in the image and chart modules.  If you hide a category, images in that category will be hidden, so only hide a category if you are certain it has never been used.  Multiple categories can be set to show in the Chart module, but only one category should be set for patient pictures, statements, and tooth charts. Selecting multiple categories for treatment plans will save the treatment plan in each category. Affects all patient records.");
                    break;

                case DefCat.InsurancePaymentType:
                    defCOption.CanDelete   = true;
                    defCOption.CanHide     = false;
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "N=Not selected for deposit");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "These are claim payment types for insurance payments attached to claims.");
                    break;

                case DefCat.InsuranceVerificationStatus:
                    defCOption.ValueText = Lans.g("FormDefinitions", "Usage");
                    defCOption.HelpText  = Lans.g("FormDefinitions", "These are statuses for the insurance verification list.");
                    break;

                case DefCat.JobPriorities:
                    defCOption.CanDelete   = false;
                    defCOption.CanHide     = true;
                    defCOption.EnableValue = true;
                    defCOption.EnableColor = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "Comma-delimited keywords");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "These are job priorities that determine how jobs are sorted in the Job Manager System.  Required values are: OnHold, Low, Normal, MediumHigh, High, Urgent, BugDefault, JobDefault, DocumentationDefault.");
                    break;

                case DefCat.LetterMergeCats:
                    defCOption.HelpText = Lans.g("FormDefinitions", "Categories for Letter Merge.  You can safely make any changes you want.");
                    break;

                case DefCat.MiscColors:
                    defCOption.CanEditName = false;
                    defCOption.EnableColor = true;
                    defCOption.HelpText    = "";
                    break;

                case DefCat.PaymentTypes:
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "N=Not selected for deposit");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Types of payments that patients might make. Any changes will affect all patients.");
                    break;

                case DefCat.PayPlanCategories:
                    defCOption.HelpText = Lans.g("FormDefinitions", "Assign payment plans to different categories");
                    break;

                case DefCat.PaySplitUnearnedType:
                    defCOption.ValueText   = "Do Not Show on Account";
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Usually only used by offices that use accrual basis accounting instead of cash basis accounting. Any changes will affect all patients.");
                    defCOption.EnableValue = true;
                    break;

                case DefCat.ProcButtonCats:
                    defCOption.HelpText = Lans.g("FormDefinitions", "These are similar to the procedure code categories, but are only used for organizing and grouping the procedure buttons in the Chart module.");
                    break;

                case DefCat.ProcCodeCats:
                    defCOption.HelpText = Lans.g("FormDefinitions", "These are the categories for organizing procedure codes. They do not have to follow ADA categories.  There is no relationship to insurance categories which are setup in the Ins Categories section.  Does not affect any patient records.");
                    break;

                case DefCat.ProgNoteColors:
                    defCOption.CanEditName = false;
                    defCOption.EnableColor = true;
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Changes color of text for different types of entries in the Chart Module Progress Notes.");
                    break;

                case DefCat.Prognosis:
                    //Nothing special. Might add HelpText later.
                    break;

                case DefCat.ProviderSpecialties:
                    defCOption.HelpText = Lans.g("FormDefinitions", "Provider specialties cannot be deleted.  Changes to provider specialties could affect e-claims.");
                    break;

                case DefCat.RecallUnschedStatus:
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "Abbreviation");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Recall/Unsched Status.  Abbreviation must be 7 characters or less.  Changes affect all patients.");
                    break;

                case DefCat.Regions:
                    defCOption.CanHide  = false;
                    defCOption.HelpText = Lans.g("FormDefinitions", "The region identifying the clinic it is assigned to.");
                    break;

                case DefCat.SupplyCats:
                    defCOption.CanDelete = true;
                    defCOption.CanHide   = false;
                    defCOption.HelpText  = Lans.g("FormDefinitions", "The categories for inventory supplies.");
                    break;

                case DefCat.TaskPriorities:
                    defCOption.EnableColor = true;
                    defCOption.EnableValue = true;
                    defCOption.ValueText   = Lans.g("FormDefinitions", "D = Default, R = Reminder");
                    defCOption.HelpText    = Lans.g("FormDefinitions", "Priorities available for selection within the task edit window.  Task lists are sorted using the order of these priorities.  They can have any description and color.  At least one priority should be Default (D).  If more than one priority is flagged as the default, the last default in the list will be used.  If no default is set, the last priority will be used.  Use (R) to indicate the initial reminder task priority to use when creating reminder tasks.  Changes affect all tasks where the definition is used.");
                    break;

                case DefCat.TxPriorities:
                    defCOption.EnableColor            = true;
                    defCOption.EnableValue            = true;
                    defCOption.DoShowItemOrderInValue = true;
                    defCOption.ValueText = Lan.g(_lanThis, "Internal Priority");
                    defCOption.HelpText  = Lan.g(_lanThis, "Displayed order should match order of priority of treatment.  They are used in Treatment Plan and Chart "
                                                 + "modules. They can be simple numbers or descriptive abbreviations 7 letters or less.  Changes affect all procedures where the "
                                                 + "definition is used.  'Internal Priority' does not show, but is used for list order and for automated selection of which procedures "
                                                 + "are next in a planned appointment.");
                    break;

                case DefCat.WebSchedNewPatApptTypes:
                    defCOption.CanDelete = true;
                    defCOption.CanHide   = false;
                    defCOption.ValueText = Lans.g("FormDefinitions", "Appointment Type");
                    defCOption.HelpText  = Lans.g("FormDefinitions", "Appointment types to be displayed in the Web Sched New Pat Appt web application.  These are selectable for the new patients and will be saved to the appointment note.");
                    break;

                case DefCat.CarrierGroupNames:
                    defCOption.CanHide  = true;
                    defCOption.HelpText = Lans.g("FormDefinitions", "These are group names for Carriers.");
                    break;

                case DefCat.TimeCardAdjTypes:
                    defCOption.CanEditName = true;
                    defCOption.CanHide     = true;
                    defCOption.HelpText    = Lans.g("FormDefinitions", "These are PTO Adjustments Types used for tracking on employee time cards and ADP export.");
                    break;
                }
                listDefCatOptions.Add(defCOption);
            }
            return(listDefCatOptions);
        }