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']) {
12 require_once("new.php");
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");
33 if ($result['pid'] > 1)
34 $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']) {
51 $form_fname = ucwords(trim($_POST["fname"]));
52 $form_lname = ucwords(trim($_POST["lname"]));
53 $form_mname = ucwords(trim($_POST["mname"]));
55 // ===================
57 $form_dbcprefix = ( $GLOBALS['dutchpc'] ) ?
ucwords(trim($_POST["dbc_prefix"])) : '' ;
58 $form_dbcprefixpartner = ( $GLOBALS['dutchpc'] ) ?
trim($_POST["dbc_prefix_partner"]) : '' ;
59 $form_dbclastpartner = ( $GLOBALS['dutchpc'] ) ?
trim($_POST["dbc_lastname_partner"]) : '' ;
60 $form_sex = ( $GLOBALS['dutchpc'] ) ?
trim($_POST["dbc_sex"]) : '' ;
61 // in db the value for sex is a word! so we must translate it
62 switch ( $form_sex ) {
63 case 1 : $form_sex = 'Male'; break;
64 case 2: $form_sex = 'Female'; break;
65 default: $form_sex = 'Male';
67 $form_voorletters = ( $GLOBALS['dutchpc'] ) ?
trim($_POST["dbc_voorletters"]) : '' ;
68 $form_dob = ( $GLOBALS['dutchpc'] ) ?
trim($_POST["dbc_geboort"]) : '' ;
69 $form_street = ( $GLOBALS['dutchpc'] ) ?
trim($_POST["dbc_straat"]) : '' ;
70 $form_number = ( $GLOBALS['dutchpc'] ) ?
trim($_POST["dbc_nummer"]) : '' ;
71 $form_addition = ( $GLOBALS['dutchpc'] ) ?
trim($_POST["dbc_toevoe"]) : '' ;
72 $form_city = ( $GLOBALS['dutchpc'] ) ?
trim($_POST["dbc_plaats"]) : '' ;
73 $form_postcode = ( $GLOBALS['dutchpc'] ) ?
trim($_POST["dbc_postal"]) : '' ;
74 $form_countrycode = ( $GLOBALS['dutchpc'] ) ?
trim($_POST["dbc_land"]) : '' ;
75 $form_provider = ( $GLOBALS['dutchpc'] ) ?
trim($_POST["dbc_insurance"]) : '' ;
76 $form_insdate = ( $GLOBALS['dutchpc'] ) ?
trim($_POST["dbc_insdatum"]) : '' ;
77 $form_policy = ( $GLOBALS['dutchpc'] ) ?
trim($_POST["dbc_policy"]) : '' ;
79 // ===================
89 $form_street, // street
90 $form_street, // DBC use ---- $nstreet
91 $form_number, // DBC use ---- $nnr
92 $form_addition, // DBC use ---- $nadd
93 $form_postcode, // postal_code
96 $form_countrycode, // country_code
103 "", // contact_relationship
110 "", // migrantseasonal
112 "", // monthly_income
114 "", // financial_review
126 0, // $pharmacy_id = 0,
127 "", // $drivers_license = "",
128 "", // $hipaa_notice = "",
129 "", // $hipaa_message = "",
131 // ======== dutch specific
132 $form_dbcprefix, // $prefixlast
133 $form_dbcprefixpartner, // $prefixlastpartner
134 $form_dbclastpartner, // $lastpartner
135 $form_voorletters, // initials
136 "", // $provider_data
138 // ======== EOS dutch specific
142 newEmployerData($pid);
143 newHistoryData($pid);
144 newInsuranceData($pid, "primary");
145 newInsuranceData($pid, "secondary");
146 newInsuranceData($pid, "tertiary");
149 // DBC DUTCH INSURANCE DATA
150 if ( $GLOBALS['dutchpc'] ) set_insurer_nl($pid, $form_provider, $form_insdate, $form_policy);
153 // Set referral source separately because we don't want it messed
154 // with later by newPatientData().
155 if ($refsource = trim($_POST["refsource"])) {
156 sqlQuery("UPDATE patient_data SET referral_source = '$refsource' " .
157 "WHERE pid = '$pid'");
161 if ( $GLOBALS['dutchpc'] ) {
162 generate_id1250($pid); // generate an ID1250 number
169 <script language
="Javascript">
172 echo "alert('$alertmsg');\n";
174 if ($GLOBALS['concurrent_layout']) {
175 echo "window.location='$rootdir/patient_file/summary/demographics.php?" .
176 "set_pid=$pid&is_new=1';\n";
178 echo "window.location='$rootdir/patient_file/patient_file.php?set_pid=$pid';\n";