forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
insurance_form.php
377 lines (335 loc) · 12.1 KB
/
insurance_form.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<?php
/**
* Insurance form posting for the WordPress Patient Portal.
*
* @package OpenEMR
* @link http:https://www.open-emr.org
* @author Rod Roark <[email protected]>
* @author Brady Miller <[email protected]>
* @copyright Copyright (c) 2014 Rod Roark <[email protected]>
* @copyright Copyright (c) 2017-2019 Brady Miller <[email protected]>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/
require_once("../globals.php");
require_once("$srcdir/patient.inc");
require_once("$srcdir/options.inc.php");
require_once("portal.inc.php");
use OpenEMR\Core\Header;
// Consider this a step towards converting the insurance form to layout-based.
// Faking it here makes things easier.
// Also note that some fields like SSN and most of the subscriber employer
// items have been omitted because they are not relevant for claims.
//
$insurance_layout = array(
array('field_id' => 'type',
'title' => 'Type',
'uor' => '2',
'data_type' => '1',
'list_id' => 'insurance_types',
'edit_options' => '',
),
array('field_id' => 'date',
'title' => 'Effective Date',
'uor' => '2',
'data_type' => '4', // Text-date
'list_id' => '',
'edit_options' => '',
),
array('field_id' => 'provider',
'title' => 'Provider',
'uor' => '2',
'data_type' => '16', // Insurance Providers
'list_id' => '',
'edit_options' => '',
),
array('field_id' => 'plan_name',
'title' => 'Plan Name',
'uor' => '1',
'data_type' => '2', // Text
'list_id' => '',
'edit_options' => '',
),
array('field_id' => 'policy_number',
'title' => 'Policy Number',
'uor' => '1',
'data_type' => '2', // Text
'list_id' => '',
'edit_options' => '',
),
array('field_id' => 'group_number',
'title' => 'Group Number',
'uor' => '1',
'data_type' => '2', // Text
'list_id' => '',
'edit_options' => '',
),
array('field_id' => 'subscriber_employer',
'title' => 'Group Name',
'uor' => '1',
'data_type' => '2', // Text
'list_id' => '',
'edit_options' => '',
),
array('field_id' => 'subscriber_lname',
'title' => 'Subscriber Last Name',
'uor' => '2',
'data_type' => '2', // Text
'list_id' => '',
'edit_options' => '',
),
array('field_id' => 'subscriber_fname',
'title' => 'Subscriber First Name',
'uor' => '1',
'data_type' => '2', // Text
'list_id' => '',
'edit_options' => '',
),
array('field_id' => 'subscriber_mname',
'title' => 'Subscriber Middle Name',
'uor' => '1',
'data_type' => '2', // Text
'list_id' => '',
'edit_options' => '',
),
array('field_id' => 'subscriber_DOB',
'title' => 'Subscriber DOB',
'uor' => '2',
'data_type' => '4', // Text-date
'list_id' => '',
'edit_options' => '',
),
array('field_id' => 'subscriber_sex',
'title' => 'Subscriber Sex',
'uor' => '2',
'data_type' => '1', // List
'list_id' => 'sex',
'edit_options' => '',
),
array('field_id' => 'subscriber_relationship',
'title' => 'Subscriber Relationship',
'uor' => '2',
'data_type' => '1', // List
'list_id' => 'sub_relation',
'edit_options' => '',
),
array('field_id' => 'subscriber_street',
'title' => 'Subscriber Street',
'uor' => '1',
'data_type' => '2', // Text
'list_id' => '',
'edit_options' => '',
),
array('field_id' => 'subscriber_city',
'title' => 'Subscriber City',
'uor' => '1',
'data_type' => '2', // Text
'list_id' => '',
'edit_options' => '',
),
array('field_id' => 'subscriber_state',
'title' => 'Subscriber State',
'uor' => '1',
'data_type' => '1', // List
'list_id' => 'state',
'edit_options' => '',
),
array('field_id' => 'subscriber_postal_code',
'title' => 'Subscriber Zip',
'uor' => '1',
'data_type' => '2', // Text
'list_id' => '',
'edit_options' => '',
),
array('field_id' => 'subscriber_phone',
'title' => 'Subscriber Phone',
'uor' => '1',
'data_type' => '2', // Text
'list_id' => '',
'edit_options' => '',
),
);
$postid = intval($_REQUEST['postid']);
if ($_POST['bn_save']) {
$newdata = array();
$ptid = intval($_POST['ptid']);
foreach ($insurance_layout as $frow) {
$data_type = $frow['data_type'];
$field_id = $frow['field_id'];
$newdata[$field_id] = get_layout_form_value($frow);
}
newInsuranceData(
$ptid,
$newdata['type'],
$newdata['provider'],
$newdata['policy_number'],
$newdata['group_number'],
$newdata['plan_name'],
$newdata['subscriber_lname'],
$newdata['subscriber_mname'],
$newdata['subscriber_fname'],
$newdata['subscriber_relationship'],
'', // subscriber_ss
$newdata['subscriber_DOB'],
$newdata['subscriber_street'],
$newdata['subscriber_postal_code'],
$newdata['subscriber_city'],
$newdata['subscriber_state'],
'', // subscriber_country
$newdata['subscriber_phone'],
$newdata['subscriber_employer'],
'', // subscriber_employer_street
'', // subscriber_employer_city
'', // subscriber_employer_postal_code
'', // subscriber_employer_state
'', // subscriber_employer_country
'', // copay
$newdata['subscriber_sex'],
$newdata['date'],
'TRUE', // accept_assignment
'' // policy_type
);
// Finally, delete the request from the portal.
$result = cms_portal_call(array('action' => 'delpost', 'postid' => $postid));
if ($result['errmsg']) {
die(text($result['errmsg']));
}
echo "<html><body><script language='JavaScript'>\n";
echo "if (top.restoreSession) top.restoreSession(); else opener.top.restoreSession();\n";
echo "document.location.href = 'list_requests.php';\n";
echo "</script></body></html>\n";
exit();
}
// Get the portal request data.
if (!$postid) {
die(xlt('Request ID is missing!'));
}
$result = cms_portal_call(array('action' => 'getpost', 'postid' => $postid));
if ($result['errmsg']) {
die(text($result['errmsg']));
}
// Look up the patient in OpenEMR.
$ptid = lookup_openemr_patient($result['post']['user']);
?>
<html>
<head>
<?php Header::setupHeader('datetime-picker'); ?>
<style>
tr.head { font-size:10pt; background-color:#cccccc; text-align:center; }
tr.detail { font-size:10pt; background-color:#ddddff; }
td input { background-color:transparent; }
</style>
<script language="JavaScript">
var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
function myRestoreSession() {
if (top.restoreSession) top.restoreSession(); else opener.top.restoreSession();
return true;
}
// This capitalizes the first letter of each word in the passed input
// element. It also strips out extraneous spaces.
// Copied from demographics_full.php.
function capitalizeMe(elem) {
var a = elem.value.split(' ');
var s = '';
for(var i = 0; i < a.length; ++i) {
if (a[i].length > 0) {
if (s.length > 0) s += ' ';
s += a[i].charAt(0).toUpperCase() + a[i].substring(1);
}
}
elem.value = s;
}
function validate() {
var f = document.forms[0];
// TBD
return true;
}
$(function () {
$('.datepicker').datetimepicker({
<?php $datetimepicker_timepicker = false; ?>
<?php $datetimepicker_showseconds = false; ?>
<?php $datetimepicker_formatInput = true; ?>
<?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
<?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
});
$('.datetimepicker').datetimepicker({
<?php $datetimepicker_timepicker = true; ?>
<?php $datetimepicker_showseconds = false; ?>
<?php $datetimepicker_formatInput = true; ?>
<?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
<?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
});
});
</script>
</head>
<body class="body_top">
<center>
<form method='post' action='insurance_form.php' onsubmit='return validate()'>
<input type='hidden' name='ptid' value='<?php echo attr($ptid); ?>' />
<input type='hidden' name='postid' value='<?php echo attr($postid); ?>' />
<table width='100%' cellpadding='1' cellspacing='2'>
<tr class='head'>
<th align='left'><?php echo xlt('Field'); ?></th>
<th align='left'><?php echo xlt('Current Value'); ?></th>
<th align='left'><?php echo xlt('New Value'); ?></th>
</tr>
<?php
$insrow = getInsuranceData($pid, $result['fields']['type']);
foreach ($insurance_layout as $lorow) {
$data_type = $lorow['data_type'];
$field_id = $lorow['field_id'];
$list_id = $lorow['list_id'];
$field_title = $lorow['title'];
$currvalue = '';
if (isset($insrow[$field_id])) {
$currvalue = $insrow[$field_id];
}
$newvalue = '';
if (isset($result['fields'][$field_id])) {
$newvalue = trim($result['fields'][$field_id]);
}
// Translate $newvalue for certain field types including lists.
if ($newvalue !== '') {
if ($list_id) {
$tmp = sqlQuery(
"SELECT option_id FROM list_options WHERE " .
"list_id = ? AND title = ? AND activity = 1 ORDER BY option_id LIMIT 1",
array($list_id, $newvalue)
);
if (isset($tmp['option_id'])) {
$newvalue = $tmp['option_id'];
}
}
// Some data types like insurance provider are pretty hopeless, so let the display
// logic generate a "Fix me" message and the user can translate it.
}
echo " <tr class='detail'>\n";
echo " <td class='bold'>" . text($field_title) . "</td>\n";
echo " <td>";
echo generate_display_field($lorow, $currvalue);
echo "</td>\n";
echo " <td>";
generate_form_field($lorow, $newvalue);
echo "</td>\n";
echo " </tr>\n";
}
?>
</table>
<p>
<input type='submit' name='bn_save' value='<?php echo xla('Save and Delete Request'); ?>' />
<input type='button' value='<?php echo xla('Back'); ?>' onclick="window.history.back()" />
<!-- Was: onclick="myRestoreSession();location='list_requests.php'" -->
</p>
</form>
<script language="JavaScript">
// Fix inconsistently formatted phone numbers from the database.
var f = document.forms[0];
if (f.form_phone) phonekeyup(f.form_phone, mypcc);
// This is a by-product of generate_form_field().
<?php echo $date_init; ?>
</script>
<!-- include support for the list-add selectbox feature -->
<?php include $GLOBALS['fileroot'] . "/library/options_listadd.inc"; ?>
</center>
</body>
</html>