Plugin code broken since 13.1.16

This forum is for programmers who have questions about the source code.
Post Reply
User avatar
wjstarck
Posts: 936
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Plugin code broken since 13.1.16

Post by wjstarck » Wed Apr 03, 2013 10:42 pm

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?
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA

User avatar
Justin Shafer
Posts: 596
Joined: Sat Jul 28, 2007 7:34 pm
Location: Fort Worth, TX.

Re: Plugin code broken since 13.1.16

Post by Justin Shafer » Thu Apr 04, 2013 5:50 am

Uhh.. Don't ask me. :D Reminds me of when the solid state broke. Thanks for the toner! Got it.

User avatar
wjstarck
Posts: 936
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: Plugin code broken since 13.1.16

Post by wjstarck » Thu Apr 04, 2013 8:40 am

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???
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA

User avatar
wjstarck
Posts: 936
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: Plugin code broken since 13.1.16

Post by wjstarck » Thu Apr 04, 2013 10:06 am

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 :?
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA

User avatar
jsalmon
Posts: 1555
Joined: Tue Nov 30, 2010 12:33 pm
Contact:

Re: Plugin code broken since 13.1.16

Post by jsalmon » Thu Apr 04, 2013 10:13 am

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)
The best thing about a boolean is even if you are wrong, you are only off by a bit.

Jason Salmon
Open Dental Software
http://www.opendental.com

kdna
Posts: 15
Joined: Wed Feb 22, 2012 12:59 am

Re: Plugin code broken since 13.1.16

Post by kdna » Tue Apr 30, 2013 10:59 pm

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.

User avatar
drtech
Posts: 1649
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Plugin code broken since 13.1.16

Post by drtech » Wed May 01, 2013 4:46 am

David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

Post Reply