6 * @link http://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 require_once("../globals.php");
15 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
19 // Validation for non-unique external patient identifier.
20 if (!empty($_POST["pubpid"])) {
21 $form_pubpid = trim($_POST["pubpid"]);
22 $result = sqlQuery("SELECT count(*) AS count FROM patient_data WHERE " .
23 "pubpid = ?", array($form_pubpid));
24 if ($result['count']) {
26 require_once("new.php");
31 require_once("$srcdir/pid.inc");
32 require_once("$srcdir/patient.inc");
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 // TBD: This looks wrong to unlock the table before we have added our
41 // patient with its newly allocated pid!
43 sqlStatement("unlock tables");
47 if ($result['pid'] > 1) {
48 $newpid = $result['pid'];
57 // what do we set for the public pid?
58 if (isset($_POST["pubpid"]) && ($_POST["pubpid"] != "")) {
59 $mypubpid = $_POST["pubpid"];
64 if ($_POST['form_create']) {
65 $form_fname = ucwords(trim($_POST["fname"]));
66 $form_lname = ucwords(trim($_POST["lname"]));
67 $form_mname = ucwords(trim($_POST["mname"]));
69 // ===================
70 // DBC SYSTEM WAS REMOVED
71 $form_sex = trim($_POST["sex"]) ;
72 $form_dob = DateToYYYYMMDD(trim($_POST["DOB"])) ;
76 $form_countrycode = '' ;
77 $form_regdate = DateToYYYYMMDD(trim($_POST['regdate']));
79 // ===================
89 $form_street, // street
90 $form_postcode, // postal_code
93 $form_countrycode, // country_code
100 "", // contact_relationship
107 "", // migrantseasonal
109 "", // monthly_income
111 "", // financial_review
124 0, // $pharmacy_id = 0,
125 "", // $drivers_license = "",
126 "", // $hipaa_notice = "",
127 "", // $hipaa_message = "",
131 newEmployerData($pid);
132 newHistoryData($pid);
133 newInsuranceData($pid, "primary");
134 newInsuranceData($pid, "secondary");
135 newInsuranceData($pid, "tertiary");
137 // Set referral source separately because we don't want it messed
138 // with later by newPatientData().
139 if ($refsource = trim($_POST["refsource"])) {
140 sqlQuery("UPDATE patient_data SET referral_source = ? " .
141 "WHERE pid = ?", array($refsource, $pid));
147 <script language
="Javascript">
150 echo "alert(" . js_escape($alertmsg) . ");\n";
153 echo "window.location='$rootdir/patient_file/summary/demographics.php?" .
154 "set_pid=" . attr_url($pid) . "&is_new=1';\n";