PHP7 Project. Commit 20. Fixes in calendar module.
[openemr.git] / interface / main / calendar / new_patient_save.php
blob5e2114f94b2f636be2c49c6b22bde5f796b7c642
1 <?php
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) {
10 global $pid;
12 $_SESSION['pid']=$new_pid;
13 $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"});
21 } else {
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");
29 //end table lock
31 //do not set pid
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"];
40 } else {
41 $mypubpid = $pid;
44 newPatientData($_POST["db_id"],
45 $_POST["title"],
46 ucwords($_POST["fname"]),
47 ucwords($_POST["lname"]),
48 ucwords($_POST["mname"]),
49 "",
50 "",
51 "",
52 "",
53 "",
54 "",
55 "",
56 "",
57 "",
58 "",
59 "",
60 "",
61 "",
62 "",
63 "",
64 "",
65 "",
66 "",
67 "",
68 "",
69 "",
70 "",
71 "",
72 "",
73 "",
74 "$mypubpid",
75 $pid
78 newEmployerData( $pid);
80 newHistoryData( $pid);
82 newInsuranceData( $pid, "primary");
84 newInsuranceData( $pid, "secondary");
86 newInsuranceData( $pid, "tertiary");
91 <html>
92 <body>
93 <script language="Javascript">
95 window.location="<?php echo "find_patient.php?mode=setpatient&pid=$pid";?>";
97 </script>
99 </body>
100 </html>