CDR Module CMQ PQRI database addition.
[openemr.git] / interface / practice / ins_list.php
blobbdedaba503d705f7229eec93b8491c2ab01f2d24
1 <?php
2 // Copyright (C) 2005 Rod Roark <rod@sunsetsystems.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 // The purpose of this module is to show a list of insurance
10 // companies that match the passed-in search strings, and to allow
11 // one of them to be selected.
13 include_once("../globals.php");
15 // Putting a message here will cause a popup window to display it.
16 $info_msg = "";
18 function addwhere($where, $colname, $value) {
19 if ($value) {
20 $where .= " AND ";
21 $where .= "$colname LIKE '%$value%'";
23 return $where;
26 // The following code builds the appropriate SQL query from the
27 // search parameters passed by our opener (ins_search.php).
29 $where = '';
30 $where = addwhere($where, 'i.name' , $_REQUEST['form_name'] );
31 $where = addwhere($where, 'i.attn' , $_REQUEST['form_attn'] );
32 $where = addwhere($where, 'i.cms_id', $_REQUEST['form_cms_id']);
33 $where = addwhere($where, 'a.line1' , $_REQUEST['form_addr1'] );
34 $where = addwhere($where, 'a.line2' , $_REQUEST['form_addr2'] );
35 $where = addwhere($where, 'a.city' , $_REQUEST['form_city'] );
36 $where = addwhere($where, 'a.state' , $_REQUEST['form_state'] );
37 $where = addwhere($where, 'a.zip' , $_REQUEST['form_zip'] );
39 $phone_parts = array();
41 // Search by area code if there is one.
42 if (preg_match("/(\d\d\d)/",
43 $_REQUEST['form_phone'], $phone_parts))
44 $where = addwhere($where, 'p.area_code', $phone_parts[1]);
46 // If there is also an exchange, search for that too.
47 if (preg_match("/\d\d\d\D*(\d\d\d)/",
48 $_REQUEST['form_phone'], $phone_parts))
49 $where = addwhere($where, 'p.prefix', $phone_parts[1]);
51 // If the last 4 phone number digits are given, search for that too.
52 if (preg_match("/\d\d\d\D*\d\d\d\D*(\d\d\d\d)/",
53 $_REQUEST['form_phone'], $phone_parts))
54 $where = addwhere($where, 'p.number', $phone_parts[1]);
56 $query = "SELECT " .
57 "i.id, i.name, i.attn, " .
58 "a.line1, a.line2, a.city, a.state, a.zip, " .
59 "p.area_code, p.prefix, p.number " .
60 "FROM insurance_companies AS i, addresses AS a, phone_numbers AS p " .
61 "WHERE a.foreign_id = i.id AND p.foreign_id = i.id$where " .
62 "ORDER BY i.name, a.zip";
63 $res = sqlStatement($query);
65 <html>
66 <head>
67 <title><?php xl('List Insurance Companies','e');?></title>
68 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
70 <style>
71 td { font-size:10pt; }
72 </style>
74 <script language="JavaScript">
76 // This is invoked when an insurance company name is clicked.
77 function setins(ins_id, ins_name) {
78 parent.set_insurance(ins_id, ins_name);
79 parent.$.fn.fancybox.close();
80 return false;
83 </script>
85 </head>
87 <body class="body_top">
88 <form method='post' name='theform'>
89 <center>
91 <table border='0' width='100%'>
92 <tr>
93 <td><b><?php xl('Name','e');?></b>&nbsp;</td>
94 <td><b><?php xl('Attn','e');?></b>&nbsp;</td>
95 <td><b><?php xl('Address','e');?></b>&nbsp;</td>
96 <td><b>&nbsp;</b>&nbsp;</td>
97 <td><b><?php xl('City','e');?></b>&nbsp;</td>
98 <td><b><?php xl('State','e');?></b>&nbsp;</td>
99 <td><b><?php xl('Zip','e');?></b>&nbsp;</td>
100 <td><b><?php xl('Phone','e');?></b></td>
101 </tr>
103 <?php
104 while ($row = sqlFetchArray($res)) {
105 $anchor = "<a href=\"\" onclick=\"return setins(" .
106 $row['id'] . ",'" . addslashes($row['name']) . "')\">";
107 $phone = '&nbsp';
108 if ($row['number']) {
109 $phone = $row['area_code'] . '-' . $row['prefix'] . '-' . $row['number'];
111 echo " <tr>\n";
112 echo " <td valign='top'>$anchor" . $row['name'] . "</a>&nbsp;</td>\n";
113 echo " <td valign='top'>" . $row['attn'] . "&nbsp;</td>\n";
114 echo " <td valign='top'>" . $row['line1'] . "&nbsp;</td>\n";
115 echo " <td valign='top'>" . $row['line2'] . "&nbsp;</td>\n";
116 echo " <td valign='top'>" . $row['city'] . "&nbsp;</td>\n";
117 echo " <td valign='top'>" . $row['state'] . "&nbsp;</td>\n";
118 echo " <td valign='top'>" . $row['zip'] . "&nbsp;</td>\n";
119 echo " <td valign='top'>$phone</td>\n";
120 echo " </tr>\n";
123 </table>
125 </center>
126 </form>
127 </body>
128 </html>