fix: Smarty cal php82 warnings (#6316)
[openemr.git] / interface / orders / patient_match_dialog.php
blob38f6217fabef6889b472805c0c573d4ef9551255
1 <?php
3 /**
4 * Patient matching and selection dialog.
6 * @package OpenEMR
7 * @link https://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2013-2015 Rod Roark <rod@sunsetsystems.com>
11 * @copyright Copyright (c) 2019 Brady Miller <brady.g.miller@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../globals.php");
16 require_once("$srcdir/patient.inc.php");
17 require_once("$srcdir/options.inc.php");
19 use OpenEMR\Common\Csrf\CsrfUtils;
20 use OpenEMR\Core\Header;
22 $form_key = $_REQUEST['key'];
23 $args = unserialize($form_key, ['allowed_classes' => false]);
24 $form_ss = preg_replace('/[^0-9]/', '', $args['ss']);
25 $form_fname = $args['fname'];
26 $form_lname = $args['lname'];
27 $form_DOB = $args['DOB'];
29 <!DOCTYPE html>
30 <html>
31 <head>
32 <?php Header::setupHeader(['opener']); ?>
33 <style>
34 .oneResult {
36 </style>
37 <script>
39 $(function () {
40 $(".oneresult").mouseover(function () {
41 $(this).addClass("highlight");
42 });
43 $(".oneresult").mouseout(function () {
44 $(this).removeClass("highlight");
45 });
46 });
48 function myRestoreSession() {
49 if (top.restoreSession) top.restoreSession(); else opener.top.restoreSession();
50 return true;
53 function openPatient(ptid) {
54 var f = opener.document.forms[0];
55 var ename = <?php echo js_escape("select[$form_key]"); ?>;
56 if (f[ename]) {
57 f[ename].value = ptid;
58 window.close();
60 else {
61 alert(<?php echo xlj('Form element not found'); ?> + ': ' + ename);
65 </script>
66 </head>
68 <body class="body_top">
69 <form method='post' action='patient_select.php' onsubmit='return myRestoreSession()'>
70 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
71 <?php
72 if ($form_key) {
73 $clarr = array();
74 $clsql = "0";
75 // First name.
76 if ($form_fname !== '') {
77 $clsql .= " + ((fname IS NOT NULL AND fname = ?) * 5)";
78 $clarr[] = $form_fname;
81 // Last name.
82 if ($form_lname !== '') {
83 $clsql .= " + ((lname IS NOT NULL AND lname = ?) * 5)";
84 $clarr[] = $form_lname;
87 // Birth date.
88 if ($form_DOB !== '') {
89 $clsql .= " + ((DOB IS NOT NULL AND DOB = ?) * 5)";
90 $clarr[] = $form_DOB;
93 // SSN match is worth a lot and we allow for matching on last 4 digits.
94 if (strlen($form_ss) > 3) {
95 $clsql .= " + ((ss IS NOT NULL AND ss LIKE ?) * 10)";
96 $clarr[] = "%$form_ss";
99 $sql = "SELECT $clsql AS closeness, " .
100 "pid, pubpid, fname, lname, mname, DOB, ss, postal_code, street, " .
101 "phone_biz, phone_home, phone_cell, phone_contact, sex " .
102 "FROM patient_data " .
103 "ORDER BY closeness DESC, lname, fname LIMIT 10";
104 $res = sqlStatement($sql, $clarr);
107 <div id="searchResults">
109 <table class="table table-striped table-sm">
110 <h5>
111 <?php
112 echo xlt('Matching for Patient') . ": " .
113 text("$form_lname, $form_fname") . text(" Dob = $form_DOB") .
114 " SS = " . text(($form_ss ? $form_ss : "unk"))
116 </h5>
117 <tr>
118 <th><?php echo xlt('Name'); ?></th>
119 <th><?php echo xlt('DOB'); ?></th>
120 <th><?php echo xlt('Sex'); ?></th>
121 <th><?php echo xlt('Phone'); ?></th>
122 <th><?php echo xlt('SS'); ?></th>
123 <th><?php echo xlt('Address'); ?></th>
124 </tr>
126 <?php
127 while ($row = sqlFetchArray($res)) {
128 if ($row['closeness'] == 0) {
129 continue;
132 $phone = $row['phone_biz'];
133 if (empty($phone)) {
134 $phone = $row['phone_home'];
137 if (empty($phone)) {
138 $phone = $row['phone_cell'];
141 if (empty($phone)) {
142 $phone = $row['phone_contact'];
145 echo " <tr class='oneresult'";
146 echo " onclick=\"openPatient(" . attr_js($row['pid']) . ")\">\n";
147 echo " <td>" . text($row['lname'] . ", " . $row['fname']) . "</td>\n";
148 echo " <td>" . text($row['DOB']) . "</td>\n";
149 echo " <td>" . text(substr($row['sex'], 0, 1)) . "</td>\n";
150 echo " <td>" . text($phone) . "</td>\n";
151 echo " <td>" . text($row['ss']) . "</td>\n";
152 echo " <td>" . text($row['street'] . ' ' . $row['postal_code']) . "</td>\n";
153 echo " </tr>\n";
156 </table>
157 </div>
158 <?php
163 <input type='button' value='<?php echo xla('Add New Patient'); ?>' onclick="openPatient(0)"/>
164 <input type='button' value='<?php echo xla('Cancel'); ?>' onclick="window.close()"/>
165 </p>
167 </form>
168 </center>
169 </body>
170 </html>