Display fix: width in manila for demographics (#1909)
[openemr.git] / library / pid.inc
blobb6128f3a641857b572b9981abe0705a79b65108b
1 <?php
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License
4 // as published by the Free Software Foundation; either version 2
5 // of the License, or (at your option) any later version.
7 require_once(dirname(__FILE__). "/../interface/globals.php");
8 require_once(dirname(__FILE__)."/log.inc");
10 // Function called to set the global session variable for patient id (pid) number.
11 function setpid($new_pid)
13     global $pid, $encounter;
15   // Escape $new_pid by forcing it to an integer to protect from sql injection
16     $new_pid_int = intval($new_pid);
17   // If the $new_pid was not an integer, then send an error to error log
18     if (!is_numeric($new_pid)) {
19         error_log("Critical OpenEMR Error: Attempt to set pid to following non-integer value was denied: ".$new_pid, 0);
20         error_log("Requested pid ".$new_pid, 0);
21         error_log("Returned pid ".$new_pid_int, 0);
22     }
24   // Be careful not to clear the encounter unless the pid is really changing.
25     if (!isset($_SESSION['pid']) || $pid != $new_pid_int || $pid != $_SESSION['pid']) {
26         $_SESSION['encounter'] = $encounter = 0;
27     }
29   // unset therapy_group session when set session for patient
30     if ($_SESSION['pid'] != 0 && isset($_SESSION['therapy_group'])) {
31         unset($_SESSION['therapy_group']);
32     }
35   // Set pid to the escaped pid
36     $_SESSION['pid'] = $new_pid_int;
37     $pid = $new_pid_int;
39     newEvent("view", $_SESSION["authUser"], $_SESSION["authProvider"], 1, '', $pid);