/
ins_list.php
176 lines (150 loc) · 4.97 KB
/
ins_list.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
<?php
/**
* The purpose of this module is to show a list of insurance
* companies that match the passed-in search strings, and to allow
* one of them to be selected.
*
* @package OpenEMR
* @link https://www.open-emr.org
* @author Rod Roark <rod@sunsetsystems.com>
* @author Brady Miller <brady.g.miller@gmail.com>
* @author Stephen Waite <stephen.waite@cmsvt.com>
* @copyright Copyright (c) 2005 Rod Roark <rod@sunsetsystems.com>
* @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
* @copyright Copyright (c) 2021 Stephen Waite <stephen.waite@cmsvt.com>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/
require_once("../globals.php");
use OpenEMR\Common\Csrf\CsrfUtils;
use OpenEMR\Core\Header;
if (!CsrfUtils::verifyCsrfToken($_GET["csrf_token_form"])) {
CsrfUtils::csrfNotVerified();
}
// Putting a message here will cause a popup window to display it.
$info_msg = "";
function addwhere($where, $colname, $value)
{
if ($value) {
$where .= " AND ";
$where .= "$colname LIKE '%" . add_escape_custom($value) . "%'";
}
return $where;
}
// The following code builds the appropriate SQL query from the
// search parameters passed by our opener (ins_search.php).
$where = '';
$where = addwhere($where, 'i.name', $_GET['form_name']);
$where = addwhere($where, 'i.attn', $_GET['form_attn']);
$where = addwhere($where, 'i.cms_id', $_GET['form_cms_id']);
$where = addwhere($where, 'a.line1', $_GET['form_addr1']);
$where = addwhere($where, 'a.line2', $_GET['form_addr2']);
$where = addwhere($where, 'a.city', $_GET['form_city']);
$where = addwhere($where, 'a.state', $_GET['form_state']);
$where = addwhere($where, 'a.zip', $_GET['form_zip']);
$phone_parts = array();
$area_code = null;
$prefix = null;
$digits = null;
// Search by area code if there is one.
if (
preg_match(
"/(\d\d\d)/",
$_GET['form_phone'],
$phone_parts
)
) {
$area_code = $phone_parts[1];
$where = addwhere($where, 'p.area_code', $area_code);
}
// If there is also an exchange, search for that too.
if (
preg_match(
"/\d\d\d\D*(\d\d\d)/",
$_GET['form_phone'],
$phone_parts
)
) {
$prefix = $phone_parts[1];
$where = addwhere($where, 'p.prefix', $prefix);
}
// If the last 4 phone number digits are given, search for that too.
if (
preg_match(
"/\d\d\d\D*\d\d\d\D*(\d\d\d\d)/",
$_GET['form_phone'],
$phone_parts
)
) {
$digits = $phone_parts[1];
$where = addwhere($where, 'p.number', $digits);
}
$query = "SELECT " .
"i.id, i.name, i.attn, " .
"a.line1, a.line2, a.city, a.state, a.zip, " .
"p.area_code, p.prefix, p.number " .
"FROM insurance_companies i " .
"LEFT JOIN addresses a ON a.foreign_id = i.id " .
"LEFT JOIN phone_numbers p ON p.foreign_id = i.id WHERE 1=1 ";
$query .= $where . " ORDER BY i.name, a.zip";
$res = sqlStatement($query);
?>
<html>
<head>
<title><?php echo xlt('List Insurance Companies');?></title>
<?php Header::setupHeader(); ?>
<style>
td {
font-size: 0.8125rem;
}
</style>
<script>
// This is invoked when an insurance company name is clicked.
function setins(ins_id, ins_name) {
opener.set_insurance(ins_id, ins_name);
dlgclose();
return false;
}
</script>
</head>
<body class="body_top">
<form method='post' name='theform'>
<center>
<table class="table table-sm border-0 w-100">
<tr>
<td class='font-weight-bold'><?php echo xlt('Name');?> </td>
<td class='font-weight-bold'><?php echo xlt('Attn');?> </td>
<td class='font-weight-bold'><?php echo xlt('Address');?> </td>
<td class='font-weight-bold'> </td>
<td class='font-weight-bold'><?php echo xlt('City');?> </td>
<td class='font-weight-bold'><?php echo xlt('State');?> </td>
<td class='font-weight-bold'><?php echo xlt('Zip');?> </td>
<td class='font-weight-bold'><?php echo xlt('Phone');?></td>
</tr>
<?php
if (empty($res->_numOfRows)) {
echo " <td>" . xlt('No matches found.') . "</td>";
}
while ($row = sqlFetchArray($res)) {
$anchor = "<a href=\"\" onclick=\"return setins(" .
attr_js($row['id']) . "," . attr_js($row['name']) . ")\">";
$phone = ' ';
if ($row['number'] ?? null) {
$phone = text($row['area_code']) . '-' . text($row['prefix']) . '-' . text($row['number']);
}
echo " <tr>\n";
echo " <td valign='top'>$anchor" . text($row['name']) . "</a> </td>\n";
echo " <td valign='top'>" . text($row['attn']) . " </td>\n";
echo " <td valign='top'>" . text($row['line1']) . " </td>\n";
echo " <td valign='top'>" . text($row['line2']) . " </td>\n";
echo " <td valign='top'>" . text($row['city']) . " </td>\n";
echo " <td valign='top'>" . text($row['state']) . " </td>\n";
echo " <td valign='top'>" . text($row['zip']) . " </td>\n";
echo " <td valign='top'>" . $phone . "</td>\n";
}
echo " </tr>\n";
?>
</table>
</center>
</form>
</body>
</html>