flexible apache recs to secure multiple sites
[openemr.git] / interface / new / new_patient_save.php
blobedd2f72cb73ba3f141a7024eacb1f8e4b89ccb56
1 <?php
2 require_once("../globals.php");
3 require_once("$srcdir/sql.inc");
5 // Validation for non-unique external patient identifier.
6 if (!empty($_POST["pubpid"])) {
7 $form_pubpid = trim($_POST["pubpid"]);
8 $result = sqlQuery("SELECT count(*) AS count FROM patient_data WHERE " .
9 "pubpid = '$form_pubpid'");
10 if ($result['count']) {
11 // Error, not unique.
12 require_once("new.php");
13 exit();
17 require_once("$srcdir/pid.inc");
18 require_once("$srcdir/patient.inc");
20 //here, we lock the patient data table while we find the most recent max PID
21 //other interfaces can still read the data during this lock, however
22 sqlStatement("lock tables patient_data read");
24 $result = sqlQuery("select max(pid)+1 as pid from patient_data");
26 // TBD: This looks wrong to unlock the table before we have added our
27 // patient with its newly allocated pid!
29 sqlStatement("unlock tables");
30 //end table lock
31 $newpid = 1;
33 if ($result['pid'] > 1)
34 $newpid = $result['pid'];
36 setpid($newpid);
38 if($pid == NULL) {
39 $pid = 0;
42 // what do we set for the public pid?
43 if (isset($_POST["pubpid"]) && ($_POST["pubpid"] != "")) {
44 $mypubpid = $_POST["pubpid"];
45 } else {
46 $mypubpid = $pid;
49 if ($_POST['form_create']) {
51 $form_fname = ucwords(trim($_POST["fname"]));
52 $form_lname = ucwords(trim($_POST["lname"]));
53 $form_mname = ucwords(trim($_POST["mname"]));
55 // ===================
56 // DBC SYSTEM WAS REMOVED
57 $form_sex = trim($_POST["sex"]) ;
58 $form_dob = trim($_POST["DOB"]) ;
59 $form_street = '' ;
60 $form_city = '' ;
61 $form_postcode = '' ;
62 $form_countrycode = '' ;
63 // EOS DBC
64 // ===================
66 newPatientData(
67 $_POST["db_id"],
68 $_POST["title"],
69 $form_fname,
70 $form_lname,
71 $form_mname,
72 $form_sex, // sex
73 $form_dob, // dob
74 $form_street, // street
75 $form_postcode, // postal_code
76 $form_city, // city
77 "", // state
78 $form_countrycode, // country_code
79 "", // ss
80 "", // occupation
81 "", // phone_home
82 "", // phone_biz
83 "", // phone_contact
84 "", // status
85 "", // contact_relationship
86 "", // referrer
87 "", // referrerID
88 "", // email
89 "", // language
90 "", // ethnoracial
91 "", // interpreter
92 "", // migrantseasonal
93 "", // family_size
94 "", // monthly_income
95 "", // homeless
96 "", // financial_review
97 "$mypubpid",
98 $pid,
99 "", // providerID
100 "", // genericname1
101 "", // genericval1
102 "", // genericname2
103 "", // genericval2
104 "", // phone_cell
105 "", // hipaa_mail
106 "", // hipaa_voice
107 0, // squad
108 0, // $pharmacy_id = 0,
109 "", // $drivers_license = "",
110 "", // $hipaa_notice = "",
111 "", // $hipaa_message = "",
112 $_POST['regdate']
115 newEmployerData($pid);
116 newHistoryData($pid);
117 newInsuranceData($pid, "primary");
118 newInsuranceData($pid, "secondary");
119 newInsuranceData($pid, "tertiary");
121 // Set referral source separately because we don't want it messed
122 // with later by newPatientData().
123 if ($refsource = trim($_POST["refsource"])) {
124 sqlQuery("UPDATE patient_data SET referral_source = '$refsource' " .
125 "WHERE pid = '$pid'");
130 <html>
131 <body>
132 <script language="Javascript">
133 <?php
134 if ($alertmsg) {
135 echo "alert('$alertmsg');\n";
137 if ($GLOBALS['concurrent_layout']) {
138 echo "window.location='$rootdir/patient_file/summary/demographics.php?" .
139 "set_pid=$pid&is_new=1';\n";
140 } else {
141 echo "window.location='$rootdir/patient_file/patient_file.php?set_pid=$pid';\n";
144 </script>
146 </body>
147 </html>