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