more organization of autoloaded files (#424)
[openemr.git] / interface / main / calendar / new_patient_save.php
blob2bd238fa0a7a9e839ae498fda146c7bc426fab45
1 <?php
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) {
9 global $pid;
11 $_SESSION['pid']=$new_pid;
12 $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"});
20 } else {
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");
28 //end table lock
30 //do not set pid
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"];
39 } else {
40 $mypubpid = $pid;
43 newPatientData($_POST["db_id"],
44 $_POST["title"],
45 ucwords($_POST["fname"]),
46 ucwords($_POST["lname"]),
47 ucwords($_POST["mname"]),
48 "",
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 "$mypubpid",
74 $pid
77 newEmployerData( $pid);
79 newHistoryData( $pid);
81 newInsuranceData( $pid, "primary");
83 newInsuranceData( $pid, "secondary");
85 newInsuranceData( $pid, "tertiary");
90 <html>
91 <body>
92 <script language="Javascript">
94 window.location="<?php echo "find_patient.php?mode=setpatient&pid=$pid";?>";
96 </script>
98 </body>
99 </html>