Fully responsive globals.php with vertical menu (#2460)
[openemr.git] / interface / main / finder / multi_patients_finder_ajax.php
blob7267302bb2776542df001b6be84eed721eb6fb7a
1 <?php
2 /**
3 * Ajax interface for popup of multi select patient.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Amiel Elboim <amielel@matrix.co.il>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2017 Amiel Elboim <amielel@matrix.co.il
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
14 require_once('../../globals.php');
15 require_once("$srcdir/patient.inc");
17 if (!verifyCsrfToken($_GET["csrf_token_form"])) {
18 csrfNotVerified();
21 $type = $_GET['type'];
22 $search = $_GET['search'];
24 switch ($type) {
25 case 'by-id':
26 // load patients ids for select2.js library, expect receive 'text' and 'id'.
27 $results=getPatientId("$search%", 'pubpid as text, pid as id', 'pubpid');
28 foreach ($results as $key => $result) {
29 //clean data using 'text' function
30 $results[$key] = array_map('text', $result);
32 break;
33 case 'by-name':
34 // load patients names for select2.js library, expect receive 'text' and 'id'.
35 $results=getPatientLnames("%$search%", 'pid as id, CONCAT(lname, ", ",fname) as text', 'lname ASC, fname ASC');
36 foreach ($results as $key => $result) {
37 //clean data using 'text' function
38 $results[$key] = array_map('text', $result);
40 break;
41 case 'patient-by-id':
42 $results=getPatientData($search, 'id, pid, lname, fname, mname, pubpid, ss, DOB, phone_home');
43 //clean data using 'text' function
44 $results=array_map('text', $results);
45 $results['DOB'] = oeFormatShortDate($results['DOB']);
46 break;
49 $output = array('results' => $results);
50 echo json_encode($output);
51 die;