3 include_once("../../globals.php");
5 include_once("$srcdir/sql.inc");
6 include_once("$srcdir/patient.inc");
8 //function called to set the global session variable for patient id (pid) number
9 function setpid($new_pid) {
12 $_SESSION['pid']=$new_pid;
15 newEvent("view",$_SESSION["authUser"],$_SESSION["authProvider"],1, $pid);
18 //check if the name already exists:
19 if ($result = sqlQuery("select * from patient_data where lower(fname)=lower('".$_POST["fname"]."') and lower(lname)=lower('".$_POST["lname"]."')")) {
20 //setpid($result{"pid"});
22 //here, we lock the patient data table while we find the most recent max PID
23 //other interfaces can still read the data during this lock, however
24 sqlStatement("lock tables patient_data read");
26 $result = sqlQuery("select max(pid)+1 as pid from patient_data");
28 sqlStatement("unlock tables");
32 //setpid($result{"pid"});
33 $pid = $result{"pid"};
35 if($pid == NULL) { $pid = 0; }
37 //what do we set for the public pid?
38 if (isset($_POST["pubpid"]) && ($_POST["pubpid"] != "")) {
39 $mypubpid = $_POST["pubpid"];
44 newPatientData($_POST["db_id"],
46 ucwords($_POST["fname"]),
47 ucwords($_POST["lname"]),
48 ucwords($_POST["mname"]),
78 newEmployerData( $pid);
80 newHistoryData( $pid);
82 newInsuranceData( $pid, "primary");
84 newInsuranceData( $pid, "secondary");
86 newInsuranceData( $pid, "tertiary");
93 <script language
="Javascript">
95 window
.location
="<?php echo "find_patient
.php?mode
=setpatient
&pid
=$pid";?>";