private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textADA.Text == "")
     {
         MessageBox.Show(Lan.g(this, "Code cannot be left blank."));
         listConditions.SelectedIndex = -1;
         FillList();
         return;
     }
     AutoCodeItemCur.CodeNum = ProcedureCodes.GetCodeNum(textADA.Text);
     if (IsNew)
     {
         AutoCodeItems.Insert(AutoCodeItemCur);
     }
     else
     {
         AutoCodeItems.Update(AutoCodeItemCur);
     }
     AutoCodeConds.DeleteForItemNum(AutoCodeItemCur.AutoCodeItemNum);
     for (int i = 0; i < listConditions.SelectedIndices.Count; i++)
     {
         AutoCodeCond AutoCodeCondCur = new AutoCodeCond();
         AutoCodeCondCur.AutoCodeItemNum = AutoCodeItemCur.AutoCodeItemNum;
         AutoCodeCondCur.Cond            = (AutoCondition)listConditions.SelectedIndices[i];
         AutoCodeConds.Insert(AutoCodeCondCur);
     }
     DialogResult = DialogResult.OK;
 }
Exemple #2
0
        private void FillTable()
        {
            int count = 0;

            AutoCodeItems.RefreshCache();
            AutoCodeConds.RefreshCache();
            _listAutoCodeConds = AutoCodeConds.GetDeepCopy();
            listForCode        = AutoCodeItems.GetListForCode(AutoCodeCur.AutoCodeNum);
            tbAutoItem.ResetRows(listForCode.Count);
            tbAutoItem.SetGridColor(Color.Gray);
            tbAutoItem.SetBackGColor(Color.White);
            for (int i = 0; i < listForCode.Count; i++)
            {
                tbAutoItem.Cell[0, i] = ProcedureCodes.GetProcCode(listForCode[i].CodeNum).ProcCode;
                tbAutoItem.Cell[1, i] = ProcedureCodes.GetProcCode(listForCode[i].CodeNum).Descript;
                count = 0;
                for (int j = 0; j < _listAutoCodeConds.Count; j++)
                {
                    if (_listAutoCodeConds[j].AutoCodeItemNum == listForCode[i].AutoCodeItemNum)
                    {
                        if (count != 0)
                        {
                            tbAutoItem.Cell[2, i] += ", ";
                        }
                        tbAutoItem.Cell[2, i] += _listAutoCodeConds[j].Cond.ToString();
                        count++;
                    }
                }
            }
            tbAutoItem.LayoutTables();
        }
Exemple #3
0
        private void FillTable()
        {
            int count = 0;

            AutoCodeItems.Refresh();
            AutoCodeConds.Refresh();
            AutoCodeItems.GetListForCode(AutoCodeCur.AutoCodeNum);
            tbAutoItem.ResetRows(AutoCodeItems.ListForCode.Length);
            tbAutoItem.SetGridColor(Color.Gray);
            tbAutoItem.SetBackGColor(Color.White);
            for (int i = 0; i < AutoCodeItems.ListForCode.Length; i++)
            {
                tbAutoItem.Cell[0, i] = ProcedureCodes.GetProcCode(AutoCodeItems.ListForCode[i].CodeNum).ProcCode;
                tbAutoItem.Cell[1, i] = ProcedureCodes.GetProcCode(AutoCodeItems.ListForCode[i].CodeNum).Descript;
                count = 0;
                for (int j = 0; j < AutoCodeConds.List.Length; j++)
                {
                    if (AutoCodeConds.List[j].AutoCodeItemNum == AutoCodeItems.ListForCode[i].AutoCodeItemNum)
                    {
                        if (count != 0)
                        {
                            tbAutoItem.Cell[2, i] += ", ";
                        }
                        tbAutoItem.Cell[2, i] += AutoCodeConds.List[j].Cond.ToString();
                        count++;
                    }
                }
            }
            tbAutoItem.LayoutTables();
        }
Exemple #4
0
        ///<summary>Only called from ContrChart.listProcButtons_Click.  Called once for each tooth selected and for each autocode item attached to the button.</summary>
        public static string GetADA(int autoCodeNum, string toothNum, string surf, bool isAdditional, int patNum, int age)
        {
            bool allCondsMet;

            GetListForCode(autoCodeNum);
            if (ListForCode.Length == 0)
            {
                return("");
            }
            bool willBeMissing = Procedures.WillBeMissing(toothNum, patNum);

            for (int i = 0; i < ListForCode.Length; i++)
            {
                AutoCodeConds.GetListForItem(ListForCode[i].AutoCodeItemNum);
                allCondsMet = true;
                for (int j = 0; j < AutoCodeConds.ListForItem.Length; j++)
                {
                    if (!AutoCodeConds.ConditionIsMet
                            (AutoCodeConds.ListForItem[j].Cond, toothNum, surf, isAdditional, willBeMissing, age))
                    {
                        allCondsMet = false;
                    }
                }
                if (allCondsMet)
                {
                    return(ListForCode[i].ADACode);
                }
            }
            return(ListForCode[0].ADACode);           //if couldn't find a better match
        }
Exemple #5
0
        private void butDelete_Click(object sender, System.EventArgs e)
        {
            if (tbAutoItem.SelectedRow == -1)
            {
                MessageBox.Show(Lan.g(this, "Please select an item first."));
                return;
            }
            AutoCodeItem AutoCodeItemCur = listForCode[tbAutoItem.SelectedRow];

            AutoCodeConds.DeleteForItemNum(AutoCodeItemCur.AutoCodeItemNum);
            AutoCodeItems.Delete(AutoCodeItemCur);
            FillTable();
        }
        private void FillList()
        {
            listConditions.Items.Clear();
            foreach (string s in Enum.GetNames(typeof(AutoCondition)))
            {
                listConditions.Items.Add(Lan.g("enumAutoConditions", s));
            }
            List <AutoCodeCond> listAutoCodeConds = AutoCodeConds.GetWhere(x => x.AutoCodeItemNum == AutoCodeItemCur.AutoCodeItemNum);

            for (int i = 0; i < listAutoCodeConds.Count; i++)
            {
                listConditions.SetSelected((int)listAutoCodeConds[i].Cond, true);
            }
        }
 private void FormAutoItemEdit_Load(object sender, System.EventArgs e)
 {
     AutoCodeConds.RefreshCache();
     if (IsNew)
     {
         this.Text = Lan.g(this, "Add Auto Code Item");
     }
     else
     {
         this.Text    = Lan.g(this, "Edit Auto Code Item");
         textADA.Text = ProcedureCodes.GetStringProcCode(AutoCodeItemCur.CodeNum);
     }
     FillList();
 }
Exemple #8
0
 private void FormAutoItemEdit_Load(object sender, System.EventArgs e)
 {
     AutoCodeConds.Refresh();
     if (IsNew)
     {
         this.Text = Lan.g(this, "Add Auto Code Item");
     }
     else
     {
         this.Text    = Lan.g(this, "Edit Auto Code Item");
         textADA.Text = AutoCodeItemCur.ADACode;
     }
     FillList();
 }
Exemple #9
0
 private void FormAutoCodeEdit_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (DialogResult == DialogResult.OK)
     {
         return;
     }
     if (IsNew)
     {
         for (int i = 0; i < AutoCodeItems.ListForCode.Length; i++)
         {
             AutoCodeItem AutoCodeItemCur = AutoCodeItems.ListForCode[i];
             AutoCodeConds.DeleteForItemNum(AutoCodeItemCur.AutoCodeItemNum);
             AutoCodeItems.Delete(AutoCodeItemCur);
         }
         AutoCodes.Delete(AutoCodeCur);
     }
 }
Exemple #10
0
        ///<summary>Only called when closing the procedure edit window. Usually returns the supplied adaCode, unless a better match is found.</summary>
        public static string VerifyCode(string ADACode, string toothNum, string surf, bool isAdditional, int patNum, int age,
                                        out AutoCode AutoCodeCur)
        {
            bool allCondsMet;

            AutoCodeCur = null;
            if (!HList.ContainsKey(ADACode))
            {
                return(ADACode);
            }
            if (!AutoCodes.HList.ContainsKey((int)HList[ADACode]))
            {
                return(ADACode);               //just in case.
            }
            AutoCodeCur = (AutoCode)AutoCodes.HList[(int)HList[ADACode]];
            if (AutoCodeCur.LessIntrusive)
            {
                return(ADACode);
            }
            bool willBeMissing = Procedures.WillBeMissing(toothNum, patNum);

            //AutoCode verAutoCode=(AutoCode)HList[ADACode];
            GetListForCode((int)HList[ADACode]);
            for (int i = 0; i < ListForCode.Length; i++)
            {
                AutoCodeConds.GetListForItem(ListForCode[i].AutoCodeItemNum);
                allCondsMet = true;
                for (int j = 0; j < AutoCodeConds.ListForItem.Length; j++)
                {
                    if (!AutoCodeConds.ConditionIsMet
                            (AutoCodeConds.ListForItem[j].Cond, toothNum, surf, isAdditional, willBeMissing, age))
                    {
                        allCondsMet = false;
                    }
                }
                if (allCondsMet)
                {
                    return(ListForCode[i].ADACode);
                }
            }
            return(ADACode);           //if couldn't find a better match
        }
Exemple #11
0
        private void FormAutoCodeEdit_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult != DialogResult.OK)
            {
                if (IsNew)
                {
                    try {
                        AutoCodes.Delete(AutoCodeCur);
                    }
                    catch (ApplicationException ex) {
                        //should never happen
                        MessageBox.Show(ex.Message);
                    }
                    return;
                }
                if (listForCode.Count == 0)
                {
                    //Since changes to AutoCodeItems and AutoCodeConds are written to the database already, Cancel isn't a true cancel.
                    MsgBox.Show(this, "Must have at least one Code in the list.");                   //Block this invalid AutoCode state.
                    e.Cancel = true;
                    return;
                }
            }
            AutoCodeItems.RefreshCache();
            AutoCodeConds.RefreshCache();
            for (int i = 0; i < listForCode.Count; i++)       //Attach the conditions to the items for better organization
            {
                listForCode[i].ListConditions = new List <AutoCodeCond>();
                for (int j = 0; j < _listAutoCodeConds.Count; j++)//Fill conditions for this AutoCodeItem
                {
                    if (_listAutoCodeConds[j].AutoCodeItemNum == listForCode[i].AutoCodeItemNum)
                    {
                        listForCode[i].ListConditions.Add(_listAutoCodeConds[j]);
                    }
                }
            }
            //Must have same number of conditions for each AutoCodeItem.----------------------------------------------------------------------------------
            for (int i = 1; i < listForCode.Count; i++)       //start at 1 and compare to the 0 index.
            {
                if (listForCode[i].ListConditions.Count != listForCode[0].ListConditions.Count)
                {
                    MsgBox.Show(this, "All AutoCode items must have the same number of conditions.");
                    e.Cancel = true;
                    return;
                }
            }
            if (listForCode[0].ListConditions.Count == 0)           //Rest of the checks assume at least one condition.
            {
                return;
            }
            //Check for duplicate AutoCodeItem condition lists.-------------------------------------------------------------------------------------------
            for (int i = 1; i < listForCode.Count; i++) //start at 1
            {
                for (int j = 0; j < i; j++)             //loop through the lower-indexed entries
                {
                    int matches = 0;
                    for (int k = 0; k < listForCode[i].ListConditions.Count; k++)                           //For each condition in i, check for matches with conditions in j
                    {
                        if (listForCode[i].ListConditions[k].Cond == listForCode[j].ListConditions[k].Cond) //if the same condition is in both rows.
                        {
                            matches++;
                        }
                    }
                    if (matches == listForCode[i].ListConditions.Count)                   //If the number of matches equals the number of conditions on this row
                    {
                        MsgBox.Show(this, "Cannot have two AutoCode Items with duplicate conditions.");
                        e.Cancel = true;
                        return;
                    }
                }
            }
            //Decide which categories are involved.------------------------------------------------------------------------------------------------------
            bool isAnt          = false; //Not a category, could be isAntPost or isAntPreMol
            bool isAntPost      = false;
            bool isAntPreMol    = false; //Anterior/premolar/molar
            bool isNumSurf      = false;
            bool isFirstEachAdd = false;
            bool isMaxMand      = false;
            bool isPriPerm      = false;
            bool isPontRet      = false;

            for (int i = 0; i < listForCode.Count; i++)
            {
                //If the item matches the category, set the boolean to true.
                for (int j = 0; j < listForCode[i].ListConditions.Count; j++)
                {
                    if (listForCode[i].ListConditions[j].Cond == AutoCondition.Anterior)
                    {
                        isAnt = true;
                        //We want to also set either isAntPost or isAntPreMol, but we don't have enough information yet to set that.
                        continue;
                    }
                    if (listForCode[i].ListConditions[j].Cond == AutoCondition.Posterior)
                    {
                        isAntPost = true;
                        continue;
                    }
                    if (listForCode[i].ListConditions[j].Cond == AutoCondition.Premolar ||
                        listForCode[i].ListConditions[j].Cond == AutoCondition.Molar
                        )
                    {
                        isAntPreMol = true;
                        continue;
                    }
                    if (listForCode[i].ListConditions[j].Cond == AutoCondition.One_Surf ||
                        listForCode[i].ListConditions[j].Cond == AutoCondition.Two_Surf ||
                        listForCode[i].ListConditions[j].Cond == AutoCondition.Three_Surf ||
                        listForCode[i].ListConditions[j].Cond == AutoCondition.Four_Surf ||
                        listForCode[i].ListConditions[j].Cond == AutoCondition.Five_Surf
                        )
                    {
                        isNumSurf = true;
                        continue;
                    }
                    if (listForCode[i].ListConditions[j].Cond == AutoCondition.First ||
                        listForCode[i].ListConditions[j].Cond == AutoCondition.EachAdditional
                        )
                    {
                        isFirstEachAdd = true;
                        continue;
                    }
                    if (listForCode[i].ListConditions[j].Cond == AutoCondition.Maxillary ||
                        listForCode[i].ListConditions[j].Cond == AutoCondition.Mandibular
                        )
                    {
                        isMaxMand = true;
                        continue;
                    }
                    if (listForCode[i].ListConditions[j].Cond == AutoCondition.Primary ||
                        listForCode[i].ListConditions[j].Cond == AutoCondition.Permanent
                        )
                    {
                        isPriPerm = true;
                        continue;
                    }
                    if (listForCode[i].ListConditions[j].Cond == AutoCondition.Pontic ||
                        listForCode[i].ListConditions[j].Cond == AutoCondition.Retainer
                        )
                    {
                        isPontRet = true;
                        continue;
                    }
                }
            }
            //After the loop, you had better have exactly the same number of booleans true as number of conditions on each item.--------------------
            if (isAntPost && isAntPreMol)
            {
                MsgBox.Show(this, "Cannot have both Posterior and Premolar/Molar categories.");
                e.Cancel = true;
                return;
            }
            if (isAnt)             //This is the only purpose of the isAnt bool.  We won't use it anymore.
            {
                if (!isAntPost && !isAntPreMol)
                {
                    MsgBox.Show(this, "Anterior condition is present without any corresponding posterior or premolar/molar condition.");
                    e.Cancel = true;
                    return;
                }
            }
            //Count how many categories were hit.
            int numCategories = 0;

            if (isAntPost)
            {
                numCategories++;
            }
            if (isAntPreMol)
            {
                numCategories++;
            }
            if (isNumSurf)
            {
                numCategories++;
            }
            if (isFirstEachAdd)
            {
                numCategories++;
            }
            if (isMaxMand)
            {
                numCategories++;
            }
            if (isPriPerm)
            {
                numCategories++;
            }
            if (isPontRet)
            {
                numCategories++;
            }
            if (numCategories != listForCode[0].ListConditions.Count)           //Every row has to have the same number of conditions
            {
                MessageBox.Show(Lan.g(this, "When using ") + listForCode[0].ListConditions.Count + Lan.g(this, " condition(s), you must use conditions from ")
                                + listForCode[0].ListConditions.Count + Lan.g(this, " logical categories. You are using conditions from ") + numCategories + Lan.g(this, " logical categories."));
                e.Cancel = true;
                return;
            }
            //Make sure that the number of AutoCodeItems is right. For example, if isAntPost and isNumSurf are the only true one, there should be 10 items.----------------------------------------
            int reqNumAutoCodeItems = 1;

            if (isAntPost)
            {
                reqNumAutoCodeItems = reqNumAutoCodeItems * 2;
            }
            if (isAntPreMol)
            {
                if (isPriPerm)
                {
                    reqNumAutoCodeItems = reqNumAutoCodeItems * 5;                //normally this would be 2*3 but primary molars don't exist, so we have 2*3-1=5
                }
                else
                {
                    reqNumAutoCodeItems = reqNumAutoCodeItems * 3;
                }
            }
            else
            {
                if (isPriPerm)
                {
                    reqNumAutoCodeItems = reqNumAutoCodeItems * 2;
                }
            }
            if (isNumSurf)
            {
                reqNumAutoCodeItems = reqNumAutoCodeItems * 5;
            }
            if (isFirstEachAdd)
            {
                reqNumAutoCodeItems = reqNumAutoCodeItems * 2;
            }
            if (isMaxMand)
            {
                reqNumAutoCodeItems = reqNumAutoCodeItems * 2;
            }
            if (isPontRet)
            {
                reqNumAutoCodeItems = reqNumAutoCodeItems * 2;
            }
            if (listForCode.Count != reqNumAutoCodeItems)
            {
                MessageBox.Show(Lan.g(this, "For the condition categories you are using, you should have ")
                                + reqNumAutoCodeItems + Lan.g(this, " entries in your list. You have ") + listForCode.Count + ".");
                e.Cancel = true;
                return;
            }
        }