3 include_once("../../globals.php");
5 include_once("$srcdir/patient.inc");
7 //function called to set the global session variable for patient id (pid) number
8 function setpid($new_pid) {
11 $_SESSION['pid']=$new_pid;
14 newEvent("view",$_SESSION["authUser"],$_SESSION["authProvider"],1, $pid);
17 //check if the name already exists:
18 if ($result = sqlQuery("select * from patient_data where lower(fname)=lower('".$_POST["fname"]."') and lower(lname)=lower('".$_POST["lname"]."')")) {
19 //setpid($result{"pid"});
21 //here, we lock the patient data table while we find the most recent max PID
22 //other interfaces can still read the data during this lock, however
23 sqlStatement("lock tables patient_data read");
25 $result = sqlQuery("select max(pid)+1 as pid from patient_data");
27 sqlStatement("unlock tables");
31 //setpid($result{"pid"});
32 $pid = $result{"pid"};
34 if($pid == NULL) { $pid = 0; }
36 //what do we set for the public pid?
37 if (isset($_POST["pubpid"]) && ($_POST["pubpid"] != "")) {
38 $mypubpid = $_POST["pubpid"];
43 newPatientData($_POST["db_id"],
45 ucwords($_POST["fname"]),
46 ucwords($_POST["lname"]),
47 ucwords($_POST["mname"]),
77 newEmployerData( $pid);
79 newHistoryData( $pid);
81 newInsuranceData( $pid, "primary");
83 newInsuranceData( $pid, "secondary");
85 newInsuranceData( $pid, "tertiary");
92 <script language
="Javascript">
94 window
.location
="<?php echo "find_patient
.php?mode
=setpatient
&pid
=$pid";?>";