-
-
Notifications
You must be signed in to change notification settings - Fork 2k
/
ins_search.php
374 lines (320 loc) · 10.4 KB
/
ins_search.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
<?php
// Copyright (C) 2005 Rod Roark <rod@sunsetsystems.com>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// This module is used to find and add insurance companies.
// It is opened as a popup window. The opener may have a
// JavaScript function named set_insurance(id, name), in which
// case selecting or adding an insurance company will cause the
// function to be called passing the ID and name of that company.
// When used for searching, this module will in turn open another
// popup window ins_list.php, which lists the matched results and
// permits selection of one of them via the same set_insurance()
// function.
include_once("../globals.php");
include_once("$srcdir/acl.inc");
// Putting a message here will cause a popup window to display it.
$info_msg = "";
// This is copied from InsuranceCompany.class.php. It should
// really be in a SQL table.
$freeb_type_array = array(''
, xl('Other HCFA')
, xl('Medicare Part B')
, xl('Medicaid')
, xl('ChampUSVA')
, xl('ChampUS')
, xl('Blue Cross Blue Shield')
, xl('FECA')
, xl('Self Pay')
, xl('Central Certification')
, xl('Other Non-Federal Programs')
, xl('Preferred Provider Organization (PPO)')
, xl('Point of Service (POS)')
, xl('Exclusive Provider Organization (EPO)')
, xl('Indemnity Insurance')
, xl('Health Maintenance Organization (HMO) Medicare Risk')
, xl('Automobile Medical')
, xl('Commercial Insurance Co.')
, xl('Disability')
, xl('Health Maintenance Organization')
, xl('Liability')
, xl('Liability Medical')
, xl('Other Federal Program')
, xl('Title V')
, xl('Veterans Administration Plan')
, xl('Workers Compensation Health Plan')
, xl('Mutually Defined')
);
?>
<html>
<head>
<title><?php xl('Insurance Company Search/Add','e');?></title>
<link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
<style>
td { font-size:10pt; }
.search { background-color:#aaffaa }
#form_entry {
display:block;
}
#form_list {
display:none;
}
</style>
<script type="text/javascript" src="../../library/topdialog.js"></script>
<script type="text/javascript" src="../../library/dialog.js"></script>
<script type="text/javascript" src="../../library/js/jquery.1.3.2.js"></script>
<script language="JavaScript">
var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
<?php require($GLOBALS['srcdir'] . "/restoreSession.php"); ?>
function doescape(value) {
return encodeURIComponent(value);
}
// This is invoked when our Search button is clicked.
function dosearch() {
$("#form_entry").hide();
var f = document.forms[0];
var search_list = 'ins_list.php' +
'?form_name=' + doescape(f.form_name.value ) +
'&form_attn=' + doescape(f.form_attn.value ) +
'&form_addr1=' + doescape(f.form_addr1.value ) +
'&form_addr2=' + doescape(f.form_addr2.value ) +
'&form_city=' + doescape(f.form_city.value ) +
'&form_state=' + doescape(f.form_state.value ) +
'&form_zip=' + doescape(f.form_zip.value ) +
'&form_phone=' + doescape(f.form_phone.value ) +
'&form_cms_id=' + doescape(f.form_cms_id.value);
top.restoreSession();
$("#form_list").load( search_list ).show();
return false;
}
// The ins_list.php window calls this to set the selected insurance.
function set_insurance(ins_id, ins_name) {
if (opener.closed || ! opener.set_insurance)
alert('The target form was closed; I cannot apply your selection.');
else
opener.set_insurance(ins_id, ins_name);
parent.$.fn.fancybox.close();
parent.location.reload();
top.restoreSession();
}
// This is set to true on a mousedown of the Save button. The
// reason is so we can distinguish between clicking on the Save
// button vs. hitting the Enter key, as we prefer the "default"
// action to be search and not save.
var save_clicked = false;
// Onsubmit handler.
function validate(f) {
// If save was not clicked then default to searching.
if (! save_clicked) return dosearch();
save_clicked = false;
msg = '';
if (! f.form_name.value.length ) msg += 'Company name is missing. ';
if (! f.form_addr1.value.length) msg += 'Address is missing. ';
if (! f.form_city.value.length ) msg += 'City is missing. ';
if (! f.form_state.value.length) msg += 'State is missing. ';
if (! f.form_zip.value.length ) msg += 'Zip is missing.';
if (msg) {
alert(msg);
return false;
}
top.restoreSession();
return true;
}
</script>
</head>
<body class="body_top" onunload='imclosing()'>
<?php
// If we are saving, then save and close the window.
//
if ($_POST['form_save']) {
$ins_id = '';
$ins_name = $_POST['form_name'];
if ($ins_id) {
// sql for updating could go here if this script is enhanced to support
// editing of existing insurance companies.
} else {
$ins_id = generate_id();
sqlInsert("INSERT INTO insurance_companies ( " .
"id, name, attn, cms_id, freeb_type, x12_receiver_id, x12_default_partner_id " .
") VALUES ( " .
$ins_id . ", " .
"'" . $ins_name . "', " .
"'" . $_POST['form_attn'] . "', " .
"'" . $_POST['form_cms_id'] . "', " .
"'" . $_POST['form_freeb_type'] . "', " .
"'" . $_POST['form_partner'] . "', " .
"'" . $_POST['form_partner'] . "' " .
")");
sqlInsert("INSERT INTO addresses ( " .
"id, line1, line2, city, state, zip, country, foreign_id " .
") VALUES ( " .
generate_id() . ", " .
"'" . $_POST['form_addr1'] . "', " .
"'" . $_POST['form_addr2'] . "', " .
"'" . $_POST['form_city'] . "', " .
"'" . $_POST['form_state'] . "', " .
"'" . $_POST['form_zip'] . "', " .
"'" . $_POST['form_country'] . "', " .
$ins_id . " " .
")");
$phone_parts = array();
preg_match("/(\d\d\d)\D*(\d\d\d)\D*(\d\d\d\d)/", $_POST['form_phone'],
$phone_parts);
sqlInsert("INSERT INTO phone_numbers ( " .
"id, country_code, area_code, prefix, number, type, foreign_id " .
") VALUES ( " .
generate_id() . ", " .
"'+1'" . ", " .
"'" . $phone_parts[1] . "', " .
"'" . $phone_parts[2] . "', " .
"'" . $phone_parts[3] . "', " .
"'2'" . ", " .
$ins_id . " " .
")");
}
// Close this window and tell our opener to select the new company.
//
echo "<script language='JavaScript'>\n";
if ($info_msg) echo " alert('$info_msg');\n";
echo " parent.$.fn.fancybox.close();\n";
echo " top.restoreSession();\n";
echo " if (parent.set_insurance) parent.set_insurance($ins_id,'$ins_name');\n";
echo "</script></body></html>\n";
exit();
}
// Query x12_partners.
$xres = sqlStatement(
"SELECT id, name FROM x12_partners ORDER BY name"
);
?>
<div id="form_entry">
<form method='post' name='theform' action='ins_search.php'
onsubmit='return validate(this)'>
<center>
<p>
<table border='0' width='100%'>
<!--
<tr>
<td valign='top' width='1%' nowrap> </td>
<td>
Note: Green fields are searchable.
</td>
</tr>
-->
<tr>
<td valign='top' width='1%' nowrap><b><?php xl('Name','e');?>:</b></td>
<td>
<input type='text' size='20' name='form_name' maxlength='35'
class='search' style='width:100%' title=<?php xl('Name of insurance company','e');?> />
</td>
</tr>
<tr>
<td valign='top' nowrap><b><?php xl('Attention','e');?>:</b></td>
<td>
<input type='text' size='20' name='form_attn' maxlength='35'
class='search' style='width:100%' title=".xl('Contact name')." />
</td>
</tr>
<tr>
<td valign='top' nowrap><b><?php xl('Address1','e');?>:</b></td>
<td>
<input type='text' size='20' name='form_addr1' maxlength='35'
class='search' style='width:100%' title='First address line' />
</td>
</tr>
<tr>
<td valign='top' nowrap><b><?php xl('Address2','e');?>:</b></td>
<td>
<input type='text' size='20' name='form_addr2' maxlength='35'
class='search' style='width:100%' title='Second address line, if any' />
</td>
</tr>
<tr>
<td valign='top' nowrap><b><?php xl('City/State','e');?>:</b></td>
<td>
<input type='text' size='20' name='form_city' maxlength='25'
class='search' title='City name' />
<input type='text' size='3' name='form_state' maxlength='35'
class='search' title='State or locality' />
</td>
</tr>
<tr>
<td valign='top' nowrap><b><?php xl('Zip/Country:','e'); ?></b></td>
<td>
<input type='text' size='20' name='form_zip' maxlength='10'
class='search' title='Postal code' />
<input type='text' size='20' name='form_country' value='USA' maxlength='35'
title='Country name' />
</td>
</tr>
<tr>
<td valign='top' nowrap><b><?php xl('Phone','e');?>:</b></td>
<td>
<input type='text' size='20' name='form_phone' maxlength='20'
class='search' title='Telephone number' />
</td>
</tr>
<!--
<tr>
<td valign='top' width='1%' nowrap> </td>
<td>
<br><b>Other data:</b>
</td>
</tr>
-->
<tr>
<td valign='top' nowrap><b><?php xl('CMS ID','e');?>:</b></td>
<td>
<input type='text' size='20' name='form_cms_id' maxlength='15'
class='search' title='Identifier assigned by CMS' />
</td>
</tr>
<tr>
<td valign='top' nowrap><b><?php xl('Payer Type','e');?>:</b></td>
<td>
<select name='form_freeb_type'>
<?php
for ($i = 1; $i < count($freeb_type_array); ++$i) {
echo " <option value='$i'";
// if ($i == $row['freeb_type']) echo " selected";
echo ">" . $freeb_type_array[$i] . "\n";
}
?>
</select>
</td>
</tr>
<tr>
<td valign='top' nowrap><b><?php xl('X12 Partner','e');?>:</b></td>
<td>
<select name='form_partner' title='Default X12 Partner'>
<option value=""><?php xl('None','e','-- ',' --'); ?></option>
<?php
while ($xrow = sqlFetchArray($xres)) {
echo " <option value='" . $xrow['id'] . "'";
// if ($xrow['id'] == $row['x12_default_partner_id']) echo " selected";
echo ">" . $xrow['name'] . "</option>\n";
}
?>
</select>
</td>
</tr>
</table>
<p> <br>
<input type='button' value='<?php xl('Search','e'); ?>' class='search' onclick='dosearch()' />
<input type='submit' value='<?php xl('Save as New','e'); ?>' name='form_save' onmousedown='save_clicked=true' />
<input type='button' value='<?php xl('Cancel','e'); ?>' onclick='parent.$.fn.fancybox.close();'/>
</p>
</center>
</form>
</div>
<div id="form_list">
</div>
</body>
</html>