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.
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
;
25 // If we are searching, search.
26 // first set $result to empty
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", "*");
48 <?php Header
::setupHeader(['common', 'datetime-picker', 'opener']); ?
>
49 <title
><?php
echo htmlspecialchars(xl('Patient Finder'), ENT_NOQUOTES
); ?
></title
>
62 #searchResultsHeader {
64 border
-collapse
: collapse
;
68 border
-collapse
: collapse
;
69 background
-color
: var(--white
);
79 border
-bottom
: 1px solid
var(--light
);
86 /* for search results or 'searching' notification */
98 /* highlight for the mouse-over */
100 background
-color
: #336699;
105 <!-- ViSolve
: Verify the noresult parameter
-->
107 if (isset($_GET["res"])) {
110 // Pass the variable to parent hidden type and submit
111 opener.document.theform.resname.value = "noresult";
112 opener.document.theform.submit();
118 <!-- ViSolve
: Verify the noresult parameter
-->
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')) {
134 } ?
>><?php
echo htmlspecialchars(xl('Phone'), ENT_NOQUOTES
); ?
></option
>
135 <option value
="ID"<?php
if (!empty($searchby) && ($searchby == 'ID')) {
137 } ?
>><?php
echo htmlspecialchars(xl('ID'), ENT_NOQUOTES
); ?
></option
>
138 <option value
="SSN"<?php
if (!empty($searchby) && ($searchby == 'SSN')) {
140 } ?
>><?php
echo htmlspecialchars(xl('SSN'), ENT_NOQUOTES
); ?
></option
>
141 <option value
="DOB"<?php
if (!empty($searchby) && ($searchby == 'DOB')) {
143 } ?
>><?php
echo htmlspecialchars(xl('DOB'), ENT_NOQUOTES
); ?
></option
>
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); ?>' />
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
>
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
); ?
>
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'
163 if (isset($_GET['pflag']) ||
(!AclMain
::aclCheckCore('patients', 'demo', '', array('write','addonly')))) {
164 ?
> style
="display: none;"
168 <?php
echo htmlspecialchars(xl('Click Here to add a new patient.'), ENT_NOQUOTES
); ?
></a
>
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
>
176 <?php
if (isset($result)) : ?
>
177 <table
class="table table-sm">
178 <thead id
="searchResultsHeader" class="head">
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
>
187 <tbody id
="searchResults">
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
);
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";
227 // jQuery stuff to make the page a little easier to use
230 $
("#searchparm").focus();
231 $
(".oneresult").mouseover(function() { $
(this
).toggleClass("highlight"); });
232 $
(".oneresult").mouseout(function() { $
(this
).toggleClass("highlight"); });
233 $
(".oneresult").click(function() { SelectPatient(this
); });
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 ?>
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); ?>");
259 opener
.setpatient(pid
, lname
, fname
, dob
);
264 // show the 'searching...' status and submit the form
265 var SubmitForm
= function(eObj
) {
266 $
("#submitbtn").css("disabled", "true");
267 $
("#searchspinner").css("visibility", "visible");
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
) {
276 var parts
= objID
.split("~");
277 return selpid(parts
[0], parts
[1], parts
[2], parts
[3]);