added mechanism to not print links in form reports, ie CAMOS and the custom report
[openemr.git] / library / ajax / find_patients.php
blobdf53e91a7944a568b37e4c065b761daf2d60c1d1
1 <?php
2 // Copyright (C) 2009 Jason Morrill <jason@italktech.net>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 //
9 // This file is used to find patient(s) that match the given
10 // criteria passed in
12 // OUTPUT is varied and based on the returntype parameter
14 // Important - Ensure that display_errors=Off in php.ini settings.
16 include_once("../../interface/globals.php");
17 include_once("{$GLOBALS['srcdir']}/sql.inc");
19 // set an upper limit on the number of results returned from the database
20 $limit = $_GET['limit'];
21 $limit = 50;
23 if ($_GET['returntype'] == 'count') {
24 // only get the number of patients matching the input criteria
26 // input check - don't search if all input parameters are empty
27 if ($_GET['fname'] == "" && $_GET['mname'] == "" && $_GET['lname'] == "" &&
28 $_GET['pubpid'] == "" && $_GET['DOB'] == "" && $_GET['sex'] == "" &&
29 $_GET['ss'] == "")
30 { echo "0"; exit; }
32 $sql = "select count(*) as total from patient_data where ";
33 $sql_and = "";
34 if ($_GET['fname']) { $sql .= $sql_and. " fname='".$_GET['fname']."'"; $sql_and = " AND "; }
35 if ($_GET['mname']) { $sql .= $sql_and. " mname='".$_GET['mname']."'"; $sql_and = " AND "; }
36 if ($_GET['lname']) { $sql .= $sql_and. " lname='".$_GET['lname']."'"; $sql_and = " AND "; }
37 if ($_GET['pubpid']) { $sql .= $sql_and. " pubpid='".$_GET['pubpid']."'"; $sql_and = " AND "; }
38 if ($_GET['DOB']) { $sql .= $sql_and. " DOB='".$_GET['DOB']."'"; $sql_and = " AND "; }
39 if ($_GET['sex']) { $sql .= $sql_and. " sex='".$_GET['sex']."'"; $sql_and = " AND "; }
40 if ($_GET['ss']) { $sql .= $sql_and. " ss='".$_GET['ss']."'"; $sql_and = " AND "; }
41 $sql .= " limit ".$limit;
43 $results = sqlStatement($sql);
44 $row = sqlFetchArray($results);
45 echo $row['total'];
46 exit;
49 exit;