feat: upgrade icd10 2025 (#7713)
[openemr.git] / interface / main / calendar / find_patient_popup.php
blobfd457648432c63cf95bc26c9d525e492ac5d9777
1 <?php
3 /* Copyright (C) 2005-2007 Rod Roark <rod@sunsetsystems.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 */
13 * This popup is called when adding/editing a calendar event
17 require_once('../../globals.php');
18 require_once("$srcdir/patient.inc.php");
20 use OpenEMR\Common\Acl\AclMain;
21 use OpenEMR\Core\Header;
23 $info_msg = "";
25 // If we are searching, search.
26 // first set $result to empty
27 $result = "";
28 if (!empty($_REQUEST['searchby']) && !empty($_REQUEST['searchparm'])) {
29 $searchby = $_REQUEST['searchby'];
30 $searchparm = trim($_REQUEST['searchparm']);
32 if ($searchby == "Last") {
33 $result = getPatientLnames("$searchparm", "*");
34 } elseif ($searchby == "Phone") { //(CHEMED) Search by phone number
35 $result = getPatientPhone("$searchparm", "*");
36 } elseif ($searchby == "ID") {
37 $result = getPatientId("$searchparm", "*");
38 } elseif ($searchby == "DOB") {
39 $result = getPatientDOB(DateToYYYYMMDD($searchparm), "*");
40 } elseif ($searchby == "SSN") {
41 $result = getPatientSSN("$searchparm", "*");
45 <!DOCTYPE html>
46 <html>
47 <head>
48 <?php Header::setupHeader(['common', 'datetime-picker', 'opener']); ?>
49 <title><?php echo htmlspecialchars(xl('Patient Finder'), ENT_NOQUOTES); ?></title>
51 <style>
52 form {
53 padding: 0;
54 margin: 0;
56 #searchCriteria {
57 text-align: center;
58 width: 100%;
59 font-weight: bold;
60 padding: 3px;
62 #searchResultsHeader {
63 width: 100%;
64 border-collapse: collapse;
66 #searchResults {
67 width: 100%;
68 border-collapse: collapse;
69 background-color: var(--white);
70 overflow: auto;
73 #searchResults tr {
74 cursor: hand;
75 cursor: pointer;
77 #searchResults td {
78 /*font-size: 0.7em;*/
79 border-bottom: 1px solid var(--light);
81 .billing {
82 color: var(--danger);
83 font-weight: bold;
86 /* for search results or 'searching' notification */
87 #searchstatus {
88 font-weight: bold;
89 font-style: italic;
90 color: var(--black);
91 text-align: center;
93 #searchspinner {
94 display: inline;
95 visibility: hidden;
98 /* highlight for the mouse-over */
99 .highlight {
100 background-color: #336699;
101 color: var(--white);
103 </style>
105 <!-- ViSolve: Verify the noresult parameter -->
106 <?php
107 if (isset($_GET["res"])) {
108 echo '
109 <script>
110 // Pass the variable to parent hidden type and submit
111 opener.document.theform.resname.value = "noresult";
112 opener.document.theform.submit();
113 // Close the window
114 window.self.close();
115 </script>';
118 <!-- ViSolve: Verify the noresult parameter -->
120 </head>
122 <body class="body_top">
123 <div class="container-responsive">
124 <div id="searchCriteria" class="bg-light p-2 pt-3">
125 <form method='post' name='theform' id="theform" action='find_patient_popup.php?<?php if (isset($_GET['pflag'])) {
126 echo "pflag=0"; } ?>'>
127 <div class="form-row">
128 <label for="searchby" class="col-form-label col-form-label-sm col"><?php echo htmlspecialchars(xl('Search by:'), ENT_NOQUOTES); ?></label>
129 <select name='searchby' id='searchby' class="form-control form-control-sm col">
130 <option value="Last"><?php echo htmlspecialchars(xl('Name'), ENT_NOQUOTES); ?></option>
131 <!-- (CHEMED) Search by phone number -->
132 <option value="Phone"<?php if (!empty($searchby) && ($searchby == 'Phone')) {
133 echo ' selected';
134 } ?>><?php echo htmlspecialchars(xl('Phone'), ENT_NOQUOTES); ?></option>
135 <option value="ID"<?php if (!empty($searchby) && ($searchby == 'ID')) {
136 echo ' selected';
137 } ?>><?php echo htmlspecialchars(xl('ID'), ENT_NOQUOTES); ?></option>
138 <option value="SSN"<?php if (!empty($searchby) && ($searchby == 'SSN')) {
139 echo ' selected';
140 } ?>><?php echo htmlspecialchars(xl('SSN'), ENT_NOQUOTES); ?></option>
141 <option value="DOB"<?php if (!empty($searchby) && ($searchby == 'DOB')) {
142 echo ' selected';
143 } ?>><?php echo htmlspecialchars(xl('DOB'), ENT_NOQUOTES); ?></option>
144 </select>
145 <label for="searchparm" class="col-form-label col-form-label-sm col"><?php echo htmlspecialchars(xl('for:'), ENT_NOQUOTES); ?></label>
146 <input type='text' class="form-control form-control-sm col" id='searchparm' name='searchparm' size='12' value='<?php echo attr($_REQUEST['searchparm'] ?? ''); ?>' title='<?php echo htmlspecialchars(xl('If name, any part of lastname or lastname,firstname'), ENT_QUOTES); ?>' />
147 <div class="col">
148 <input class='btn btn-primary btn-sm' type='submit' id="submitbtn" value='<?php echo htmlspecialchars(xl('Search'), ENT_QUOTES); ?>' />
149 <div id="searchspinner"><img src="<?php echo $GLOBALS['webroot'] ?>/interface/pic/ajax-loader.gif" /></div>
150 </div>
151 </div>
152 </form>
153 </div>
155 <?php if (! isset($_REQUEST['searchparm'])) : ?>
156 <div id="searchstatus"><?php echo htmlspecialchars(xl('Enter your search criteria above'), ENT_NOQUOTES); ?></div>
157 <?php elseif (! is_countable($result)) : ?>
158 <div id="searchstatus" class="alert alert-danger rounded-0"><?php echo htmlspecialchars(xl('No records found. Please expand your search criteria.'), ENT_NOQUOTES); ?>
159 <br />
160 <!--VicarePlus :: If pflag is set the new patient create link will not be displayed -->
161 <a class="noresult" href='find_patient_popup.php?res=noresult'
162 <?php
163 if (isset($_GET['pflag']) || (!AclMain::aclCheckCore('patients', 'demo', '', array('write','addonly')))) {
164 ?> style="display: none;"
165 <?php
167 ?> >
168 <?php echo htmlspecialchars(xl('Click Here to add a new patient.'), ENT_NOQUOTES); ?></a>
169 </div>
170 <?php elseif (count($result) >= 100) : ?>
171 <div id="searchstatus" class="alert alert-danger rounded-0"><?php echo htmlspecialchars(xl('More than 100 records found. Please narrow your search criteria.'), ENT_NOQUOTES); ?></div>
172 <?php elseif (count($result) < 100) : ?>
173 <div id="searchstatus" class="alert alert-success rounded-0"><?php echo htmlspecialchars(count($result), ENT_NOQUOTES); ?> <?php echo htmlspecialchars(xl('records found.'), ENT_NOQUOTES); ?></div>
174 <?php endif; ?>
176 <?php if (isset($result)) : ?>
177 <table class="table table-sm">
178 <thead id="searchResultsHeader" class="head">
179 <tr>
180 <th class="srName"><?php echo htmlspecialchars(xl('Name'), ENT_NOQUOTES); ?></th>
181 <th class="srPhone"><?php echo htmlspecialchars(xl('Phone'), ENT_NOQUOTES); ?></th> <!-- (CHEMED) Search by phone number -->
182 <th class="srSS"><?php echo htmlspecialchars(xl('SS'), ENT_NOQUOTES); ?></th>
183 <th class="srDOB"><?php echo htmlspecialchars(xl('DOB'), ENT_NOQUOTES); ?></th>
184 <th class="srID"><?php echo htmlspecialchars(xl('ID'), ENT_NOQUOTES); ?></th>
185 </tr>
186 </thead>
187 <tbody id="searchResults">
188 <?php
189 if (is_countable($result)) {
190 foreach ($result as $iter) {
191 $iterpid = $iter['pid'];
192 $iterlname = $iter['lname'];
193 $iterfname = $iter['fname'];
194 $itermname = $iter['mname'];
195 $iterdob = $iter['DOB'];
197 // If billing note exists, then it gets special coloring and an extra line of output
198 // in the 'name' column.
199 $trClass = "oneresult";
200 if (!empty($iter['billing_note'])) {
201 $trClass .= " billing";
204 echo " <tr class='" . $trClass . "' id='" .
205 htmlspecialchars($iterpid . "~" . $iterlname . "~" . $iterfname . "~" . $iterdob, ENT_QUOTES) . "'>";
206 echo " <td class='srName'>" . htmlspecialchars($iterlname . ", " . $iterfname . " " . $itermname, ENT_NOQUOTES);
207 if (!empty($iter['billing_note'])) {
208 echo "<br />" . htmlspecialchars($iter['billing_note'], ENT_NOQUOTES);
211 echo "</td>\n";
212 echo " <td class='srPhone'>" . htmlspecialchars($iter['phone_home'], ENT_NOQUOTES) . "</td>\n"; //(CHEMED) Search by phone number
213 echo " <td class='srSS'>" . htmlspecialchars($iter['ss'], ENT_NOQUOTES) . "</td>\n";
214 echo " <td class='srDOB'>" . htmlspecialchars($iter['DOB'], ENT_NOQUOTES) . "</td>\n";
215 echo " <td class='srID'>" . htmlspecialchars($iter['pubpid'], ENT_NOQUOTES) . "</td>\n";
216 echo " </tr>";
220 </tbody>
221 </table>
223 <?php endif; ?>
225 <script>
227 // jQuery stuff to make the page a little easier to use
229 $(function () {
230 $("#searchparm").focus();
231 $(".oneresult").mouseover(function() { $(this).toggleClass("highlight"); });
232 $(".oneresult").mouseout(function() { $(this).toggleClass("highlight"); });
233 $(".oneresult").click(function() { SelectPatient(this); });
234 //ViSolve
235 $(".noresult").click(function () { SubmitForm(this);});
237 //$(".event").dblclick(function() { EditEvent(this); });
238 $("#theform").submit(function() { SubmitForm(this); });
240 $('select[name="searchby"]').on('change', function () {
241 if($(this).val() === 'DOB'){
242 $('#searchparm').datetimepicker({
243 <?php $datetimepicker_timepicker = false; ?>
244 <?php $datetimepicker_showseconds = false; ?>
245 <?php $datetimepicker_formatInput = true; ?>
246 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
247 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
249 } else {
250 $('#searchparm').datetimepicker("destroy");
255 function selpid(pid, lname, fname, dob) {
256 if (opener.closed || ! opener.setpatient)
257 alert("<?php echo htmlspecialchars(xl('The destination form was closed; I cannot act on your selection.'), ENT_QUOTES); ?>");
258 else
259 opener.setpatient(pid, lname, fname, dob);
260 dlgclose();
261 return false;
264 // show the 'searching...' status and submit the form
265 var SubmitForm = function(eObj) {
266 $("#submitbtn").css("disabled", "true");
267 $("#searchspinner").css("visibility", "visible");
268 return true;
272 // another way to select a patient from the list of results
273 // parts[] ==> 0=PID, 1=LName, 2=FName, 3=DOB
274 var SelectPatient = function (eObj) {
275 objID = eObj.id;
276 var parts = objID.split("~");
277 return selpid(parts[0], parts[1], parts[2], parts[3]);
280 </script>
282 </div>
283 </body>
284 </html>