robots.txt (#2077)
[openemr.git] / interface / practice / ins_list.php
blobf3768f22072cf62e0a86ffd675ecb0109e645f81
1 <?php
2 /**
3 * The purpose of this module is to show a list of insurance
4 * companies that match the passed-in search strings, and to allow
5 * one of them to be selected.
7 * @package OpenEMR
8 * @link http://www.open-emr.org
9 * @author Rod Roark <rod@sunsetsystems.com>
10 * @author Brady Miller <brady.g.miller@gmail.com>
11 * @copyright Copyright (c) 2005 Rod Roark <rod@sunsetsystems.com>
12 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
13 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
17 require_once("../globals.php");
19 if (!verifyCsrfToken($_GET["csrf_token_form"])) {
20 csrfNotVerified();
24 // Putting a message here will cause a popup window to display it.
25 $info_msg = "";
27 function addwhere($where, $colname, $value)
29 if ($value) {
30 $where .= " AND ";
31 $where .= "$colname LIKE '%" . add_escape_custom($value) . "%'";
34 return $where;
37 // The following code builds the appropriate SQL query from the
38 // search parameters passed by our opener (ins_search.php).
40 $where = '';
41 $where = addwhere($where, 'i.name', $_GET['form_name']);
42 $where = addwhere($where, 'i.attn', $_GET['form_attn']);
43 $where = addwhere($where, 'i.cms_id', $_GET['form_cms_id']);
44 $where = addwhere($where, 'a.line1', $_GET['form_addr1']);
45 $where = addwhere($where, 'a.line2', $_GET['form_addr2']);
46 $where = addwhere($where, 'a.city', $_GET['form_city']);
47 $where = addwhere($where, 'a.state', $_GET['form_state']);
48 $where = addwhere($where, 'a.zip', $_GET['form_zip']);
50 $phone_parts = array();
52 // Search by area code if there is one.
53 if (preg_match(
54 "/(\d\d\d)/",
55 $_GET['form_phone'],
56 $phone_parts
57 )) {
58 $where = addwhere($where, 'p.area_code', $phone_parts[1]);
61 // If there is also an exchange, search for that too.
62 if (preg_match(
63 "/\d\d\d\D*(\d\d\d)/",
64 $_GET['form_phone'],
65 $phone_parts
66 )) {
67 $where = addwhere($where, 'p.prefix', $phone_parts[1]);
70 // If the last 4 phone number digits are given, search for that too.
71 if (preg_match(
72 "/\d\d\d\D*\d\d\d\D*(\d\d\d\d)/",
73 $_GET['form_phone'],
74 $phone_parts
75 )) {
76 $where = addwhere($where, 'p.number', $phone_parts[1]);
79 $query = "SELECT " .
80 "i.id, i.name, i.attn, " .
81 "a.line1, a.line2, a.city, a.state, a.zip, " .
82 "p.area_code, p.prefix, p.number " .
83 "FROM insurance_companies AS i, addresses AS a, phone_numbers AS p " .
84 "WHERE a.foreign_id = i.id AND p.foreign_id = i.id$where " .
85 "ORDER BY i.name, a.zip";
86 $res = sqlStatement($query);
88 <html>
89 <head>
90 <title><?php echo xlt('List Insurance Companies');?></title>
91 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
93 <style>
94 td { font-size:10pt; }
95 </style>
97 <script language="JavaScript">
99 // This is invoked when an insurance company name is clicked.
100 function setins(ins_id, ins_name) {
101 opener.set_insurance(ins_id, ins_name);
102 dlgclose();
103 return false;
106 </script>
108 </head>
110 <body class="body_top">
111 <form method='post' name='theform'>
112 <center>
114 <table class="table table-condensed" border='0' width='100%'>
115 <tr>
116 <td><b><?php echo xlt('Name');?></b>&nbsp;</td>
117 <td><b><?php echo xlt('Attn');?></b>&nbsp;</td>
118 <td><b><?php echo xlt('Address');?></b>&nbsp;</td>
119 <td><b>&nbsp;</b>&nbsp;</td>
120 <td><b><?php echo xlt('City');?></b>&nbsp;</td>
121 <td><b><?php echo xlt('State');?></b>&nbsp;</td>
122 <td><b><?php echo xlt('Zip');?></b>&nbsp;</td>
123 <td><b><?php echo xlt('Phone');?></b></td>
124 </tr>
126 <?php
127 while ($row = sqlFetchArray($res)) {
128 $anchor = "<a href=\"\" onclick=\"return setins(" .
129 attr_js($row['id']) . "," . attr_js($row['name']) . ")\">";
130 $phone = '&nbsp';
131 if ($row['number']) {
132 $phone = text($row['area_code']) . '-' . text($row['prefix']) . '-' . text($row['number']);
135 echo " <tr>\n";
136 echo " <td valign='top'>$anchor" . text($row['name']) . "</a>&nbsp;</td>\n";
137 echo " <td valign='top'>" . text($row['attn']) . "&nbsp;</td>\n";
138 echo " <td valign='top'>" . text($row['line1']) . "&nbsp;</td>\n";
139 echo " <td valign='top'>" . text($row['line2']) . "&nbsp;</td>\n";
140 echo " <td valign='top'>" . text($row['city']) . "&nbsp;</td>\n";
141 echo " <td valign='top'>" . text($row['state']) . "&nbsp;</td>\n";
142 echo " <td valign='top'>" . text($row['zip']) . "&nbsp;</td>\n";
143 echo " <td valign='top'>" . $phone . "</td>\n";
144 echo " </tr>\n";
147 </table>
149 </center>
150 </form>
151 </body>
152 </html>