Esempio n. 1
0
        private void butNew_Click(object sender, System.EventArgs e)
        {
            //won't be visible if no permission
            FormProcCodeNew FormPCN = new FormProcCodeNew();

            FormPCN.ShowDialog();
            if (FormPCN.DialogResult != DialogResult.OK)
            {
                return;
            }
            if (FormPCN.textNewCode.Text == "")
            {
                return;
            }
            ProcedureCode procCode;

            if (ProcedureCodes.HList.ContainsKey(FormPCN.textNewCode.Text))
            {
                procCode = (ProcedureCode)ProcedureCodes.HList[FormPCN.textNewCode.Text];
                textAbbreviation.Text = "";
                textDescription.Text  = "";
                textCode.Text         = FormPCN.textNewCode.Text;
                if (DefB.GetHidden(DefCat.ProcCodeCats, procCode.ProcCat))
                {
                    checkShowHidden.Checked = true;
                    FillCats();
                }
                for (int i = 0; i < CatList.Length; i++)
                {
                    if (CatList[i].DefNum == procCode.ProcCat)
                    {
                        listCategories.SetSelected(i, true);
                    }
                    else
                    {
                        listCategories.SetSelected(i, false);
                    }
                }
                FillGrid();
                MessageBox.Show(Lan.g(this, "That code already exists."));
                return;
            }
            procCode         = new ProcedureCode();
            procCode.ADACode = FormPCN.textNewCode.Text;
            //procCode.ProcTime="/X/";//moved to contructor.
            procCode.ProcCat = DefB.Short[(int)DefCat.ProcCodeCats][0].DefNum;
            //procCode.GraphicColor=Color.FromArgb(0);//moved to contructor.
            ProcedureCodes.Insert(procCode);
            FormProcCodeEdit FormP = new FormProcCodeEdit(procCode);

            FormP.IsNew = true;
            FormP.ShowDialog();
            if (FormP.DialogResult == DialogResult.OK)
            {
                changed = true;
                FillGrid();
            }
            SecurityLogs.MakeLogEntry(Permissions.Setup, 0, "Added Procedure Code: " + procCode.ADACode);
        }
Esempio n. 2
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
        }
Esempio n. 3
0
        ///<summary>Returns a code in format Z###, depending on which codes are already in use for the current patnum.
        ///The returned code is guaranteed to exist in the database, because codes are created if they do not exist.</summary>
        private string GetProcCodeForNewCharge(long patNumForRegKey)
        {
            //Locate a proc code for eRx which is not already in use.
            string procCode = "Z000";
            int    attempts = 0;
            bool   procCodeInUse;

            do
            {
                procCodeInUse = false;
                foreach (RepeatCharge repeatCharge in _listErxRepeatCharges)
                {
                    if (repeatCharge.PatNum != patNumForRegKey)
                    {
                        continue;
                    }
                    if (repeatCharge.ProcCode != procCode)
                    {
                        continue;
                    }
                    procCodeInUse = true;
                    break;
                }
                if (procCodeInUse)
                {
                    attempts++;                    //Should start at 2. The Codes will be "Z001", "Z002", "Z003", etc...
                    if (attempts > 999)
                    {
                        throw new Exception("Cannot add more than 999 Z-codes yet.  Ask programmer to increase.");
                    }
                    procCode = "Z" + (attempts.ToString().PadLeft(3, '0'));
                }
            } while(procCodeInUse);
            //If the selected code is not in the database already, then add it automatically.
            long codeNum = ProcedureCodes.GetCodeNum(procCode);

            if (codeNum == 0)           //The selected code does not exist, so we must add it.
            {
                ProcedureCode code = new ProcedureCode();
                code.ProcCode  = procCode;
                code.Descript  = "Electronic Rx";
                code.AbbrDesc  = "eRx";
                code.ProcTime  = "/X/";
                code.ProcCat   = 162;            //Software
                code.TreatArea = TreatmentArea.Mouth;
                ProcedureCodes.Insert(code);
                ProcedureCodes.RefreshCache();
            }
            return(procCode);
        }
Esempio n. 4
0
        ///<summary>Returns the code NewCrop or a code like NewCrop##, depending on which codes are already in use for the current patnum.
        ///The returned code is guaranteed to exist in the database, because codes are created if they do not exist.</summary>
        private string GetProcCodeForNewCharge(List <RepeatCharge> repeatChargesCur)
        {
            //Locate a proc code for NewCrop which is not already in use.
            string procCode = "NewCrop";
            int    attempts = 1;
            bool   procCodeInUse;

            do
            {
                procCodeInUse = false;
                for (int i = 0; i < repeatChargesCur.Count; i++)
                {
                    if (repeatChargesCur[i].ProcCode == procCode)
                    {
                        procCodeInUse = true;
                        break;
                    }
                }
                if (procCodeInUse)
                {
                    attempts++;                    //Should start at 2. The Codes will be "NewCrop", "NewCrop02", "NewCrop03", etc...
                    if (attempts > 99)
                    {
                        throw new Exception("Cannot add more than 99 NewCrop repeating charges yet. Ask programmer to increase.");
                    }
                    procCode = "NewCrop" + (attempts.ToString().PadLeft(2, '0'));
                }
            } while(procCodeInUse);
            //If the selected code is not in the database already, then add it automatically.
            long codeNum = ProcedureCodes.GetCodeNum(procCode);

            if (codeNum == 0)           //The selected code does not exist, so we must add it.
            {
                ProcedureCode code = new ProcedureCode();
                code.ProcCode  = procCode;
                code.Descript  = "NewCrop Rx";
                code.AbbrDesc  = "NewCrop";
                code.ProcTime  = "/X/";
                code.ProcCat   = 162;            //Software
                code.TreatArea = TreatmentArea.Mouth;
                ProcedureCodes.Insert(code);
                ProcedureCodes.RefreshCache();
            }
            return(procCode);
        }
Esempio n. 5
0
        private bool AddProc()
        {
            if (textNewCode.Text == "")
            {
                MsgBox.Show(this, "Code not allowed to be blank.");
                return(false);
            }
            if (ProcedureCodes.IsValidCode(textNewCode.Text))
            {
                MsgBox.Show(this, "That code already exists.");
                return(false);
            }
            if (textDescription.Text == "")
            {
                MsgBox.Show(this, "Description not allowed to be blank.");
                return(false);
            }
            if (textAbbreviation.Text == "")
            {
                MsgBox.Show(this, "Abbreviation not allowed to be blank.");
                return(false);
            }
            //ok to add code-----------------------------------------------------------------------------------
            ProcedureCode code = new ProcedureCode();

            code.ProcCode = textNewCode.Text;
            //code.ProcTime="/X/";//moved to contructor.
            //code.GraphicColor=Color.FromArgb(0);//moved to contructor.
            code.Descript  = textDescription.Text;
            code.AbbrDesc  = textAbbreviation.Text;
            code.SetRecall = checkSetRecall.Checked;
            code.NoBillIns = checkNoBillIns.Checked;
            code.IsHygiene = checkIsHygiene.Checked;
            code.IsProsth  = checkIsProsth.Checked;
            code.PaintType = (ToothPaintingType)comboPaintType.SelectedIndex;
            code.TreatArea = (TreatmentArea)comboTreatArea.SelectedIndex + 1;
            //if(comboCategory.SelectedIndex!=-1)
            code.ProcCat = DefB.Short[(int)DefCat.ProcCodeCats][comboCategory.SelectedIndex].DefNum;
            ProcedureCodes.Insert(code);
            Changed = true;
            SecurityLogs.MakeLogEntry(Permissions.Setup, 0, "Added Procedure Code: " + code.ProcCode);
            return(true);
        }
Esempio n. 6
0
        ///<Summary>Can be called externally as part of the update sequence.  Surround with try catch.  Returns number of codes inserted.</Summary>
        public static int ImportProcCodes(string path, bool askBeforeReplace)
        {
            if (!File.Exists(path))
            {
                throw new ApplicationException(Lan.g("FormProcCodes", "File does not exist."));
            }
            XmlSerializer        serializer = new XmlSerializer(typeof(List <ProcedureCode>));
            List <ProcedureCode> listCodes  = new List <ProcedureCode>();

            //ClaimForm tempClaimForm=new ClaimForm();
            try {
                using (TextReader reader = new StreamReader(path)){
                    listCodes = (List <ProcedureCode>)serializer.Deserialize(reader);
                }
            }
            catch {
                throw new ApplicationException(Lan.g("FormProcCodes", "Invalid file format"));
            }
            int retVal = 0;

            for (int i = 0; i < listCodes.Count; i++)
            {
                if (ProcedureCodes.HList.ContainsKey(listCodes[i].ADACode))
                {
                    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);
                    listCodes[i].ProcCat = def.DefNum;
                }
                ProcedureCodes.Insert(listCodes[i]);
                retVal++;
            }
            return(retVal);
        }