using OemrUI class in Fees > Fee Sheet, Billing, Payment, Checkout, Batch Payments...
[openemr.git] / library / pid.inc
bloba942485cb27fa081bf58c4d8b50354de0afcac80
1 <?php
2 /**
3  * pid.inc
4  *
5  * @package   OpenEMR
6  * @link      http://www.open-emr.org
7  * @author    Brady Miller <brady.g.miller@gmail.com>
8  * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
9  * @license   https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
10  */
13 require_once(dirname(__FILE__). "/../interface/globals.php");
14 require_once(dirname(__FILE__)."/log.inc");
16 // Function called to set the global session variable for patient id (pid) number.
17 function setpid($new_pid)
19     global $pid, $encounter;
21   // Escape $new_pid by forcing it to an integer to protect from sql injection
22     $new_pid_int = intval($new_pid);
23   // If the $new_pid was not an integer, then send an error to error log
24     if (!is_numeric($new_pid)) {
25         error_log("Critical OpenEMR Error: Attempt to set pid to following non-integer value was denied: ".$new_pid, 0);
26         error_log("Requested pid ".$new_pid, 0);
27         error_log("Returned pid ".$new_pid_int, 0);
28     }
30   // Be careful not to clear the encounter unless the pid is really changing.
31     if (!isset($_SESSION['pid']) || $pid != $new_pid_int || $pid != $_SESSION['pid']) {
32         $_SESSION['encounter'] = $encounter = 0;
33     }
35   // unset therapy_group session when set session for patient
36     if ($_SESSION['pid'] != 0 && isset($_SESSION['therapy_group'])) {
37         unset($_SESSION['therapy_group']);
38     }
41   // Set pid to the escaped pid
42     $_SESSION['pid'] = $new_pid_int;
43     $pid = $new_pid_int;
45     newEvent("view", $_SESSION["authUser"], $_SESSION["authProvider"], 1, '', $pid);