Fix a nasty bug; avoid 0 value for pc_multiple field.
[openemr.git] / interface / main / calendar / new_patient_save.php
blob06471f050155ab68c3a02694de9e987e1b6d2189
1 <?
2 include_once("../../globals.php");
4 include_once("$srcdir/sql.inc");
5 include_once("$srcdir/patient.inc");
9 //function called to set the global session variable for patient id (pid) number
10 function setpid($new_pid) {
11 global $pid;
13 $_SESSION['pid']=$new_pid;
14 $pid=$new_pid;
16 newEvent("view",$_SESSION["authUser"],$_SESSION["authProvider"],$pid);
24 //check if the name already exists:
25 if ($result = sqlQuery("select * from patient_data where lower(fname)=lower('".$_POST["fname"]."') and lower(lname)=lower('".$_POST["lname"]."')")) {
26 //setpid($result{"pid"});
29 } else {
34 //here, we lock the patient data table while we find the most recent max PID
35 //other interfaces can still read the data during this lock, however
36 sqlStatement("lock tables patient_data read");
38 $result = sqlQuery("select max(pid)+1 as pid from patient_data");
40 sqlStatement("unlock tables");
41 //end table lock
43 //do not set pid
44 //setpid($result{"pid"});
45 $pid = $result{"pid"};
47 if($pid == NULL) {
48 $pid = 0;
51 //what do we set for the public pid?
52 if (isset($_POST["pubpid"]) && ($_POST["pubpid"] != "")) {
53 $mypubpid = $_POST["pubpid"];
54 } else {
55 $mypubpid = $pid;
60 newPatientData( $_POST["db_id"],
61 $_POST["title"],
62 ucwords($_POST["fname"]),
63 ucwords($_POST["lname"]),
64 ucwords($_POST["mname"]),
65 "",
66 "",
67 "",
68 "",
69 "",
70 "",
71 "",
72 "",
73 "",
74 "",
75 "",
76 "",
77 "",
78 "",
79 "",
80 "",
81 "",
82 "",
83 "",
84 "",
85 "",
86 "",
87 "",
88 "",
89 "",
90 "$mypubpid",
91 $pid
95 newEmployerData( $pid);
97 newHistoryData( $pid);
100 newInsuranceData( $pid, "primary");
105 newInsuranceData( $pid, "secondary");
108 newInsuranceData( $pid, "tertiary");
127 <html>
128 <body>
129 <script language="Javascript">
131 window.location="<?echo "find_patient.php?mode=setpatient&pid=$pid";?>";
134 </script>
137 </body>
138 </html>