Patient_file.php question and more

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”><?}

sunsetsystems wrote on Friday, July 08, 2005:

It certainly appears that "calenc" is leftover cruft from something that no longer exists.  It sounds like "calendar encounter" - maybe for one-time walk-ins or something, dunno.

I agree that your method of learning makes sense, especially if you are learning from it.  :-)  And yes the proposed Wiki topic sounds useful also.

– Rod <rod at sunsetsystems dot com>

markleeds wrote on Friday, July 08, 2005:

Thanks!  Sorry for posting so much code.  I guess it’s dangerous to remove stuff too quickly.  Maybe it could be tagged for future removal to give anyone a chance to jump in and say “hey, I put that there for a reason and I was about to start using it!”.  Studying this code is like an archaeological dig.  The authors and their intentions are rarely known.

I had another idea regarding documenting the program’s structure.  There could be a README file in each directory discussing what is contained in that directory and how it works and any other comments.  If each entry includes the date and author, it would be like a built in discussion.  If anyone who does not have access to the CVS stuff wants to add anything, just submit to someone who does have access. There is no need to put one in each directory at the start.  Just add them as entries come in.

sunsetsystems wrote on Friday, July 08, 2005:

Good idea!

– Rod <rod at sunsetsystems dot com>

drbowen wrote on Saturday, July 09, 2005:

I started a topic in the wiki at:

http://www.oemr.org/OpenEMRWiki/OpenEMRCodeDiscussion

markleeds wrote on Monday, July 11, 2005:

Great.  I am going to get some content up there very soon.

markleeds wrote on Tuesday, July 12, 2005:

I started work on a discussion of the code without actually getting to the code itself quite yet.  I posted what I did so far today at:

http://www.oemr.org/OpenEMRWiki/OpenEMRCodeDiscussion#preview

I tried to give some detail in the intro that a beginner could appreciate.  If anyone has time, take a look and let me know what you think.  I’ll keep going from where I left off.