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>;.
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/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'];
38 <?php
html_header_show(); ?
>
39 <link rel
=stylesheet href
="<?php echo $css_header; ?>" type
="text/css">
47 #searchResults table {
49 border
-collapse
: collapse
;
50 background
-color
: white
;
53 background
-color
: lightgrey
;
59 border
-bottom
: 1px solid
#eee;
65 background
-color
: #336699;
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");});
81 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
83 function myRestoreSession() {
84 if (top
.restoreSession
) top
.restoreSession(); else opener
.top
.restoreSession();
88 function openPatient(ptid
) {
89 var f
= opener
.document
.forms
[0];
90 var ename
= '<?php echo addslashes("select[$form_key]"); ?>';
92 f
[ename
].value
= ptid
;
96 alert('<?php echo xls('Form element not found
'); ?>: ' + ename
);
103 <body
class="body_top">
105 <form method
='post' action
='patient_select.php' onsubmit
='return myRestoreSession()'>
112 if ($form_fname !== '') {
113 $clsql .= " + ((fname IS NOT NULL AND fname = ?) * 5)";
114 $clarr[] = $form_fname;
117 if ($form_lname !== '') {
118 $clsql .= " + ((lname IS NOT NULL AND lname = ?) * 5)";
119 $clarr[] = $form_lname;
122 if ($form_DOB !== '') {
123 $clsql .= " + ((DOB IS NOT NULL AND DOB = ?) * 5)";
124 $clarr[] = $form_DOB;
126 // SSN match is worth a lot and we allow for matching on last 4 digits.
127 if (strlen($form_ss) > 3) {
128 $clsql .= " + ((ss IS NOT NULL AND ss LIKE ?) * 10)";
129 $clarr[] = "%$form_ss";
132 $sql = "SELECT $clsql AS closeness, " .
133 "pid, pubpid, fname, lname, mname, DOB, ss, postal_code, street, " .
134 "phone_biz, phone_home, phone_cell, phone_contact " .
135 "FROM patient_data " .
136 "ORDER BY closeness DESC, lname, fname LIMIT 10";
137 $res = sqlStatement($sql, $clarr);
140 <div id
="searchResults">
143 <th
><?php
echo xlt('Name' ); ?
></th
>
144 <th
><?php
echo xlt('Phone'); ?
></th
>
145 <th
><?php
echo xlt('SS' ); ?
></th
>
146 <th
><?php
echo xlt('DOB' ); ?
></th
>
147 <th
><?php
echo xlt('Address'); ?
></th
>
150 <th style
='font-weight:normal'><?php
echo text("$form_lname, $form_fname"); ?
></th
>
151 <th style
='font-weight:normal'><?php
echo ' '; ?
></th
>
152 <th style
='font-weight:normal'><?php
echo text($form_ss); ?
></th
>
153 <th style
='font-weight:normal'><?php
echo text($form_DOB); ?
></th
>
154 <th style
='font-weight:normal'><?php
echo ' '; ?
></th
>
158 while ($row = sqlFetchArray($res)) {
159 if ($row['closeness'] == 0) continue;
161 $phone = $row['phone_biz'];
162 if (empty($phone)) $phone = $row['phone_home'];
163 if (empty($phone)) $phone = $row['phone_cell'];
164 if (empty($phone)) $phone = $row['phone_contact'];
166 echo " <tr class='oneresult'";
167 echo " onclick=\"openPatient(" .
168 "'" . addslashes($row['pid']) . "'" .
170 echo " <td>" . text($row['lname'] . ", " . $row['fname']) . "</td>\n";
171 echo " <td>" . text($phone ) . "</td>\n";
172 echo " <td>" . text($row['ss'] ) . "</td>\n";
173 echo " <td>" . text($row['DOB'] ) . "</td>\n";
174 echo " <td>" . text($row['street'] . ' ' . $row['postal_code']) . "</td>\n";
185 <input type
='button' value
='<?php echo xla('Add
New Patient
'); ?>' onclick
="openPatient(0)" />
187 <input type
='button' value
='<?php echo xla('Cancel
'); ?>' onclick
="window.close()" />