Пример #1
0
        ///<summary>Can be called externally as part of the update sequence.  Surround with try catch.  Returns number of codes inserted.  Supply path to file to import or a list of procedure codes, or an xml string.  Make sure to set the other two values blank or empty(not null).</summary>
        public static int ImportProcCodes(string path, List <ProcedureCode> listCodes, string xmlData)
        {
            //xmlData should already be tested ahead of time to make sure it's not blank.
            XmlSerializer serializer = new XmlSerializer(typeof(List <ProcedureCode>));

            if (path != "")
            {
                if (!File.Exists(path))
                {
                    throw new ApplicationException(Lan.g("FormProcCodes", "File does not exist."));
                }
                try {
                    using (TextReader reader = new StreamReader(path)) {
                        listCodes = (List <ProcedureCode>)serializer.Deserialize(reader);
                    }
                }
                catch {
                    throw new ApplicationException(Lan.g("FormProcCodes", "Invalid file format"));
                }
            }
            else if (xmlData != "")
            {
                try {
                    using (TextReader reader = new StringReader(xmlData)) {
                        listCodes = (List <ProcedureCode>)serializer.Deserialize(reader);
                    }
                }
                catch {
                    throw new ApplicationException(Lan.g("FormProcCodes", "xml format"));
                }
            }
            int retVal = 0;

            for (int i = 0; i < listCodes.Count; i++)
            {
                if (ProcedureCodes.HList.ContainsKey(listCodes[i].ProcCode))
                {
                    continue;                    //don't import duplicates.
                }
                listCodes[i].ProcCat = DefB.GetByExactName(DefCat.ProcCodeCats, listCodes[i].ProcCatDescript);
                if (listCodes[i].ProcCat == 0)               //no category exists with that name
                {
                    Def def = new Def();
                    def.Category  = DefCat.ProcCodeCats;
                    def.ItemName  = listCodes[i].ProcCatDescript;
                    def.ItemOrder = DefB.Long[(int)DefCat.ProcCodeCats].Length;
                    Defs.Insert(def);
                    Defs.Refresh();
                    listCodes[i].ProcCat = def.DefNum;
                }
                ProcedureCodes.Insert(listCodes[i]);
                retVal++;
            }
            return(retVal);
            //don't forget to refresh procedurecodes
        }
Пример #2
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);
        }
Пример #3
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();
                }
            }
        }