light_coder wrote on Friday, September 10, 2010:
I have noticed (for a while now) that after an encounter/visit has been saved, the “Facility” name, under “Reason” always shows blank.
I have also noticed that the reason for that is that the “facility” field in the form_encounter table does not get updated.
To fix this I made some changes in the interface/forms/newpatient/save.php file which updates the form_encounter table. My changes are as followed:
$facilityresult = sqlQuery(“select name FROM facility WHERE id = $facility_id”);
$facility = $facilityresult; // This line and the one above it were added by me just to grab the facility name
if ($GLOBALS)
$normalurl = “$rootdir/patient_file/encounter/encounter_top.php”;
else
$normalurl = “$rootdir/patient_file/encounter/patient_encounter.php”;
$nexturl = $normalurl;
if ($mode == ‘new’)
{
$provider_id = $userauthorized ? $_SESSION : 0;
$encounter = $conn->GenID(“sequences”);
addForm($encounter, “New Patient Encounter”,
sqlInsert("INSERT INTO form_encounter SET " .
"date = ‘$date’, " .
"onset_date = ‘$onset_date’, " .
"reason = ‘$reason’, " .
"facility = ‘$facility’, " . // Added by me to set the facility name in the form_encounter table
"pc_catid = ‘$pc_catid’, " .
"facility_id = ‘$facility_id’, " .
"sensitivity = ‘$sensitivity’, " .
"pid = ‘$pid’, " .
"encounter = ‘$encounter’, " .
“provider_id = ‘$provider_id’”),
“newpatient”, $pid, $userauthorized, $date);
}
else if ($mode == ‘update’)
{
$id = $_POST;
$result = sqlQuery(“SELECT encounter, sensitivity FROM form_encounter WHERE id = ‘$id’”);
if ($result && !acl_check(‘sensitivities’, $result)) {
die(“You are not authorized to see this encounter.”);
}
$encounter = $result;
// See view.php to allow or disallow updates of the encounter date.
// $datepart = $_POST ? "date = ‘$date’, " : “”;
$datepart = acl_check(‘encounters’, ‘date_a’) ? "date = ‘$date’, " : “”;
sqlStatement("UPDATE form_encounter SET " .
$datepart .
"onset_date = ‘$onset_date’, " .
"reason = ‘$reason’, " .
"facility = ‘$facility’, " . // Added by me to set the facility name in the form_encounter table
"pc_catid = ‘$pc_catid’, " .
"facility_id = ‘$facility_id’, " .
"sensitivity = ‘$sensitivity’ " .
“WHERE id = ‘$id’”);
……………
……………
I have added comments (above) wherever I made changes.
I am no database expert, but that’s how I was able to fix this. There may be more efficient or secure ways to do this. You guys can look into it and let us know.
Thanks
Jude