OpenEMR 5.0.2: Apache Webserver (AWS Standard) occasionally cannot load a page


(Ralf Lukner MD PhD) #1

Situation
Our clinic has upgraded from OpenEMR 5.0.1(7) to 5.0.2. Occasionally, a particular tab (?frame) cannot be displayed and give a message with a path and a message suggesting that perhaps the web server is temporarily down or the page has moved.
Here is the kind of message we see:
[ :frowning: ] The webpage at https://…/interface/main/calendar/index.php?=module=PostCalendar&func-view&tplview=&viewtype=day&Date=20190820&pc_username=&pc_category=&pc_topic=
might be temporarily down or it may have moved permanently to a new web address.

OpenEMR Version
I’m using OpenEMR version 5.0.2 AWS Standard using a Windows 10 Chrome or Edge browser (more frequent errors than in other environments, especially with several tabs open) or macOS Mojave laptop with Chrome or FF (less commonly seen on the Mac).

Browser:
I’m using: mostly Chrome and FF latest versions on Windows 10 or macOS Mojave.

Operating System
I’m using: AWS Standard

Logs
Someone remind me where to look for the logs (path) ;-).

The issue is not limited to the calendar. I have seen it happen on a tab that was holding a patient’s encounter (with the various Encounter, Vitals, SOAP, etc. templates) becoming inaccessible. When this happens, other functionality seems to work fine (can open other charts, view various reports) but whatever was contained in the “broken” page cannot be accessed in that Web Client session. The “fix” is usually to use a different computer, restart the browser, or something very “aggressive.” Simply closing the web client tab and opening a New OpenEMR session usually does not correct the problem.

I was holding off on reporting this because I wanted to figure out how to reproduce the problem. I have tried for a couple of weeks and cannot come up with a way to reliably reproduce this issue. One factor seems to be having multiple tabs (other web pages, etc.) open. Opening other OpenEMR session tabs is not required to see this problem as far as I can tell.

It happens often enough to one user (who seems to have a lot of other web sessions for billing services, etc. open) to make that user think that 5.0.2 is far less reliable and usable than 5.0.1(7) was and needs other users to “look up” information on different computers because it isn’t possible for that user to retrieve certain information from OpenEMR. Most users seem to be OK because they tend to have fewer browser tabs open on their computers.


(Ralf Lukner MD PhD) #2

I spoke with another EMR user (a computer savvy person) in our clinic. He was able to reproduce the issue several times last week and this morning just by using the flowboard and calendar. However, by logging out, logging back in (perhaps doing something to refresh the cache?). He was able to reproduce the issue. I’m going to try clearing the browser cache on the computers where this happens and see if that clears the problem when this occurs.
–Ralf


(Ralf Lukner MD PhD) #3


(Brady Miller) #4

hi @Ralf_Lukner ,
What is the name of your openemr docker (can see with command: docker ps -a )? Then I can give you a cool command to display the log from outside the docker.


(Brady Miller) #5

btw: a patch is coming out very soon, so hoping to clear out any known bugs before then.


(Ralf Lukner MD PhD) #6

standard_openemr_1

ubuntu@ip-10-0-1-145:~$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f721b8799187 openemr/openemr:5.0.2 “./run_openemr.sh” 10 days ago Up 37 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp standard_openemr_1
3344de9fe048 hello-world “/hello” 6 weeks ago Exited (0) 6 weeks ago nostalgic_neumann


(Brady Miller) #7

Hi @Ralf_Lukner ,
The following command will output the logfile from outside the docker:

docker exec -i standard_openemr_1 sh -c 'cat /var/log/apache2/error.log'

(Ralf Lukner MD PhD) #8

The log is huge. I shut down the instance and database at night so there are all kinds of errors associated with that. I perused the log and found something that might be a clue:

[Mon Aug 12 15:38:30.735946 2019] [php7:warn] [pid 1150] [client 67.61.155.243:56072] PHP Warning: A non-numeric value encountered in /var/www/localhost/htdocs/openemr/library/patient.inc on line 1919, referer: https://mydomain.com/interface/main/tabs/main.php

[Mon Aug 12 18:53:57.640111 2019] [php7:warn] [pid 2463] [client 67.61.155.243:59198] PHP Warning: A non-numeric value encountered in /var/www/localhost/htdocs/openemr/library/patient.inc on line 1919, referer: https://mydomain.com/interface/patient_file/summary/demographics.php?set_pid=21


(TechMed) #10

Ralf, my client used to get same “non-numeric value” errors re: [OpenEMR]/library/patient.inc file after 5.0.2 and PHP 7.2 upgrades /Linux/.

Here is how I did bypass it (a temp solution):

  1. Edit [OpenEMR]/library/patient.inc file (make a file backup beforehand)

  2. Find two lines with the following calcs causing these errors:

    a. $yearDiff = $nowYear - $dobYear;
    b. $ageInMonths = (($nowYear * 12) + $nowMonth) - (($dobYear*12) + $dobMonth);

  3. Replace with the following code:

    // A non-numeric value encountered error temp fix
    if (is_numeric($dobYear))
    {
    $yearDiff = $nowYear - $dobYear;
    }
    else
    {
    //echo “Not Numeric”;
    }

// A non-numeric value encountered error temp fix
if (is_numeric($dobYear))
{
$ageInMonths = (($nowYear * 12) + $nowMonth) - (($dobYear*12) + $dobMonth);
}
else
{
//echo “Not Numeric”;
}

That should do it for you for now. I had checked client’s database and it did contain valid patients’ DOB data so this seems to me most likely it has to do with a newer PHP 7.1+ version being more sensitive to these type of calc data (not specifically to latest OpenEMR 5.0.2 ver) – so yes, we’re looking forward for a perm solution for this. Cheers.


(TechMed) #11

To add on… yes, you could do it all in one IF statement bloc but I always treat each calc separately for a troubleshooting purpose, even if they are two in one line after each other. Cheers.

// A non-numeric dobYear value encountered error temp fix
if (is_numeric($dobYear))
{
$yearDiff = $nowYear - $dobYear;
$ageInMonths = (($nowYear * 12) + $nowMonth) - (($dobYear*12) + $dobMonth);
}
else
{
//echo “Not Numeric”;
}


(Ralf Lukner MD PhD) #12

Thank you, @TechMed! I will try out your temp fix and see how it works.
–Ralf


(Ralf Lukner MD PhD) #13

I made the temporary fix … I will post again if this does not repair the original issue or if there is an issue related to this fix:

$dayDiff = $nowDay - $dobDay;                                                                      
$monthDiff = $nowMonth - $dobMonth;                                                                
// $yearDiff = $nowYear - $dobYear;                                                                
                                                                                                   
// A non-numeric value encountered error temp fix                                                  
if (is_numeric($dobYear))                                                                          
{                                                                                                  
   $yearDiff = $nowYear - $dobYear;                                                                
   $ageInMonths = (($nowYear * 12) + $nowMonth) - (($dobYear*12) + $dobMonth);                     
}                                                                                                  
else                                                                                               
{                                                                                                  
   //echo ...Not Numeric...;                                                                       
}                                                                                                  
                                                                                                   
// $ageInMonths = (($nowYear * 12) + $nowMonth) - (($dobYear*12) + $dobMonth);

(Brady Miller) #14

Hi @Ralf_Lukner ,

That php warning is likely not why your error is happening. Albeit we definitely want to fix php warnings; are you able to push your fix as a Pull Request to github?(if not, I can do this)

We can try to be more specific on the log where we just look for certain element; in this case maybe interface/main/calendar/index.php. So, could try:

docker exec -i standard_openemr_1 sh -c 'grep -A 5 -B 5 "interface/main/calendar/index.php" /var/log/apache2/error.log'

(this will return place in log with interface/main/calendar/index.php in addition to 5 lines above and below each “hit”)

-brady


(Ralf Lukner MD PhD) #15

Hello @brady.miller,

I agree. This is not likely the issue of the original problem.

I will try to push the change in there to openemr on GitHub. I would like to learn how (I have never done this before but I have some idea of what version control is). I have the GitHub desktop program and PHPStorm on my Mac. I could set up a development system on an EC2 instance if I need to. Which branch am I supposed to push the change to? Also, are there any suggestions/guides on things I should or should not do with regard to the push’ing the Pull Request?

See text file of output, attached.

scratch.gitignore (22.6 KB)
–Ralf


(Ralf Lukner MD PhD) #16

@brady.miller
One of my staff just saw this issue and the error.log did not change so I do not know why this is happening. This staff member was able to reproduce the issue on two different Windows 10 PCs with the latest version of Chrome. I have debugging on, so if there was a code-level error, it would present that.

Update: Found this in the error log:
[Sun Aug 25 22:23:23.622504 2019] [php7:error] [pid 28] [client 185.53.88.54:33732] script ‘/var/www/localhost/htdocs/openemr/about.php’ not found or unable to stat

[Sun Aug 25 22:25:24.836205 2019] [allowmethods:error] [pid 22] [client 149.202.10.237:21611] AH01623: client method denied by server configuration: ‘CONNECT’ to /var/www/localhost/htdocs/openemr/

[Sun Aug 25 22:28:12.444638 2019] [php7:error] [pid 30] [client 185.53.88.54:44664] script ‘/var/www/localhost/htdocs/openemr/about.php’ not found or unable to stat

[Mon Aug 26 11:26:53.687038 2019] [allowmethods:error] [pid 239] [client 124.88.113.154:2009] AH01623: client method denied by server configuration: ‘CONNECT’ to /var/www/localhost/htdocs/openemr/

[Mon Aug 26 11:26:56.289208 2019] [allowmethods:error] [pid 265] [client 112.66.99.200:18213] AH01623: client method denied by server configuration: ‘CONNECT’ to /var/www/localhost/htdocs/openemr/

[Mon Aug 26 11:27:02.527585 2019] [allowmethods:error] [pid 319] [client 111.224.234.70:54478] AH01623: client method denied by server configuration: ‘CONNECT’ to /var/www/localhost/htdocs/openemr/
–Ralf


(R Magauran) #17

I found this error is filling the logs now also. It is rooted in the Calendar I believe. The Calendar is looking for things to display in “interface/main/calendar/modules/PostCalendar/pnuserapi.php”. As it builds its array, it looks to the function getPatientAge for each member in the array, including NON patient things like out of office etc.

interface/main/calendar/modules/PostCalendar/pnuserapi.php:

$events[$i][‘patient_age’] = getPatientAge($tmp[‘patient_dob’]);

$tmp[‘patient_dob’] is empty if there is no patient in the event…
if the Calendar is the only place causing this problem, maybe the fix should be there?

if (!empty($tmp[‘patient_dob’])) {
$events[$i][‘patient_age’] = getPatientAge($tmp[‘patient_dob’]);
} else {
$events[$i][‘patient_age’] = ‘’;
}

Alternatively, if there are other places raising this error, the fix can be here ( patient.inc) as Ralf points out.
I added this as the first line of the function and it works also:

if (empty($dobYMD)) return false;

I’ll let @brady.miller figure out which is best. If you want an official PR I can do that also.