HTMLFormEntry Module update affected existing JQuery functions

OpenMRS

1.11.6

We recently update our OpenMRS version form 1.9.7 to 1.11.6 which needed HtmlFormEntry module version 3.3.2, we had some JQuery functions which we used to validate data entry but since the upgrade the functions are no longer working, Does any one have a solution to this problem? Kindly help

@rugute have you also installed the " htmlformentry19ext Module"as per the Requirements Here ?

Since you are using OpenMRS ! 1.9 +

I believe I remember an issue like this being reported (and fixed) previously, but unfortunately I don’t remember exactly when/where… have you tried updating to the latest versions of the HTML Form Entry and HTML Form Entry UI modules (they should both work with 1.11.6.)

Take care, Mark

1 Like

Hello sorry have been too silent for long have tricked all those options but have not succeeded.

Do you remember how to sort this problem?

@rugute which version of the htmlformentry module are you using?

Also, do you see any errors in your Javascript console when trying to execute the functions? What variable are you using to access Jquery?

Take care, Mark

Am using version 3.3.2

This is what I get from the consult.

Uncaught TypeError: Cannot read property ‘toLowerCase’ of undefined at Date.getHoliday (htmlFormEntry.form?personId=204773&patientId=204773&returnUrl=&formId=109:1185) at Date.badAppointmentDay (htmlFormEntry.form?personId=204773&patientId=204773&returnUrl=&formId=109:1222) at adjustDate (htmlFormEntry.form?personId=204773&patientId=204773&returnUrl=&formId=109:1281) at HTMLInputElement. (htmlFormEntry.form?personId=204773&patientId=204773&returnUrl=&formId=109:1478) at HTMLInputElement.dispatch (jquery-1.8.3.min.js?v=1.11.6:2) at HTMLInputElement.u (jquery-1.8.3.min.js?v=1.11.6:2) at Object.trigger (jquery-1.8.3.min.js?v=1.11.6:2) at HTMLInputElement. (jquery-1.8.3.min.js?v=1.11.6:2) at Function.each (jquery-1.8.3.min.js?v=1.11.6:2) at init.each (jquery-1.8.3.min.js?v=1.11.6:2) htmlFormEntry.form?personId=204773&patientId=204773&returnUrl=&formId=109:1185 Uncaught TypeError: Cannot read property ‘toLowerCase’ of undefined at Date.getHoliday (htmlFormEntry.form?personId=204773&patientId=204773&returnUrl=&formId=109:1185) at Date.badAppointmentDay (htmlFormEntry.form?personId=204773&patientId=204773&returnUrl=&formId=109:1222) at adjustDate (htmlFormEntry.form?personId=204773&patientId=204773&returnUrl=&formId=109:1281) at HTMLInputElement. (htmlFormEntry.form?personId=204773&patientId=204773&returnUrl=&formId=109:1478) at HTMLInputElement.dispatch (jquery-1.8.3.min.js?v=1.11.6:2) at HTMLInputElement.u (jquery-1.8.3.min.js?v=1.11.6:2) at Object.trigger (jquery-1.8.3.min.js?v=1.11.6:2) at HTMLInputElement. (jquery-1.8.3.min.js?v=1.11.6:2) at Function.each (jquery-1.8.3.min.js?v=1.11.6:2) at init.each (jquery-1.8.3.min.js?v=1.11.6:2)

Is this in some custom Javascript code you wrote? If so, can we take a look at it? Looks like “Date.getHoliday” (a function I’m not familiar with) is returning undefined, and so it’s throwing an error when it tried to convert "undefined’ to lower case.

Take care, Mark

This the function.

Date.prototype.getHoliday = function() { // Returns the reason if clinic is closed on this day. var holiday = undefined; // Return this unless we find a holiday below. var dayMonth = this.getDate() + “-” + this.getMonth1(); // Day-Month // // Look for holidays that fall on the same day each year. // switch (dayMonth) // Day-Month (month 1=Jan, 2=Feb, …) { case “1-1”: holiday = “New Years Day”; break; case “1-5”: holiday = “Labour Day”; break; case “1-6”: holiday = “Madaraka Day”; break; case “20-10”: holiday = “Mashujaa Day”; break; case “12-12”: holiday = “Jamhuri Day”; break; case “25-12”: holiday = “Christmas Day”; break; case “26-12”: holiday = “Boxing Day”; break; } // // If a holiday falls on a Sunday, then the following Monday is observed as a holiday. // Therefore look for the day after a holiday when it falls on a Monday. // (Except that the day after Christmas will be boxing day anyway, so don’t look for it.) // switch (dayMonth + “/” + this.getDay()) // Day-Month/Weekday (0=Sun, 1=Mon, …) { case “2-1/1”: holiday = “New Years Day (observed on Monday)”; break; case “2-5/1”: holiday = “Labour Day (observed on Monday)”; break; case “2-6/1”: holiday = “Madaraka Day (observed on Monday)”; break; case “21-10/1”: holiday = “Mashujaa Day (observed on Monday)”; break; case “13-12/1”: holiday = “Jamhuri Day (observed on Monday)”; break; case “27-12/1”: holiday = “Boxing Day (observed on Monday)”; break; } // // Look for Good Friday and Easter Monday. // switch (dayMonth + “-” + this.getFullYear()) { case “22-4-2011”: holiday = “Easter Friday”; break; case “25-4-2011”: holiday = “Easter Monday”; break;

    case "6-4-2012":	holiday = "Easter Friday";	break;
    case "9-4-2012":	holiday = "Easter Monday";	break;

    case "29-3-2013":	holiday = "Easter Friday";	break;
    case "1-4-2013":	holiday = "Easter Monday";	break;

    case "18-4-2014":	holiday = "Easter Friday";	break;
    case "21-4-2014":	holiday = "Easter Monday";	break;

    case "3-4-2015":	holiday = "Easter Friday";	break;
    case "6-4-2015":	holiday = "Easter Monday";	break;

    case "25-3-2016":	holiday = "Easter Friday";	break;
    case "28-3-2016":	holiday = "Easter Monday";	break;

    case "14-4-2017":	holiday = "Easter Friday";	break;
    case "17-4-2017":	holiday = "Easter Monday";	break;

    case "30-3-2018":	holiday = "Easter Friday";	break;
    case "2-4-2018":	holiday = "Easter Monday";	break;

    case "19-4-2019":	holiday = "Easter Friday";	break;
    case "22-4-2019":	holiday = "Easter Monday";	break;

    case "10-4-2020":	holiday = "Easter Friday";	break;
    case "13-4-2020":	holiday = "Easter Monday";	break;

    case "2-4-2021":	holiday = "Easter Friday";	break;
    case "5-4-2021":	holiday = "Easter Monday";	break;

    case "15-4-2022":	holiday = "Easter Friday";	break;
    case "18-4-2022":	holiday = "Easter Monday";	break;

    case "7-4-2023":	holiday = "Easter Friday";	break;
    case "10-4-2023":	holiday = "Easter Monday";	break;

    case "29-3-2024":	holiday = "Easter Friday";	break;
    case "1-4-2024":	holiday = "Easter Monday";	break;

    case "18-4-2025":	holiday = "Easter Friday";	break;
    case "21-4-2025":	holiday = "Easter Monday";	break;
}
//
// See if the clinic is closed for a special, configured reason
//

// alert(this.toDateString()) var closed = closedDates[this.toDateString()]; if (!(closed === undefined)) { holiday = closed; } //

Can to trace further and see what the value is that is “undefined” that shouldn’t be? From the error message, looks like it would be at line 1185? I

Take care, Mark