Ejemplo n.º 1
0
        ///<summary>Inserts one SubstitutionLink into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(SubstitutionLink substitutionLink, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                substitutionLink.SubstitutionLinkNum = ReplicationServers.GetKey("substitutionlink", "SubstitutionLinkNum");
            }
            string command = "INSERT INTO substitutionlink (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "SubstitutionLinkNum,";
            }
            command += "PlanNum,CodeNum) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(substitutionLink.SubstitutionLinkNum) + ",";
            }
            command +=
                POut.Long(substitutionLink.PlanNum) + ","
                + POut.Long(substitutionLink.CodeNum) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                substitutionLink.SubstitutionLinkNum = Db.NonQ(command, true, "SubstitutionLinkNum", "substitutionLink");
            }
            return(substitutionLink.SubstitutionLinkNum);
        }
Ejemplo n.º 2
0
        private void butOK_Click(object sender, EventArgs e)
        {
            if (!_insPlan.CodeSubstNone && gridInsPlanSubstInc.Rows.Count == 0 && gridInsPlanSubstExc.Rows.Count > 0)
            {
                if (MsgBox.Show(this, MsgBoxButtons.YesNo, "You have chosen to exclude all substituion codes.  "
                                + "The checkbox option named 'Don't Substitute Codes (e.g. posterior composites)' "
                                + "in the Other Ins Info tab of the Edit Insurance Plan window can be used to exclude all substitution codes.\r\n"
                                + "Would you like to enable this option instead of excluding specific codes?"))
                {
                    _insPlan.CodeSubstNone = true;
                    DialogResult           = DialogResult.OK;
                    return;
                }
            }
            List <SubstitutionLink> listSubstLinks = new List <SubstitutionLink>();

            foreach (UI.ODGridRow row in gridInsPlanSubstExc.Rows)
            {
                ProcedureCode    procCode = (ProcedureCode)row.Tag;
                SubstitutionLink subLink  = _listDbSubstLinks.FirstOrDefault(x => x.CodeNum == procCode.CodeNum);
                if (subLink == null)
                {
                    subLink         = new SubstitutionLink();
                    subLink.PlanNum = _insPlan.PlanNum;
                    subLink.CodeNum = procCode.CodeNum;
                }
                listSubstLinks.Add(subLink);
            }
            SubstitutionLinks.Sync(listSubstLinks, _listDbSubstLinks);
            DialogResult = DialogResult.OK;
        }
Ejemplo n.º 3
0
 ///<summary>Inserts one SubstitutionLink into the database.  Returns the new priKey.</summary>
 public static long Insert(SubstitutionLink substitutionLink)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         substitutionLink.SubstitutionLinkNum = DbHelper.GetNextOracleKey("substitutionlink", "SubstitutionLinkNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(substitutionLink, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     substitutionLink.SubstitutionLinkNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(substitutionLink, false));
     }
 }
Ejemplo n.º 4
0
        ///<summary>Updates one SubstitutionLink in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
        public static bool Update(SubstitutionLink substitutionLink, SubstitutionLink oldSubstitutionLink)
        {
            string command = "";

            if (substitutionLink.PlanNum != oldSubstitutionLink.PlanNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PlanNum = " + POut.Long(substitutionLink.PlanNum) + "";
            }
            if (substitutionLink.CodeNum != oldSubstitutionLink.CodeNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CodeNum = " + POut.Long(substitutionLink.CodeNum) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE substitutionlink SET " + command
                      + " WHERE SubstitutionLinkNum = " + POut.Long(substitutionLink.SubstitutionLinkNum);
            Db.NonQ(command);
            return(true);
        }
        private void butDelete_Click(object sender, EventArgs e)
        {
            if (gridMain.GetSelectedIndex() == -1)
            {
                MsgBox.Show(this, "Please select a substitution code first.");
                return;
            }
            ProcedureCode    procCode = gridMain.SelectedTag <ProcedureCode>();
            SubstitutionLink subLink  = _listSubstLinks.FirstOrDefault(x => x.CodeNum == procCode.CodeNum);

            if (subLink == null)           //User selected a procedure code level substitution code. Cannot delete
            {
                MsgBox.Show(this, "Cannot delete a global substitution code.");
                return;
            }
            string msgText = "Delete the selected insurance specific substitution code?\r\nDeleting the insurance specific substitution code will default to "
                             + "the global substitution code for procedure";

            if (!MsgBox.Show(this, MsgBoxButtons.YesNo, Lan.g(this, msgText) + " \"" + procCode.ProcCode + "\"."))
            {
                return;
            }
            _listSubstLinks.Remove(subLink);
            FillGridMain();
        }
        ///<summary>Opens FormProcCodes in SelectionMode. Creates a new SubstitutionLink for the selected Procedure.</summary>
        private void ButAdd_Click(object sender, EventArgs e)
        {
            FormProcCodes FormP = new FormProcCodes();

            FormP.IsSelectionMode = true;
            FormP.ShowDialog();
            if (FormP.DialogResult != DialogResult.OK)
            {
                return;
            }
            _listAllProcCodes = ProcedureCodes.GetAllCodes();          //in case they added a new proc code
            ProcedureCode procSelected = _listAllProcCodes.FirstOrDefault(x => x.CodeNum == FormP.SelectedCodeNum);

            if (procSelected == null)
            {
                return;                //should never happen, just in case
            }
            //Valid procedure selected. Create a new SubstitutionLink.  The user will be able to add the substition code on the cell grid.
            SubstitutionLink subLink = new SubstitutionLink();

            subLink.CodeNum          = procSelected.CodeNum;
            subLink.PlanNum          = _insPlan.PlanNum;
            subLink.SubstOnlyIf      = SubstitutionCondition.Always;
            subLink.SubstitutionCode = "";          //Set to blank. The user will be able to add in the cell grid
            //The substitution link will be synced on OK click.
            _listSubstLinks.Add(subLink);
            FillGridMain();
            //Set the substitution link we just added as selected. The X pos at 3 is the SubstCode column.
            gridMain.SetSelected(new Point(3, gridMain.ListGridRows.ToList().FindIndex(x => (x.Tag as ProcedureCode).CodeNum == subLink.CodeNum)));
        }
Ejemplo n.º 7
0
        ///<summary>Inserts one SubstitutionLink into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(SubstitutionLink substitutionLink, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO substitutionlink (";

            if (!useExistingPK && isRandomKeys)
            {
                substitutionLink.SubstitutionLinkNum = ReplicationServers.GetKeyNoCache("substitutionlink", "SubstitutionLinkNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "SubstitutionLinkNum,";
            }
            command += "PlanNum,CodeNum) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(substitutionLink.SubstitutionLinkNum) + ",";
            }
            command +=
                POut.Long(substitutionLink.PlanNum) + ","
                + POut.Long(substitutionLink.CodeNum) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                substitutionLink.SubstitutionLinkNum = Db.NonQ(command, true, "SubstitutionLinkNum", "substitutionLink");
            }
            return(substitutionLink.SubstitutionLinkNum);
        }
Ejemplo n.º 8
0
        ///<summary>Updates one SubstitutionLink in the database.</summary>
        public static void Update(SubstitutionLink substitutionLink)
        {
            string command = "UPDATE substitutionlink SET "
                             + "PlanNum            =  " + POut.Long(substitutionLink.PlanNum) + ", "
                             + "CodeNum            =  " + POut.Long(substitutionLink.CodeNum) + " "
                             + "WHERE SubstitutionLinkNum = " + POut.Long(substitutionLink.SubstitutionLinkNum);

            Db.NonQ(command);
        }
Ejemplo n.º 9
0
        public static SubstitutionLink CreateSubstitutionLink(long codeNum, string subCode, SubstitutionCondition substOnlyIf, long planNum)
        {
            SubstitutionLink subLink = new SubstitutionLink();

            subLink.CodeNum          = codeNum;
            subLink.SubstitutionCode = subCode;
            subLink.SubstOnlyIf      = substOnlyIf;
            subLink.PlanNum          = planNum;
            SubstitutionLinks.Insert(subLink);
            return(subLink);
        }
Ejemplo n.º 10
0
        ///<summary>Updates one SubstitutionLink in the database.</summary>
        public static void Update(SubstitutionLink substitutionLink)
        {
            string command = "UPDATE substitutionlink SET "
                             + "PlanNum            =  " + POut.Long(substitutionLink.PlanNum) + ", "
                             + "CodeNum            =  " + POut.Long(substitutionLink.CodeNum) + ", "
                             + "SubstitutionCode   = '" + POut.String(substitutionLink.SubstitutionCode) + "', "
                             + "SubstOnlyIf        =  " + POut.Int((int)substitutionLink.SubstOnlyIf) + " "
                             + "WHERE SubstitutionLinkNum = " + POut.Long(substitutionLink.SubstitutionLinkNum);

            Db.NonQ(command);
        }
Ejemplo n.º 11
0
        private void FillGridMain()
        {
            ProcedureCode selectedCode = gridMain.SelectedTag <ProcedureCode>();

            gridMain.BeginUpdate();
            gridMain.ListGridRows.Clear();
            if (gridMain.ListGridColumns.Count == 0)
            {
                gridMain.ListGridColumns.Add(new GridColumn(Lan.g(gridMain.TranslationName, "ProcCode"), 90));
                gridMain.ListGridColumns.Add(new GridColumn(Lan.g(gridMain.TranslationName, "AbbrDesc"), 100));
                gridMain.ListGridColumns.Add(new GridColumn(Lan.g(gridMain.TranslationName, "SubstOnlyIf"), 100)
                {
                    ListDisplayStrings = _listSubConditions
                });                                                                                                               //Dropdown combobox
                gridMain.ListGridColumns.Add(new GridColumn(Lan.g(gridMain.TranslationName, "SubstCode"), 90, true));             //Can edit cell
                gridMain.ListGridColumns.Add(new GridColumn(Lan.g(gridMain.TranslationName, "SubstDesc"), 90));
                gridMain.ListGridColumns.Add(new GridColumn(Lan.g(gridMain.TranslationName, "InsOnly"), 0));
            }
            //Add all substitution codes for procedure code level
            foreach (ProcedureCode procCode in _listSubstProcCodes)
            {
                SubstitutionLink subLink = _listSubstLinks.FirstOrDefault(x => x.CodeNum == procCode.CodeNum && x.PlanNum == _insPlan.PlanNum);
                if (subLink != null)
                {
                    //Procedure has a Substitution Link for this insplan(override). The procedure will be added in the next foreach loop.
                    continue;
                }
                //procedure code level substitution code
                AddRow(gridMain, procCode);
            }
            //Add all substitution codes for insurance level
            foreach (SubstitutionLink subLink in _listSubstLinks)
            {
                ProcedureCode procCode = _listAllProcCodes.FirstOrDefault(x => x.CodeNum == subLink.CodeNum);
                if (procCode == null)
                {
                    continue;                    //This shouldn't happen.
                }
                //Procedure has a Substitution Link for this insplan.
                AddRow(gridMain, procCode, subLink);
            }
            SortGridByProc(gridMain);
            gridMain.EndUpdate();
            //Try an reselect the procedure code that was already selected prior to refreshing the grid.
            if (selectedCode != null)
            {
                int index = gridMain.ListGridRows.ToList().FindIndex(x => (x.Tag as ProcedureCode).CodeNum == selectedCode.CodeNum);
                if (index > -1)
                {
                    gridMain.SetSelected(new Point(2, index));
                }
            }
        }
Ejemplo n.º 12
0
 ///<summary>Returns true if Update(SubstitutionLink,SubstitutionLink) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(SubstitutionLink substitutionLink, SubstitutionLink oldSubstitutionLink)
 {
     if (substitutionLink.PlanNum != oldSubstitutionLink.PlanNum)
     {
         return(true);
     }
     if (substitutionLink.CodeNum != oldSubstitutionLink.CodeNum)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 13
0
 ///<summary>Inserts one SubstitutionLink into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(SubstitutionLink substitutionLink)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(substitutionLink, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             substitutionLink.SubstitutionLinkNum = DbHelper.GetNextOracleKey("substitutionlink", "SubstitutionLinkNum");                  //Cacheless method
         }
         return(InsertNoCache(substitutionLink, true));
     }
 }
Ejemplo n.º 14
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <SubstitutionLink> TableToList(DataTable table)
        {
            List <SubstitutionLink> retVal = new List <SubstitutionLink>();
            SubstitutionLink        substitutionLink;

            foreach (DataRow row in table.Rows)
            {
                substitutionLink = new SubstitutionLink();
                substitutionLink.SubstitutionLinkNum = PIn.Long(row["SubstitutionLinkNum"].ToString());
                substitutionLink.PlanNum             = PIn.Long(row["PlanNum"].ToString());
                substitutionLink.CodeNum             = PIn.Long(row["CodeNum"].ToString());
                retVal.Add(substitutionLink);
            }
            return(retVal);
        }
Ejemplo n.º 15
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <SubstitutionLink> TableToList(DataTable table)
        {
            List <SubstitutionLink> retVal = new List <SubstitutionLink>();
            SubstitutionLink        substitutionLink;

            foreach (DataRow row in table.Rows)
            {
                substitutionLink = new SubstitutionLink();
                substitutionLink.SubstitutionLinkNum = PIn.Long(row["SubstitutionLinkNum"].ToString());
                substitutionLink.PlanNum             = PIn.Long(row["PlanNum"].ToString());
                substitutionLink.CodeNum             = PIn.Long(row["CodeNum"].ToString());
                substitutionLink.SubstitutionCode    = PIn.String(row["SubstitutionCode"].ToString());
                substitutionLink.SubstOnlyIf         = (OpenDentBusiness.SubstitutionCondition)PIn.Int(row["SubstOnlyIf"].ToString());
                retVal.Add(substitutionLink);
            }
            return(retVal);
        }
Ejemplo n.º 16
0
        private void AddRow(ODGrid grid, ProcedureCode procCode, SubstitutionLink subLink = null)
        {
            //Set all of the row values for the procedure code passed in.
            string        enumSubstCondition = procCode.SubstOnlyIf.ToString();
            string        subCode            = procCode.SubstitutionCode;
            ProcedureCode procCodeSubst      = _listAllProcCodes.FirstOrDefault(x => x.ProcCode == procCode.SubstitutionCode);
            string        subCodeDescript    = (procCodeSubst == null)?"":procCodeSubst.AbbrDesc;
            string        insOnly            = "";

            if (subLink != null)
            {
                //This procedure code has a SubstitutionLink for this insurance plan.
                //set the row values to the Insplan override.
                enumSubstCondition = subLink.SubstOnlyIf.ToString();
                subCode            = subLink.SubstitutionCode;
                subCodeDescript    = "";
                insOnly            = "X";
                //Validate the subLink.SubstitutionCode. subCodeDescript blank if the substitution code is not valid.
                //User can enter an invalid procedure code if they want.
                if (!string.IsNullOrEmpty(subLink.SubstitutionCode))
                {
                    ProcedureCode procCodeSub = _listAllProcCodes.FirstOrDefault(x => x.ProcCode == subLink.SubstitutionCode);
                    if (procCodeSub != null)
                    {
                        subCodeDescript = procCodeSub.AbbrDesc;
                    }
                }
            }
            GridRow row = new GridRow();

            row.Cells.Add(procCode.ProcCode);
            row.Cells.Add(procCode.AbbrDesc);
            GridCell cell = new GridCell(Lan.g("enumSubstitutionCondition", enumSubstCondition));

            cell.ComboSelectedIndex = _listSubConditions.FindIndex(x => x == enumSubstCondition);
            row.Cells.Add(cell);
            row.Cells.Add(subCode);
            row.Cells.Add(subCodeDescript);
            row.Cells.Add(insOnly);
            row.Tag = procCode;
            grid.ListGridRows.Add(row);
        }
Ejemplo n.º 17
0
        ///<summary>Changes the SubstitutionCode to what is entered in the cell.
        ///If the user modifies a procedure level substitution code, a new SubstitutionLink will be added for the inplan(override).
        ///The new SubstitutionLink will be added to _listDbSubstLinks</summary>
        private void gridMain_CellLeave(object sender, ODGridClickEventArgs e)
        {
            if (e.Col != 3 || e.Row < 0)         //Return if not substitution code column or invalid row
            {
                return;
            }
            ProcedureCode procCode = gridMain.ListGridRows[e.Row].Tag as ProcedureCode;

            if (procCode == null)
            {
                return;
            }
            string newText = gridMain.ListGridRows[e.Row].Cells[e.Col].Text;

            if (_oldText == newText)
            {
                return;
            }
            //Substitution code changed.
            //We will not validate the new substitution code.
            //Get SubstitutionLink for ins level substitution code if one exist.
            SubstitutionLink subLink = _listSubstLinks.FirstOrDefault(x => x.CodeNum == procCode.CodeNum);

            if (subLink != null)           //Ins level sub code
            {
                subLink.SubstitutionCode = newText;
            }
            else              //procedure code level substitution code
                              //We will not update the procedure code level substitution code. We will create an insplan override.
                              //Create a new SubstitutionLink for ins plan override for this proccode.
            {
                subLink                  = new SubstitutionLink();
                subLink.CodeNum          = procCode.CodeNum;
                subLink.SubstitutionCode = newText;
                subLink.PlanNum          = _insPlan.PlanNum;
                subLink.SubstOnlyIf      = procCode.SubstOnlyIf;
                _listSubstLinks.Add(subLink);
            }
            FillGridMain();
        }
Ejemplo n.º 18
0
        ///<summary>Changes the SubstOnlyIf after the user selects a new SubstitutionCondition.
        ///If the user modifies a procedure level substitution code, a new SubstitutionLink will be added for the inplan(override).
        ///The new SubstitutionLink will be added to _listDbSubstLinks</summary>
        private void gridMain_CellSelectionCommitted(object sender, ODGridClickEventArgs e)
        {
            if (e.Col != 2 || e.Row < 0 || e.Row >= gridMain.ListGridRows.Count)       //Return if not SubstOnlyIf column or invalid row
            {
                return;
            }
            //Get the grid tag
            ProcedureCode procCode = gridMain.ListGridRows[e.Row].Tag as ProcedureCode;

            if (procCode == null)
            {
                return;
            }
            //Get the selected substitution condition.
            SubstitutionCondition selectedCondition = (SubstitutionCondition)_listSubConditions.IndexOf(gridMain.ListGridRows[e.Row].Cells[e.Col].Text);
            //Get the SubstitutionLink if one exist
            SubstitutionLink subLink = _listSubstLinks.FirstOrDefault(x => x.CodeNum == procCode.CodeNum);

            if (subLink != null)           //Ins level sub code
            {
                subLink.SubstOnlyIf = selectedCondition;
            }
            else              //procedure code level substitution code
                              //Changing the SubstitutionCondition will not update the procedure code level SubstitutionCondition. We will create an insplan override.
                              //Create a new SubstitutionLink for ins plan override for this proccode.
            {
                subLink         = new SubstitutionLink();
                subLink.CodeNum = procCode.CodeNum;
                //SubstitutionCode will be the same as the procedure codes SubstitutionCode since all the user changed was the SubstitutionCondition
                subLink.SubstitutionCode = procCode.SubstitutionCode;
                subLink.PlanNum          = _insPlan.PlanNum;
                subLink.SubstOnlyIf      = selectedCondition;
                _listSubstLinks.Add(subLink);
            }
            FillGridMain();
        }
Ejemplo n.º 19
0
 ///<summary>Inserts many SubstitutionLinks into the database.  Provides option to use the existing priKey.</summary>
 public static void InsertMany(List <SubstitutionLink> listSubstitutionLinks, bool useExistingPK)
 {
     if (!useExistingPK && PrefC.RandomKeys)
     {
         foreach (SubstitutionLink substitutionLink in listSubstitutionLinks)
         {
             Insert(substitutionLink);
         }
     }
     else
     {
         StringBuilder sbCommands = null;
         int           index      = 0;
         int           countRows  = 0;
         while (index < listSubstitutionLinks.Count)
         {
             SubstitutionLink substitutionLink = listSubstitutionLinks[index];
             StringBuilder    sbRow            = new StringBuilder("(");
             bool             hasComma         = false;
             if (sbCommands == null)
             {
                 sbCommands = new StringBuilder();
                 sbCommands.Append("INSERT INTO substitutionlink (");
                 if (useExistingPK)
                 {
                     sbCommands.Append("SubstitutionLinkNum,");
                 }
                 sbCommands.Append("PlanNum,CodeNum,SubstitutionCode,SubstOnlyIf) VALUES ");
                 countRows = 0;
             }
             else
             {
                 hasComma = true;
             }
             if (useExistingPK)
             {
                 sbRow.Append(POut.Long(substitutionLink.SubstitutionLinkNum)); sbRow.Append(",");
             }
             sbRow.Append(POut.Long(substitutionLink.PlanNum)); sbRow.Append(",");
             sbRow.Append(POut.Long(substitutionLink.CodeNum)); sbRow.Append(",");
             sbRow.Append("'" + POut.String(substitutionLink.SubstitutionCode) + "'"); sbRow.Append(",");
             sbRow.Append(POut.Int((int)substitutionLink.SubstOnlyIf)); sbRow.Append(")");
             if (sbCommands.Length + sbRow.Length + 1 > TableBase.MaxAllowedPacketCount && countRows > 0)
             {
                 Db.NonQ(sbCommands.ToString());
                 sbCommands = null;
             }
             else
             {
                 if (hasComma)
                 {
                     sbCommands.Append(",");
                 }
                 sbCommands.Append(sbRow.ToString());
                 countRows++;
                 if (index == listSubstitutionLinks.Count - 1)
                 {
                     Db.NonQ(sbCommands.ToString());
                 }
                 index++;
             }
         }
     }
 }
Ejemplo n.º 20
0
 ///<summary>Inserts one SubstitutionLink into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(SubstitutionLink substitutionLink)
 {
     return(InsertNoCache(substitutionLink, false));
 }