예제 #1
0
        ///<summary>Used by FormUpdate to check whether codes starting with T exist and are in a visible category.  If so, it moves them to the Obsolete category.</summary>
        public static void TcodesMove()
        {
            string    command = @"SELECT DISTINCT ProcCat FROM procedurecode,definition 
				WHERE procedurecode.ADACode LIKE 'T%'
				AND definition.IsHidden=0
				AND procedurecode.ProcCat=definition.DefNum"                ;
            DataTable table   = General.GetTable(command);

            if (table.Rows.Count == 0)
            {
                return;
            }
            int catNum = DefB.GetByExactName(DefCat.ProcCodeCats, "Obsolete");         //check to make sure an Obsolete category exists.

            if (catNum == 0)
            {
                Def def = new Def();
                def.Category  = DefCat.ProcCodeCats;
                def.ItemName  = "Obsolete";
                def.ItemOrder = DefB.Long[(int)DefCat.ProcCodeCats].Length;
                Defs.Insert(def);
                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);
            }
        }
예제 #2
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textName.Text == "")
            {
                MsgBox.Show(this, "Name required.");
                return;
            }
            DefCur.ItemName = textName.Text;
            List <string> itemVal = new List <string>();

            if (checkCutCopyPaste.Checked)
            {
                itemVal.Add(BlockoutType.DontCopy.GetDescription());
            }
            if (checkOverlap.Checked)
            {
                itemVal.Add(BlockoutType.NoSchedule.GetDescription());
            }
            DefCur.ItemValue = string.Join(",", itemVal);
            DefCur.IsHidden  = checkHidden.Checked;
            DefCur.ItemColor = butColor.BackColor;
            if (IsNew)
            {
                Defs.Insert(DefCur);
            }
            else
            {
                Defs.Update(DefCur);
            }
            DialogResult = DialogResult.OK;
        }
예제 #3
0
        public static void ResetApptProcsQuickAdd()
        {
            string command = "DELETE FROM definition WHERE Category=3";

            General.NonQ(command);
            string[] array = new string[] {
                "CompEx-4BW-Pano-Pro-Flo", "D0150,D0274,D0330,D1110,D1204",
                "CompEx-2BW-Pano-ChPro-Flo", "D0150,D0272,D0330,D1120,D1203",
                "PerEx-4BW-Pro-Flo", "D0120,D0274,D1110,D1204",
                "LimEx-PA", "D0140,D0220",
                "PerEx-4BW-Pro-Flo", "D0120,D0274,D1110,D1204",
                "PerEx-2BW-ChildPro-Flo", "D0120,D0272,D1120,D1203",
                "Comp Exam", "D0150",
                "Per Exam", "D0120",
                "Lim Exam", "D0140",
                "1 PA", "D0220",
                "2BW", "D0272",
                "4BW", "D0274",
                "Pano", "D0330",
                "Pro Adult", "D1110",
                "Fluor Adult", "D1204",
                "Pro Child", "D1120",
                "Fuor Child", "D1203",
                "PostOp", "N4101",
                "DentAdj", "N4102",
                "Consult", "D9310"
            };
            Def def;

            string[] codelist;
            bool     allvalid;
            int      itemorder = 0;

            for (int i = 0; i < array.Length; i += 2)
            {
                //first, test all procedures for valid
                codelist = array[i + 1].Split(',');
                allvalid = true;
                for (int c = 0; c < codelist.Length; c++)
                {
                    if (!ProcedureCodes.IsValidCode(codelist[c]))
                    {
                        allvalid = false;
                    }
                }
                if (!allvalid)
                {
                    continue;
                }
                def           = new Def();
                def.Category  = DefCat.ApptProcsQuickAdd;
                def.ItemOrder = itemorder;
                def.ItemName  = array[i];
                def.ItemValue = array[i + 1];
                Defs.Insert(def);
                itemorder++;
            }
        }
예제 #4
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
        }
예제 #5
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);
        }
예제 #6
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textName.Text == "")
            {
                MsgBox.Show(this, "Name required.");
                return;
            }
            DefCur.ItemName = textName.Text;
            string itemVal = "";

            if (checkX.Checked)
            {
                itemVal += "X";
            }
            if (checkF.Checked)
            {
                itemVal += "F";
            }
            if (checkP.Checked)
            {
                itemVal += "P";
            }
            if (checkS.Checked)
            {
                itemVal += "S";
            }
            if (checkT.Checked)
            {
                itemVal += "T";
            }
            DefCur.ItemValue = itemVal;
            DefCur.IsHidden  = checkHidden.Checked;
            if (IsNew)
            {
                Defs.Insert(DefCur);
            }
            else
            {
                Defs.Update(DefCur);
            }
            DialogResult = DialogResult.OK;
        }
예제 #7
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);
        }
 private void butOK_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(textName.Text.Trim()))
     {
         MsgBox.Show(this, "Reason required.");
         return;
     }
     if (_apptTypeCur == null)
     {
         MsgBox.Show(this, "Appointment Type required.");
         return;
     }
     _defCur.ItemName = PIn.String(textName.Text);
     if (_defCur.IsNew)
     {
         Defs.Insert(_defCur);
     }
     else
     {
         Defs.Update(_defCur);
     }
     DefLinks.SetFKeyForDef(_defCur.DefNum, _apptTypeCur.AppointmentTypeNum, DefLinkType.AppointmentType);
     DialogResult = DialogResult.OK;
 }
예제 #9
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textName.Text == "")
            {
                MsgBox.Show(this, "Name required.");
                return;
            }
            switch ((DefCat)DefCur.Category)
            {
            case DefCat.AdjTypes:
                if (textValue.Text != "+" && textValue.Text != "-")
                {
                    MessageBox.Show(Lan.g(this, "Valid values are + or -."));
                    return;
                }
                break;

            case DefCat.ApptProcsQuickAdd:
                string[] procs = textValue.Text.Split(',');
                for (int i = 0; i < procs.Length; i++)
                {
                    if (ProcedureCodes.GetProcCode(procs[i]).ProcCode == null)
                    {
                        MessageBox.Show(Lan.g(this, "Invalid procedure code or formatting. Valid format example: D1234,D2345,D3456"));
                        return;
                    }
                }
                //test for not require tooth number if time
                break;

            case DefCat.BillingTypes:
                if (textValue.Text != "" && textValue.Text != "E")
                {
                    MsgBox.Show(this, "Valid values are blank or E.");
                    return;
                }
                if (checkHidden.Checked && Patients.IsBillingTypeInUse(DefCur.DefNum))
                {
                    if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Warning: Billing type is currently in use by patients."))
                    {
                        return;
                    }
                }
                break;

            case DefCat.CommLogTypes:
                if (textValue.Text != "" && textValue.Text != "MISC" && textValue.Text != "APPT" &&
                    textValue.Text != "FIN" && textValue.Text != "RECALL")
                {
                    MessageBox.Show(Lan.g(this, "Valid values are blank,APPT,FIN,RECALL,or MISC."));
                    return;
                }
                break;

            case DefCat.RecallUnschedStatus:
                if (textValue.Text.Length > 7)
                {
                    MessageBox.Show(Lan.g(this, "Maximum length is 7."));
                    return;
                }
                break;

            case DefCat.DiscountTypes:
                int discVal;
                if (textValue.Text == "")
                {
                    break;
                }
                try{
                    discVal = System.Convert.ToInt32(textValue.Text);
                }
                catch {
                    MessageBox.Show(Lan.g(this, "Not a valid number"));
                    return;
                }
                if (discVal < 0 || discVal > 100)
                {
                    MessageBox.Show(Lan.g(this, "Valid values are between 0 and 100"));
                    return;
                }
                textValue.Text = discVal.ToString();
                break;

            case DefCat.OperatoriesOld:
                if (textValue.Text.Length > 5)
                {
                    MessageBox.Show(Lan.g(this, "Maximum length of abbreviation is 5."));
                    return;
                }
                break;

            case DefCat.TxPriorities:
                if (textValue.Text.Length > 7)
                {
                    MessageBox.Show(Lan.g(this, "Maximum length of abbreviation is 7."));
                    return;
                }
                break;

            case DefCat.ImageCats:
                textValue.Text = textValue.Text.ToUpper().Replace(",", "");
                if (!Regex.IsMatch(textValue.Text, @"^[XPS]*$"))
                {
                    textValue.Text = "";
                }
                break;

            case DefCat.ProcCodeCats:
                if (checkHidden.Checked)
                {
                    Defs.RefreshCache();
                    Def[] enabledDefs = DefC.Short[(int)DefCat.ProcCodeCats];
                    //if no enabled defs or this is the only enabled def, don't allow disabling
                    if (enabledDefs.Length == 0 || (enabledDefs.Length == 1 && enabledDefs[0].DefNum == DefCur.DefNum))
                    {
                        MsgBox.Show(this, "At least one procedure code category must be enabled.");
                        return;
                    }
                }
                break;

                /*case DefCat.FeeSchedNames:
                 *      if(textValue.Text=="C" || textValue.Text=="c") {
                 *              textValue.Text="C";
                 *      }
                 *      else if(textValue.Text=="A" || textValue.Text=="a") {
                 *              textValue.Text="A";
                 *      }
                 *      else textValue.Text="";
                 *      break;*/
            }            //end switch
            DefCur.ItemName = textName.Text;
            if (EnableValue)
            {
                DefCur.ItemValue = textValue.Text;
            }
            if (EnableColor)
            {
                DefCur.ItemColor = butColor.BackColor;
            }
            DefCur.IsHidden = checkHidden.Checked;
            if (IsNew)
            {
                Defs.Insert(DefCur);
            }
            else
            {
                Defs.Update(DefCur);
            }
            DialogResult = DialogResult.OK;
        }
예제 #10
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textName.Text == "")
            {
                MsgBox.Show(this, "Name required.");
                return;
            }
            switch ((DefCat)DefCur.Category)
            {
            case DefCat.AdjTypes:
                if (textValue.Text != "+" && textValue.Text != "-")
                {
                    MessageBox.Show(Lan.g(this, "Valid values are + or -."));
                    return;
                }
                break;

            case DefCat.ApptProcsQuickAdd:
                string[] procs = textValue.Text.Split(',');
                for (int i = 0; i < procs.Length; i++)
                {
                    if (ProcedureCodes.GetProcCode(procs[i]).ADACode == null)
                    {
                        MessageBox.Show(Lan.g(this, "Invalid procedure code or formatting. Valid format example: D1234,D2345,D3456"));
                        return;
                    }
                }
                //test for not require tooth number if time
                break;

            //case DefCat.ClaimFormats:
            //	if(textValue.Text!="ADA2002" && textValue.Text!="eclaim"){
            //		MessageBox.Show(Lan.g(this,"Value must equal ADA2002 or eclaim"));
            //		return;
            //	}
            //	break;
            case DefCat.RecallUnschedStatus:
                if (textValue.Text.Length > 7)
                {
                    MessageBox.Show(Lan.g(this, "Maximum length is 7."));
                    return;
                }
                break;

            case DefCat.DiscountTypes:
                int discVal;
                if (textValue.Text == "")
                {
                    break;
                }
                try{
                    discVal = System.Convert.ToInt32(textValue.Text);
                }
                catch {
                    MessageBox.Show(Lan.g(this, "Not a valid number"));
                    return;
                }
                if (discVal < 0 || discVal > 100)
                {
                    MessageBox.Show(Lan.g(this, "Valid values are between 0 and 100"));
                    return;
                }
                textValue.Text = discVal.ToString();
                break;

            case DefCat.OperatoriesOld:
                if (textValue.Text.Length > 5)
                {
                    MessageBox.Show(Lan.g(this, "Maximum length of abbreviation is 5."));
                    return;
                }
                break;

            case DefCat.TxPriorities:
                if (textValue.Text.Length > 7)
                {
                    MessageBox.Show(Lan.g(this, "Maximum length of abbreviation is 7."));
                    return;
                }
                break;

            case DefCat.ImageCats:
                if (textValue.Text == "P" || textValue.Text == "p")
                {
                    textValue.Text = "P";
                }
                else if (textValue.Text == "X" || textValue.Text == "x")
                {
                    textValue.Text = "X";
                }
                else if (textValue.Text.ToUpper() == "XP")
                {
                    textValue.Text = "XP";
                }
                else
                {
                    textValue.Text = "";
                }
                break;

            case DefCat.FeeSchedNames:
                if (textValue.Text == "C" || textValue.Text == "c")
                {
                    textValue.Text = "C";
                }
                else if (textValue.Text == "A" || textValue.Text == "a")
                {
                    textValue.Text = "A";
                }
                else
                {
                    textValue.Text = "";
                }
                break;
            }            //end switch
            DefCur.ItemName = textName.Text;
            if (EnableValue)
            {
                DefCur.ItemValue = textValue.Text;
            }
            if (EnableColor)
            {
                DefCur.ItemColor = butColor.BackColor;
            }
            DefCur.IsHidden = checkHidden.Checked;
            if (IsNew)
            {
                Defs.Insert(DefCur);
            }
            else
            {
                Defs.Update(DefCur);
            }
            DialogResult = DialogResult.OK;
            Close();
        }
예제 #11
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();
                }
            }
        }
예제 #12
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (checkHidden.Checked)
            {
                if (Defs.IsDefinitionInUse(DefCur))
                {
                    if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Warning: This definition is currently in use within the program."))
                    {
                        return;
                    }
                }
            }
            if (textName.Text == "")
            {
                MsgBox.Show(this, "Name required.");
                return;
            }
            DefCur.ItemName = textName.Text;
            string itemVal = "";

            if (checkChartModule.Checked)
            {
                itemVal += "X";
            }
            if (checkPatientForms.Checked)
            {
                itemVal += "F";
            }
            if (checkPatientPortal.Checked)
            {
                itemVal += "L";
            }
            if (checkPatientPictures.Checked)
            {
                itemVal += "P";
            }
            if (checkStatements.Checked)
            {
                itemVal += "S";
            }
            if (checkToothCharts.Checked)
            {
                itemVal += "T";
            }
            if (checkTreatmentPlans.Checked)
            {
                itemVal += "R";
            }
            if (checkExpanded.Checked)
            {
                itemVal += "E";
            }
            if (checkPaymentPlans.Checked)
            {
                itemVal += "A";
            }
            if (!IsNew && checkExpanded.Checked != DefCur.ItemValue.Contains("E"))           //If checkbox has been changed since opening form.
            {
                if (MsgBox.Show(this, true, "Expanded by default option changed.  This change will affect all users.  Continue?"))
                {
                    //Remove all user specific preferences to enforce the new default.
                    UserOdPrefs.DeleteForFkey(0, UserOdFkeyType.Definition, DefCur.DefNum);
                }
            }
            if (checkClaimAttachments.Checked)
            {
                itemVal += "C";
            }
            if (checkLabCases.Checked)
            {
                itemVal += "B";
            }
            DefCur.ItemValue = itemVal;
            DefCur.IsHidden  = checkHidden.Checked;
            if (IsNew)
            {
                Defs.Insert(DefCur);
            }
            else
            {
                Defs.Update(DefCur);
            }
            DialogResult = DialogResult.OK;
        }
예제 #13
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (Defs.IsHidable(DefCur.Category) && checkHidden.Checked)
            {
                if (Defs.IsDefinitionInUse(DefCur))
                {
                    if (DefCur.DefNum == PrefC.GetLong(PrefName.BrokenAppointmentAdjustmentType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.AppointmentTimeArrivedTrigger) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.AppointmentTimeSeatedTrigger) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.AppointmentTimeDismissedTrigger) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.TreatPlanDiscountAdjustmentType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.BillingChargeAdjustmentType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.FinanceChargeAdjustmentType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.PrepaymentUnearnedType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.PracticeDefaultBillType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.SalesTaxAdjustmentType))
                    {
                        MsgBox.Show(this, "You cannot hide a definition if it is in use within Module Preferences.");
                        return;
                    }
                    else if (DefCur.DefNum.In(
                                 PrefC.GetLong(PrefName.RecallStatusMailed),
                                 PrefC.GetLong(PrefName.RecallStatusTexted),
                                 PrefC.GetLong(PrefName.RecallStatusEmailed),
                                 PrefC.GetLong(PrefName.RecallStatusEmailedTexted)))
                    {
                        MsgBox.Show(this, "You cannot hide a definition that is used as a status in the Setup Recall window.");
                        return;
                    }
                    else if (DefCur.DefNum == PrefC.GetLong(PrefName.WebSchedNewPatConfirmStatus))
                    {
                        MsgBox.Show(this, "You cannot hide a definition that is used as an appointment confirmation status in Web Sched New Pat Appt.");
                        return;
                    }
                    else if (DefCur.DefNum == PrefC.GetLong(PrefName.WebSchedRecallConfirmStatus))
                    {
                        MsgBox.Show(this, "You cannot hide a definition that is used as an appointment confirmation status in Web Sched Recall Appt.");
                        return;
                    }
                    else
                    {
                        if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Warning: This definition is currently in use within the program."))
                        {
                            return;
                        }
                    }
                }
                //Stop users from hiding the last definition in categories that must have at least one def in them.
                if (!_defsList.Any(x => x.DefNum != DefCur.DefNum && !x.IsHidden))
                {
                    MsgBox.Show(this, "You cannot hide the last definition in this category.");
                    return;
                }
            }
            if (textName.Text == "")
            {
                MsgBox.Show(this, "Name required.");
                return;
            }
            switch (DefCur.Category)
            {
            case DefCat.AccountQuickCharge:
            case DefCat.ApptProcsQuickAdd:
                string[]      procCodes     = textValue.Text.Split(',');
                List <string> listProcCodes = new List <string>();
                for (int i = 0; i < procCodes.Length; i++)
                {
                    ProcedureCode procCode = ProcedureCodes.GetProcCode(procCodes[i]);
                    if (procCode.CodeNum == 0)
                    {
                        //Now check to see if the trimmed version of the code does not exist either.
                        procCode = ProcedureCodes.GetProcCode(procCodes[i].Trim());
                        if (procCode.CodeNum == 0)
                        {
                            MessageBox.Show(Lan.g(this, "Invalid procedure code entered") + ": " + procCodes[i]);
                            return;
                        }
                    }
                    listProcCodes.Add(procCode.ProcCode);
                }
                textValue.Text = String.Join(",", listProcCodes);
                break;

            case DefCat.AdjTypes:
                if (textValue.Text != "+" && textValue.Text != "-" && textValue.Text != "dp")
                {
                    MessageBox.Show(Lan.g(this, "Valid values are +, -, or dp."));
                    return;
                }
                break;

            case DefCat.BillingTypes:
                if (textValue.Text != "" && textValue.Text != "E" && textValue.Text != "C")
                {
                    MsgBox.Show(this, "Valid values are blank, E, or C.");
                    return;
                }
                if (checkHidden.Checked && Patients.IsBillingTypeInUse(DefCur.DefNum))
                {
                    if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Warning: Billing type is currently in use by patients, insurance plans, or preferences."))
                    {
                        return;
                    }
                }
                break;

            case DefCat.ClaimCustomTracking:
                int value = 0;
                if (!Int32.TryParse(textValue.Text, out value) || value < 0)
                {
                    MsgBox.Show(this, "Days Suppressed must be a valid non-negative number.");
                    return;
                }
                break;

            case DefCat.CommLogTypes:
                if (textValue.Text != "" && textValue.Text != "MISC" && textValue.Text != "APPT" &&
                    textValue.Text != "FIN" && textValue.Text != "RECALL" && textValue.Text != "TEXT")
                {
                    MessageBox.Show(Lan.g(this, "Valid values are blank,APPT,FIN,RECALL,MISC,or TEXT."));
                    return;
                }
                break;

            case DefCat.DiscountTypes:
                int discVal;
                if (textValue.Text == "")
                {
                    break;
                }
                try {
                    discVal = System.Convert.ToInt32(textValue.Text);
                }
                catch {
                    MessageBox.Show(Lan.g(this, "Not a valid number"));
                    return;
                }
                if (discVal < 0 || discVal > 100)
                {
                    MessageBox.Show(Lan.g(this, "Valid values are between 0 and 100"));
                    return;
                }
                textValue.Text = discVal.ToString();
                break;

            /*case DefCat.FeeSchedNames:
             *      if(textValue.Text=="C" || textValue.Text=="c") {
             *              textValue.Text="C";
             *      }
             *      else if(textValue.Text=="A" || textValue.Text=="a") {
             *              textValue.Text="A";
             *      }
             *      else textValue.Text="";
             *      break;*/
            case DefCat.ImageCats:
                textValue.Text = textValue.Text.ToUpper().Replace(",", "");
                if (!Regex.IsMatch(textValue.Text, @"^[XPS]*$"))
                {
                    textValue.Text = "";
                }
                break;

            case DefCat.InsurancePaymentType:
                if (textValue.Text != "" && textValue.Text != "N")
                {
                    MsgBox.Show(this, "Valid values are blank or N.");
                    return;
                }
                break;

            case DefCat.OperatoriesOld:
                if (textValue.Text.Length > 5)
                {
                    MessageBox.Show(Lan.g(this, "Maximum length of abbreviation is 5."));
                    return;
                }
                break;

            case DefCat.ProcCodeCats:
                if (checkHidden.Checked)
                {
                    if (IsDefCurLastShowing())
                    {
                        MsgBox.Show(this, "At least one procedure code category must be enabled.");
                        return;
                    }
                }
                break;

            case DefCat.ProviderSpecialties:
                if (checkHidden.Checked &&
                    (Providers.IsSpecialtyInUse(DefCur.DefNum) ||
                     Referrals.IsSpecialtyInUse(DefCur.DefNum)))
                {
                    MsgBox.Show(this, "You cannot hide a specialty if it is in use by a provider or a referral source.");
                    checkHidden.Checked = false;
                    return;
                }
                break;

            case DefCat.RecallUnschedStatus:
                if (textValue.Text.Length > 7)
                {
                    MessageBox.Show(Lan.g(this, "Maximum length is 7."));
                    return;
                }
                break;

            case DefCat.TaskPriorities:
                if (checkHidden.Checked)
                {
                    if (IsDefCurLastShowing())
                    {
                        MsgBox.Show(this, "You cannot hide the last priority.");
                        return;
                    }
                }
                break;

            case DefCat.TxPriorities:
                if (textValue.Text.Length > 7)
                {
                    MessageBox.Show(Lan.g(this, "Maximum length of abbreviation is 7."));
                    return;
                }
                break;

            default:
                break;
            }            //end switch DefCur.Category
            DefCur.ItemName  = textName.Text;
            DefCur.ItemValue = _selectedValueString;
            if (_defCatOptions.EnableValue && !_defCatOptions.IsValueDefNum)
            {
                DefCur.ItemValue = textValue.Text;
            }
            if (_defCatOptions.EnableColor)
            {
                DefCur.ItemColor = butColor.BackColor;
            }
            DefCur.IsHidden = checkHidden.Checked;
            if (IsNew)
            {
                Defs.Insert(DefCur);
            }
            else
            {
                Defs.Update(DefCur);
            }
            //Must be after the upsert so that we have access to the DefNum for new Defs.
            if (DefCur.Category == DefCat.ApptConfirmed)
            {
                //==================== EXCLUDE SEND ====================
                if (checkExcludeSend.Checked)
                {
                    _listExcludeSendNums.Add(DefCur.DefNum);
                }
                else
                {
                    _listExcludeSendNums.RemoveAll(x => x == DefCur.DefNum);
                }
                string sendString = string.Join(",", _listExcludeSendNums.Distinct().OrderBy(x => x));
                Prefs.UpdateString(PrefName.ApptConfirmExcludeESend, sendString);
                //==================== EXCLUDE CONFIRM ====================
                if (checkExcludeConfirm.Checked)
                {
                    _listExcludeConfirmNums.Add(DefCur.DefNum);
                }
                else
                {
                    _listExcludeConfirmNums.RemoveAll(x => x == DefCur.DefNum);
                }
                string confirmString = string.Join(",", _listExcludeConfirmNums.Distinct().OrderBy(x => x));
                Prefs.UpdateString(PrefName.ApptConfirmExcludeEConfirm, confirmString);
                //==================== EXCLUDE REMIND ====================
                if (checkExcludeRemind.Checked)
                {
                    _listExcludeRemindNums.Add(DefCur.DefNum);
                }
                else
                {
                    _listExcludeRemindNums.RemoveAll(x => x == DefCur.DefNum);
                }
                string remindString = string.Join(",", _listExcludeRemindNums.Distinct().OrderBy(x => x));
                Prefs.UpdateString(PrefName.ApptConfirmExcludeERemind, remindString);
                Signalods.SetInvalid(InvalidType.Prefs);
            }
            DialogResult = DialogResult.OK;
        }
예제 #14
0
        private int ReallocateAll()
        {
            string    command = "SELECT DefNum FROM definition WHERE Category=1 AND ItemName='Reallocation'";
            DataTable table   = General.GetTable(command);
            int       defnum;

            if (table.Rows.Count == 0)
            {
                Def def = new Def();
                def.Category  = DefCat.AdjTypes;
                def.ItemName  = "Reallocation";
                def.ItemValue = "+";
                def.ItemOrder = DefB.Long[(int)DefCat.AdjTypes].Length;
                Defs.Insert(def);
                defnum = def.DefNum;
                DataValid.SetInvalid(InvalidTypes.Defs);
            }
            else
            {
                defnum = PIn.PInt(table.Rows[0][0].ToString());
            }
            //find all families where someone has a negative balance.
            command = "SELECT DISTINCT Guarantor FROM patient WHERE EstBalance < 0";
            DataTable tableGuarantors = General.GetTable(command);
            int       changed         = 0;

            //bool result;
            double[]   familyBals;
            DataTable  tablePatients;
            Adjustment adj;
            Double     delta;

            for (int i = 0; i < tableGuarantors.Rows.Count; i++)
            {
                command       = "SELECT PatNum,EstBalance FROM patient WHERE Guarantor=" + tableGuarantors.Rows[i][0].ToString();
                tablePatients = General.GetTable(command);
                if (tablePatients.Rows.Count == 1)              //impossible to allocate
                {
                    continue;
                }
                familyBals = new double[tablePatients.Rows.Count];
                for (int p = 0; p < tablePatients.Rows.Count; p++)
                {
                    familyBals[p] = PIn.PDouble(tablePatients.Rows[p]["EstBalance"].ToString());
                }
                for (int p = 0; p < familyBals.Length; p++)
                {
                    if (familyBals[p] < 0)                          //if a negative bal found
                    {
                        for (int j = 0; j < familyBals.Length; j++) //look for a positive bal to adjust
                        {
                            if (j == p)
                            {
                                continue;                                //skip same patient
                            }
                            if (familyBals[j] <= 0)
                            {
                                continue;                        //no neg bal
                            }
                            if (familyBals[j] >= -familyBals[p]) //if sufficient bal to zero out the neg
                            {
                                familyBals[j] += familyBals[p];  //because p is neg
                                familyBals[p]  = 0;
                                break;                           //quit looking for a pos bal to adj.
                            }
                            else                                 //only enough bal to reduce the negative, not eliminate it
                            {
                                familyBals[p] += familyBals[j];  //because p is neg
                                familyBals[j]  = 0;
                            }
                        }
                    }
                }
                //now, save any changes to db:
                for (int p = 0; p < familyBals.Length; p++)
                {
                    if (familyBals[p] == PIn.PDouble(tablePatients.Rows[p]["EstBalance"].ToString()))
                    {
                        continue;                        //same, so no change to db
                    }
                    adj          = new Adjustment();
                    adj.PatNum   = PIn.PInt(tablePatients.Rows[p]["PatNum"].ToString());
                    adj.AdjDate  = DateTime.Today;
                    adj.AdjNote  = "Automatic";
                    adj.AdjType  = defnum;
                    adj.ProcDate = DateTime.Today;
                    adj.ProvNum  = PrefB.GetInt("PracticeDefaultProv");
                    delta        = familyBals[p] - PIn.PDouble(tablePatients.Rows[p]["EstBalance"].ToString());         //works whether pos or neg
                    adj.AdjAmt   = delta;
                    Adjustments.InsertOrUpdate(adj, true);
                    command = "UPDATE patient SET EstBalance=EstBalance+'" + POut.PDouble(delta) + "' WHERE PatNum=" + tablePatients.Rows[p]["PatNum"].ToString();
                    General.NonQ(command);
                    changed++;
                }
            }
            return(changed);
        }