bug fix for note save return after fancybox replace. (#1320)
[openemr.git] / interface / orders / patient_match_dialog.php
blob8afaa1e898a1454d1c4b2eb287b6e2d92a56d97e
1 <?php
2 /**
3 * Patient matching and selection dialog.
5 * Copyright (C) 2012-2015 Rod Roark <rod@sunsetsystems.com>
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
18 * @package OpenEMR
19 * @author Rod Roark <rod@sunsetsystems.com>
25 require_once("../globals.php");
26 require_once("$srcdir/patient.inc");
27 require_once("$srcdir/options.inc.php");
29 $form_key = $_REQUEST['key'];
30 $args = unserialize($form_key);
31 $form_ss = preg_replace('/[^0-9]/', '', $args['ss']);
32 $form_fname = $args['fname'];
33 $form_lname = $args['lname'];
34 $form_DOB = $args['DOB'];
36 <html>
37 <head>
38 <?php html_header_show(); ?>
39 <link rel=stylesheet href="<?php echo $css_header; ?>" type="text/css">
40 <style>
42 #searchResults {
43 width: 100%;
44 height: 80%;
45 overflow: auto;
47 #searchResults table {
48 width: 96%;
49 border-collapse: collapse;
50 background-color: white;
52 #searchResults th {
53 background-color: lightgrey;
54 font-size: 0.7em;
55 text-align: left;
57 #searchResults td {
58 font-size: 0.7em;
59 border-bottom: 1px solid #eee;
60 cursor: hand;
61 cursor: pointer;
64 .highlight {
65 background-color: #336699;
66 color: white;
69 .oneResult {}
71 </style>
73 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-2/index.js"></script>
74 <script language="JavaScript">
76 $(document).ready(function(){
77 $(".oneresult").mouseover(function() {$(this).addClass("highlight");});
78 $(".oneresult").mouseout(function() {$(this).removeClass("highlight");});
79 });
81 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
83 function myRestoreSession() {
84 if (top.restoreSession) top.restoreSession(); else opener.top.restoreSession();
85 return true;
88 function openPatient(ptid) {
89 var f = opener.document.forms[0];
90 var ename = '<?php echo addslashes("select[$form_key]"); ?>';
91 if (f[ename]) {
92 f[ename].value = ptid;
93 window.close();
95 else {
96 alert('<?php echo xls('Form element not found'); ?>: ' + ename);
100 </script>
101 </head>
103 <body class="body_top">
104 <center>
105 <form method='post' action='patient_select.php' onsubmit='return myRestoreSession()'>
107 <?php
108 if ($form_key) {
109 $clarr = array();
110 $clsql = "0";
111 // First name.
112 if ($form_fname !== '') {
113 $clsql .= " + ((fname IS NOT NULL AND fname = ?) * 5)";
114 $clarr[] = $form_fname;
117 // Last name.
118 if ($form_lname !== '') {
119 $clsql .= " + ((lname IS NOT NULL AND lname = ?) * 5)";
120 $clarr[] = $form_lname;
123 // Birth date.
124 if ($form_DOB !== '') {
125 $clsql .= " + ((DOB IS NOT NULL AND DOB = ?) * 5)";
126 $clarr[] = $form_DOB;
129 // SSN match is worth a lot and we allow for matching on last 4 digits.
130 if (strlen($form_ss) > 3) {
131 $clsql .= " + ((ss IS NOT NULL AND ss LIKE ?) * 10)";
132 $clarr[] = "%$form_ss";
135 $sql = "SELECT $clsql AS closeness, " .
136 "pid, pubpid, fname, lname, mname, DOB, ss, postal_code, street, " .
137 "phone_biz, phone_home, phone_cell, phone_contact " .
138 "FROM patient_data " .
139 "ORDER BY closeness DESC, lname, fname LIMIT 10";
140 $res = sqlStatement($sql, $clarr);
143 <div id="searchResults">
144 <table>
145 <tr>
146 <th><?php echo xlt('Name'); ?></th>
147 <th><?php echo xlt('Phone'); ?></th>
148 <th><?php echo xlt('SS'); ?></th>
149 <th><?php echo xlt('DOB'); ?></th>
150 <th><?php echo xlt('Address'); ?></th>
151 </tr>
152 <tr>
153 <th style='font-weight:normal'><?php echo text("$form_lname, $form_fname"); ?></th>
154 <th style='font-weight:normal'><?php echo '&nbsp;'; ?></th>
155 <th style='font-weight:normal'><?php echo text($form_ss); ?></th>
156 <th style='font-weight:normal'><?php echo text($form_DOB); ?></th>
157 <th style='font-weight:normal'><?php echo '&nbsp;'; ?></th>
158 </tr>
160 <?php
161 while ($row = sqlFetchArray($res)) {
162 if ($row['closeness'] == 0) {
163 continue;
166 $phone = $row['phone_biz'];
167 if (empty($phone)) {
168 $phone = $row['phone_home'];
171 if (empty($phone)) {
172 $phone = $row['phone_cell'];
175 if (empty($phone)) {
176 $phone = $row['phone_contact'];
179 echo " <tr class='oneresult'";
180 echo " onclick=\"openPatient(" .
181 "'" . addslashes($row['pid']) . "'" .
182 ")\">\n";
183 echo " <td>" . text($row['lname'] . ", " . $row['fname']) . "</td>\n";
184 echo " <td>" . text($phone) . "</td>\n";
185 echo " <td>" . text($row['ss']) . "</td>\n";
186 echo " <td>" . text($row['DOB']) . "</td>\n";
187 echo " <td>" . text($row['street'] . ' ' . $row['postal_code']) . "</td>\n";
188 echo " </tr>\n";
191 </table>
192 </div>
193 <?php
198 <input type='button' value='<?php echo xla('Add New Patient'); ?>' onclick="openPatient(0)" />
199 &nbsp;
200 <input type='button' value='<?php echo xla('Cancel'); ?>' onclick="window.close()" />
201 </p>
203 </form>
204 </center>
205 </body>
206 </html>