Exemple #1
0
        ///<summary>If the named fee schedule does not exist, then it will be created.  It always returns the defnum for the feesched used, regardless of whether it already existed.  procCode must have already been tested for valid code, and feeSchedName must not be blank.</summary>
        public static int ImportTrojan(string procCode, double amt, string feeSchedName)
        {
            Def def;
            int feeSched = DefB.GetByExactName(DefCat.FeeSchedNames, feeSchedName);

            //if isManaged, then this should be done differently from here on out.
            if (feeSched == 0)
            {
                //add the new fee schedule
                def           = new Def();
                def.Category  = DefCat.FeeSchedNames;
                def.ItemName  = feeSchedName;
                def.ItemOrder = DefB.Long[(int)DefCat.FeeSchedNames].Length;
                Defs.Insert(def);
                feeSched = def.DefNum;
                Defs.Refresh();
                Fees.Refresh();
                DataValid.SetInvalid(InvalidTypes.Defs | InvalidTypes.Fees);
            }
            else
            {
                def = DefB.GetDef(DefCat.FeeSchedNames, feeSched);
            }
            if (def.IsHidden)            //if the fee schedule is hidden
            {
                def.IsHidden = false;    //unhide it
                Defs.Update(def);
                Defs.Refresh();
                DataValid.SetInvalid(InvalidTypes.Defs);
            }
            Fee fee = GetFeeByOrder(ProcedureCodes.GetCodeNum(procCode), DefB.GetOrder(DefCat.FeeSchedNames, def.DefNum));

            if (fee == null)
            {
                fee          = new Fee();
                fee.Amount   = amt;
                fee.FeeSched = def.DefNum;
                fee.CodeNum  = ProcedureCodes.GetCodeNum(procCode);
                Insert(fee);
            }
            else
            {
                fee.Amount = amt;
                Update(fee);
            }
            return(def.DefNum);
        }
Exemple #2
0
        ///<summary>Used to check whether codes starting with T exist and are in a visible category.  If so, it moves them to the Obsolete category.  If the T code has never been used, then it deletes it.</summary>
        public static void TcodesClear()
        {
            //first delete any unused T codes
            string    command = @"SELECT CodeNum,ProcCode FROM procedurecode
				WHERE NOT EXISTS(SELECT * FROM procedurelog WHERE procedurelog.CodeNum=procedurecode.CodeNum)
				AND ProcCode LIKE 'T%'"                ;
            DataTable table   = General.GetTable(command);
            int       codenum;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                codenum = PIn.PInt(table.Rows[i]["CodeNum"].ToString());
                command = "DELETE FROM fee WHERE CodeNum=" + POut.PInt(codenum);
                General.NonQ(command);
                command = "DELETE FROM procedurecode WHERE CodeNum=" + POut.PInt(codenum);
                General.NonQ(command);
            }
            //then, move any other T codes to obsolete category
            command = @"SELECT DISTINCT ProcCat FROM procedurecode,definition 
				WHERE procedurecode.ProcCode LIKE 'T%'
				AND definition.IsHidden=0
				AND procedurecode.ProcCat=definition.DefNum"                ;
            table   = General.GetTable(command);
            int catNum = DefB.GetByExactName(DefCat.ProcCodeCats, "Obsolete");         //check to make sure an Obsolete category exists.
            Def def;

            if (catNum != 0)           //if a category exists with that name
            {
                def = DefB.GetDef(DefCat.ProcCodeCats, catNum);
                if (!def.IsHidden)
                {
                    def.IsHidden = true;
                    Defs.Update(def);
                    Defs.Refresh();
                }
            }
            if (catNum == 0)
            {
                def           = new Def();
                def.Category  = DefCat.ProcCodeCats;
                def.ItemName  = "Obsolete";
                def.ItemOrder = DefB.Long[(int)DefCat.ProcCodeCats].Length;
                def.IsHidden  = true;
                Defs.Insert(def);
                Defs.Refresh();
                catNum = def.DefNum;
            }
            for (int i = 0; i < table.Rows.Count; i++)
            {
                command = "UPDATE procedurecode SET ProcCat=" + POut.PInt(catNum)
                          + " WHERE ProcCat=" + table.Rows[i][0].ToString();
                General.NonQ(command);
            }
            //finally, set Never Used category to be hidden.  This isn't really part of clearing Tcodes, but is required
            //because many customers won't have that category hidden
            catNum = DefB.GetByExactName(DefCat.ProcCodeCats, "Never Used");
            if (catNum != 0)           //if a category exists with that name
            {
                def = DefB.GetDef(DefCat.ProcCodeCats, catNum);
                if (!def.IsHidden)
                {
                    def.IsHidden = true;
                    Defs.Update(def);
                    Defs.Refresh();
                }
            }
        }