support a registration date
[openemr.git] / interface / new / new_patient_save.php
blob36a6e4840265c0436a2e5c683f44150a4b521ea7
1 <?
2 include_once("../globals.php");
3 include_once("$srcdir/sql.inc");
4 include_once("$srcdir/pid.inc");
5 include_once("$srcdir/patient.inc");
7 //here, we lock the patient data table while we find the most recent max PID
8 //other interfaces can still read the data during this lock, however
9 sqlStatement("lock tables patient_data read");
11 $result = sqlQuery("select max(pid)+1 as pid from patient_data");
13 // TBD: This looks wrong to unlock the table before we have added our
14 // patient with its newly allocated pid!
16 sqlStatement("unlock tables");
17 //end table lock
18 $newpid = 1;
20 if ($result['pid'] > 1)
21 $newpid = $result['pid'];
23 setpid($newpid);
25 if($pid == NULL) {
26 $pid = 0;
29 //what do we set for the public pid?
30 if (isset($_POST["pubpid"]) && ($_POST["pubpid"] != "")) {
31 $mypubpid = $_POST["pubpid"];
32 } else {
33 $mypubpid = $pid;
36 if ($_POST['form_create']) {
38 $form_fname = ucwords(trim($_POST["fname"]));
39 $form_lname = ucwords(trim($_POST["lname"]));
40 $form_mname = ucwords(trim($_POST["mname"]));
42 newPatientData(
43 $_POST["db_id"],
44 $_POST["title"],
45 $form_fname,
46 $form_lname,
47 $form_mname,
48 "", // sex
49 "", // dob
50 "", // street
51 "", // postal_code
52 "", // city
53 "", // state
54 "", // country_code
55 "", // ss
56 "", // occupation
57 "", // phone_home
58 "", // phone_biz
59 "", // phone_contact
60 "", // status
61 "", // contact_relationship
62 "", // referrer
63 "", // referrerID
64 "", // email
65 "", // language
66 "", // ethnoracial
67 "", // interpreter
68 "", // migrantseasonal
69 "", // family_size
70 "", // monthly_income
71 "", // homeless
72 "", // financial_review
73 "$mypubpid",
74 $pid,
75 "", // providerID
76 "", // genericname1
77 "", // genericval1
78 "", // genericname2
79 "", // genericval2
80 "", // phone_cell
81 "", // hipaa_mail
82 "", // hipaa_voice
83 0, // squad
84 0, // $pharmacy_id = 0,
85 "", // $drivers_license = "",
86 "", // $hipaa_notice = "",
87 "", // $hipaa_message = ""
88 $_POST['regdate']
91 newEmployerData($pid);
92 newHistoryData($pid);
93 newInsuranceData($pid, "primary");
94 newInsuranceData($pid, "secondary");
95 newInsuranceData($pid, "tertiary");
97 // Set referral source separately because we don't want it messed
98 // with later by newPatientData().
99 if ($refsource = trim($_POST["refsource"])) {
100 sqlQuery("UPDATE patient_data SET referral_source = '$refsource' " .
101 "WHERE pid = '$pid'");
105 <html>
106 <body>
107 <script language="Javascript">
109 if ($alertmsg) {
110 echo "alert('$alertmsg');\n";
112 if ($GLOBALS['concurrent_layout']) {
113 echo "window.location='$rootdir/patient_file/summary/demographics.php?" .
114 "set_pid=$pid&is_new=1';\n";
115 } else {
116 echo "window.location='$rootdir/patient_file/patient_file.php?set_pid=$pid';\n";
119 </script>
121 </body>
122 </html>