migrated ubiquitous libraries to composer autoloader (#421)
[openemr.git] / interface / main / calendar / find_patient_popup.php
blobd7c6b931577475c2915934df3bdeec51206fdf04
1 <?php
2 /* Copyright (C) 2005-2007 Rod Roark <rod@sunsetsystems.com>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 */
12 * This popup is called when adding/editing a calendar event
16 //SANITIZE ALL ESCAPES
17 $sanitize_all_escapes=true;
20 //STOP FAKE REGISTER GLOBALS
21 $fake_register_globals=false;
24 include_once('../../globals.php');
25 include_once("$srcdir/patient.inc");
27 $info_msg = "";
29 // If we are searching, search.
31 if ($_REQUEST['searchby'] && $_REQUEST['searchparm']) {
32 $searchby = $_REQUEST['searchby'];
33 $searchparm = trim($_REQUEST['searchparm']);
35 if ($searchby == "Last") {
36 $result = getPatientLnames("$searchparm","*");
37 } elseif ($searchby == "Phone") { //(CHEMED) Search by phone number
38 $result = getPatientPhone("$searchparm","*");
39 } elseif ($searchby == "ID") {
40 $result = getPatientId("$searchparm","*");
41 } elseif ($searchby == "DOB") {
42 $result = getPatientDOB("$searchparm","*");
43 } elseif ($searchby == "SSN") {
44 $result = getPatientSSN("$searchparm","*");
49 <html>
50 <head>
51 <?php html_header_show();?>
52 <title><?php echo htmlspecialchars( xl('Patient Finder'), ENT_NOQUOTES); ?></title>
53 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
54 <script type="text/javascript" src="<?php echo $webroot ?>/interface/main/tabs/js/include_opener.js"></script>
55 <style>
56 form {
57 padding: 0px;
58 margin: 0px;
60 #searchCriteria {
61 text-align: center;
62 width: 100%;
63 font-size: 0.8em;
64 background-color: #ddddff;
65 font-weight: bold;
66 padding: 3px;
68 #searchResultsHeader {
69 width: 100%;
70 background-color: lightgrey;
72 #searchResultsHeader table {
73 width: 96%; /* not 100% because the 'searchResults' table has a scrollbar */
74 border-collapse: collapse;
76 #searchResultsHeader th {
77 font-size: 0.7em;
79 #searchResults {
80 width: 100%;
81 height: 80%;
82 overflow: auto;
85 /* search results column widths */
86 .srName { width: 30%; }
87 .srPhone { width: 21%; }
88 .srSS { width: 17%; }
89 .srDOB { width: 17%; }
90 .srID { width: 15%; }
92 #searchResults table {
93 width: 100%;
94 border-collapse: collapse;
95 background-color: white;
97 #searchResults tr {
98 cursor: hand;
99 cursor: pointer;
101 #searchResults td {
102 font-size: 0.7em;
103 border-bottom: 1px solid #eee;
105 .oneResult { }
106 .billing { color: red; font-weight: bold; }
108 /* for search results or 'searching' notification */
109 #searchstatus {
110 font-size: 0.8em;
111 font-weight: bold;
112 padding: 1px 1px 10px 1px;
113 font-style: italic;
114 color: black;
115 text-align: center;
117 .noResults { background-color: #ccc; }
118 .tooManyResults { background-color: #fc0; }
119 .howManyResults { background-color: #9f6; }
120 #searchspinner {
121 display: inline;
122 visibility: hidden;
125 /* highlight for the mouse-over */
126 .highlight {
127 background-color: #336699;
128 color: white;
130 </style>
132 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-2/index.js"></script>
133 <!-- ViSolve: Verify the noresult parameter -->
134 <?php
135 if(isset($_GET["res"])){
136 echo '
137 <script language="Javascript">
138 // Pass the variable to parent hidden type and submit
139 opener.document.theform.resname.value = "noresult";
140 opener.document.theform.submit();
141 // Close the window
142 window.self.close();
143 </script>';
146 <!-- ViSolve: Verify the noresult parameter -->
148 <script language="JavaScript">
150 function selpid(pid, lname, fname, dob) {
151 if (opener.closed || ! opener.setpatient)
152 alert("<?php echo htmlspecialchars( xl('The destination form was closed; I cannot act on your selection.'), ENT_QUOTES); ?>");
153 else
154 opener.setpatient(pid, lname, fname, dob);
155 window.close();
156 return false;
159 </script>
161 </head>
163 <body class="body_top">
165 <div id="searchCriteria">
166 <form method='post' name='theform' id="theform" action='find_patient_popup.php?<?php if(isset($_GET['pflag'])) echo "pflag=0"; ?>'>
167 <?php echo htmlspecialchars( xl('Search by:'), ENT_NOQUOTES); ?>
168 <select name='searchby'>
169 <option value="Last"><?php echo htmlspecialchars( xl('Name'), ENT_NOQUOTES); ?></option>
170 <!-- (CHEMED) Search by phone number -->
171 <option value="Phone"<?php if ($searchby == 'Phone') echo ' selected' ?>><?php echo htmlspecialchars( xl('Phone'), ENT_NOQUOTES); ?></option>
172 <option value="ID"<?php if ($searchby == 'ID') echo ' selected' ?>><?php echo htmlspecialchars( xl('ID'), ENT_NOQUOTES); ?></option>
173 <option value="SSN"<?php if ($searchby == 'SSN') echo ' selected' ?>><?php echo htmlspecialchars( xl('SSN'), ENT_NOQUOTES); ?></option>
174 <option value="DOB"<?php if ($searchby == 'DOB') echo ' selected' ?>><?php echo htmlspecialchars( xl('DOB'), ENT_NOQUOTES); ?></option>
175 </select>
176 <?php echo htmlspecialchars( xl('for:'), ENT_NOQUOTES); ?>
177 <input type='text' id='searchparm' name='searchparm' size='12' value='<?php echo htmlspecialchars( $_REQUEST['searchparm'], ENT_QUOTES); ?>'
178 title='<?php echo htmlspecialchars( xl('If name, any part of lastname or lastname,firstname'), ENT_QUOTES); ?>'>
179 &nbsp;
180 <input type='submit' id="submitbtn" value='<?php echo htmlspecialchars( xl('Search'), ENT_QUOTES); ?>'>
181 <!-- &nbsp; <input type='button' value='<?php echo htmlspecialchars( xl('Close'), ENT_QUOTES); ?>' onclick='window.close()' /> -->
182 <div id="searchspinner"><img src="<?php echo $GLOBALS['webroot'] ?>/interface/pic/ajax-loader.gif"></div>
183 </form>
184 </div>
187 <?php if (! isset($_REQUEST['searchparm'])): ?>
188 <div id="searchstatus"><?php echo htmlspecialchars( xl('Enter your search criteria above'), ENT_NOQUOTES); ?></div>
189 <?php elseif (count($result) == 0): ?>
190 <div id="searchstatus" class="noResults"><?php echo htmlspecialchars( xl('No records found. Please expand your search criteria.'), ENT_NOQUOTES); ?>
191 <br>
192 <!--VicarePlus :: If pflag is set the new patient create link will not be displayed --!>
193 <a class="noresult" href='find_patient_popup.php?res=noresult' <?php if(isset($_GET['pflag'])) { ?> style="display:none;" <?php } ?> ><?php echo htmlspecialchars( xl('Click Here to add a new patient.'), ENT_NOQUOTES); ?></a>
194 </div>
195 <?php elseif (count($result)>=100): ?>
196 <div id="searchstatus" class="tooManyResults"><?php echo htmlspecialchars( xl('More than 100 records found. Please narrow your search criteria.'), ENT_NOQUOTES); ?></div>
197 <?php elseif (count($result)<100): ?>
198 <div id="searchstatus" class="howManyResults"><?php echo htmlspecialchars( count($result), ENT_NOQUOTES); ?> <?php echo htmlspecialchars( xl('records found.'), ENT_NOQUOTES); ?></div>
199 <?php endif; ?>
201 <?php if (isset($result)): ?>
203 <div id="searchResultsHeader">
204 <table>
205 <tr>
206 <th class="srName"><?php echo htmlspecialchars( xl('Name'), ENT_NOQUOTES); ?></th>
207 <th class="srPhone"><?php echo htmlspecialchars( xl('Phone'), ENT_NOQUOTES); ?></th> <!-- (CHEMED) Search by phone number -->
208 <th class="srSS"><?php echo htmlspecialchars( xl('SS'), ENT_NOQUOTES); ?></th>
209 <th class="srDOB"><?php echo htmlspecialchars( xl('DOB'), ENT_NOQUOTES); ?></th>
210 <th class="srID"><?php echo htmlspecialchars( xl('ID'), ENT_NOQUOTES); ?></th>
211 </tr>
212 </table>
213 </div>
215 <div id="searchResults">
216 <table>
217 <?php
218 foreach ($result as $iter) {
219 $iterpid = $iter['pid'];
220 $iterlname = $iter['lname'];
221 $iterfname = $iter['fname'];
222 $itermname = $iter['mname'];
223 $iterdob = $iter['DOB'];
225 // If billing note exists, then it gets special coloring and an extra line of output
226 // in the 'name' column.
227 $trClass = "oneresult";
228 if (!empty($iter['billing_note'])) { $trClass .= " billing"; }
230 echo " <tr class='".$trClass."' id='" .
231 htmlspecialchars( $iterpid."~".$iterlname."~".$iterfname."~".$iterdob, ENT_QUOTES) . "'>";
232 echo " <td class='srName'>" . htmlspecialchars( $iterlname.", ".$iterfname." ".$itermname, ENT_NOQUOTES);
233 if (!empty($iter['billing_note'])) { echo "<br>" . htmlspecialchars( $iter['billing_note'], ENT_NOQUOTES); }
234 echo "</td>\n";
235 echo " <td class='srPhone'>" . htmlspecialchars( $iter['phone_home'], ENT_NOQUOTES) . "</td>\n"; //(CHEMED) Search by phone number
236 echo " <td class='srSS'>" . htmlspecialchars( $iter['ss'], ENT_NOQUOTES) . "</td>\n";
237 echo " <td class='srDOB'>" . htmlspecialchars( $iter['DOB'], ENT_NOQUOTES) . "</td>\n";
238 echo " <td class='srID'>" . htmlspecialchars( $iter['pubpid'], ENT_NOQUOTES) . "</td>\n";
239 echo " </tr>";
242 </table>
243 </div>
244 <?php endif; ?>
246 <script language="javascript">
248 // jQuery stuff to make the page a little easier to use
250 $(document).ready(function(){
251 $("#searchparm").focus();
252 $(".oneresult").mouseover(function() { $(this).toggleClass("highlight"); });
253 $(".oneresult").mouseout(function() { $(this).toggleClass("highlight"); });
254 $(".oneresult").click(function() { SelectPatient(this); });
255 //ViSolve
256 $(".noresult").click(function () { SubmitForm(this);});
258 //$(".event").dblclick(function() { EditEvent(this); });
259 $("#theform").submit(function() { SubmitForm(this); });
263 // show the 'searching...' status and submit the form
264 var SubmitForm = function(eObj) {
265 $("#submitbtn").css("disabled", "true");
266 $("#searchspinner").css("visibility", "visible");
267 return true;
271 // another way to select a patient from the list of results
272 // parts[] ==> 0=PID, 1=LName, 2=FName, 3=DOB
273 var SelectPatient = function (eObj) {
274 objID = eObj.id;
275 var parts = objID.split("~");
276 return selpid(parts[0], parts[1], parts[2], parts[3]);
279 </script>
281 </center>
282 </body>
283 </html>