change eligibility batch from ssn to policy number, minor fix to filename with extra...
[openemr.git] / library / ajax / document_helpers.php
blob5fdd37201d4d6004354a5df3bfc0bb1c7da7a6ac
1 <?php
2 /**
3 * Document Helper Functions for New Documents Module.
5 * Copyright (C) 2017-2018 Jerry Padgett <sjpadgett@gmail.com>
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>.
18 * @package OpenEMR
19 * @author Jerry Padgett <sjpadgett@gmail.com>
20 * @link http://www.open-emr.org
24 require_once(dirname(__FILE__) . "/../../interface/globals.php");
26 $req = array(
27 'term' => (isset($_GET["term"]) ? filter_input(INPUT_GET, 'term') : ''),
28 'sql_limit' => (isset($_GET["limit"]) ? filter_input(INPUT_GET, 'limit') : 20),
31 function get_patients_list($req)
33 $term = "%" . $req['term'] . "%";
34 $clear = "- " . xl("Reset to no patient") . " -";
35 $response = sqlStatement(
36 "SELECT CONCAT(fname, ' ',lname,IF(IFNULL(deceased_date,0)=0,'','*')) as label, pid as value
37 FROM patient_data
38 HAVING label LIKE ?
39 ORDER BY IF(IFNULL(deceased_date,0)=0, 0, 1) ASC, IFNULL(deceased_date,0) DESC, lname ASC, fname ASC
40 LIMIT " . escape_limit($req['sql_limit']),
41 array($term)
43 $resultpd[] = array(
44 'label' => $clear,
45 'value' => '00'
47 while ($row = sqlFetchArray($response)) {
48 if ($GLOBALS['pid'] == $row['value']) {
49 $row['value'] = "00";
50 $row['label'] = xl("Locked") . "-" . xl("In Use") . ":" . $row['label'];
53 $resultpd[] = $row;
56 echo json_encode($resultpd);
59 get_patients_list($req);