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