4 * The purpose of this module is to show a list of insurance
5 * companies that match the passed-in search strings, and to allow
6 * one of them to be selected.
9 * @link https://www.open-emr.org
10 * @author Rod Roark <rod@sunsetsystems.com>
11 * @author Brady Miller <brady.g.miller@gmail.com>
12 * @author Stephen Waite <stephen.waite@cmsvt.com>
13 * @author Stephen Nielson <snielson@discoverandchange.com>
14 * @copyright Copyright (c) 2005 Rod Roark <rod@sunsetsystems.com>
15 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
16 * @copyright Copyright (c) 2021 Stephen Waite <stephen.waite@cmsvt.com>
17 * @copyright Copyright (c) 2024 Care Management Solutions, Inc. <stephen.waite@cmsvt.com>
18 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
21 require_once("../globals.php");
23 use OpenEMR\Common\Csrf\CsrfUtils
;
24 use OpenEMR\Core\Header
;
26 if (!CsrfUtils
::verifyCsrfToken($_GET["csrf_token_form"])) {
27 CsrfUtils
::csrfNotVerified();
31 // Putting a message here will cause a popup window to display it.
34 function addwhere($where, $colname, $value)
38 $where .= "$colname LIKE '%" . add_escape_custom($value) . "%'";
44 // The following code builds the appropriate SQL query from the
45 // search parameters passed by our opener (ins_search.php).
48 $where = addwhere($where, 'i.name', $_GET['form_name']);
49 $where = addwhere($where, 'i.attn', $_GET['form_attn']);
50 $where = addwhere($where, 'i.cms_id', $_GET['form_cms_id']);
51 $where = addwhere($where, 'a.line1', $_GET['form_addr1']);
52 $where = addwhere($where, 'a.line2', $_GET['form_addr2']);
53 $where = addwhere($where, 'a.city', $_GET['form_city']);
54 $where = addwhere($where, 'a.state', $_GET['form_state']);
55 $where = addwhere($where, 'a.zip', $_GET['form_zip']);
57 $phone_parts = array();
62 // Search by area code if there is one.
70 $area_code = $phone_parts[1];
71 $where = addwhere($where, 'p.area_code', $area_code);
74 // If there is also an exchange, search for that too.
77 "/\d\d\d\D*(\d\d\d)/",
82 $prefix = $phone_parts[1];
83 $where = addwhere($where, 'p.prefix', $prefix);
86 // If the last 4 phone number digits are given, search for that too.
89 "/\d\d\d\D*\d\d\d\D*(\d\d\d\d)/",
94 $digits = $phone_parts[1];
95 $where = addwhere($where, 'p.number', $digits);
99 "i.id, i.name, i.attn, " .
100 "a.line1, a.line2, a.city, a.state, a.zip, " .
101 "p.area_code, p.prefix, p.number " .
102 "FROM insurance_companies i " .
103 "LEFT JOIN addresses a ON a.foreign_id = i.id " .
104 "LEFT JOIN phone_numbers p ON p.foreign_id = i.id WHERE 1=1 ";
106 $query .= $where . " ORDER BY i.name, a.zip";
107 $res = sqlStatement($query);
111 <title
><?php
echo xlt('List Insurance Companies');?
></title
>
112 <?php Header
::setupHeader(); ?
>
116 font
-size
: 0.8125rem
;
122 // This is invoked when an insurance company name is clicked.
123 function setins(ins_id
, ins_name
) {
124 if (!window
.opener
) {
125 return; // nothing to do here as somehow we got here without the opener
128 action
: 'insurance-search-set-insurance'
130 ,insuranceName
: ins_name
132 // fire off a message so we can decouple things so we don't have to have a specific function
133 // name in the global scope of the opener
134 opener
.postMessage(postMessage
, window
.location
.origin
);
136 alert('The target form was closed; I cannot apply your selection.');
138 else if (opener
.set_insurance
) {
139 opener
.set_insurance(ins_id
, ins_name
);
142 // if we don't have a set_insurance function then we will just close the window as the opener is
143 // using post message to receive events.
153 <body
class="body_top">
154 <form method
='post' name
='theform'>
157 <table
class="table table-sm border-0 w-100">
159 <td
class='font-weight-bold'><?php
echo xlt('Name');?
> 
;</td
>
160 <td
class='font-weight-bold'><?php
echo xlt('Attn');?
> 
;</td
>
161 <td
class='font-weight-bold'><?php
echo xlt('Address');?
> 
;</td
>
162 <td
class='font-weight-bold'> 
; 
;</td
>
163 <td
class='font-weight-bold'><?php
echo xlt('City');?
> 
;</td
>
164 <td
class='font-weight-bold'><?php
echo xlt('State');?
> 
;</td
>
165 <td
class='font-weight-bold'><?php
echo xlt('Zip');?
> 
;</td
>
166 <td
class='font-weight-bold'><?php
echo xlt('Phone');?
></td
>
170 if (empty($res->_numOfRows
)) {
171 echo " <td>" . xlt('No matches found.') . "</td>";
173 while ($row = sqlFetchArray($res)) {
174 $anchor = "<a href=\"\" onclick=\"return setins(" .
175 attr_js($row['id']) . "," . attr_js($row['name']) . ")\">";
177 if ($row['number'] ??
null) {
178 $phone = text($row['area_code']) . '-' . text($row['prefix']) . '-' . text($row['number']);
182 echo " <td valign='top'>$anchor" . text($row['name']) . "</a> </td>\n";
183 echo " <td valign='top'>" . text($row['attn']) . " </td>\n";
184 echo " <td valign='top'>" . text($row['line1']) . " </td>\n";
185 echo " <td valign='top'>" . text($row['line2']) . " </td>\n";
186 echo " <td valign='top'>" . text($row['city']) . " </td>\n";
187 echo " <td valign='top'>" . text($row['state']) . " </td>\n";
188 echo " <td valign='top'>" . text($row['zip']) . " </td>\n";
189 echo " <td valign='top'>" . $phone . "</td>\n";