Page 1 of 1

Plugin code broken since 13.1.16

Posted: Wed Apr 03, 2013 10:42 pm
by wjstarck
Hello-

This plugin code has been working fine for several years but broke recently as of 13.1.16. What this code block does is split the default note for procedures with a delimiter in this case '+-+' . It added this functionality to allow us OMSs to have a different note appear for an upper vs. a lower tooth because the default note is almost always different for upper vs. lower.

So if the default note for, say a D7240 looks like

Code: Select all

This is the upper note
+-+
This is the lower note
Then the block would trim the inappropriate code based on the tooth being extracted.

The three hooks that call this block are

Code: Select all

 case 
 "ContrChart.menuItemSetComplete_Click_procLoop"://with delimiter '+-+' between notes for upper and lower, enters appropriate note according to tooth #
ProcList = Procedures.Refresh(FormOpenDental.CurPatNum);
Procedure oldProc = new Procedure();
textNotes = new ODtextBox();
FormOpenDentalA.UpperLowerNoteFixFromMenu((object)sender, (Procedure)parameters[0], (Procedure)parameters[1], (ODtextBox)textNotes);
return true;
				case "FormProcEdit.butSetComplete_Click_end": //with delimiter '+-+' between notes for upper and lower, enters appropriate note according to tooth #. Also used to release ProcLock.
					ProcList = Procedures.Refresh(FormOpenDental.CurPatNum);
                    oldProc = new Procedure();
                    textNotes = new ODtextBox();
                    FormOpenDentalA.UpperLowerNoteFixFromMenu((object)sender,(Procedure)parameters[0], (Procedure)parameters[1], (ODtextBox)parameters[2]);
					FormOpenDentalA.ReleaseProcLock((object)sender, (Procedure)parameters[0]);
                    return true;
				case "Procedures.SetCompleteInAppt_procLoop": //with delimiter '+-+' between notes for upper and lower, enters appropriate note according to tooth #                     
					ProcList = Procedures.Refresh(FormOpenDental.CurPatNum);
					FormOpenDentalA.UpperLowerNoteFix((Procedures)sender, (Procedure)parameters[0], (Procedure)parameters[1]);
					return true;

Code: Select all

        /// <summary>
        /// Adds appropriate note for upper vs. lower teeth if delimiter '+-+' is used between note for upper and lower
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="procCur"></param>
        /// <param name="procOld"></param>

        public static void UpperLowerNoteFixFromMenu(object sender, Procedure procCur, Procedure procOld, ODtextBox textNotes) { //setting 'Complete' from ContrAppr or FormProcEdit uses this method

            string test = textNotes.Text;
            Procedure procOrig = procOld;
            if (procOld.Note == String.Empty || procCur.Note == String.Empty || procOld.Note == null) {
                procCur.Note = ProcCodeNotes.GetNote(procCur.ProvNum, procCur.CodeNum);
                beforeDelim = procCur.Note;
                afterDelim = procCur.Note;

                string[] parts = beforeDelim.Split(new string[] { "\r\n+-+\r\n" }, StringSplitOptions.None);
                for (int j = 0; j < parts.Length; j++) {
                    if (j == 0)
                    {
                        beforeDelim = (parts[j]);
                    }
                    if (j == 1)
                    {
                        afterDelim = (parts[j]);
                    }
                }
                if (procCur.ToothNum == String.Empty) {
                    Procedures.Update(procCur, procOld);
                    textNotes.Text = procOrig.Note;
                    return;
                }
            }
            else if (procOld.Note == null) {
                beforeDelim = procCur.Note;
                afterDelim = procCur.Note;
            }
            else {
                beforeDelim = procOld.Note;
                afterDelim = procOld.Note;
			}
            string upperNote = beforeDelim;
            string lowerNote = afterDelim;
            Regex isPedoUpper = new Regex("^[a-jA-J]*$");
            Regex isPedoLower = new Regex("^[k-tK-T]*$");
            if (procCur.ToothNum != "") { //because some Proc don't have a toothNum, eg., exams

                if (isPedoUpper.IsMatch(procCur.ToothNum)) { //primary upper teeth
                    if (procCur.Note != procOld.Note)
                        procCur.Note = upperNote;
                    if (procCur.Note != "")  {//prevents double note getting added from ContrChart
                        procOld.Note = String.Empty;
                    }
                }

                else if (isPedoLower.IsMatch(procCur.ToothNum)) { //primary lower teeth
                    if (procCur.Note != procOld.Note)
                        procCur.Note = lowerNote;
                    if (procCur.Note != "")  {//prevents double note getting added from ContrChart
                        procOld.Note = String.Empty;
                    }
                }

                else if (Convert.ToInt64(procCur.ToothNum) <= 16 || ((Convert.ToInt64(procCur.ToothNum) >= 51 && (Convert.ToInt64(procCur.ToothNum) <= 66)))) { //check if permanent or supernumerary upper
                    if (procCur.Note != procOld.Note)
                        procCur.Note = upperNote;
                    if (procCur.Note != "") {//prevents double note getting added from ContrChart
                        procOld.Note = String.Empty;
                    }
                }

                else if (Convert.ToInt64(procCur.ToothNum) >= 17 | ((Convert.ToInt64(procCur.ToothNum) >= 67 && (Convert.ToInt64(procCur.ToothNum) <= 82)))) { //check if permanent or supernumerary lower
                    if (procCur.Note != procOld.Note)
                        procCur.Note = lowerNote;
                    if (procCur.Note != "") {//prevents double note getting added from ContrChart
                        procOld.Note = String.Empty;
                    }
                }

            }
            else if (procCur.Note != "") {
                procCur.Note = procOld.Note; //prevents template note from overwriting changes to note

            }

            Procedures.Update(procCur, procOld);
            textNotes.Text = procCur.Note; //only needed when completing note on FormProcEdit

        }
I can't seem to find any changes in the repository that would have broken this working code.

Any suggestions?

Re: Plugin code broken since 13.1.16

Posted: Thu Apr 04, 2013 5:50 am
by Justin Shafer
Uhh.. Don't ask me. :D Reminds me of when the solid state broke. Thanks for the toner! Got it.

Re: Plugin code broken since 13.1.16

Posted: Thu Apr 04, 2013 8:40 am
by wjstarck
Well this is perplexing.

This code block

Code: Select all

           string[] parts = beforeDelim.Split(new string[] { "\r\n+-+\r\n" }, StringSplitOptions.None);
                    for (int j = 0; j < parts.Length; j++) {
                        if (j == 0) {
                            beforeDelim = (parts[j]);
							string test = beforeDelim;
                        }
                        if (j == 1) {
                            afterDelim = (parts[j]);
                        }
                    }
from here:

Code: Select all

        public static void UpperLowerNoteFix(Procedures sender, Procedure procCur, Procedure procOld) { //setting 'Complete' from ApptBook uses this method
            
          if (procOld.Note == String.Empty || procOld.Note == null) {

                   procCur.Note = ProcCodeNotes.GetNote(procCur.ProvNum, procCur.CodeNum);
                    beforeDelim = procCur.Note;
                    afterDelim = procCur.Note;

                    string[] parts = beforeDelim.Split(new string[] { "\r\n+-+\r\n" }, StringSplitOptions.None);
                    for (int j = 0; j < parts.Length; j++) {
                        if (j == 0) {
                            beforeDelim = (parts[j]);
							string test = beforeDelim;
                        }
                        if (j == 1) {
                            afterDelim = (parts[j]);
                        }
                    }
                    if (procCur.ToothNum == String.Empty)
                        return;
            } 
No longer seems to break the string at the delimiter, even though it has been working for years.

So this doesn't seem to be an OD problem???

Re: Plugin code broken since 13.1.16

Posted: Thu Apr 04, 2013 10:06 am
by wjstarck
OK, well now the code block works as expected if the '\r's are removed from the statement

Code: Select all

 string[] parts = beforeDelim.Split(new string[] { "\r\n+-+\r\n" }, StringSplitOptions.None);
I changed that code block to this now because it's a little cleaner:

Code: Select all

				string[] delim = new string[] {"\n+-+\n"};
					string[] result;
					result = beforeDelim.Split(delim, StringSplitOptions.None);
					beforeDelim = result[0];
					afterDelim = result[1];
I have no idea why this suddenly broke, unless it has to do with how procNotes are stored in the db now but I don't see any evidence of that in the repository :?

Re: Plugin code broken since 13.1.16

Posted: Thu Apr 04, 2013 10:13 am
by jsalmon
The text boxes got changed to rich text boxes and it looks like the \r is no longer present. Try matching for "\n+-+\n"

You beat me to the fix. I should have refreshed this thread before posting 8)

Re: Plugin code broken since 13.1.16

Posted: Tue Apr 30, 2013 10:59 pm
by kdna
Would it be possible for you guys to write a simple tutorial explaining how to make a simple hello world plugin?
How to integrate with external programs?

I would like to extend Open Dental but am very confused.

Thank you.

Re: Plugin code broken since 13.1.16

Posted: Wed May 01, 2013 4:46 am
by drtech