fix: Update patient_tracker.php (#6595)
[openemr.git] / library / ajax / document_helpers.php
blobf4dbf7cf0e7bc934a4373d2e52e7fc93cc18a704
1 <?php
3 /**
4 * Document Helper Functions for New Documents Module.
6 * @package OpenEMR
7 * @link https://www.open-emr.org
8 * @author Jerry Padgett <sjpadgett@gmail.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2017-2018 Jerry Padgett <sjpadgett@gmail.com>
11 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once(dirname(__FILE__) . "/../../interface/globals.php");
17 use OpenEMR\Common\Csrf\CsrfUtils;
19 //verify csrf
20 if (!CsrfUtils::verifyCsrfToken($_GET["csrf_token_form"])) {
21 CsrfUtils::csrfNotVerified();
24 $req = array(
25 'term' => (isset($_GET["term"]) ? filter_input(INPUT_GET, 'term') : ''),
26 'sql_limit' => (isset($_GET["limit"]) ? filter_input(INPUT_GET, 'limit') : 20),
29 function get_patients_list($req)
31 $term = "%" . $req['term'] . "%";
32 $clear = "- " . xl("Reset to no patient") . " -";
33 $response = sqlStatement(
34 "SELECT CONCAT(fname, ' ',lname,IF(IFNULL(deceased_date,0)=0,'','*')) as label, pid as value
35 FROM patient_data
36 HAVING label LIKE ?
37 ORDER BY IF(IFNULL(deceased_date,0)=0, 0, 1) ASC, IFNULL(deceased_date,0) DESC, lname ASC, fname ASC
38 LIMIT " . escape_limit($req['sql_limit']),
39 array($term)
41 $resultpd[] = array(
42 'label' => $clear,
43 'value' => '00'
45 while ($row = sqlFetchArray($response)) {
46 if ($GLOBALS['pid'] == $row['value']) {
47 $row['value'] = "00";
48 $row['label'] = xl("Locked") . "-" . xl("In Use") . ":" . $row['label'];
51 $resultpd[] = $row;
54 echo json_encode($resultpd);
57 get_patients_list($req);