forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
new_patient_save.php
171 lines (152 loc) · 5.04 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
include_once("../globals.php");
include_once("$srcdir/sql.inc");
include_once("$srcdir/pid.inc");
include_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
$form_dbcprefix = ( $GLOBALS['dutchpc'] ) ? ucwords(trim($_POST["dbc_prefix"])) : '' ;
$form_dbcprefixpartner = ( $GLOBALS['dutchpc'] ) ? trim($_POST["dbc_prefix_partner"]) : '' ;
$form_dbclastpartner = ( $GLOBALS['dutchpc'] ) ? trim($_POST["dbc_lastname_partner"]) : '' ;
$form_sex = ( $GLOBALS['dutchpc'] ) ? trim($_POST["dbc_sex"]) : '' ;
// in db the value for sex is a word! so we must translate it
switch ( $form_sex ) {
case 1 : $form_sex = 'Male'; break;
case 2: $form_sex = 'Female'; break;
default: $form_sex = 'Male';
}
$form_voorletters = ( $GLOBALS['dutchpc'] ) ? trim($_POST["dbc_voorletters"]) : '' ;
$form_dob = ( $GLOBALS['dutchpc'] ) ? trim($_POST["dbc_geboort"]) : '' ;
$form_street = ( $GLOBALS['dutchpc'] ) ? trim($_POST["dbc_straat"]) : '' ;
$form_number = ( $GLOBALS['dutchpc'] ) ? trim($_POST["dbc_nummer"]) : '' ;
$form_addition = ( $GLOBALS['dutchpc'] ) ? trim($_POST["dbc_toevoe"]) : '' ;
$form_city = ( $GLOBALS['dutchpc'] ) ? trim($_POST["dbc_plaats"]) : '' ;
$form_postcode = ( $GLOBALS['dutchpc'] ) ? trim($_POST["dbc_postal"]) : '' ;
$form_countrycode = ( $GLOBALS['dutchpc'] ) ? trim($_POST["dbc_land"]) : '' ;
$form_provider = ( $GLOBALS['dutchpc'] ) ? trim($_POST["dbc_insurance"]) : '' ;
$form_insdate = ( $GLOBALS['dutchpc'] ) ? trim($_POST["dbc_insdatum"]) : '' ;
$form_policy = ( $GLOBALS['dutchpc'] ) ? trim($_POST["dbc_policy"]) : '' ;
// EOS DBC
// ===================
newPatientData(
$_POST["db_id"],
$_POST["title"],
$form_fname,
$form_lname,
$form_mname,
$form_sex, // sex
$form_dob, // dob
$form_street, // street
$form_street, // DBC use ---- $nstreet
$form_number, // DBC use ---- $nnr
$form_addition, // DBC use ---- $nadd
$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
"", // phone_cell
"", // hipaa_mail
"", // hipaa_voice
0, // squad
0, // $pharmacy_id = 0,
"", // $drivers_license = "",
"", // $hipaa_notice = "",
"", // $hipaa_message = "",
$_POST['regdate'],
// ======== dutch specific
$form_dbcprefix, // $prefixlast
$form_dbcprefixpartner, // $prefixlastpartner
$form_dbclastpartner, // $lastpartner
$form_voorletters, // initials
"", // $provider_data
"" // $referer_data
// ======== EOS dutch specific
);
newEmployerData($pid);
newHistoryData($pid);
newInsuranceData($pid, "primary");
newInsuranceData($pid, "secondary");
newInsuranceData($pid, "tertiary");
// DBC DUTCH INSURANCE DATA
if ( $GLOBALS['dutchpc'] ) set_insurer_nl($pid, $form_provider, $form_insdate, $form_policy);
// EOS DBC
// 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'");
}
// DBC Dutch System
if ( $GLOBALS['dutchpc'] ) {
generate_id1250($pid); // generate an ID1250 number
}
}
?>
<html>
<body>
<script language="Javascript">
<?
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>