markleeds wrote on Friday, July 08, 2005:
I have been doing a little exploring to see what happens with the various variables that maintain state in OpenEMR. The code below (see A below) is something I stuck at the end of interface/globals.php. I also tried putting it at the beginning, thinking that some variables might be cleared or changed. I then played around in OpenEMR and with each click, checked my log file. Of course, it generates a lot of output because with each click, globals.php is included in every frame loaded. It should not be loaded any more than once per frame I think because it is always included with include_once().
One thing I was wondering about was the interface/patient_file/patient_file.php code. There are three possible presentations based on the if, elseif, else statements (see B below). I observed that only the else statement code was executed as I browsed around a patient folder. Even when starting an encounter. Using grep, I found only one place where the elseif statement might be called from:
./interface/main/calendar/modules/PostCalendar/pntemplates/default/user/patient_line.html:12: <a href="[-$TPL_ROOTDIR-]/patient_file/patient_file.php?go=encounter&pid=[-$event.pid-]&set_pid=[-$event.pid-]" target="_top"><img align="middle" src="[-$TPL_IMAGE_PATH-]/encounter_hotlink.gif" border="0" vspace="0" hspace="0"/></a>
I assume this would be linking from the calendar to an encounter, but I’m not sure.
Regarding the if statement, I don’t know what calenc is. All of the lines that use it are setting it to itself, like this: <frame src=“encounter/patient_encounter.php?mode=new&calenc=<?echo $_GET[“calenc”];?>” name=“Main” scrolling=“AUTO” noresize frameborder=“0”>
Little question: what is calenc?
Big questions: does this method of learning how OpenEMR works make any sense? Besides this, I have tried logging sql statements by intercepting them in the functions in library/sql.inc. Is there a better way to explore/debug? Is anyone interested in a section of the wiki for discussing the structure of the code and how things work and don’t work?
Thanks!
-Mark
A) incorporated into interface/globals.php
---------------------------------------
//debug
$fp = fopen("/usr/local/apache2/htdocs/openemr4/log_debug", "a");
fwrite($fp, "-------------------------------------------------------------------\n");
fwrite($fp, strftime("%D %T")."\n");
fwrite($fp, "GET\n");
foreach($_GET as $key => $value) { fwrite($fp, "$key = $value\n"); }
fwrite($fp, "POST\n");
foreach($_POST as $key => $value) { fwrite($fp, "$key = $value\n"); }
fwrite($fp, "SESSION\n");
foreach($_SESSION as $key => $value) { fwrite($fp, "$key = $value\n"); }
fwrite($fp, "-------------------------------------------------------------------\n");
fclose($fp);
//debug
?>
B) cut from interface/patient_file/patient_file.php with additional debug code
---------------------------------------------------------------------------
if (isset($_GET[“calenc”])) {
$_SESSION[‘mjl_debug’] = “get calenc”;
:?>
<frame src=“navigation.php” name=“Navigation” scrolling=“NO” noresize frameborder=“0”> <frame src=“encounter/encounter_title.php” name=“Title” scrolling=“no” noresize frameborder=“0”> <frame src=“encounter/patient_encounter.php?mode=new&calenc=<?echo $_GET[“calenc”];?>” name=“Main” scrolling=“AUTO” noresize frameborder=“0”> <?}
elseif ($_GET[‘go’] == “encounter”){
$_SESSION[‘mjl_debug’] = “get go encounter”;
?>
<frame src=“navigation.php?pid=<?=$_GET[‘pid’]?>&set_pid=<?=$_GET[‘pid’]?>” name=“Navigation” scrolling=“NO” noresize frameborder=“0”>
<frame src=“encounter/encounter_title.php?pid=<?=$_GET[‘pid’]?>&set_pid=<?=$_GET[‘pid’]?>” name=“Title” scrolling=“no” noresize frameborder=“0”>
<frame src=“encounter/patient_encounter.php?mode=new&pid=<?=$_GET[‘pid’]?>&set_pid=<?=$_GET[‘pid’]?>” name=“Main” scrolling=“AUTO” noresize frameborder=“0”>
<?
}
else {
$_SESSION[‘mjl_debug’] = “else”;
?>
<frame src=“navigation.php” name=“Navigation” scrolling=“NO” noresize frameborder=“0”>
<frame src=“summary/summary_title.php” name=“Title” scrolling=“no” noresize frameborder=“0”>
<frame src=“summary/patient_summary.php” name=“Main” scrolling=“AUTO” noresize frameborder=“0”><?}