2 require_once("../globals.php");
4 // Validation for non-unique external patient identifier.
5 if (!empty($_POST["pubpid"])) {
6 $form_pubpid = trim($_POST["pubpid"]);
7 $result = sqlQuery("SELECT count(*) AS count FROM patient_data WHERE " .
8 "pubpid = ?", array($form_pubpid));
9 if ($result['count']) {
11 require_once("new.php");
16 require_once("$srcdir/pid.inc");
17 require_once("$srcdir/patient.inc");
19 //here, we lock the patient data table while we find the most recent max PID
20 //other interfaces can still read the data during this lock, however
21 sqlStatement("lock tables patient_data read");
23 $result = sqlQuery("select max(pid)+1 as pid from patient_data");
25 // TBD: This looks wrong to unlock the table before we have added our
26 // patient with its newly allocated pid!
28 sqlStatement("unlock tables");
32 if ($result['pid'] > 1) {
33 $newpid = $result['pid'];
42 // what do we set for the public pid?
43 if (isset($_POST["pubpid"]) && ($_POST["pubpid"] != "")) {
44 $mypubpid = $_POST["pubpid"];
49 if ($_POST['form_create']) {
50 $form_fname = ucwords(trim($_POST["fname"]));
51 $form_lname = ucwords(trim($_POST["lname"]));
52 $form_mname = ucwords(trim($_POST["mname"]));
54 // ===================
55 // DBC SYSTEM WAS REMOVED
56 $form_sex = trim($_POST["sex"]) ;
57 $form_dob = DateToYYYYMMDD(trim($_POST["DOB"])) ;
61 $form_countrycode = '' ;
62 $form_regdate = DateToYYYYMMDD(trim($_POST['regdate']));
64 // ===================
74 $form_street, // street
75 $form_postcode, // postal_code
78 $form_countrycode, // country_code
85 "", // contact_relationship
92 "", // migrantseasonal
96 "", // financial_review
109 0, // $pharmacy_id = 0,
110 "", // $drivers_license = "",
111 "", // $hipaa_notice = "",
112 "", // $hipaa_message = "",
116 newEmployerData($pid);
117 newHistoryData($pid);
118 newInsuranceData($pid, "primary");
119 newInsuranceData($pid, "secondary");
120 newInsuranceData($pid, "tertiary");
122 // Set referral source separately because we don't want it messed
123 // with later by newPatientData().
124 if ($refsource = trim($_POST["refsource"])) {
125 sqlQuery("UPDATE patient_data SET referral_source = ? " .
126 "WHERE pid = ?", array($refsource, $pid));
132 <script language
="Javascript">
135 echo "alert('" . addslashes($alertmsg) . "');\n";
138 echo "window.location='$rootdir/patient_file/summary/demographics.php?" .
139 "set_pid=" . attr($pid) . "&is_new=1';\n";