3 * Patient matching and selection dialog.
5 * Copyright (C) 2012-2014 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>;.
19 * @author Rod Roark <rod@sunsetsystems.com>
22 $sanitize_all_escapes = true;
23 $fake_register_globals = false;
25 require_once("../globals.php");
26 require_once("$srcdir/patient.inc");
27 require_once("$srcdir/formdata.inc.php");
28 require_once("$srcdir/options.inc.php");
30 $form_key1 = $_REQUEST['key1'];
31 $form_key2 = $_REQUEST['key2'];
32 $form_ss = preg_replace('/[^0-9]/', '', $_REQUEST['ss']);
33 $form_fname = $_REQUEST['fname'];
34 $form_lname = $_REQUEST['lname'];
35 $form_DOB = $_REQUEST['DOB'];
40 <?php
html_header_show(); ?
>
41 <link rel
=stylesheet href
="<?php echo $css_header; ?>" type
="text/css">
49 #searchResults table {
51 border
-collapse
: collapse
;
52 background
-color
: white
;
55 background
-color
: lightgrey
;
61 border
-bottom
: 1px solid
#eee;
67 background
-color
: #336699;
75 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-1.2.2.min.js"></script
>
76 <script language
="JavaScript">
78 $
(document
).ready(function(){
79 $
(".oneresult").mouseover(function() {$
(this
).addClass("highlight");});
80 $
(".oneresult").mouseout(function() {$
(this
).removeClass("highlight");});
83 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
85 function myRestoreSession() {
86 if (top
.restoreSession
) top
.restoreSession(); else opener
.top
.restoreSession();
90 function openPatient(ptid
) {
91 var f
= opener
.document
.forms
[0];
92 var ename
= '<?php echo addslashes("select[$form_key1][$form_key2]"); ?>';
94 f
[ename
].value
= ptid
;
98 alert('<?php echo xls('Form element not found
'); ?>: ' + ename
);
105 <body
class="body_top">
107 <form method
='post' action
='patient_select.php' onsubmit
='return myRestoreSession()'>
114 if ($form_fname !== '') {
115 $clsql .= " + ((fname IS NOT NULL AND fname = ?) * 5)";
116 $clarr[] = $form_fname;
119 if ($form_lname !== '') {
120 $clsql .= " + ((lname IS NOT NULL AND lname = ?) * 5)";
121 $clarr[] = $form_lname;
124 if ($form_DOB !== '') {
125 $clsql .= " + ((DOB IS NOT NULL AND DOB = ?) * 5)";
126 $clarr[] = $form_DOB;
128 // SSN match is worth a lot and we allow for matching on last 4 digits.
129 if (strlen($form_ss) > 3) {
130 $clsql .= " + ((ss IS NOT NULL AND ss LIKE ?) * 10)";
131 $clarr[] = "%$form_ss";
134 $sql = "SELECT $clsql AS closeness, " .
135 "pid, pubpid, fname, lname, mname, DOB, ss, postal_code, street, " .
136 "phone_biz, phone_home, phone_cell, phone_contact " .
137 "FROM patient_data " .
138 "ORDER BY closeness DESC, lname, fname LIMIT 10";
139 $res = sqlStatement($sql, $clarr);
142 <div id
="searchResults">
145 <th
><?php
echo xlt('Name' ); ?
></th
>
146 <th
><?php
echo xlt('Phone'); ?
></th
>
147 <th
><?php
echo xlt('SS' ); ?
></th
>
148 <th
><?php
echo xlt('DOB' ); ?
></th
>
149 <th
><?php
echo xlt('Address'); ?
></th
>
152 <th style
='font-weight:normal'><?php
echo text("$form_lname, $form_fname"); ?
></th
>
153 <th style
='font-weight:normal'><?php
echo ' '; ?
></th
>
154 <th style
='font-weight:normal'><?php
echo text($form_ss); ?
></th
>
155 <th style
='font-weight:normal'><?php
echo text($form_DOB); ?
></th
>
156 <th style
='font-weight:normal'><?php
echo ' '; ?
></th
>
160 while ($row = sqlFetchArray($res)) {
161 if ($row['closeness'] == 0) continue;
163 $phone = $row['phone_biz'];
164 if (empty($phone)) $phone = $row['phone_home'];
165 if (empty($phone)) $phone = $row['phone_cell'];
166 if (empty($phone)) $phone = $row['phone_contact'];
168 echo " <tr class='oneresult'";
169 echo " onclick=\"openPatient(" .
170 "'" . addslashes($row['pid']) . "'" .
172 echo " <td>" . text($row['lname'] . ", " . $row['fname']) . "</td>\n";
173 echo " <td>" . text($phone ) . "</td>\n";
174 echo " <td>" . text($row['ss'] ) . "</td>\n";
175 echo " <td>" . text($row['DOB'] ) . "</td>\n";
176 echo " <td>" . text($row['street'] . ' ' . $row['postal_code']) . "</td>\n";
187 <input type
='button' value
='<?php echo xla('Add
New Patient
'); ?>' onclick
="openPatient(0)" />
189 <input type
='button' value
='<?php echo xla('Cancel
'); ?>' onclick
="window.close()" />