Encounter error

voipbound wrote on Wednesday, October 22, 2008:

There hasn’t been a problem with the encounters until last 2-3 wks when I would get an error display at the bottom half of the encounter screen.  Let me post my php file and see if yours is like mine.  I am using 2.9 version.

/var/www/openemr/interface/patient_file/history/encounters.php

<?php
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.

include_once("…/…/globals.php");
include_once("$srcdir/forms.inc");
include_once("$srcdir/billing.inc");
include_once("$srcdir/pnotes.inc");
include_once("$srcdir/patient.inc");
include_once("$srcdir/lists.inc");
include_once("$srcdir/acl.inc");
include_once("$srcdir/sql-ledger.inc");
include_once("$srcdir/invoice_summary.inc.php");
include_once("…/…/…/custom/code_types.inc.php");

$accounting_enabled = $GLOBALS[‘oer_config’][‘ws_accounting’][‘enabled’];

//maximum number of encounter entries to display on this page:
$N = 12;

// Get relevant ACL info.
$auth_notes_a  = acl_check(‘encounters’, ‘notes_a’);
$auth_notes    = acl_check(‘encounters’, ‘notes’);
$auth_coding_a = acl_check(‘encounters’, ‘coding_a’);
$auth_coding   = acl_check(‘encounters’, ‘coding’);
$auth_relaxed  = acl_check(‘encounters’, ‘relaxed’);
$auth_med      = acl_check(‘patients’  , ‘med’);
$auth_demo     = acl_check(‘patients’  , ‘demo’);

$tmp = getPatientData($pid, “squad”);
if ($tmp[‘squad’] && ! acl_check(‘squads’, $tmp[‘squad’]))
  $auth_notes_a = $auth_notes = $auth_coding_a = $auth_coding = $auth_med = $auth_demo = $auth_relaxed = 0;

if (!($auth_notes_a || $auth_notes || $auth_coding_a || $auth_coding || $auth_med || $auth_relaxed)) {
  echo “<body>\n<html>\n”;
  echo “<p>(”.xl(‘Encounters not authorized’).")</p>\n";
  echo “</body>\n</html>\n”;
  exit();
}

// Perhaps the view choice should be saved as a session variable.
//
$tmp = sqlQuery("select authorized from users " .
  “where id = '” . $_SESSION[‘authUserID’] . “’”);
$billing_view = $tmp[‘authorized’] ? 0 : 1;
if (isset($_GET[‘billing’]))
  $billing_view = empty($_GET[‘billing’]) ? 0 : 1;

// This is called to generate a line of output for a patient document.
//
function showDocument(&$drow) {
  global $ISSUE_TYPES, $auth_med;

  $docdate = $drow[‘docdate’];

  $href = “javascript:todocument(” . $drow[‘id’] . “)”;
  $linkbeg = “<a class=‘text’ href=’$href’ style=‘color:#0000ff’>”;
  $linkend = “</a>”;

  echo "<tr>\n";

  // show date
  echo “<td valign=‘top’>$linkbeg$docdate$linkend</td>\n”;

  // show associated issue, if any
  echo “<td valign=‘top’>$linkbeg”;
  if ($auth_med) {
    $irow = sqlQuery("SELECT type, title, begdate " .
      "FROM lists WHERE " .
      “id = '” . $drow[‘list_id’] . "’ " .
      “LIMIT 1”);
    if ($irow) {
      $tcode = $irow[‘type’];
      if ($ISSUE_TYPES[$tcode]) $tcode = $ISSUE_TYPES[$tcode][2];
      echo "$tcode: " . $irow[‘title’];
    }
  } else {
    echo “(” . xl(‘No access’) . “)”;
  }
  echo “$linkend</td>\n”;

  // show document name and category
  echo “<td valign=‘top’ colspan=‘3’>$linkbeg” .
    xl(‘Document’) . ": " .
    basename($drow[‘url’]) . ’ (’ . $drow[‘name’] . ‘)’ .
    “$linkend</td>\n”;

  // skip insurance column
  if (!$GLOBALS[‘athletic_team’]) {
    echo “<td valign=‘top’>&nbsp;</td>\n”;
  }

  echo "</tr>\n";
}
?>
<html>
<head>
<?php html_header_show();?>
<link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
<script type="text/javascript" src="…/…/…/library/tooltip.js"></script>

<script language="JavaScript">

function toencounter(enc, datestr) {
  top.restoreSession();
<?php if ($GLOBALS[‘concurrent_layout’]) { ?>
  parent.left_nav.setEncounter(datestr, enc, window.name);
  parent.left_nav.setRadio(window.name, ‘enc’);
  location.href  = ‘…/encounter/encounter_top.php?set_encounter=’ + enc;
<?php } else { ?>
  top.Title.location.href = ‘…/encounter/encounter_title.php?set_encounter=’   + enc;
  top.Main.location.href  = ‘…/encounter/patient_encounter.php?set_encounter=’ + enc;
<?php } ?>
}

function todocument(docid) {
  h = ‘…/…/…/controller.php?document&view&patient_id=<?php echo $pid ?>&doc_id=’ + docid;
  top.restoreSession();
<?php if ($GLOBALS[‘concurrent_layout’]) { ?>
  parent.left_nav.setRadio(window.name, ‘doc’);
  location.href = h;
<?php } else { ?>
  top.Main.location.href = h;
<?php } ?>
}

// Helper function to set the contents of a div.
function setDivContent(id, content) {
  if (document.getElementById) {
   var x = document.getElementById(id);
   x.innerHTML = ‘’;
   x.innerHTML = content;
  }
  else if (document.all) {
   var x = document.all[id];
   x.innerHTML = content;
  }
}

// Called when clicking on a billing note.
function editNote(feid) {
  top.restoreSession(); // this is probably not needed
  var c = “<iframe src='edit_billnote.php?feid=” + feid +
    “’ style=‘width:100%;height:88pt;’></iframe>”;
  setDivContent(‘note_’ + feid, c);
}

// Called when the billing note editor closes.
function closeNote(feid, fenote) {
  var c = “<div onclick='editNote(” + feid +
   “)’ title=‘Click to edit’ class=‘text’ style=‘cursor:pointer’>” +
   fenote + “</div>”;
  setDivContent(‘note_’ + feid, c);
}

</script>

</head>

<body class="body_bottom">

<div id=‘tooltipdiv’
style=‘position:absolute;width:500px;border:1px solid black;padding:2px;background-color:#ffffaa;visibility:hidden;z-index:1000;font-size:9pt;’
></div>

<?php if ($GLOBALS[‘concurrent_layout’]) { ?>
<!-- <a href=‘encounters_full.php’> -->
<?php } else { ?>
<!-- <a href=‘encounters_full.php’ target=‘Main’> -->
<?php } ?>
<font class=‘title’><?php xl(‘Past Encounters and Documents’,‘e’); ?></font>
&nbsp;&nbsp;

<?php if ($billing_view) { ?>
<a href=‘encounters.php?billing=0’ onclick=‘top.restoreSession()’ style=‘font-size:8pt’>(To Clinical View)</a>
<?php } else { ?>
<a href=‘encounters.php?billing=1’ onclick=‘top.restoreSession()’ style=‘font-size:8pt’>(To Billing View)</a>
<?php } ?>

<br>

<table width=“100%”>
<tr>
  <td class=‘bold’><?php xl(‘Date’,‘e’);        ?></td>

<?php if ($billing_view) { ?>
  <td class=‘bold’ style=‘width:25%’><?php xl(‘Billing Note’,‘e’); ?></td>
<?php } else { ?>
  <td class=‘bold’><?php xl(‘Issue’,‘e’);       ?></td>
  <td class=‘bold’><?php xl(‘Reason/Form’,‘e’); ?></td>
  <td class=‘bold’><?php xl(‘Provider’,‘e’);    ?></td>
<?php } ?>

<?php if ($billing_view && $accounting_enabled) { ?>
  <td class=‘bold’>Code</td>
  <td class=‘bold’ align=‘right’>Chg</td>
  <td class=‘bold’ align=‘right’>Paid</td>
  <td class=‘bold’ align=‘right’>Adj</td>
  <td class=‘bold’ align=‘right’>Bal</td>
<?php } else { ?>
  <td class=‘bold’ colspan=‘5’><?php echo ($GLOBALS[‘phone_country_code’] == ‘1’) ? ‘Billing’ : ‘Coding’ ?></td>
<?php } ?>

<?php if (!$GLOBALS[‘athletic_team’]) { ?>
  <td class=‘bold’>&nbsp;<?php xl(($GLOBALS[‘weight_loss_clinic’] ? ‘Payment’ : ‘Insurance’),‘e’); ?></td>
<?php } ?>

</tr>

<?php
$drow = false;
if (! $billing_view) {
  // Query the documents for this patient.
  $dres = sqlStatement("SELECT d.id, d.type, d.url, d.docdate, d.list_id, c.name " .
    "FROM documents AS d, categories_to_documents AS cd, categories AS c WHERE " .
    "d.foreign_id = ‘$pid’ AND cd.document_id = d.id AND c.id = cd.category_id " .
    “ORDER BY d.docdate DESC, d.id DESC”);
  $drow = sqlFetchArray($dres);
}

$count = 0;
if ($result = getEncounters($pid)) {

  if ($billing_view && $accounting_enabled) SLConnect();

$bgcolor = ( $bgcolor===’#ddddff’ ? “#ffdddd” : “#ddddff”);

foreach ($result as $iter ) {
  foreach ($result as $iter ) {
    // $count++; // Forget about limiting the number of encounters
    if ($count > $N) {
      //we have more encounters to print, but we’ve reached our display maximum
      print “<tr><td colspan=‘4’ align=‘center’>” .
        “<a target=‘Main’ href=‘encounters_full.php’ class=‘alert’ onclick=‘top.restoreSession()’>” .
        xl(‘Some encounters were not displayed. Click here to view all.’) .
        “</a></td></tr>\n”;
      break;
    }

    // $href = “javascript:window.toencounter(” . $iter[‘encounter’] . “)”;
    $reason_string = “”;
    $auth_sensitivity = true;
    // $linkbeg = “<a class=‘text’ href=’$href’>”;
    $linkend = “</a>”;

    $raw_encounter_date = ‘’;
    if ($result4 = sqlQuery(“SELECT * FROM form_encounter WHERE encounter = '” .
      $iter{“encounter”} . “’ AND pid = ‘$pid’”))
    {
      $raw_encounter_date = date(“Y-m-d”, strtotime($result4{“date”}));
      $encounter_date = date(“D F jS”, strtotime($result4{“date”}));

      // if ($auth_notes_a || ($auth_notes && $iter[‘user’] == $_SESSION[‘authUser’]))
      $reason_string .= $result4{“reason”} . “<br>\n”;
      // else
      //   $reason_string = “(No access)”;

      $href = “javascript:window.toencounter(” . $iter[‘encounter’] . “,&quot;$raw_encounter_date&quot;)”;
      $linkbeg = “<a class=‘text’ href=’$href’>”;

      if ($result4[‘sensitivity’]) {
        $auth_sensitivity = acl_check(‘sensitivities’, $result4[‘sensitivity’]);
        if (!$auth_sensitivity) {
          $reason_string = “(No access)”;
          $linkbeg = “<span class=‘text’>”;
          $linkend = “</span>”;
        }
      }
    }

    $erow = sqlQuery(“SELECT user FROM forms WHERE encounter = '” .
      $iter[‘encounter’] . “’ AND formdir = ‘newpatient’ LIMIT 1”);

    // This generates document lines as appropriate for the date order.
    while ($drow && $raw_encounter_date && $drow[‘docdate’] > $raw_encounter_date) {
      showDocument($drow);
      $drow = sqlFetchArray($dres);
    }

    // Fetch all forms for this encounter, if the user is authorized to see
    // this encounter’s notes and this is the clinical view.
    //
    $encarr = array();
    $encounter_rows = 1;
    if (!$billing_view && $auth_sensitivity &&
      ($auth_notes_a || ($auth_notes && $iter[‘user’] == $_SESSION[‘authUser’])))
    {
      $encarr = getFormByEncounter($pid, $iter[‘encounter’], “formdir, user, form_name, form_id”);
      $encounter_rows = count($encarr);
    }

    echo “<tr bgcolor=’$bgcolor’>\n”;

    // show encounter date
    echo “<td valign=‘top’>$linkbeg$raw_encounter_date$linkend</td>\n”;

    if ($billing_view) {

      // Show billing note that you can click on to edit.
      $feid = $result4[‘id’] ? $result4[‘id’] : 0; // form_encounter id
      echo “<td valign=‘top’>”;
      echo “<div id=‘note_$feid’>”;
      echo “<div onclick=‘editNote($feid)’ title=‘Click to edit’ class=‘text’ style=‘cursor:pointer’>”;
      echo $result4[‘billing_note’] ? nl2br($result4[‘billing_note’]) : ‘[Add]’;
      echo “</div>”;
      echo “</div>”;
      echo “</td>\n”;

    } // end billing view
    else {

      // show issues for this encounter
      echo “<td valign=‘top’>$linkbeg”;
      if ($auth_med && $auth_sensitivity) {
        $ires = sqlStatement("SELECT lists.type, lists.title, lists.begdate " .
          "FROM issue_encounter, lists WHERE " .
          "issue_encounter.pid = ‘$pid’ AND " .
          “issue_encounter.encounter = '” . $iter[‘encounter’] . "’ AND " .
          "lists.id = issue_encounter.list_id " .
          “ORDER BY lists.type, lists.begdate”);
        for ($i = 0; $irow = sqlFetchArray($ires); ++$i) {
          if ($i > 0) echo “<br>”;
          $tcode = $irow[‘type’];
          if ($ISSUE_TYPES[$tcode]) $tcode = $ISSUE_TYPES[$tcode][2];
          echo "$tcode: " . $irow[‘title’];
        }
      } else {
        echo “(” . xl(‘No access’) . “)”;
      }
      echo “$linkend</td>\n”;

      // show encounter reason/title
      echo “<td valign=‘top’>$linkbeg” .
        $reason_string . “$linkend</td>\n”;

      // show user who created the encounter
      echo “<td valign=‘top’>$linkbeg” .
        $erow[‘user’] . “$linkend</td>\n”;

    } // end not billing view

    //this is where we print out the text of the billing that occurred on this encounter
    $thisauth = $auth_coding_a;
    if (!$thisauth && $auth_coding) {
      if ($erow[‘user’] == $_SESSION[‘authUser’])
        $thisauth = $auth_coding;
    }
    $coded = “”;
    $arid = 0;
    if ($thisauth && $auth_sensitivity) {
     $binfo = array(’’, ‘’, ‘’, ‘’, ‘’);
     if ($subresult2 = getBillingByEncounter($pid, $iter[‘encounter’],
      “code_type, code, modifier, code_text, fee”))
     {
      // Get A/R info, if available, for this encounter.
      $arinvoice = array();
      $arlinkbeg = “”;
      $arlinkend = “”;
      if ($billing_view && $accounting_enabled) {
        $arid = SLQueryValue(“SELECT id FROM ar WHERE invnumber = " .
          “’$pid.{$iter[‘encounter’]}’”);
        if ($arid) {
          $arinvoice = get_invoice_summary($arid, true);
          $arlinkbeg = “<a href=’…/…/billing/sl_eob_invoice.php?id=$arid’” .
            " target=’_blank’ class=‘text’ style=‘color:#00cc00’>”;
          $arlinkend = “</a>”;
        }
      }

      // This creates 5 columns of billing information:
      // billing code, charges, payments, adjustments, balance.
      foreach ($subresult2 as $iter2) {
        // Next 2 lines were to skip diagnoses, but that seems unpopular.
        // if ($iter2[‘code_type’] != ‘COPAY’ &&
        //   !$code_types[$iter2[‘code_type’]][‘fee’]) continue;
        $title = addslashes($iter2[‘code_text’]);
        $codekey = $iter2[‘code’];
        if ($iter2[‘code_type’] == ‘COPAY’) $codekey = ‘CO-PAY’;
        if ($iter2[‘modifier’]) $codekey .= ‘:’ . $iter2[‘modifier’];
        if ($binfo[0]) $binfo[0] .= ‘<br>’;
        $binfo[0] .= "<span " .
          “onmouseover=‘ttshow(this,&quot;$title&quot;)’ onmouseout=‘tthide()’>” .
          $arlinkbeg . $codekey . $arlinkend . “</span>”;
        if ($billing_view && $accounting_enabled) {
          if ($binfo[1]) {
            for ($i = 1; $i < 5; ++$i) $binfo[$i] .= ‘<br>’;
          }
          if (empty($arinvoice[$codekey])) {
            // If no invoice, show the fee.
            if ($arlinkbeg)
              $binfo[1] .= ‘&nbsp;’;
            else
              $binfo[1] .= sprintf(’%.2f’, $iter2[‘fee’]);
            for ($i = 2; $i < 5; ++$i) $binfo[$i] .= ‘&nbsp;’;
          }
          else {
            $binfo[1] .= sprintf(’%.2f’, $arinvoice[$codekey][‘chg’] + $arinvoice[$codekey][‘adj’]);
            $binfo[2] .= sprintf(’%.2f’, $arinvoice[$codekey][‘chg’] - $arinvoice[$codekey][‘bal’]);
            $binfo[3] .= sprintf(’%.2f’, $arinvoice[$codekey][‘adj’]);
            $binfo[4] .= sprintf(’%.2f’, $arinvoice[$codekey][‘bal’]);
            unset($arinvoice[$codekey]);
          }
        }
      } // end foreach
      // Pick up any remaining unmatched invoice items from the accounting
      // system.  Display them in red, as they should be unusual.
      if ($accounting_enabled && !empty($arinvoice)) {
        foreach ($arinvoice as $codekey => $val) {
          if ($binfo[0]) {
            for ($i = 0; $i < 5; ++$i) $binfo[$i] .= ‘<br>’;
          }
          for ($i = 0; $i < 5; ++$i) $binfo[$i] .= “<font color=‘red’>”;
          $binfo[0] .= $codekey;
          $binfo[1] .= sprintf(’%.2f’, $val[‘chg’] + $val[‘adj’]);
          $binfo[2] .= sprintf(’%.2f’, $val[‘chg’] - $val[‘bal’]);
          $binfo[3] .= sprintf(’%.2f’, $val[‘adj’]);
          $binfo[4] .= sprintf(’%.2f’, $val[‘bal’]);
          for ($i = 0; $i < 5; ++$i) $binfo[$i] .= “</font>”;
        }
      }
     } // end if there is billing
     echo “<td class=‘text’ valign=‘top’ rowspan=’$encounter_rows’ nowrap>” .
       $binfo[0] . “</td>\n”;
     for ($i = 1; $i < 5; ++$i) {
       echo “<td class=‘text’ valign=‘top’ align=‘right’ rowspan=’$encounter_rows’ nowrap>” .
         $binfo[$i] . “</td>\n”;
     }
    } // end if authorized
    else {
      echo “<td class=‘text’ valign=‘top’ colspan=‘5’ rowspan=’$encounter_rows’>(No access)</td>\n”;
    }

    // show insurance
    if (!$GLOBALS[‘athletic_team’]) {
      $insured = “$raw_encounter_date”;
      if ($auth_demo) {
        $responsible = $arid ? responsible_party($arid) : -1;

        $subresult5 = getInsuranceDataByDate($pid, $raw_encounter_date, “primary”);
        if ($subresult5 && $subresult5{“provider_name”}) {
          $style = $responsible == 1 ? " style=‘color:red’" : “”;
          $insured = “<span class=‘text’$style>&nbsp;” . xl(‘Primary’) . “: " .
            $subresult5{“provider_name”} . “</span><br>\n”;
        }
        $subresult6 = getInsuranceDataByDate($pid, $raw_encounter_date, “secondary”);
        if ($subresult6 && $subresult6{“provider_name”}) {
          $style = $responsible == 2 ? " style=‘color:red’” : “”;
          $insured .= “<span class=‘text’$style>&nbsp;” . xl(‘Secondary’) . “: " .
            $subresult6{“provider_name”} . “</span><br>\n”;
        }
        $subresult7 = getInsuranceDataByDate($pid, $raw_encounter_date, “tertiary”);
        if ($subresult6 && $subresult7{“provider_name”}) {
          $style = $responsible == 3 ? " style=‘color:red’” : “”;
          $insured .= “<span class=‘text’$style>&nbsp;” . xl(‘Tertiary’) . “: " .
            $subresult7{“provider_name”} . “</span><br>\n”;
        }
        if ($responsible == 0) {
          $insured .= “<span class=‘text’ style=‘color:red’>&nbsp;” . xl(‘Patient’) .
            “</span><br>\n”;
        }
      } else {
        $insured = " (No access)”;
      }
      echo “<td valign=‘top’>$linkbeg” .
        $insured . “$linkend</td>\n”;
    }

    echo "</tr>\n";

    if (! $billing_view) {

      // Now show a line for each encounter form, if the user is authorized to
      // see this encounter’s notes.
      //
      foreach ($encarr as $enc) {
        if ($enc[‘formdir’] == ‘newpatient’) continue;

        $title = “”;
        if ($enc[‘formdir’] != ‘physical_exam’) {
          $frow = sqlQuery(“select * from form_” . $enc[‘formdir’] .
            " where id = " . $enc[‘form_id’]);
          foreach ($frow as $fkey => $fvalue) {
            if (! preg_match(’/[A-Za-z]/’, $fvalue)) continue;
            if ($title) $title .= "; ";
            $title .= strtoupper($fkey) . ': ’ . $fvalue;
          }
          $title = htmlspecialchars(strtr($title, “\t\n\r”, "   "), ENT_QUOTES);
        }

        echo “<tr bgcolor=’$bgcolor’>\n”;
        echo " <td valign=‘top’ colspan=‘2’></td>\n";
        echo " <td valign=‘top’ " .
          “onmouseover=‘ttshow(this,&quot;$title&quot;)’ onmouseout=‘tthide()’>” .
          “$linkbeg&nbsp;&nbsp;&nbsp;” .
          $enc[‘form_name’] . “$linkend</td>\n”;
        echo " <td valign=‘top’ colspan=‘2’>$linkbeg" .
          $enc[‘user’] . “$linkend</td>\n”;
        echo “</tr>\n”;
      } // end foreach $encarr

    } // end if not billing view

  } // end foreach $result

  if ($billing_view && $accounting_enabled) SLClose();

} // end if

// Dump remaining document lines if count not exceeded.
while ($drow && $count <= $N) {
  showDocument($drow);
  $drow = sqlFetchArray($dres);
}
?>

</table>

</body>
</html>

voipbound wrote on Thursday, October 23, 2008:

can anyone help?

markleeds wrote on Thursday, October 23, 2008:

What was the error?

If you attempt to manually delete encounter data directly from the database, you will get an error if you do not delete the appropriate entries from the forms table.

This probably has nothing to do with your problem, but I am just guessing based on your description.

voipbound wrote on Friday, October 24, 2008:

Actually, I did not notice it before but the error is found on the bottom half of the screen, in the second window on both the History and Encounter tab.  The error is "Parse error: syntax error, unexpected $end in /var/www/openemr/interface/patient_file/history/encounters.php on line 522" on both of the screens.

cfapress wrote on Wednesday, October 29, 2008:

That’s an odd error. In my encounters.php file, fresh from CVS, there are not 522 lines in the file. So having an error on line 522 would be impossible. I’ve got 518 lines.

But when I copied and pasted your code into an editor I could see 522 lines if the last one was a blank. The PHP error indicates either a variable problem or it reached the end of some PHP code without a closing bracket. Yet I clearly see a closing ‘?>’ in your code.

Did you make edits to the code?

You could try grabbing a fresh copy of the file directly from CVS. It hasn’t really changed much.
http://openemr.cvs.sourceforge.net/viewvc/openemr/openemr/interface/patient_file/history/

Jason

voipbound wrote on Tuesday, November 04, 2008:

No I did no alter the encounter.php or know of its existence until the error.  I will look at the CVS and download the original to see if that correct the problem.  THank you…

voipbound wrote on Tuesday, November 04, 2008:

Well did that and it still show the same error.  Now a bunch or other errors are cropping up for no reason.  How do I reinstall and still keep the patient data, meds, icd9, etc…?

voipbound wrote on Wednesday, November 05, 2008:

Well, problem fixed by overwriting back up encounter.php to the one with error.  Thread end.

ideaman911 wrote on Sunday, November 09, 2008:

Hi;

I am a newbie, so please be gentle.  I do not program in PHP, but I am able to make edits if clearly understood.

On my fresh install of OpenEMR (it is in Windows, but i don’t think that matters), I have two problems with “Encounters”.

a)  Even though the "New Encounters" I enter seem to post properly to their databases, as soon as I have entered the very first encounter, all displays of the "Encounters" screen give the following message, except that the PID codes are different:

ERROR: query failed: select formdir, user, form_name, form_id from forms where encounter = ‘2’ and pid=‘3’ ORDER BY FIND_IN_SET(formdir,‘vitals’) DESC, date DESC

Error: Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation ‘find_in_set’

b)  In the “Reports” areas, all “encounters” are labeled with “New Patient Encounter”.  That is confusing for my provider/user who would prefer it to say only “Patient Encounter” unless it ius actually for a “New Patient”.  How do I fix that?  My guess is an edit in a “Globals.PHP” or “Reportnnnn.PHP” files, but unsure which, and don’t want to make the situation simply worse.

Note that after I enter the encounter, the encounters list gives me the error above, but the reports pages all seem to show the encounter.

Help?

ideaman911 wrote on Monday, November 10, 2008:

I forgot to mention; the error displays ONLY for the clinical view - the Billing View has no problem.  Switching back and forth gives the same error every time any encounter has been entered for the select patient, and shows up at the clinical view.

voipbound wrote on Tuesday, November 11, 2008:

I do not know how to help with this problem because I am also new and learning as I go along.  I have not ran across this problem yet.  One thing I have learned is that the error message you get does not necessarily reflect the error of whatever file that it is stating.  The error has almost always been away from that actual file.  That probably is not what you are hoping for but it may point you away and start looking for other potential problem.

cfapress wrote on Thursday, November 13, 2008:

Joe,

I’ll try to help.

Problem 1)
----------
Sounds like a MySQL configuration error:
Log into OpenEMR as an administrator.
Click on the Admin link.
Click on the Database link.
What does phpMyAdmin say you have for Language?
You should see it in the main body of the web page. Mine says "English en-iso-8859-1"

This is just the start for diagnosing the trouble but I’m strongly leaning toward a configuration error with MySQL on your machine.

Problem 2)
----------
You’re seeing ‘New Patient Encounter’ because that is how the form name is saved to the database. Each patient encounter is saved as a ‘form’ into the MySQL table “forms”. If you use the Admin tool ‘Database’ you can look at the ‘forms’ table to see what I’m talking about. It seems the term ‘New Patient Encounter’ is a standard. It’s also referenced many times in the source code too. So I don’t believe there is a simple solution here. New code would need to be crafted.

This could be something added as a new feature request here:
http://sourceforge.net/tracker/?group_id=60081&atid=493004

Click on the link that says ‘add new artifact’. How’s that for a cryptic description?!

Let us know about your MySQL stuff previously mentioned.
Jason

voipbound wrote on Wednesday, November 26, 2008:

I noted a new error now.  I am listing it here because I think it is related from the same problem as above.  After I updated to Ubuntu 8.1, all these error started.

This new one is related to adding new patient.  When I add new patient, I get

Fault: Code: 4 Reason ‘error executing RPC `ezybiz.add_customer’. Undefined subroutine &CT::save_customer called at /usr/share/sql-ledger/ws_server.pl line 130.

However, the patient get added fine and I can start a note on them.  Then when I go to CAMOS to add prescription, I can only add one med.  It is the last med from a list of meds that is registered.  So lets say out of 5 meds, the last one that is added is visible.  Any idea?

voipbound wrote on Wednesday, November 26, 2008:

There is another thread about this error back in 2007 with sql-ledger 2.6.  I am using 2.8.1.5 and OpenEMR 2.9.0.  I verified all the settings in my sql-ledger.conf, config.php and global.php.  They are all correct.  I even recreated MS service just in case.  No better.

https://sourceforge.net/forum/message.php?msg_id=3512639

ideaman911 wrote on Saturday, November 29, 2008:

I found the problem.  It is caused by an included instruction within the forms.inc found in \Library\ (again, I am running the Xampp setup under Windows XP, but the problem is identical in both 2.9.0 and the devel version 2.9.1 I just got from Dr Bowen which has helped me tremendously in solving some silly stuff, this being one).  Line 43 contains an $sql definition which supposed to list the encounters in some logical order according to the comment above it.  But it simply causes a logic confusion for the next instruction as it arrives in the latest downloads.

My fix, (whether it is good coding or not will be for KNOWLEDGEABLE people, unlike me, to figure out :wink: was to simply add two slashes // ahead of the line 43 instruction, and the error goes away.  I have found no functional problems with the encounters since fixing that.

I do not know if any of the other problems noted in this series are related, but that is definitely a problem as delivered in the code.

BTW - Dr Bowen has offered a spot for me to post my "lessons learned" for Windows installs, which I plan to do by yearend if my own work results continue as expected.  Hopefully they will help others.

voipbound wrote on Sunday, November 30, 2008:

Thank you for trying Holzer & CFA.  Unfortunately, none worked.  Can anyone help me with backing up the database, patient, ICD9, CPT, et…  I would like to reinstall everything and do a restore to see if that would solve my problems.  The EMR was working perfectly until I upgraded ubuntu to the current version of 8.1.

drbowen wrote on Monday, December 01, 2008:

Method 1)
The database can be dumped from inside of MyPHPAdmin or from the command line:

Method 2)
mysqldump  -u  root  -p  openemr  >  openemr.sql

Where root is the mysql root user.  Mysqldump will ask for the root user password.

openemr  is the name of your openemr database.

openemr.sql  will contain all the statements necessary to recreate the database.  The mysql server will need to be able to have write privileges on the directory where you are writing the file.  This doesn’t matter in Windows but is definitely a problem in Linux.

Method 3)
Stop the mysql server.
copy the entire mysql directory to a safe location.

Ultrparanoid method 4)
Do all three of the above.

_______________________________________________

Ubuntu 8.1 has probably changed the compile options on PHP 5.  You could recompile the PHP 5 yourself to make sure it includes the options that you need.  This may be easier than recreating your database.

Sam Bowen, MD

voipbound wrote on Monday, December 01, 2008:

I will try the backup first.  It will back up all the data right?  Then I will stop the servers and copy dir for gacl, openemr and sql.  Then I will try to recompile PHP5 through googling.  If all that do not work, I will reinstall everything.  in the future, I will definitely add a test bed environment when I put this into production.

drbowen wrote on Tuesday, December 02, 2008:

If you have gacl installed this will need to backed up separately from openemr.  What databases do you have listed in the mysql directory?

Likely the mysql is usually under /var/lib/mysql/

"Fault: Code: 4 Reason ‘error executing RPC `ezybiz.add_customer’. Undefined subroutine &CT::save_customer called at /usr/share/sql-ledger/ws_server.pl line 130. "

Is not related to OpenEMR per se but to the interaction between OpenEMR and SQL-Ledger.  This error code means that you do not have all the required PERL modules installed for this routine to work.

Sam Bowen, MD

voipbound wrote on Thursday, December 04, 2008:

So, I could not fix the problem and had to reinstall everything.  I could not dump my database at all and just copied the entire directory.  Now, how do I import the data from the backup directory?