From 70542b0ea93982d4005a1f58cf123247e2ae2f8f Mon Sep 17 00:00:00 2001 From: Rod Roark Date: Mon, 5 Mar 2012 12:31:57 -0800 Subject: [PATCH] Implemented AJAX tooltips to show encounter form data from the encounters list. --- interface/patient_file/history/encounters.php | 100 ++++++--------------- interface/patient_file/history/encounters_ajax.php | 31 +++++++ interface/reports/players_report_ajax.php | 11 ++- library/js/ajtooltip.js | 47 +++++----- 4 files changed, 90 insertions(+), 99 deletions(-) create mode 100644 interface/patient_file/history/encounters_ajax.php diff --git a/interface/patient_file/history/encounters.php b/interface/patient_file/history/encounters.php index dee8cdb67..192cd75bf 100644 --- a/interface/patient_file/history/encounters.php +++ b/interface/patient_file/history/encounters.php @@ -127,6 +127,7 @@ function generatePageElement($start,$pagesize,$billing,$issue,$text) + @@ -429,11 +438,12 @@ while ($result4 = sqlFetchArray($res4)) { $rawdata = $result4['encounter'] . "~" . oeFormatShortDate($raw_encounter_date); echo "\n"; + "'>\n"; // show encounter date - echo "" . htmlspecialchars( oeFormatShortDate($raw_encounter_date), ENT_NOQUOTES) . "\n"; + echo "" . + htmlspecialchars(oeFormatShortDate($raw_encounter_date), ENT_NOQUOTES) . "\n"; if ($billing_view) { @@ -496,44 +506,17 @@ while ($result4 = sqlFetchArray($res4)) { ($auth_relaxed && ($formdir == 'sports_fitness' || $formdir == 'podiatry'))) ; else continue; - /***************************************************** - // build the potentially HUGE tooltip used by ttshow - $title = xl('View encounter'); - // - // Normally skip the tooltip because of poor database performance. - // However athletic teams want it. - // - if ($GLOBALS['athletic_team']) { - if ($enc['formdir'] != 'physical_exam' && - $enc['formdir'] != 'procedure_order' && - substr($enc['formdir'],0,3) != 'LBF') - { - $frow = sqlQuery("select * from form_" . add_escape_custom($enc['formdir']) . - " where id = ?", array($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); - } - } // end athletic team - echo ""; - echo htmlspecialchars( xl_form_title($enc['form_name']), ENT_NOQUOTES); - echo "
"; - *****************************************************/ - // Show the form name. In addition, for the specific-issue case show // the data collected by the form (this used to be a huge tooltip // but we did away with that). // - echo htmlspecialchars(xl_form_title($enc['form_name']), ENT_NOQUOTES); - echo "
"; + $formdir = $enc['formdir']; if ($issue) { + echo htmlspecialchars(xl_form_title($enc['form_name']), ENT_NOQUOTES); + echo "
"; echo "
"; // Use the form's report.php for display. Forms with names starting with LBF // are list-based forms sharing a single collection of code. - $formdir = $enc['formdir']; if (substr($formdir,0,3) == 'LBF') { include_once($GLOBALS['incdir'] . "/forms/LBF/report.php"); call_user_func("lbf_report", $pid, $result4['encounter'], 2, $enc['form_id'], $formdir); @@ -544,6 +527,14 @@ while ($result4 = sqlFetchArray($res4)) { } echo "
"; } + else { + echo "
"; + echo htmlspecialchars(xl_form_title($enc['form_name']), ENT_NOQUOTES); + echo "
"; + } } // end encounter Forms loop @@ -741,6 +732,11 @@ while ($drow /* && $count <= $N */) { + + + diff --git a/interface/patient_file/history/encounters_ajax.php b/interface/patient_file/history/encounters_ajax.php new file mode 100644 index 000000000..6b938e731 --- /dev/null +++ b/interface/patient_file/history/encounters_ajax.php @@ -0,0 +1,31 @@ + +// +// 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. + +$sanitize_all_escapes=true; +$fake_register_globals=false; + +require_once("../../globals.php"); +require_once($GLOBALS["srcdir"] . "/formdata.inc.php"); + +$ptid = $_GET['ptid'] + 0; +$encid = $_GET['encid'] + 0; +$formname = strtr($_GET['formname'], + array('.' => '', '\\' => '', '/' => '', '\'' => '', '"' => '', "\r" => '', "\n" => '')); +$formid = $_GET['formid'] + 0; + +if (substr($formname, 0, 3) == 'LBF') { + include_once("{$GLOBALS['incdir']}/forms/LBF/report.php"); + lbf_report($ptid, $encid, 2, $formid, $formname); +} +else { + include_once("{$GLOBALS['incdir']}/forms/$formname/report.php"); + $report_function = $formname . '_report'; + if (!function_exists($report_function)) exit; + call_user_func($report_function, $ptid, $encid, 2, $formid); +} +?> diff --git a/interface/reports/players_report_ajax.php b/interface/reports/players_report_ajax.php index 121cd65a4..5c335f169 100644 --- a/interface/reports/players_report_ajax.php +++ b/interface/reports/players_report_ajax.php @@ -1,5 +1,5 @@ +// Copyright (C) 2009, 2012 Rod Roark // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -35,7 +35,10 @@ else { } if ($s === '') $s = "No issues"; } -// echo "ttTitle = '$s';"; -$s = str_replace("\r", "", $s); -echo "ttobject.innerHTML = '" . str_replace("\n", "", $s) . "';"; + +// $s = str_replace("\r", "", $s); +// $s = str_replace("\n", "", $s); +// echo "ttCallback('$s');\n"; + +echo $s; ?> diff --git a/library/js/ajtooltip.js b/library/js/ajtooltip.js index 691f24a7f..73159968f 100644 --- a/library/js/ajtooltip.js +++ b/library/js/ajtooltip.js @@ -1,4 +1,4 @@ -// Copyright (C) 2009 Rod Roark +// Copyright (C) 2009, 2012 Rod Roark // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -30,6 +30,7 @@ var ttTimerId = 0; var ttElem = null; var ttobject = null; var ttUrl = ''; +var ttWantContent = false; function ttClearTimer() { if (ttTimerId) { @@ -38,34 +39,32 @@ function ttClearTimer() { ttElem = null; ttUrl = ''; } + ttWantContent = false; } // timer completion handler function ttMake() { - ttobject = document.getElementById("tooltipdiv"); - // ttobject.innerHTML = (ttTitle.length > 0) ? ttTitle : 'Loading...'; - ttobject.innerHTML = ' '; - var x = ttGetX(ttElem); - var dw = window.innerWidth ? window.innerWidth - 20 : document.body.clientWidth; - if (dw && dw < (x + ttobject.offsetWidth)) { - x = dw - ttobject.offsetWidth; - if (x < 0) x = 0; - } - // var y = ttGetY(ttElem) - ttobject.offsetHeight - 10; - // if (y < 0) y = ttGetY(ttElem) + ttElem.offsetHeight + 10; - var dh = window.innerHeight ? window.innerHeight : document.body.clientHeight; - // var y = ttGetY(ttElem) + ttobject.offsetHeight + 10; - var y = ttGetY(ttElem) + ttElem.offsetHeight; - // if (y + 40 > dh) y = 0; // does not work for a scrolled page! - ttobject.style.left = x; - ttobject.style.top = y; - ttobject.style.visibility='visible'; - // if (!ttElem.ttTitle) { - myUrl = ttUrl; - $.getScript(ttUrl); - // } + ttWantContent = true; + top.restoreSession(); + $.get(ttUrl, function(data) { + if (!ttWantContent) return; + ttobject = document.getElementById("tooltipdiv"); + ttobject.innerHTML = data; + var x = ttGetX(ttElem); + var dw = window.innerWidth ? window.innerWidth - 20 : document.body.clientWidth; + if (dw && dw < (x + ttobject.offsetWidth)) { + x = dw - ttobject.offsetWidth; + if (x < 0) x = 0; + } + var dh = window.innerHeight ? window.innerHeight : document.body.clientHeight; + var y = ttGetY(ttElem) + ttElem.offsetHeight; + ttobject.style.left = x; + ttobject.style.top = y; + ttobject.style.visibility='visible'; + ttWantContent = false; + ttElem = null; + }); ttTimerId = 0; - ttElem = null; } // onmouseover handler -- 2.11.4.GIT