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 require_once("../globals.php");
23 require_once("$srcdir/patient.inc");
24 require_once("$srcdir/options.inc.php");
26 use OpenEMR\Core\Header
;
28 $form_key = $_REQUEST['key'];
29 $args = unserialize($form_key);
30 $form_ss = preg_replace('/[^0-9]/', '', $args['ss']);
31 $form_fname = $args['fname'];
32 $form_lname = $args['lname'];
33 $form_DOB = $args['DOB'];
38 <?php Header
::setupHeader(['opener']); ?
>
43 <script language
="JavaScript">
45 $
(document
).ready(function () {
46 $
(".oneresult").mouseover(function () {
47 $
(this
).addClass("highlight");
49 $
(".oneresult").mouseout(function () {
50 $
(this
).removeClass("highlight");
54 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
56 function myRestoreSession() {
57 if (top
.restoreSession
) top
.restoreSession(); else opener
.top
.restoreSession();
61 function openPatient(ptid
) {
62 var f
= opener
.document
.forms
[0];
63 var ename
= '<?php echo addslashes("select[$form_key]"); ?>';
65 f
[ename
].value
= ptid
;
69 alert('<?php echo xls('Form element not found
'); ?>: ' + ename
);
76 <body
class="body_top">
77 <form method
='post' action
='patient_select.php' onsubmit
='return myRestoreSession()'>
78 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(collectCsrfToken()); ?>" />
84 if ($form_fname !== '') {
85 $clsql .= " + ((fname IS NOT NULL AND fname = ?) * 5)";
86 $clarr[] = $form_fname;
90 if ($form_lname !== '') {
91 $clsql .= " + ((lname IS NOT NULL AND lname = ?) * 5)";
92 $clarr[] = $form_lname;
96 if ($form_DOB !== '') {
97 $clsql .= " + ((DOB IS NOT NULL AND DOB = ?) * 5)";
101 // SSN match is worth a lot and we allow for matching on last 4 digits.
102 if (strlen($form_ss) > 3) {
103 $clsql .= " + ((ss IS NOT NULL AND ss LIKE ?) * 10)";
104 $clarr[] = "%$form_ss";
107 $sql = "SELECT $clsql AS closeness, " .
108 "pid, pubpid, fname, lname, mname, DOB, ss, postal_code, street, " .
109 "phone_biz, phone_home, phone_cell, phone_contact " .
110 "FROM patient_data " .
111 "ORDER BY closeness DESC, lname, fname LIMIT 10";
112 $res = sqlStatement($sql, $clarr);
115 <div id
="searchResults">
117 <table
class="table table-striped table-condensed">
120 echo xlt('Matching for Patient') . ": " .
121 text("$form_lname, $form_fname") . text(" Dob = $form_DOB") .
122 " SS = " . text(($form_ss ?
$form_ss : "unk"))
126 <th
><?php
echo xlt('Name'); ?
></th
>
127 <th
><?php
echo xlt('Phone'); ?
></th
>
128 <th
><?php
echo xlt('SS'); ?
></th
>
129 <th
><?php
echo xlt('DOB'); ?
></th
>
130 <th
><?php
echo xlt('Address'); ?
></th
>
134 while ($row = sqlFetchArray($res)) {
135 if ($row['closeness'] == 0) {
139 $phone = $row['phone_biz'];
141 $phone = $row['phone_home'];
145 $phone = $row['phone_cell'];
149 $phone = $row['phone_contact'];
152 echo " <tr class='oneresult'";
153 echo " onclick=\"openPatient(" .
154 "'" . addslashes($row['pid']) . "'" .
156 echo " <td>" . text($row['lname'] . ", " . $row['fname']) . "</td>\n";
157 echo " <td>" . text($phone) . "</td>\n";
158 echo " <td>" . text($row['ss']) . "</td>\n";
159 echo " <td>" . text($row['DOB']) . "</td>\n";
160 echo " <td>" . text($row['street'] . ' ' . $row['postal_code']) . "</td>\n";
171 <input type
='button' value
='<?php echo xla('Add
New Patient
'); ?>' onclick
="openPatient(0)"/>
172 <input type
='button' value
='<?php echo xla('Cancel
'); ?>' onclick
="window.close()"/>